1. Win32Lib: Call for EXAMPLE programs
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Sep 03, 2000
- 419 views
Hi all, I'm working on a little thing relating to Win32Lib which might be of some help to newbies (& perennial newbies like myself), and it could benefit from some additional EXAMPLE programs illustrating how to do basic things with Win32Lib. Contributions of examples would be gratefully accepted and acknowledged. Here's what I mean: I asked a question about using right-clicks to select items in a listbox, and Al Getz sent me a sample program illustrating his solution. I modified it superficially, & it's below. It's the kind of thing others could find useful. But there's a lot of other example programs that like this that could help make using Win32Lib easier for newbies. That's what I'm asking for. TIA Dan --<code begins> -- Rclick: allows right clicking on an item in a list box to select & use it -- by Al Getz 9/2/00 ----------------------------------------------------------------------- include Win32Lib.ew without warning constant Desktop=0 ------------------------------------------------------------- -- creates controls: constant Window1= create(Window,"Allows RIGHT click to select item in listbox",Desktop,10,10,580,460,0) constant ListBox2=create(List,"2",Window1,40,20,260,200,0) -- label to show info from selected item in listbox: global constant DataLabel = create( CText, "", Window1, 0, 0, 40, 30, 0 ) ---------------------------------------------------------------- --fills listbox with demo items: for j=1 to 30 do addItem(ListBox2,"entry"&sprintf("%d",j)) end for ------------------------------------------------------- --defines constants if not already defined in Win32Lib.ew: -- ADD THIS TO YOUR PROGRAM (unless it gets added to Win32Lib) constant LB_GETITEMHEIGHT=#01A1, LB_GETTOPINDEX=#018E -- LB_SETCURSEL=#0186 ---------------------------------------------------- --puts an onMouse event in your program code: procedure onMouse_ListBox2(integer event, integer x, integer y, integer shift) -- ADD THESE VARIABLES TO YOUR PROGRAM in your onMouse event: atom index,bool,height,topindex,indexoffset sequence itemtext -- (insert YOUR routine's VARIABLES here:) if event=RIGHT_DOWN then -- note: can use "RightDown", also -- start of "housekeeping" to allow right click to work: height=sendMessage(ListBox2,LB_GETITEMHEIGHT,0,0) topindex=sendMessage(ListBox2,LB_GETTOPINDEX,0,0) indexoffset=floor(y/height) index=indexoffset+topindex bool=sendMessage(ListBox2,LB_SETCURSEL,index,0) index +=1 -- NOTE: USE "INDEX" TO REFERENCE TO ITEM SELECTED BY RIGHT CLICK -- end of right click housekeeping itemtext=getItem(ListBox2,index) -- shows item selected in list: -- (REMOVE or remark this in your program) setText(DataLabel,itemtext ) --put YOUR code to process the event here: -- end if end procedure onMouse[ListBox2]=routine_id("onMouse_ListBox2") ----------------------------------------------------------------- ------------------------------------------------------------------- ------------------------------------------------------------------- --may have to modify this last line for your version of Win32Lib: WinMain(Window1,Normal)
2. Re: Win32Lib: Call for EXAMPLE programs
- Posted by Al Getz <xaxo at AOL.COM> Sep 03, 2000
- 428 views
Dan, Nice additions to the sample! Before inserting into a program though i think i would add returned index validation after: itemtext=getItem(ListBox2,index) such as: if length(itemtext)>0 then --item is valid --insert your event handler here: -- end if BTW, would you be interested in starting an example library for Win32Lib? I think it would be very interesting not to mention solve about 1,000,000 problems for various users. I'd start by contributing a tree view with full drag and drop image support if anyone is interested Good luck with your coding... -- Al
3. Re: Win32Lib: Call for EXAMPLE programs
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Sep 03, 2000
- 439 views
Al, Index validation: makes sense, will add it, thanks, that's the kind of thing I was hoping people would do. Example library: well, that's almost exactly what I *am* trying to do :) I'm making a kind of example gateway, which RUNS all the examples from a list, and alternatively SHOWS the code for each so you can cut & paste easily, and it also has jumps to Euphoria manual, Win32Lib manual, a FAQ file, and (will have) to Wolf's Tutorial. So "a tree view with full drag and drop image" would be a very welcome addition, as would be anything else anyone can think of! As would be Questions/Answers to add to the FAQ, too. Dan ----- Original Message ----- From: "Al Getz" <xaxo at AOL.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Sunday, September 03, 2000 7:04 AM Subject: Re: Win32Lib: Call for EXAMPLE programs > Dan, > > Nice additions to the sample! Before inserting into a program though > i think i would add returned index validation after: > > itemtext=getItem(ListBox2,index) > > such as: > > if length(itemtext)>0 then > --item is valid > --insert your event handler here: > > -- > end if > > BTW, would you be interested in starting an example library for Win32Lib? > I think it would be very interesting not to mention solve about 1,000,000 > problems for various users. I'd start by contributing a tree view with > full drag and drop image support if anyone is interested > > Good luck with your coding... > -- Al
4. Re: Win32Lib: Call for EXAMPLE programs
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Sep 06, 2000
- 462 views
------=_NextPart_000_0011_01C017B5.4C52FB40 charset="iso-8859-1" Attached is an example program of some different styles of windows. I do have some questions about it, though: 1. How can I make my little windows open automatically with the main window? I tried onOpen main, onPaint main, but couldn't get them to open on entry. 2. How can I make the child window have "3D" borders? I couldn't make the child window work except with thin borders. 3. Is there something wrong with the positioning parameters for child windows? I had to make the child at y=122 in order to make it line up with other windows at y=150. 4. How can I make a "modal" window? I think that is one which won't let main close until it is closed; I thought I made one once before, but I looked, & I used WS_CAPTION there, & it works, but it doesn't work here (I think something changed in Win32Lib?). I also tried WS_EX_DLGMODALFRAME, but it didn't work either. 5. Can anyone suggest any other potentially interesting window styles that should be included in this example (plus parameter combos that create them!)? Thanks, Dan Moyer ----- Original Message ----- From: "Dan B Moyer" <DANMOYER at prodigy.net> To: "Euphoria Mail List" <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Sunday, September 03, 2000 5:25 AM Subject: Win32Lib: Call for EXAMPLE programs > Hi all, > > I'm working on a little thing relating to Win32Lib which might be of some > help to newbies (& perennial newbies like myself), and it could benefit from > some additional EXAMPLE programs illustrating how to do basic things with > Win32Lib. Contributions of examples would be gratefully accepted and > acknowledged. > > Here's what I mean: I asked a question about using right-clicks to select > items in a listbox, and Al Getz sent me a sample program illustrating his > solution. I modified it superficially, & it's below. It's the kind of > thing others could find useful. But there's a lot of other example programs > that like this that could help make using Win32Lib easier for newbies. > That's what I'm asking for. > > TIA > Dan > > --<code begins> > > -- Rclick: allows right clicking on an item in a list box to select & use it > -- by Al Getz 9/2/00 > > ----------------------------------------------------------------------- > include Win32Lib.ew > without warning > > constant Desktop=0 > > ------------------------------------------------------------- > -- creates controls: > constant Window1= > create(Window,"Allows RIGHT click to select item in > listbox",Desktop,10,10,580,460,0) > > constant ListBox2=create(List,"2",Window1,40,20,260,200,0) > > -- label to show info from selected item in listbox: > global constant DataLabel = create( CText, "", Window1, 0, 0, 40, 30, 0 ) > ---------------------------------------------------------------- > --fills listbox with demo items: > > for j=1 to 30 do > addItem(ListBox2,"entry"&sprintf("%d",j)) > end for > > ------------------------------------------------------- > > --defines constants if not already defined in Win32Lib.ew: > > -- ADD THIS TO YOUR PROGRAM (unless it gets added to Win32Lib) > > constant LB_GETITEMHEIGHT=#01A1, > LB_GETTOPINDEX=#018E > > -- LB_SETCURSEL=#0186 > > ---------------------------------------------------- > > --puts an onMouse event in your program code: > > procedure onMouse_ListBox2(integer event, integer x, integer y, integer > shift) > -- ADD THESE VARIABLES TO YOUR PROGRAM in your onMouse event: > atom index,bool,height,topindex,indexoffset > sequence itemtext > > -- (insert YOUR routine's VARIABLES here:) > > if event=RIGHT_DOWN then -- note: can use "RightDown", also > -- start of "housekeeping" to allow right click to work: > height=sendMessage(ListBox2,LB_GETITEMHEIGHT,0,0) > topindex=sendMessage(ListBox2,LB_GETTOPINDEX,0,0) > indexoffset=floor(y/height) > index=indexoffset+topindex > bool=sendMessage(ListBox2,LB_SETCURSEL,index,0) > index +=1 > -- NOTE: USE "INDEX" TO REFERENCE TO ITEM SELECTED BY RIGHT CLICK > -- end of right click housekeeping > > itemtext=getItem(ListBox2,index) > -- shows item selected in list: > -- (REMOVE or remark this in your program) > setText(DataLabel,itemtext ) > > --put YOUR code to process the event here: > > > -- > end if > end procedure > > onMouse[ListBox2]=routine_id("onMouse_ListBox2") > ----------------------------------------------------------------- > > ------------------------------------------------------------------- > ------------------------------------------------------------------- > > --may have to modify this last line for your version of Win32Lib: > WinMain(Window1,Normal) > > > > ------=_NextPart_000_0011_01C017B5.4C52FB40 name="Styles6.zip"