April 19, 2024, 10:36:15 AM

News:

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


Dialog questions

Started by arono, January 16, 2017, 12:18:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arono

Hi,

I'm having trouble with the appearance of my dialogs which were created in the Form Editor.  In the Editor, their appearance has an easily-read fontsize and the borders that surround them are what I want.  The generated source code from the Editor was placed in my program but when the dialogs are displayed in my window, they are larger and the fontsize is tiny. 
What can I do to bring across what I see in the Editor to my program window?

I've tried using the SETFONT command: SETFONT w, "Arial", 15, 400, 0, DrawTblAdd_OK
before the SHOWDIALOG command, after the SHOWDIALOG, in the handler in the @IDINITDIALOG section, but none of this works. 

---------------------------------------------------
My second question has to do with editing the data the user entered in a dialog. 
Once the user presses the OK button after adding data to the dialog (clicking the appropriate radio buttons and inserting data into an Edit control), my logic validates the data and may display error messages.  What I would like to do if there are errors is to show the dialog again with the data they previously entered (the settings of the radio buttons and the data in the Edit control) set the way they had it before. 
The only problem with this is how to set the radio buttons to the previous values.  You can't use the SETCONTROLTEXT for them to 0 or -1 because they are not text controls.  Is there some other command I can use?

Thanks.



billhsln

For: SETFONT w, "Arial", 15, 400, 0, DrawTblAdd_OK
Is the dialog defined as w? I thought you were using ScreenFileEdit.  If you are using ScreenFileEdit then the command should be:
SETFONT ScreenFileEdit, "Arial", 15, 400, 0, DrawTblAdd_OK
And you would use this after the field is created.

For the second question, keep your dialog open until after the data is clean.  Don't close it until it passes all the validation checks, that should just leave the settings as they are on the screen.

Bill
When all else fails, get a bigger hammer.

LarryMc

What Bill says above is the "normal" way of doing it. 
That's because you can nest dialogs and popup additional dialogs explaining an error during validation or just do it wit a simple MESSAGEBOX.

If for some reason you are absolutely wanting to close the dialog then validate the results and reset the previous entries/settings if they fail it can be done.
1. You only nee to use CREATEDIALOG once.
2. define  global variables to hold the initial values and the exit values
2a. open dialog
3. in the initdialog load the controls with the initial values
  SETSTATE window | dialog, ID, state    is used to set the radiobuttons to the state you want
4. before closing the dialog save all the control values to the exit value variables
   use GETSTATE to save the radiobutton state
5. do your validation
6 if it fails perform user notification
7. update initial value variables(or leave the original) and go back to 2a.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

arono

Thanks for your replies.  I appreciate it very much.

The SETFONT example I supplied in the post was another dialog in the program.  I had tried using the dialog name instead of w in the statement (as you show) but get the same result: no change in fonts in the dialog.  The command is placed immediately after the CREATEDIALOG and CONTROLS for the dialog.

Still wondering why my program  is displaying my dialogs differently than the Form Editor.  Is that normal?

Regarding validating the dialog data, I didn't think about calling my validation subroutine from within the handler.  I put it in the CASE statement for the OK button.  If errors are detected in validation, the CLOSEDIALOG is skipped.  The dialog and validation work fine now.

LarryMc

You have to remember there is a big difference between windows and dialogs.
When you use OPENWINDOW to create a window it actually exists at that point.
And since it exists at that point when you add controls they exists the instance you add them.
And since the window and controls exist exist you can issue commands that change their font,size, colors etc.

When you use CREATEDIALOG to create a dialog it does NOT actually exist at that point.
All you have done is allocate memory and internal pointers for the dialog.
And when you follow that with adding controls the controls do NOT actually exist at that point.
Again, you have only allocated memory and inernal pointers for the controls.
If you try to changed any of their  fonts, colors, etc at this time it won't work because they don't exist.

When you issue a SHOWDIALOG or DOMODAL command the dialog is actually created and you have your shot at changing it's visual appearance before it is seen by putting the commands in the CASE @IDINITDIALOG statement

hope that makes sense.

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

arono

Thanks Larry,

Makes perfect sense.  And it worked for me.