Is there any way to give a position on the screen for dialogboxes, created with CreateDialog? With normal windows (created with CreateWindow) this is possible, but CreateDialog only seems to accept 4 parameters.
Also, is it possible to give these dialogboxes normal window things like resizing, minimizing, etc.?
To create a dialog, you need to prepare dialog template, which is normally created as resource.
RC script is compiled by resource compiler(rc script source), and resource compiler ouputs binary data.
Binary data is merged into EXE or DLL(They are placed on resource section) by linker.
Dialog's x, y, width, height is inside the dialog template.
Dialog template contains many properties of a dialog.
typedef struct {
DWORD style;
DWORD dwExtendedStyle;
WORD cdit;
short x;
short y;
short cx;
short cy;
} DLGTEMPLATE, *LPDLGTEMPLATE;
typedef struct {
WORD dlgVer;
WORD signature;
DWORD helpID;
DWORD exStyle;
DWORD style;
WORD cDlgItems;
short x;
short y;
short cx;
short cy;
sz_Or_Ord menu;
sz_Or_Ord windowClass;
WCHAR title[titleLen];
WORD pointsize;
WORD weight;
BYTE italic;
BYTE charset;
WCHAR typeface[stringLen];
} DLGTEMPLATEEX;
To change x, y, width, and height on the code,
you can simply resize the dialog box after you created a dialog.
example)
HWND hDialog = CreateDialog(...);
MoveWindow(hDialog, x, y, width, height, TRUE);
.....
Also you can manipulate the dialog template binary data directly, and call CreateDialogIndirect(Param), but this method is a little complicated...
You can resize dialog box with MoveWindow, SetWindowPos functions.
CreateDialog returns HWND.
You can pass the HWND to any of the functions that receives HWND.
I've found out there is just a property (I use the Visual Studio Resource editor) to set positions on screen. Also, there seems to be some properties to maximize/minimize box.
2 questions:
1) As it seems these things can be done both with the properties and with API functions, which method is the best? Is there any reason why one method is wrong?
2) I can't find a property to make the window (dialog) resizeable - is this possible?
1. best..? hmm.. hard question..
When you need to resize and reposition a dialog box on the code, just do that... that's all.
Normally, you may need to reposition a dialog to place it on the center of the parent window.
(I prefer using CBT hook to do this...)
You can do resizing with MoveWindow, but normally(normally. not on special cases)
dialog's size is determined on designing time, not on the code.
2. There are some styles to make the dialog box
(not only dialog boxes, but also plain windows) resizable...
Maybe WS_SIZEBOX.? If not, try to find another style on the MSDN.
SetWindowPos() is generally the best way to resize and manipulate windows/dialogs.
I have an app where I have set all dialogs sizes to 0,0,0,0 in the resource file, and then resize them dynamically to the rect of my main dialog using SetWindowPos().