Skip to main content
gamedev.net
🔒 Locked

dialog boxes

Started by Ranthalion Jul 19, 2003 at 9:41 PM 5 replies 450+ views
Original Post
Ranthalion
Ranthalion
Is it possible to make a dialog box that is not moveable? Also, how would you set the focus to a specific control in a dialog box on creation? I have a dialog box that asks for a password, and I want the cursor to automatically be in the password edit box on creation. I''m using MSVC++ 6
infinitycool
infinitycool
Using MFC or oldschool C style Win32?
"Black Holes are where God divided by zero"
Ranthalion
Ranthalion
I don''t know anything about MFC, so I suppose I''m going Win32 route. I have made a resource and call the dialog with DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1),
NULL, (DLGPROC)MainDialogProc);
S1CA
S1CA
Your DialogProc gets the same messages a normal window does (because it is a window).

So you could:

1) use SetCapture() and similar to treat the cursor as exclusive

2) respond to WM_NCHITTEST with HTCLIENT to trick Windows into thinking that any clicks on the border, title bar etc are actually inside the window.

3) respond to WM_SYSCOMMAND for things like SC_MOVE and SC_SIZE

4) respond to similar messages that might interfere with your dialog.


--
Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Beer Hunter
Beer Hunter
quote:
Original post by S1CA
respond to WM_NCHITTEST with HTCLIENT to trick Windows into thinking that any clicks on the border, title bar etc are actually inside the window.
Seconded.

For the other question, make a handler for WM_INITDIALOG. In it, set the focus to the desired control, then return FALSE.
Ranthalion
Ranthalion
how would I set the focus to that control though?
Beer Hunter
Beer Hunter
SetFocus(GetDlgItem(hWnd, IDC_PASSWORD));
(where ''hWnd'' is the first parameter to the DialogProc, and IDC_PASSWORD is the identifier of the edit box)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.