- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a lot I don't understand about WIN32, dialog boxes, and DFLOGM. I have a dialog box which has, among many other things, 3 pairs of radio buttons. The first of each pair is checked "group" and the second is not. If I use the following code in the dlg proc:
the dialog, and in particular, the radio buttons work fine, except that none of the radio buttons is on when the dialog first appears. However, with the following version:
the radio buttons work perfectly. This surprises me because the statement
bret = DlgSet(dlg,IDC_optheme,'qtest')
is quite irrelevant as far as the radio buttons are concerned, yet it appears necessary, as do the other extra bits and pieces. Please could someone explain what's going on here.
With many thanks
Mike
select case(message) case(WM_INITDIALOG) call CenterWindow(hDlg,GetWindow(hDlg,GW_OWNER)) OverlayDlgProc = 1 return
the dialog, and in particular, the radio buttons work fine, except that none of the radio buttons is on when the dialog first appears. However, with the following version:
use dflogm implicit none type (dialog) dlg dlg.hwnd = hDlg select case(message) case(WM_INITDIALOG) bret = DlgInit(IDD_overlay,dlg) call CenterWindow(hDlg,GetWindow(hDlg,GW_OWNER)) bret = DlgSet(dlg,IDC_optheme,'qtest') OverlayDlgProc = 1 return
the radio buttons work perfectly. This surprises me because the statement
bret = DlgSet(dlg,IDC_optheme,'qtest')
is quite irrelevant as far as the radio buttons are concerned, yet it appears necessary, as do the other extra bits and pieces. Please could someone explain what's going on here.
With many thanks
Mike
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're toying with fire here. I can tell you what's going on, but that's not the way to do it. You're loading the Dlg structure to memory using DlgInit, and then fill in Dlg%hWnd. In this way, the Dlg structure is "almost" valid, but DialogProc is yours, not the one within DFLOGM. Now, take a look at source of DFLOGM.f90: when you call DlgSetChar, it calls DlgFlush at the end to synchronize dialog appearance with contents of Dlg structure. It calls Data2Dialog, which within CASE(ctrl_radiobutton) ultimately calls:
Do not fiddle with DFLOGM once you wrote your own DialogProc and invoked it with DialogBox(Indirect) API. Instead, initialize your controls using native APIs -- mostly Send(DlgItem)Message. So, the "real" solution is to
Most of your DialogProc will contain calls to SendDlgItemMessage, which is (more or less) what DlgSet/DlgGet do. Although the number of message symbolic names is big, they're systematized rather consistently: for example, BM_ are button messages, EM_ edit box messages, CB_ combobox etc. And you can always refer to source of DFLOGM.f90 (particularly Data2Dialog and Dialog2Data) to find out how it's implemented there -- just don't USE it. You might get away with it, as in this case, but IMO you're asking for trouble.
Jugoslav
dummyi = DlgSendMessage( hwndControl, BM_SETCHECK, & log2int( dlg % list(index) % logvalue(2) ), 0 )The variable in question is by default initialized to .TRUE. in DlgInit for the first radio button. So, it "magically works".
Do not fiddle with DFLOGM once you wrote your own DialogProc and invoked it with DialogBox(Indirect) API. Instead, initialize your controls using native APIs -- mostly Send(DlgItem)Message. So, the "real" solution is to
SendDlgItemMessage(hDlg,IDC_FIRSTRADIO,BM_SETCHECK,BST_CHECKED,0)on WM_INITDIALOG. There's also CheckRadioButton API (which is actually just a wrapper around BM_SETCHECK).
Most of your DialogProc will contain calls to SendDlgItemMessage, which is (more or less) what DlgSet/DlgGet do. Although the number of message symbolic names is big, they're systematized rather consistently: for example, BM_ are button messages, EM_ edit box messages, CB_ combobox etc. And you can always refer to source of DFLOGM.f90 (particularly Data2Dialog and Dialog2Data) to find out how it's implemented there -- just don't USE it. You might get away with it, as in this case, but IMO you're asking for trouble.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankyou, Jugoslav, I am beginning to see the light now.
Mike
Mike

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page