- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I have issues with dialogue boxes I have created in the Quick Win framework. Please look for example the dialogue box below.
What I do here is potting a pointer in a plot I have created to zoom in a section of it. However I have two issues.
Firstly for some reason I cannot get the "Cancel" button to work. Both "OK" and "Cancel" work as "OK". This means that any number written in the Edit Box is kept as a variable. For example I have tried (ID is IDCANCEL)
LOGICAL bret
...
bret = DlgSetSub( dlg, IDCANCEL, cancel2)
...
with cancel2 being a simple subroutine:
subroutine cancel2()
implicit none
write(*,*) "No zoom performed"
end subroutine cancel2
or a subroutine containing cases from the above or other boxes with
select case(local_id)
case(IDCANCEL)
write(*,*) "No zoom performed"
end select
Nothing works. I would like to note that the X in the upper right has the same problem.
Secondly, if I try to input a negative number in the Edit Box the program crashes:
Is there a way to correct this?
I would like to thank everyone who answers in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the example. Lots of issues here.
- DLG_SELCHANGE isn't for use on edit boxes. If you wanted to be notified on ANY change to the box, use DLG_CHANGE, but you don't want that either. Instead, you want to wait until the user click OK and then get the values using DLGGET. You might use DLG_CHANGE if you wanted to validate values as they were entered, but you can't do that with list-directed input as it will fail with partial input.
- And that means you don't want to call Update - either as an action when the control changes nor explicitly in the code.
- If you set a callback for the Cancel button, that overrides the default actions. You don't want to do that. Leave it at the default and check for DLGMODAL returning IDCANCEL.
- If you do call DLGSETSUB and specify a procedure (which you don't need here), you have to filter on the callback type being DLG_INIT for initialization. Also you had too many SELECT CASEs, I merged them.
- In a QuickWin application, you really should call SLEEPQQ(500) in the spinwait loop.
Basically, the only reason to use DLGSETSUB is if you want to change the content of a dialog while the user is selecting controls. Otherwise, wait until DLGMODAL returns, and if the control return isn't IDCANCEL, get the values and process them.
A revised version is attached - some lines commented out, some removed.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You haven't included any of the relevant parts of the program, so it is difficult to help you. It's always best to attach a minimal but complete test case that demonstrates the problem.
Regarding Cancel, your call to DLGMODAL will return IDCANCEL. What your program does with it then is up to you.
As for the input, you have not shown us the text that is triggering the error nor the READ statement. List-directed input is very forgiving, but I'm guessing that it is being presented with something other than what you think it should.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your input.
I have created a sample functioning project that shows my issue. If the code is compiled the function I have added is the last one in the "File" menu called "Input Pointer".
In the Edit Control there the user is asked to input two values to be used in numerical applications but in this example they are simply printed in the screen. If one inputs a negative "-" sign (located in the right of Zero in a typical EU keyboard) the program crashes. It also crashes if the default input is deleted without giving time to input a new value.
Finally the "Cancel" and "X" buttons show not right behaviour but this is a mistake on my part that I don't know how to fix. I have this problem also in child windows not shown in this test code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the example. Lots of issues here.
- DLG_SELCHANGE isn't for use on edit boxes. If you wanted to be notified on ANY change to the box, use DLG_CHANGE, but you don't want that either. Instead, you want to wait until the user click OK and then get the values using DLGGET. You might use DLG_CHANGE if you wanted to validate values as they were entered, but you can't do that with list-directed input as it will fail with partial input.
- And that means you don't want to call Update - either as an action when the control changes nor explicitly in the code.
- If you set a callback for the Cancel button, that overrides the default actions. You don't want to do that. Leave it at the default and check for DLGMODAL returning IDCANCEL.
- If you do call DLGSETSUB and specify a procedure (which you don't need here), you have to filter on the callback type being DLG_INIT for initialization. Also you had too many SELECT CASEs, I merged them.
- In a QuickWin application, you really should call SLEEPQQ(500) in the spinwait loop.
Basically, the only reason to use DLGSETSUB is if you want to change the content of a dialog while the user is selecting controls. Otherwise, wait until DLGMODAL returns, and if the control return isn't IDCANCEL, get the values and process them.
A revised version is attached - some lines commented out, some removed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the help. The book I was reading overcomplicated things and since till now I used Combo Boxes I thought they were needed in Edit Boxes too.
One final question: DLGGET can be used generally between DLGMODAL and DLGUNINIT to update the values of the variables thus making (in simple cases as mine though) the program simpler?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"DLGGET can be used generally between DLGMODAL and DLGUNINIT" Yes is the answer to that! One additional comment you could have a custom exit button with a callback that gets and checks the input and then either gives some error messages and stays in the dialog or calls dlgexit. It depends how you want to handle error conditions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for this!
Using DLGGET between DLGMODAL and DLGUNINIT helps clarity since my code is a simple GUI running numerics. DLGSETSUB is preferably used in Combo Boxes it seems.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page