Re: Making a window dialog wait for a user response (Win32Lib)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Derek Parnell wrote:
> 
> You can use the w32HActivate event to do stuff after the main window is open
> but before the user gets to do anything. This is one place where you can check
> to see if there were any errors detected and close the application before the
> user can doing anything. Here is an example ...
> 
> }}}
<eucode>
> ---------------------------------
> include Win32Lib.ew
> without warning
> 
> integer Window1
> integer PushButton2
> integer PushButton3
> integer Window2
> integer Msg
> integer PushButton5
> integer ErrCnt
> sequence ErrText
> 
> procedure PushButton2_onClick (integer self, integer event, sequence params)
>       openDialog(Window2)
> end procedure
> 
> procedure PushButton3_onClick (integer self, integer event, sequence params)
>       closeApp()
> end procedure
> 
> procedure PushButton5_onClick (integer self, integer event, sequence params)
>       closeWindow(Window2)
> end procedure
> 
> procedure Window1_onActivate (integer self, integer event, sequence params)
>     if ErrCnt > 0 then
>         setText(Msg, {"%d errors detected\n%s", {ErrCnt, ErrText}})
>         setText(PushButton5, "Abort")
>         openDialog(Window2)
>         closeApp()
>     end if
> end procedure
> 
> procedure main()
> 
>     -- Do some checking prior to opening the main window.
>     integer fh
>     object Line
> 
>     ErrCnt = 0
>     ErrText = ""
> 
>     fh = open("missing.file", "r")
>     if fh = -1 then
>         ErrCnt += 1
>         ErrText &= "'missing.file' is missing\n"
>     else
>         -- Check first line.
>         Line = gets(fh)
>         if atom(Line) then
>             ErrCnt += 1
>             ErrText &= "The file is empty\n"
>         elsif not equal(Line, "good one\n") then
>             ErrCnt += 1
>             ErrText &= "The first line is not 'good one'\n"
>             -- Check second line.
>             Line = gets(fh)
>             if atom(Line) then
>                 ErrCnt += 1
>                 ErrText &= "The second line is missing\n"
>         elsif not equal(Line, "last line\n") then
>                 ErrCnt += 1
>                 ErrText &= "The second line is not 'last line'\n"
>             end if
>         end if
>     end if
> 
>     Window1 = createEx( Window, "Window1", 0, Default, Default, 400, 300, 0, 0
>     )
>     PushButton2 = createEx( PushButton, "Open sub", Window1, 56, 176, 88, 28,
>     0, 0 )
>     PushButton3 = createEx( PushButton, "Close", Window1, 180, 176, 88, 28, 0,
>     0 )
>     Window2 = createEx( Window, "Window 2", 0, Default, Default, 285, 196, 0,
>     0 )
>     Msg  = createEx( Label, "", Window2, 10, 10 , 200, 120, 0, 0)
>     PushButton5 = createEx( PushButton, "Click me", Window2, 84, 130, 88, 28,
>     0, 0 )
> 
>     setHandler( PushButton2, w32HClick, routine_id("PushButton2_onClick"))
>     setHandler( PushButton3, w32HClick, routine_id("PushButton3_onClick"))
>     setHandler( PushButton5, w32HClick, routine_id("PushButton5_onClick"))
>     setHandler( Window1, w32HActivate, routine_id("Window1_onActivate"))
> 
>     WinMain( Window1,Normal )
> end procedure
> 
> main()
> ---------------------------------
> </eucode>
{{{

> 
> -- 
> Derek Parnell
> Melbourne, Australia
> Skype name: derek.j.parnell

Hey Derek,

That worked! Thanks again! Oh, btw, I asked you about a tool tip
that didn't show all the text I needed it to show - and you spoke
of some sort of a fix.. You remember? (Sorry, abit off topic)

Kenneth

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu