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

Set focus on simple dialog project

Intel_C_Intel
Employee
811 Views
I want to set the focus of an edit box on a simple dialog project.
I can't see anything to do with this in the SetDlg function.
How do you do it?

Thanks,
David
0 Kudos
6 Replies
Jugoslav_Dujic
Valued Contributor II
811 Views
There's no DlgSet equivalent, but you can use SetFocus(GetDlgItem(Dlg%hWnd), idControl), or, better, WM_NEXTDLGCTL.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
811 Views
Thanks, I have used the SetFocus function.
If the ID is a button then the button is highlighted - but the ID is an edit box - I expect the cursor to be placed at the first character of the edit box ready for typing but nothing appears to happen. Is there something more I have to do?

David
0 Kudos
Jugoslav_Dujic
Valued Contributor II
811 Views
From where are you calling SetFocus? This will work only when called from a callback routine (if the dialog is modal) or after DlgModeless (if it's modeless).

Jugoslav
0 Kudos
Intel_C_Intel
Employee
811 Views
It is being called from a callback routine from a modal dialog box - I think I have the termonology right.

SUBROUTINE IsoCheck(dlg,id,callbacktype )
!-----------------------------------------
!Dialog box callback for Iso Check
use dfwin
use dflogm
use Vol99Globals

include 'resource.fd'
		
type (dialog)	dlg
		
integer*4 id,callbacktype,iret
logical*4 lret

if (callbacktype == dlg_clicked) then
	lret = DlgGet(dlg, id, iso)
	lret = DlgSet(dlg,IDC_JOB3,iso,dlg_enable)
	if (iso) then
		iret=SetFocus(GetDlgItem(dlg%hwnd,IDC_JOB3))
	end if
endif
END SUBROUTINE IsoCheck
0 Kudos
Jugoslav_Dujic
Valued Contributor II
811 Views
Hmph... don't have time to try this at the moment, but that IMO should have worked.

Still, try Send/PostMessage(Dlg%hWnd, WM_NEXTDLGCTL, 1, GetDlgItem(Dlg%hWnd, IDC_JOB3)) instead. If I recall correctly, that will also select the text within the control, if any.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
811 Views
That didn't work either.

Looking back over all the work I have done, SetFocus has never worked for a Edit Box in a simple dialog application, but is OK on a API application.

There must be something missing in my initialisation.

David
0 Kudos
Reply