June 15, 2024, 05:13:57 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Child Windows

Started by tbohon, December 13, 2006, 11:11:09 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tbohon

New to EB, I'm trying to figure out how to have a different child window appear depending on which button is clicked in the main window.  In the example code below I used a group box to indicate where the two child windows would appear.  Note that each child window would have it's own set of function-specific buttons, etc.

Any help/ideas/suggestions appreciated.

Here's the sample code:

CONST BUTTON_1 = 1
CONST BUTTON_2 = 2
CONST GROUP_3 = 3
DIALOG d1
CREATEDIALOG d1,0,0,974,403,0x80C80080,0,"Main Window",&d1_handler
CONTROL d1,@BUTTON,"Window 1",30,105,70,20,0x50000000,BUTTON_1
CONTROL d1,@BUTTON,"Window 2",31,141,70,20,0x50000000,BUTTON_2
CONTROL d1,@GROUPBOX,"Group",140,21,800,364,0x50000007,GROUP_3

SUB d1_handler
        SELECT @MESSAGE
      CASE @IDINITDIALOG
         CENTERWINDOW d1
         /* Initialize any controls here */
      CASE @IDCLOSEWINDOW
         CLOSEDIALOG d1,@IDOK
      CASE @IDCONTROL
         SELECT @CONTROLID
            CASE BUTTON_1
               IF @NOTIFYCODE = 0
                  /*button clicked*/
               ENDIF
            CASE BUTTON_2
               IF @NOTIFYCODE = 0
                  /*button clicked*/
               ENDIF
         ENDSELECT
   ENDSELECT
RETURN
ENDSUB
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

LarryMc

you have to define and create the 2 other dialogs (d2 and d3) and then use domodal d2 or domodal d3 when the buttons are pressed in d1
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

tbohon

After posting this I dug back into EB docs (the conference call I was on was boring beyond belief, decided to be productiveÂÃ,  ;) ) and was reading about domodal.

Think I have it now - will find time later today or tonight to play a bit more just to confirm.

Thanks Larry!

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

tbohon

OK, that piece is working just great - thanks again.

Since I have found that I learn best by trying and then asking for help, I've been "playing" (another long conference callÂÃ,  ;D) and have two other things I don't understand.

First, although I've managed to change the background color of my main window - on which the dialog is placed - I can't seem to change the background color of the dialog itself.ÂÃ,  Is this even possible?

Second (and this is probably a glaringly naive question), how in the heck do I get the dialog to appear in response to a button click?ÂÃ,  Say I have button1 and the dialog is d1 ... what's the secret?ÂÃ,  I've tried doing a SHOWDIALOG using the left button click message as the triggerÂÃ,  but it just sits there, staring at me, making me nervous ...ÂÃ,  ???  If I didn't already know it was out to 'get' me, I'd be a bit paranoid ... !

Thanks in advance - and thanks to Paul for a terrific language, I'm really having fun blundering my way through the gui build process!

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

LarryMc

If your main dialog is d1 and you want to open d2 the code would be
QuoteDOMODAL d2, d1
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Tom,
Post your current code so we can see where you are at.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

If you are using ShowDialog then you must have a message loop in your program somewhere.  Showdialog is normally used for dialogs that are used as the main application window itself, or for a dialog that has to stick around a while like a "find and replace" dialog.
Ionic Wind Support Team

tbohon

Here's the code (no snickering, OK???ÂÃ,  ;D) :

def w:window
def d1:dialog
def d2:dialog
def d3:dialog

' Open window

openwindow w,0,0,800,600,@size,null,"Main Window",&wproc
control w,@button,"Button1",50,530,80,25,@tabstop,1
control w,@button,"Button2",150,530,80,25,@tabstop,2
control w,@button,"Button3",250,530,80,25,@tabstop,3
control w,@button,"Exit",660,530,80,25,@tabstop,4
createdialog d1,10,10,762,500,null,w,"Invoices",&d1handler

centerwindow w
SETWINDOWCOLOR w, RGB(175,200,226)

showdialog d1

run=1

waituntil run = 0

closewindow w

end

' Window w handler

sub wproc

select @message
   case @idclosewindow
      run = 0
endselect

return

endsub

' dialog 1 (Invoices) handler

sub d1handler

select @message
   case @idcontrol
      select @controlid
         case 1
            answer = getcontroltext(d1,10)
            closedialog d1,@idok
      endselect

endselect

return

endsub
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

LarryMc

try this version of your code and see if it gets you over the hump.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

tbohon

Bet I'm gonna be embarassed, huh?  :-\

Thanks - I'll see how the pros do it and go from there.

Great response from all - thanks!!!

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

tbohon

OK - got it, ran it, looked at the code - I'm impressed!

I also see what was confusing me (I think, anyway).  For some strange reason (senility perhaps?) I thought that each type of object needed a different handler and each type also had it's own sequence of numbers.  For example, I could have window tag 1 and then dialog tag 1 ... with a different handler for each ... well, you see where I was wandering around in a daze, right?

Anyway, this is great - and I even understand the code you provided.

Thanks again to everyone for the assist.

Until next time ...   ;D

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)