1. Win32 tutor part 6

Hello,

Part 6 allready of our 'tutor'. Actually it's only a little improvement o=
n
Eu_addr.exw.
You'll find version 0.2 attached here.
WARNING: Before running the program you should paste this code, provided =
by
Vince Gonzales, to the end of Win32Lib.ew, and put that file in the
directory you are running from, or in the Euphoria\include directory.
BTW: Thanks for the code, Vince; when can we see a program of yours?

--SetFonts.ew
global procedure setAllFonts(sequence faceName, integer points, integer
attrib)     -- Vince Gonzales
    for f=3D1 to length(window) do
        if window[f][2] >=3D PushButton and window[f][2] <=3D CText then
            setFont(f, faceName, points, attrib)
        end if
    end for
end procedure
----
I've tried to *really* adapt to screen resolutions other then 800*600.
If you've got such a resolution, please report back to me with your
results.
In the procedure setAllFonts() you can experiment with your favorite font=
s;
but if you want the list to look aligned you should use non-proportional
fonts!

Today I also added some more explanation:

Part 6: More on controls

The controls that can be created using Win32Lib come in different flavors=
:
- Windows (of course)
- Buttons (all kinds of them)
- Groupboxes
- Listboxes
- Scrollbars
- Labels
- Text boxes
- Menus and MenuItems

In the address program demo there are yet:
- a Main window
- a SortedList box
- a Group box (only there because I like it)
- several LText labels with enlightning text on them
- several EditText boxes to type your address data in
- a DefPushButton "&Add"
- a normal PushButton "&Close"

The SortedList box is receiving (formatted) address data if the user clic=
ks
or pushes (using the spacebar) the Add button. I'll try to explain some
more,
without using terms as 'messages', 'handles', 'objects' etc....
If you click the Add button (onClick[btnAdd]) the program looks for code,=

associated with this event. It finds the procedure onClick_btnAdd.
The function getText(), built into Win32Lib.ew, copies the texts from the=

EditText boxes into sequence variables. As we want our address data to be=

complete, we check if the key fields are not empty. If they are empty, we=
 =

give the user an appropriate message, using the yet wellknown message_box=
,
and give him/her another try. For this purpose the cursor, denoting the
active control, is set back to the first of the EditText fields.
The procedure setFocus(edtFName) is used for this.
Note that we do not clean previously input data, as some of them might be=

good already.
If the input passes the test, the data in the variables is 'formatted' an=
d =

then added to the listbox items by the procedure AddItem(ListBox1, line).=

Since the listbox is a SortedList, the lines are sorted by first name in
this example. Later we can add procedures to sort by last name, zip code
or whatever is necessary for your application.
The procedure clean_all is called to empty all edit boxes by using =

setText(control, ""), and the focus is set back to the First Name, to
receive new input.
Finally, if you're fed up with things you can click the Close button and
the application is simply ended. Of course, in a later stage you'll ask
if the user is sure and doesn't want to save data.

Ad_Rienks at compuserve.com

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu