|
-
Jan 6th, 2001, 11:56 AM
#1
Thread Starter
Frenzied Member
Hi,
I'm trying to set the focus to an edit control when a dialog box is initizlied:
hWnd = SetFocus(GetDlgItem(hDlg,IDC_EDIT1));
But it's not happening.. No errors, but the focus is not getting set on IDC_EDIT1.
Any ideas what I'm doing wrong?
thanks,
dan
-
Jan 6th, 2001, 12:02 PM
#2
Thread Starter
Frenzied Member
I just tried another approach to the set focus and it worked.. I put a button on the dialog box to set the focus. So why does that work and my first example doesn't?
I wonder if it has something to do with the fact that I'm trying to set the focus as the dialog is being initilized and maybe there is not yet a handle assigned to IDC_EDIT1?
My first example I put it under:
case WM_INITDIALOG:
Is that the wrong place? I want to set the focus when the dialog is shown...
Any help would be appreciated..
Dan
-
Jan 6th, 2001, 12:14 PM
#3
Monday Morning Lunatic
When WM_INITDIALOG is sent, the dialogue has not yet been shown - it's only been initialised. So, to change it when the dialogue is shown, use WM_SHOWWINDOW.
Incidentally, that message is sent when the window is shown or hidden, so keep an eye on the parameters:
lParam:
Code:
SW_OTHERUNZOOM The window is being uncovered because a maximize window was restored or minimized.
SW_OTHERZOOM The window is being covered by another window that has been maximized.
SW_PARENTCLOSING The window's owner window is being minimized.
SW_PARENTOPENING The window's owner window is being restored.
wParam:
Code:
TRUE The window is being shown
FALSE The window is being hidden
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|