I am dealing with dialog window created usign ResEdit as a resource editor. Now, I'd need to make a window resizable and to have all the child controls in it resize themselves according to the dialog size. Can iy actually be done?
I see lots of examples of how to do this out there but they are all for MFC
or other toolkits. I need to do this in a C++ app using normal win32 API
calls.
hoxsiew
February 15th, 2010, 08:11 PM
There's nothing inherent to MFC that makes this any different. Basically you have to do it all yourself. Make the dialog resizable (resizing border: WS_SIZEBOX or WS_THICKFRAME), then handle the WM_SIZE message. In your handler, resize all you controls to fit the dialog the way you want by calling MoveWindow or SetWindoPos on them.
Now, I'd like to avoid the window from resizing less the x300, y250 like it has some min width and minheight values....do you think that is possible?
thanks
VladimirF
February 16th, 2010, 11:07 AM
Now, I'd like to avoid the window from resizing less the x300, y250 like it has some min width and minheight values....do you think that is possible?Sure - check out WM_GETMINMAXINFO message.
THEARTOFWEB
February 16th, 2010, 12:37 PM
by the way, I have found the the status bar does not need any actual parameters to be redrawn! the following creates a status bar in the Dialog:
// Create Status Bar
//
InitCommonControls();
HWND hWndStatus = CreateWindowEx(0,STATUSCLASSNAME,NULL,WS_CHILD | WS_VISIBLE,0,0,10,10,hDlg,(HMENU)IDC_STATUSBAR,hInst,NULL);
UINT indicators[] = {250,1100}; // Lunghezza celle status bar:
//da 0 a 250 e da 250 a 1100
SendMessage( hWndStatus, SB_SETPARTS, 2, (LPARAM)(LPINT)indicators); // setta la status bar in due celle con
// con le misure create prima (indicators)
If you want to move a lot of windows without too much flickering, you can use DeferWindowPos (http://msdn.microsoft.com/en-us/library/ms632681(VS.85).aspx).
The above blog posting has instructions on how to create a minimalist re-sizeable dialog in MFC.
It is basically an implementation of Paulo Messina's posting at CodeProject but with as much extraneous stuff removed as possible, just to help clarify how to do it better.
It is fairly straightforward to implement once you've had a bit of practice: the important bits are to:
i. ensure you have his CodeProject libraries etc pulled into your project and it all compiles correctly.
ii. do the extra initialization required inside the OnInitDialog method: make the gripper visible, set the maximum dilog size, add anchor points to the dialog control items that you wish to 'stretch' etc.
iii. Replace usage of CDialog with CResizableDialog at the appropriate points: in the dialog class definition, constructor, DoDataExchange, BEGIN_MESSAGE_MAP, OnInitDialog etc.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.