Re: Initial menu
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 28, 2003
- 443 views
On Fri, 28 Feb 2003 16:36:42 +1100, Derek Parnell <ddparnell at bigpond.com> wrote: > >On Fri, 28 Feb 2003 02:45:02 +0000, Pete Lomax = <petelomax at blueyonder.co.uk>=20 >wrote: > >> >> As I understand things, you cannot call WinMain twice in the same >> program. Guess I need a dummy (invisible) window then, a popmenu >> selection, and _then_ create/display the appropriate window... >> >> Is there an example of this anywhere? >> > >What is the effect you are trying to achieve? It sounds like there are = two=20 >alternate windows that can be used, based on which the user chooses. The main one is three: expenses, bankings, and withdrawals (which are fairly similar); with estimates, quotations, invoices and credit notes (ditto), customer, bank rec, salary, and price list to follow. >If this is right, how about trying something like this... > > if message_box("Do you want window A?", ... ) =3D IDYES then > mainwin =3D create(Window, ...) > else > mainwin =3D create(Window, ....) end if > > WinMain(mainwin, 0) > Works for 2, not really for 11 choices >Points to note: The controls do not have to be constants. Controls do = not=20 >all have to be created at once. Yes, I want to change Bank for Shop, enable/disable/or not create vat (that's GST to you) and gross, etc. Hence I want the client (me) to make a choice, before I call create() preferably. I know I'm flying in the face of established Windows program design, I'm asking what the better way is. Anyway, fwiw, here is the best hack I have so far (I just couldn't get a pop menu to work at all), let me know what you think (yuks acceptable!): constant MAIN=3Dcreate(Window,"Select",0,100,100,180,150,0), r1=3Dcreate(Radio, "&One", MAIN,10,10,160,20,0), r2=3Dcreate(Radio, "&Two", MAIN,10,30,160,20,0), r3=3Dcreate(Radio, "Th&ree", MAIN,10,50,160,20,0), ok=3Dcreate(Button,"OK", MAIN,10,70,160,20,0), bc=3Dcreate(Button,"Cancel", MAIN,10,90,160,20,0), rl=3D{r1,r2,r3} setCheck(r1,True) integer i i=3D1 procedure onSel(integer self, integer event, sequence params) if event or length(params) then end if -- suppress warnings i=3Dfind(self,rl) setFocus(ok) end procedure setHandler(rl,w32HClick,routine_id("onSel")) procedure mainguts() showWindow( MAIN, SW_MINIMIZE) -- -- I guess this is where I invoke the main guts of the program, create -- windows, etc... -- ?i if getc(0) then end if closeWindow(MAIN) end procedure procedure doButton(integer self, integer event, sequence params) if event or length(params) then end if -- suppress warnings if self=3Dbc then closeWindow(MAIN) return end if mainguts() end procedure setHandler({ok,bc},w32HClick,routine_id("doButton")) procedure onkeydown(integer self, integer event, sequence params) if event or length(params) then end if -- suppress warnings if params[1]=3DVK_ESCAPE or params[1]=3DVK_ENTER and self=3Dbc then closeWindow(MAIN) return end if if params[1]=3DVK_ENTER then mainguts() end if end procedure setHandler({ok,bc},w32HKeyDown,routine_id("onkeydown")) procedure onActivate(integer self, integer event, sequence params) if self or event or length(params) then end if setFocus(ok) end procedure setHandler(MAIN,w32HActivate,routine_id("onActivate")) WinMain(MAIN,Normal)