Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Newbie Help...

infinity77
Beginner
201 Views
Hello NG,
I'm trying to build something quite easy, a simple input dialog with 2 buttons and 1 edit box. My problem is the following: I would like to set the focus on the edit box when the dialog is first opened, in order to avoid the use of the mouse. The user would start typing things inside the edit box without clicking on it before (to activate it).
I designed something with the resource editor, and I wrote this piece of code (my edit box is IDC_EDIT1):
PROGRAM MIOMES
USE DFLOGM
USE DFWIN
IMPLICIT NONE
INCLUDE 'RESOURCE.FD'

TYPE (dialog) dlg
LOGICAL returno, retlog, value
INTEGER results, iret, prevHwnd
CHARACTER(256) text
EXTERNAL OnDlgInit
returno = DLGINIT( IDD_DIALOG1, dlg )
retlog = DLGSET (dlg, IDC_EDIT1, '')
prevHwnd = GetDlgItem(dlg%hWnd,IDC_EDIT1)
prevHwnd = SetFocus(prevHwnd)
retlog = DlgSetSub(dlg,IDD_DIALOG1,OnDlgInit)
results = DLGMODAL (dlg)
value = DLGGET (dlg, IDC_EDIT1, text)
CALL DlgUninit( dlg )

END PROGRAM MIOMES
SUBROUTINE OnDlgInit(dlg, id, callbacktype)
USE DFLOGM
USE DFWIN
TYPE (dialog) dlg
INTEGER id, callbacktype, prevHwnd
INCLUDE 'RESOURCE.FD'
prevHwnd = GetDlgItem(dlg%hWnd,IDC_EDIT1)
prevHwnd = SetFocus(prevHwnd)
end subroutine OnDlgInit
But It does not work. The dialog is created but the edit box has not the focus... could you please give some suggestions?
Thank you a lot.
Andrea.
0 Kudos
1 Reply
anthonyrichards
New Contributor III
201 Views
Select the dialog in the Resource editor, choose menu item 'Layout' then 'Tab order', then click on the edit box. This should put it first in the tab order, so that it will have focus when you open the dialog. HTH
0 Kudos
Reply