Another Windows Programming Question

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

Thanks for the answers Derek and Elliott.  Yes, adding doEvents(0) in a 
couple of places did the trick.

Here's another Windows programming question.  This one is more of a style 
question.

I'm working on a program that is similar in format to a 'Wizard'.  That is, 
at the bottom of the screen, there are Previous, Next and Cancel buttons. 
Above them is a Multi-Line text box.  When Next is clicked, the text 
changes, when Previous is clicked, the last text is shown again.

I thought of two ways to do this:
(1) Have Multiple Next and Previous Buttons: btnNext1, btnNext2, etc. and 
btnPrev1, btnPrev2, etc.  All the Next buttons would be in exacttly the 
same location.  All the Previous buttons would be in exactly the same 
location.  Each buttons onClick procedure would have something like this:
procedure btnNext2_onClick()
    setVisible(btnNext2,False)
    setVisible(btnNext3,True)
    setText(MLText,"This text appears when button 2 gets clicked")
end procedure

So while the user would be actually clicking a different Next or Previous 
button each time, they'd never know it.  At program startup, all Next 
buttons, except for 1 are set invisible.  Same for the Previous buttons.

(2) Create a global variable, current_page, incrementing or decrementing it 
with each click of Next or Previous, and having a procedure like this:
procedure btnNext_onClick()
    if current_page = 1 then
        current_page += 1
        setText(MLText,"Here is the text for page 2")
    elsif current_page = 2 then
        current_page += 1
        setText(MLText,"Here is the text for page 3")
    end if
end procedure

Of course I'd have checks in there to make sure I didn't go past my last 
page and all that.

Anyway, these are the two ways I thought of to do this sort of thing.  I 
have opted for the first.  What do other Eu programmers out there think, 
and what would/did you do about this sort of program?

Thanks,
Ted Fines




--On Saturday, September 20, 2003 9:15 AM +1000 Derek Parnell 
<ddparnell at bigpond.com> wrote:

>
>
> ----- Original Message -----
> From: "Ted Fines" <fines at macalester.edu>
> To: "EUforum" <EUforum at topica.com>
> Sent: Saturday, September 20, 2003 4:59 AM
> Subject: Windows programming question
>
>
>> Hi all,
>>
>> I am not understanding how the order of events really works.  I'm using
>> Judith's IDE, and Win32lib--both the newest versions.
>>
>> Here is a procedure for a button:
>> procedure btnOK_onClick
>>     sequence themsg
>>     themsg = "Now about to run other procedure.\n"
>>     setText(InfoWindow,themsg)
>>     sleep(10)
>>     process_requirement({InfoWindow,DLProgress})
>> end procedure
>>
>> But even with the sleep(10) in there (which I just added for
>> troubleshooting this), the text in my InfoWindow (a ML Text box) doesn't
>> get updated until AFTER the other procedure has completed.
>>
>> I am guessing there is some way to force a refresh of my InfoWindow
>> before  continuing the procedure.  How?
>
> If the routine 'process_requirement' can take some time (say more than 1
> second) then it would be a good idea to insert some 'doEvents(0)' into
> it. The way Windows words is that events that happen while YOUR code is
> running, is blocked until your code returns to Windows. To help alleviate
> this, the doEvents(0) call will temporarily give control back to Windows
> so it can process any events that might have happened - including
> repainting parts of your screen.
>> Similarly, the procedure that gets called downloads a file, then runs it
>> with a "system" call.  It shows the download progress while downloading
>> the  file, in a label box.  What is displayed are bytes downloaded so
>> far, and  the percent of the total, like this:
>> "12849 bytes (5%)"
>>
>> But again, the updating of the label box lags far behind.  The program
>> actually gets downloaded, runs, and only after I quit it does the
>> progress  indicator get refreshed to say 100%.  In my initial testing of
>> the download  procedure, I just wrote everything to a command window
>> with "puts"  commands, and did not have this problem.
>>
>> Could someone fill me in on refreshing widget/window contents?
>
> Yes, definitely run a doEvents(0) call after each time you update the
> progress display.
>
> --
> Derek
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu