1. Initial menu
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?
Pete
Confucius say: Life sucks.
Get over it. You fairy.
2. Re: Initial menu
- Posted by gertie at visionsix.com
Feb 28, 2003
On 28 Feb 2003, at 2:45, Pete Lomax wrote:
<snip>
> Pete
>
> Confucius say: Life sucks.
> Get over it. You fairy.
Could you remove that from your emails, please? Or explain what you mean
by "fairy"?
Kat
3. Re: Initial menu
On Fri, 28 Feb 2003 02:45:02 +0000, Pete Lomax <petelomax at blueyonder.co.uk>
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
alternate windows that can be used, based on which the user chooses. If
this is right, how about trying something like this...
if message_box("Do you want window A?", ... ) = IDYES then
mainwin = create(Window, ...)
else
mainwin = create(Window, ....) end if
WinMain(mainwin, 0)
Points to note: The controls do not have to be constants. Controls do not
all have to be created at once.
--
cheers,
Derek Parnell
4. Re: Initial menu
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)
5. Re: Initial menu
Pete,
I made the following mod of a Win32Lib demo called "splash.exw"; it
orginally presented a "splash" screen, with a bitmap, waited a while, then
disappeared & opened the main window. The mod below shows an
initial window with text & some buttons, one button quits, the other two
open two different windows, one of which is the "main" window, and destroy
the initial menu window. Is this anything like what you were wanting?
(Even if it is, there may be better ways to do it, probably.)
Dan Moyer
PS. I second Kats remark about your signature.
-- <code begins>
--------INITIAL MENU WINDOW EXAMPLE ---------
include win32lib.ew
without warning
constant
-- Create a main window with no dimensions and out of view
Main = create( Window, "Main", 0, 0, -100, 0, 0, 0 ),
-- make a 2nd window:
secondW = create(Window, "second window", Main,0,0,200,200,0),
-- Create a window for the initial menus:
Splash = create(Window, "Splash",0, 100, 100, 200, 230,
{WS_POPUP, WS_BORDER, WS_VISIBLE}),
-- with information:
L1 = create(CText, "click on a button", Splash, 5, 10, 150, 50, 0),
-- and some buttons to open windows or exit:
b1 = create(Button, "One", Splash, 5, 150, 50, 50, 0),
b2 = create(Button, "two", Splash, 65, 150, 50, 50, 0),
b3 = create(Button, "exit", Splash, 130, 150, 50, 50, 0)
integer btn1, btn2
-- show/goto the main window:
procedure openMainWindow()
-- Show the main window now.
setRect(Main, 0, 0, 170, 350, 1)
destroy(b1)
destroy(b2)
destroy(b3)
destroy(Splash)
end procedure
onClick[b1] = routine_id("openMainWindow")
procedure open2nd()
destroy(b1)
destroy(b2)
destroy(b3)
destroy(Splash)
openWindow(secondW , Normal)
end procedure
onClick[b2] = routine_id("open2nd")
procedure quit()
destroy(b1)
destroy(b2)
destroy(b3)
destroy(Splash)
close(Main)
destroy(Main)
end procedure
onClick[b3] = routine_id("quit")
procedure initialize()
-- Begin initialising the main window's stuff.
btn1 = create(Button, "One", Main, 5, 5, 50, 50, 0)
btn2 = create(Button, "Two", Main, 5, 65, 50, 50, 0)
end procedure
onActivate[Main] = routine_id("initialize")
procedure onClose2nd()
destroy(Main)
end procedure
onClose[secondW] = routine_id("onClose2nd")
WinMain( Main, Normal )
----- Original Message -----
From: "Pete Lomax" <petelomax at blueyonder.co.uk>
To: "EUforum" <EUforum at topica.com>
Sent: Thursday, February 27, 2003 6:45 PM
Subject: Initial menu
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?
Pete
Confucius say: Life sucks.
Get over it. You fairy.
==^^===============================================================
This email was sent to: DANIELMOYER at prodigy.net
TOPICA - Start your own email discussion group. FREE!
6. Re: Initial menu
----- Original Message -----
From: "Pete Lomax" <petelomax at blueyonder.co.uk>
To: "EUforum" <EUforum at topica.com>
Subject: Re: Initial menu
>I know I'm flying in the face of established Windows program design,
>I'm asking what the better way is.
[snip]
Pete,
The method you talk about is fairly common for Window apps.
Here is a sample of a way to do this...
---------------------------
-- AppSelect.exw
without warning
include win32lib.ew
if setAppName("Application Launcher") then end if
integer Win
integer TB
integer B1
integer B2
integer B3
sequence icons
atom iconApp1
atom iconApp2
atom iconApp3
------------------
procedure LaunchApp(integer self, integer event, sequence parms)
------------------
sequence lAppName
lAppName = getUserProperty(self, "Application Name")
VOID = message_box(sprintf("Launching '%s' ...", {lAppName[1]}),
"LaunchPad", 0)
-- Here is where you can build or show the appropriate screen forms.
end procedure
------------------
procedure AppInit(sequence argv)
------------------
sequence th
-- Note that 'argv' contains the command line args
Win = createEx( Window, "Application Launchpad", 0, 0, 0, 300, 80,
{WS_BORDER, WS_SYSMENU, WS_DLGFRAME},
{WS_EX_TOOLWINDOW} )
-- Calc the size of the toolbar required.
th = getTextExtent(Screen, "|")
TB = create( FlatToolBar, "", Win, 0, 0, 0, (44 + th[2]), 0)
-- Prepare the image lists (these are sample images)
iconApp1 = extractIcon( "disk05.ico" )
iconApp2 = extractIcon( "disk06.ico" )
iconApp3 = extractIcon( "disks04.ico" )
icons = {}
icons &= addIcon( {iconApp1, iconApp1, iconApp1 } )
icons &= addIcon( {iconApp2, iconApp2, iconApp2 } )
icons &= addIcon( {iconApp3, iconApp3, iconApp3 } )
-- Add the buttons to the toolbar
B1 = create( PushButton, {"Transactions", "This will allow you to add
and change transactions"},
TB, icons[1], 10, 0, 0, 0)
VOID= create( SepButton, "", TB, 0, 0, 0, 0, 0)
B2 = create( PushButton, {"Statements", "This will print customer
statements"},
TB, icons[2], 10, 0, 0, 0)
VOID= create( SepButton, "", TB, 0, 0, 0, 0, 0)
B3 = create( PushButton, {"Audit", "This shows the list of recent audit
entries"},
TB, icons[3], 10, 0, 0, 0)
-- Initialize the button's link to their applications
setUserProperty(B1, "Application Name", "Record Transactions")
setUserProperty(B2, "Application Name", "Print Statement")
setUserProperty(B3, "Application Name", "View Audit Trail")
-- Establish the handlers.
setHandler({B1, B2, B3}, w32HClick, routine_id("LaunchApp"))
WinMain( Win, Normal )
end procedure
-- Start the launcher bar.
AppInit(command_line())
----------------
cheers,
Derek Parnell
7. Re: Initial menu
the "setUserProperty" commands need to be "defineUserProperty",
and I think a filename should go in the field after "Application Name" in
that command if it's intended to run a program.
And if you put:
shellExecute("open", lAppName[1], SW_SHOWNORMAL)
under:
"-- Here is where you can build or show the appropriate screen forms.",
then it will run the application named in the "defineUserProperty" command
when user clicks on one of the buttons.
Dan
----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Sent: Saturday, March 01, 2003 3:11 PM
Subject: Re: Initial menu
>
> ----- Original Message -----
> From: "Pete Lomax" <petelomax at blueyonder.co.uk>
> To: "EUforum" <EUforum at topica.com>
> Sent: Saturday, March 01, 2003 10:11 AM
> Subject: Re: Initial menu
>
> >I know I'm flying in the face of established Windows program design,
> >I'm asking what the better way is.
> [snip]
>
> Pete,
> The method you talk about is fairly common for Window apps.
>
> Here is a sample of a way to do this...
>
> ---------------------------
> -- AppSelect.exw
> without warning
>
> include win32lib.ew
> if setAppName("Application Launcher") then end if
>
> integer Win
> integer TB
> integer B1
> integer B2
> integer B3
> sequence icons
> atom iconApp1
> atom iconApp2
> atom iconApp3
>
> ------------------
> procedure LaunchApp(integer self, integer event, sequence parms)
> ------------------
> sequence lAppName
>
> lAppName = getUserProperty(self, "Application Name")
>
> VOID = message_box(sprintf("Launching '%s' ...", {lAppName[1]}),
> "LaunchPad", 0)
> -- Here is where you can build or show the appropriate screen forms.
>
> end procedure
>
> ------------------
> procedure AppInit(sequence argv)
> ------------------
> sequence th
>
> -- Note that 'argv' contains the command line args
>
> Win = createEx( Window, "Application Launchpad", 0, 0, 0, 300, 80,
> {WS_BORDER, WS_SYSMENU, WS_DLGFRAME},
> {WS_EX_TOOLWINDOW} )
>
> -- Calc the size of the toolbar required.
> th = getTextExtent(Screen, "|")
> TB = create( FlatToolBar, "", Win, 0, 0, 0, (44 + th[2]), 0)
>
> -- Prepare the image lists (these are sample images)
> iconApp1 = extractIcon( "disk05.ico" )
> iconApp2 = extractIcon( "disk06.ico" )
> iconApp3 = extractIcon( "disks04.ico" )
>
> icons = {}
> icons &= addIcon( {iconApp1, iconApp1, iconApp1 } )
> icons &= addIcon( {iconApp2, iconApp2, iconApp2 } )
> icons &= addIcon( {iconApp3, iconApp3, iconApp3 } )
>
> -- Add the buttons to the toolbar
> B1 = create( PushButton, {"Transactions", "This will allow you to add
> and change transactions"},
> TB, icons[1], 10, 0, 0, 0)
> VOID= create( SepButton, "", TB, 0, 0, 0, 0, 0)
> B2 = create( PushButton, {"Statements", "This will print customer
> statements"},
> TB, icons[2], 10, 0, 0, 0)
> VOID= create( SepButton, "", TB, 0, 0, 0, 0, 0)
> B3 = create( PushButton, {"Audit", "This shows the list of recent
audit
> entries"},
> TB, icons[3], 10, 0, 0, 0)
>
> -- Initialize the button's link to their applications
--THESE FOLLOWING NEED TO BE "defineUserProperty"
> setUserProperty(B1, "Application Name", "Record Transactions")
> setUserProperty(B2, "Application Name", "Print Statement")
> setUserProperty(B3, "Application Name", "View Audit Trail")
>
> -- Establish the handlers.
> setHandler({B1, B2, B3}, w32HClick, routine_id("LaunchApp"))
>
>
> WinMain( Win, Normal )
> end procedure
>
> -- Start the launcher bar.
> AppInit(command_line())
>
>
> ----------------
> cheers,
> Derek Parnell
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
8. Re: Initial menu
On Sun, 2 Mar 2003 00:09:42 -0800, Dan Moyer <DANIELMOYER at prodigy.net>
wrote:
>
> the "setUserProperty" commands need to be "defineUserProperty",
I can't remember when I added this but if the user property specified in
setUserProperty has not been defined yet, then this call will define it
automatically. In other words, you can use either call in this case.
> and I think a filename should go in the field after "Application Name" in
> that command if it's intended to run a program.
I left it up to the implementer to decide if they are going to run a
program or do something else. This is just illustrative code.
> And if you put:
> shellExecute("open", lAppName[1], SW_SHOWNORMAL)
> under:
> "-- Here is where you can build or show the appropriate screen forms.",
> then it will run the application named in the "defineUserProperty"
> command
> when user clicks on one of the buttons.
However, Dan's changes should work fine too.
--
cheers,
Derek Parnell
9. Re: Initial menu
----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Subject: Re: Initial menu
>
> On Sun, 2 Mar 2003 00:09:42 -0800, Dan Moyer <DANIELMOYER at prodigy.net>
> wrote:
>
> >
> > the "setUserProperty" commands need to be "defineUserProperty",
>
> I can't remember when I added this but if the user property specified in
> setUserProperty has not been defined yet, then this call will define it
> automatically. In other words, you can use either call in this case.
Maybe this is a version difference; when I ran your example under 57.9, it
wouldn't work with setUserProperty, but would with defineUserProperty.
Dan