- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In a certain situation I would like to be able to simulate the click of a button without actually having to click it. For example, when a user clicks a particular radio button, I would like the program to behave as though the user had then immediately clicked the OK button as well. Can this be done?
With many thanks in advance,
Mike
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is how I send such a message to a button control, ID=IDC_DISPLAY_FILE. gDlg is type T_DIALOGand gDlg%hWnd is the handle to the dialog containing the control. IOR combines the BN_CLICKEDand the control ID into high and low order parts of the first argument of the WM_COMMAND.GetDlgItem supplies the handle to the control with ID IDC_DISPLAY_FILE asthe second argument required by WM_COMMAND (See below)retlog = SendMessage(gdlg%hWnd,WM_COMMAND, IOR(BN_CLICKED,IDC_DISPLAY_FILE), & GetDlgItem(gdlg%hWnd,IDC_DISPLAY_FILE))WM_COMMAND takes two arguments (see CVF HELP) as shown belowCode:WM_COMMAND wNotifyCode = HIWORD(wParam); // notification code wID = LOWORD(wParam); // item, control, or accelerator identifier hwndCtl = (HWND) lParam; // handle of control Parameters wNotifyCode Value of the high-order word of wParam. Specifies the notification code if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0. wID Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator. hwndCtl Value of lParam. Handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.Message Edited by anthonyrichards on 08-23-2004 02:41 AM
Message Edited by anthonyrichards on 08-23-2004 02:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The BM_CLICK message has exactly that purpose.
Send it to the control with sendmessage(hctrl,BM_CLICK,0,0)
See :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/buttons/buttonreference/buttonmessages/bm_click.asp
Send it to the control with sendmessage(hctrl,BM_CLICK,0,0)
See :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/buttons/buttonreference/buttonmessages/bm_click.asp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another method is possible, if you have assigned a callback routine, MyButtonSub say,
to the button, by just calling the callback directly as
call MyButtonSub( ButtonDlg, IDC_MYBUTTON, dlg_clicked)
where ButtonDlg is type T_Dialog and is the dialog containing the button whose ID is defined to be IDC_MYBUTTON. The ID is normally listed in RESOURCE.FD that is generated by the Resource compiler when it builds your dialog, so INCLUDE RESOURCE.FD must be added to
the routine from which you call the callback routine, and the dialog ButtonDlg must be available
(possibly via a global variable) to the same routine. 'Dlg_Clicked' is defined in DFLOGM.F90 in Module DFLOGM ( integer, parameter, public :: dlg_clicked = -4), so USE DFLOGM must also be added to the code for the calling routine. HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Anthony,
The first method you suggested works very well and I am using it to great effect. However, I will note your second suggestion for the future.
With many thanks
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