-
December 7th, 2008, 10:40 PM
#1
c++ winapi - Dialog Resize in Main Window
I have a dialog created at creation time:
Code:
//WM_CREATE
CreateDialog(hInst, MAKEINTRESOURCE(id_Dialog), hwnd, reinterpret_cast<DLGPROC>(DlgProc));
//.rc
id_Dialog DIALOGEX 1, 1, 1, 1
STYLE WS_CHILD | WS_VISIBLE | WS_BORDER
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_EDIT2,155,30,198,71,ES_AUTOHSCROLL
END
I would like to resize the dialog like everything else but without making it an HWND
Code:
MoveWindow(progTreeview, 0, 30, 150, HIWORD(lParam)-50, TRUE);
MoveWindow(progToolbar, 0, 0, LOWORD(lParam), 20, TRUE);
MoveWindow(progStatus, 0, HIWORD(lParam)-20, LOWORD(lParam), 20, TRUE);
MoveWindow(progTab, 155, 30, LOWORD(lParam)-155, HIWORD(lParam)-50, TRUE);
//MoveWindow(progEdit, 2, 22, LOWORD(lParam)-159, HIWORD(lParam)-75, TRUE);
and resize the EditBox in the dialog too.
Any Ideas? Thanks.
-
December 8th, 2008, 04:07 AM
#2
Re: c++ winapi - Dialog Resize in Main Window
I don't understand what you mean by "without making it an HWND"
It is a HWND.
Resize the control in the dialogs procedure in the message WM_SIZE or WM_SIZING.
-
December 8th, 2008, 07:27 AM
#3
Re: c++ winapi - Dialog Resize in Main Window
The Main Window that contains the Dialog is HWND hwnd. I should also point out that the dialog is inside the hwnd, not a popup.
In my program, I will be creating more than one dialog with the same code:
Code:
CreateDialog(hInst, MAKEINTRESOURCE(id_Dialog), hwnd, reinterpret_cast<DLGPROC>(DlgProc));
to make the Dialog a HWND, I would put:
Code:
HWND progDialog = CreateDialog(hInst, MAKEINTRESOURCE(id_Dialog), hwnd, reinterpret_cast<DLGPROC>(DlgProc));
So no, the dialog is not an HWND until I make it an HWND.
So, if it was an HWND, I would not be asking how to resize it, and would be able to resize it here, along with everything else:
Code:
//WM_SIZE
MoveWindow(progTreeview, 0, 30, 150, HIWORD(lParam)-50, TRUE);
MoveWindow(progToolbar, 0, 0, LOWORD(lParam), 20, TRUE);
MoveWindow(progStatus, 0, HIWORD(lParam)-20, LOWORD(lParam), 20, TRUE);
MoveWindow(progTab, 155, 30, LOWORD(lParam)-155, HIWORD(lParam)-50, TRUE);
//MoveWindow(progEdit, 2, 22, LOWORD(lParam)-159, HIWORD(lParam)-75, TRUE);
Last edited by zaryk; December 8th, 2008 at 07:30 AM.
-
December 8th, 2008, 07:59 AM
#4
Re: c++ winapi - Dialog Resize in Main Window
I'm really confused.
Regardless if you assign the return value of CreateDialog, it returns a HWND.
If you just do not assign this value to a variable you do not have a direct access to this window, unless you are searching for it with EnumChildWindows for instance.
But why would you search for some handle that you create on your own?
But I guess I just didn't understand what you are really looking for.
-
December 8th, 2008, 08:36 AM
#5
Re: c++ winapi - Dialog Resize in Main Window
Is there anyway to resize a dialog or any control at all based on the id of the dialog or control??
-
December 8th, 2008, 09:17 AM
#6
Re: c++ winapi - Dialog Resize in Main Window
I will not ask why you don't just use the handle you already could have.
So I'll try to give an answer to your question.
If you don't know the dialogs or the controls handle, there are some api functions to receive it.
I guess the easiest way to accomplish a resize a window (dialogs and controls are windows indeed) is to use SetWindowPos().
So, this function needs a window handle (HWND) to identify the window it should operate on.
So you refuse to use the handle you receive by creating a dialog/control. You have to use another
function to get those handles. GetDlgItem() will return the window handle of a control in your dialog if you pass the owning handle plus the control ID.
To get the handle of a dialog it depends if it's a child or top level window.
If the dialog you want to resize is a top level window you can just use FindWindow() or FindWindowEx() if you know it's class name or window title. If the dialog is a child window you either need to use FindWindowEx() or EnumChildWindows() from the parent window.
hope this helps,
Andy
-
December 8th, 2008, 09:20 AM
#7
Re: c++ winapi - Dialog Resize in Main Window
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
|