Re: Another Windows Programming Question

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

----- Original Message ----- 
From: "Ted Fines" <fines at macalester.edu>
To: "EUforum" <EUforum at topica.com>
Subject: Another Windows Programming Question


> 
> 
> 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?

Definitely the second approach, but use 'current_page' as an index for the text
to display.

 procedure btnNextPrev_onClick(integer self, integer event, sequence parms)
     if self = PrevBtn then
        current_page -= 1
     else
        current_page += 1
     end if
     setEnabled(NextBtn, current_page != LastPage)
     setEnabled(PrevBtn, current_page != 1)
     setText(MLText,PageText[current_page])
 end procedure
 setHandler({PrevBtn,NextBtn, w32HClick, routine_id("btnNextPrev_onClick"))

 -- Initially --
 current_page = 0
 btnNextPrev_onClick(NextBtn, 0, {})

-- 
Derek

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

Search



Quick Links

User menu

Not signed in.

Misc Menu