Re: better example
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 15, 2002
- 551 views
Thanks Wolf for answering this, however I'd like to suggest that one might use the stuff that is already built into the library. Here is my example based on yours... -------------------- include win32lib.ew constant SimpleWin = create( Window, "Simple Window", 0, 0, 0, 300, 100, 0 ), menu = create(Menu,"File",SimpleWin,0,0,0,0,0), menu1 = create(MenuItem,"New",menu,0,0,0,0,0), menu2 = create(MenuItem,"Old",menu,0,0,0,0,0), menu3 = create(MenuItem,"Check First Item",menu,0,0,0,0,0) procedure w32HClick_menu3(integer self,integer event,sequence params) integer curval curval = isChecked(menu1) setText(SimpleWin, "The first menuitem is " & iff(curval, "", "NOT") & "checked.") setCheck(menu1, not curval) end procedure setHandler(menu3,w32HClick,routine_id("w32HClick_menu3")) WinMain(SimpleWin, Normal) ------------------ Derek. ----- Original Message ----- From: "Wolf" <wolfritz at KING.IGS.NET> To: "EUforum" <EUforum at topica.com> Sent: Saturday, June 15, 2002 1:00 AM Subject: Re: better example > > Hey, Jordah, I answered this on the 8'th already, but here goes again... > < quoting <snipped> from your example > > > constant SimpleWin = create( Window, "Simple Window", 0, 0, 0, 300, > 100, 0 ), > menu = create(Menu,"File",SimpleWin,0,0,0,0,0), > menu1 = create(MenuItem,"New",menu,0,0,0,0,0), > menu2 = create(MenuItem,"Old",menu,0,0,0,0,0), > -- added ! > menu3 = create(MenuItem,"Check First Item",menu,0,0,0,0,0) > > -- new stuff ! -- crude, but ... > constant > MIIM_STATE = 1, > zGetMenuItemInfo=registerw32Function(user32,"GetMenuItemInfoA",{C_INT, > C_INT, C_INT, C_INT}, C_INT) > > function isMenuRadioed(atom hMenu,atom uItem,integer fByPosition) > atom MENUITEMINFO,junk,out > MENUITEMINFO = acquire_mem(0,48) > mem_set(MENUITEMINFO,0,48) > poke4(MENUITEMINFO+0,48) > poke4(MENUITEMINFO+4,MIIM_STATE) > junk=w32Func(zGetMenuItemInfo,{hMenu,uItem,fByPosition,MENUITEMINFO}) > if junk then > out = and_bits(peek4u(MENUITEMINFO+12),MFS_CHECKED) > else -- crash_error! > end if > release_mem(MENUITEMINFO) > return out > end function > > procedure w32HClick_menu3(integer self,integer event,sequence params) > --check item zero/by position > if isMenuRadioed(getHandle(menu),0,1) then > setText(SimpleWin," YES") else setText(SimpleWin," NO") > end if > end procedure > setHandler(menu3,w32HClick,routine_id("w32HClick_menu3")) > > Now, for a 'philosophical' question, to one and all. > Since your nice example proves that it's rather easy to add all this functionality to a win32lib program *without* > adding it to the win32lib core, do we really need them 'included' ? > "Win32lib created" programs that actually use "bitmapped" menu's, and "radio's", will probably be quite rare, in most > cases. > Things will be different, of course, when Derek 'breaks' win32lib into smaller bits, but for now.... ??? > > Wolf > > > >