- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would like to simulate (for instance) the OK button of a dialog so that the DlgModal function ends.
I already tried a piece:
iRet = DlgSendCtrlMessage( gdlg, IDM_Exit, WM_IME_KEYDOWN, VK_RETURN, 0 )
iRet = DlgModal(...
without succes.
Purpose is to make dialogs automated in software-controlled situations.
Any idea?
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are creating modal dialog box. It means it does not return from dialog box subroutine until its OK button is clicked. If you want to click its button you need to do it from another thread (because your main code thread is blocked by modal dialog box). Another possibility is to use Modeless dialog box.
I did not noticed that you are using Intel Fortran dialog boxes routines. I have expected you use win32 routines.
I created simple dialog box application. Before calling DlgModal function is created another thread, which waits 10 seconds and then calls routine DlgAppApply associated with apply button
call DlgAppApply( gdlg, IDM_APPLY, dlg_clicked)
This routine handles button press and exits from dialog box.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try
iRet = SendMessage( gdlg,WM_COMMAND,BN_CLICKED,IDOK)
IDOK is usually default ID of Ok button
according to https://docs.microsoft.com/en-us/windows/win32/controls/bn-clicked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jakub,
Thanks for the replay. Unfortunately, this does not function.
The first argument of SendMessage should be a handle to the button.
I used:
Integer hButton
hButton = GetDlgItem( gdlg.Hwnd, IDOK )
iRet = SendMessage( hButton, WM_COMMAND, BN_CLICKED, IDOK )
iRet = DlgModal( gdlg )
This construction still does not function.
I also tried without succes
iRet = SendMessage( gdlg.hwnd, WM_COMMAND, BN_CLICKED, IDOK )
Does anyone have an idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am sorry, it was mistake from my side. Reading Microsoft documentation I suppose it should be something like
iRet = SendMessage( gdlg,WM_COMMAND,MAKELONG(IDOK,BN_CLICKED),0)
I.e. wParam is constituted from notification message BN_CLICKED in Higher word and ID of button in lower word.
I didn't tested it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jakub,
Thanks again. Regretfully it is still not working.
I tried gdlg.Hwnd a sthe 1st argument should be a handle and not the complete dialog structure.
I also tried hButton = GetDlgItem( gdlg.hWnd, IDOK ) instead of gdlg.
No succes.
If you have more ideas it would be great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are creating modal dialog box. It means it does not return from dialog box subroutine until its OK button is clicked. If you want to click its button you need to do it from another thread (because your main code thread is blocked by modal dialog box). Another possibility is to use Modeless dialog box.
I did not noticed that you are using Intel Fortran dialog boxes routines. I have expected you use win32 routines.
I created simple dialog box application. Before calling DlgModal function is created another thread, which waits 10 seconds and then calls routine DlgAppApply associated with apply button
call DlgAppApply( gdlg, IDM_APPLY, dlg_clicked)
This routine handles button press and exits from dialog box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Jakub,
I understand what you say about modal dialog-boxes. I was thinking of sending a button push in advance that would then be added to some kind of stack.
Thanks a lot for your example. This works fine.
Could you please explain what is the part about "!! Read and process messages" ? If I leave it out it seems to work as well. It looks like a part of the DlgModal software itself.
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Part
! Read and process messsages do while( GetMessage (mesg, NULL, 0, 0) ) if ( DlgIsDlgMessage(mesg) .EQV. FALSE ) then bret = TranslateMessage( mesg ) lret = DispatchMessage( mesg ) end if end do
was declared by template which was used to define Dialog application. It is part of every Windows application. Every mouse movement, key press, ... is send to message queue of application and it is processed in this loop.
Modal dialog box manages those messages itself.
I think for automatic control of your application will be better to not display dialogs and simply run only code doing calculations. It means to separate user interface and calculation code.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page