April 28, 2024, 09:21:56 PM

News:

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


How to question

Started by Rock Ridge Farm (Larry), November 23, 2008, 03:58:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rock Ridge Farm (Larry)

I am working on my first major Ebasic program.
I need to have a main window with a menu. ( have that done)
I need to open a second window or dialog based on a selected menu item and
then populate the original window with data based on check boxes and data entry fields in the second window.
I have searched the forum for something like this but did not find anything.
Did I miss any useful code or can someone get me started with this?
The original window will be sort of a editor (limited).

LarryMc

Create both windows at the very beginning but make the 2nd one hidden.
In the menu of the 1st window have the selected menu option "show" the 2nd window.
When you've made all your selections on the 2nd window press a "update" button.

That button will call a routine that reads all the controls in the 2nd window and loads the appropriate stuff in the 1st window controls.

If you have the 2nd window as a dialog you'll have to have the dialogs "close" handler call a routine to read all the data and update your 1st window before the dialog closes.

I use the multiple window scheme all over the place.

See if the above helps you get started.

If not, holler again.

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

Tony

Hey Larry,

  To open a second window, or probably more appropriate, a dialog you can do something like the following in the handler for your main menu:


      SELECT CASE @CLASS
      CASE @IDMENUPICK
         SELECT @MENUNUM
            CASE @MNU_OPTIONS
               RValue=DOMODAL OptionsDialog,CardWin
         ENDSELECT
      ENDSELECT


The above code responds to a Menu item named Options on a menu bar in your main menu. If you select it, it displays a dialog box, via DOMODAL. DOMODAL shows the dialog and requires you to deal with it before the user can return to the main window...ie...by clicking OK or CANCEL when they are done with it. You can use the dialog designer in EB to create the dialog. Here's some example code:

CREATEDIALOG OptionsDialog,0,0,364,108,0x80C80080,0,"Options Diaolog",&OptionsProc
CONTROL OptionsDialog,@RADIOBUTTON,"On",17,19,39,20,0x50030009,@IDSOUNDON
CONTROL OptionsDialog,@RADIOBUTTON,"Off",17,42,39,20,0x50010009,@IDSOUNDOFF
CONTROL OptionsDialog,@GROUPBOX,"Sound",5,5,70,72,0x50000007,4
CONTROL OptionsDialog,@GROUPBOX,"Level",85,5,105,72,0x50000007,5
CONTROL OptionsDialog,@RADIOBUTTON,"Easy",105,19,49,21,0x50030009,@IDEASY
CONTROL OptionsDialog,@RADIOBUTTON,"Medium",105,37,70,20,0x50010009,@IDMEDIUM
CONTROL OptionsDialog,@RADIOBUTTON,"Hard",105,53,70,20,0x50010009,@IDHARD
CONTROL OptionsDialog,@CHECKBOX,"Timed Game",142,82,80,21,0x50010003,@IDTIMED
CONTROL OptionsDialog,@BUTTON,"&OK",280,11,70,25,0x50010000,@IDOK
CONTROL OptionsDialog,@BUTTON,"&Cancel",280,51,70,25,0x50010001,@IDCANCEL
CONTROL OptionsDialog,@GROUPBOX,"Music",200,5,70,72,0x50000007,13
CONTROL OptionsDialog,@RADIOBUTTON,"On",206,19,58,20,0x50030009,@IDMUSICON
CONTROL OptionsDialog,@RADIOBUTTON,"Off",206,41,60,20,0x50010009,@IDMUSICOFF


Once your dialog is displayed, you can process user input via it's handler. In the above case, it's called OptionsProc. This is where you can save the data based on the check boxes, etc as illustrated below:

SUB OptionsProc

   SELECT @CLASS
      CASE @IDINITDIALOG
         CENTERWINDOW OptionsDialog
      CASE @IDCONTROL
         SELECT @CONTROLID
            CASE @IDOK
               SetOptions()
                  CLOSEDIALOG (OptionsDialog,@IDOK)
            CASE @IDCANCEL
               CLOSEDIALOG (OptionsDialog,@IDCANCEL)
            ENDSELECT
   ENDSELECT

ENDSUB


The SetOptions() call above is where the magic happens. It's a sub that you create to save the user input for use in the main window. The important thing, is that you save the user input for use in the main window before you close the dialog via the CLOSEDIALOG function. Once the dialog is closed, the data is lost. Here's an example of a sub routine to save user data from the dialog:

SUB SetOptions

   RValue=GETSTATE (OptionsDialog,@IDSOUNDON)

   IF RValue=@TRUE
      SoundPlaying=@TRUE
   ELSE
      SoundPlaying=@FALSE
   ENDIF

ENDSUB


As you can see, you use EB commands such as GETSTATE for seeing if a checkbox is selected and then based on that, save that info in a global variable for use in your main window.

I hope these code snippets help you some. If not, let me know and I'll whip up a quick example for you.

Thanks,

  Tony.

billhsln

I wrote an example program using Access with multiple tables that does some thing like that.  See

http://www.ionicwind.com/forums/index.php/topic,2030.0.html

Bill
When all else fails, get a bigger hammer.

hugh

Hello Tony,

I have been looking at your above sample code, is it Ebasic?
Because i am at a loss, as to the following,
@idsoundon
@idsoundoff
@ideasy
@idmedium
@idhard
@idmusicon
@idmusicoff

are the above created by you?.

because i cant find anything like them in my help file.

i hope you dont mind, i have copied your code and pasted it as a text file for now, a majority of your code is new to me.

Regards

Hugh

Ionic Wind Support Team

Ionic Wind Support Team

hugh

Thanks Paul,

Now i understand it fully.

I Will be implementing a few in my program,s

regards

Hugh

Tony

Quote from: hugh on November 24, 2008, 06:35:05 PM
Hello Tony,

I have been looking at your above sample code, is it Ebasic?
Because i am at a loss, as to the following,
@idsoundon
@idsoundoff
@ideasy
@idmedium
@idhard
@idmusicon
@idmusicoff

are the above created by you?.

because i cant find anything like them in my help file.

i hope you dont mind, i have copied your code and pasted it as a text file for now, a majority of your code is new to me.

Regards

Hugh


Hello Hugh,

  Yes, as Paul pointed out they are created by me using the SETID keyword in EB. I'm glad you find the code useful. Feel free to ask, should you have any questions. I'll be glad to help. :)