Any way to intercept WM_SIZING with SDI/MDI application
-
I need to restrict the resizing of the SDI application. I tried the method found in http://www.codeproject.com/useritems/mdibackgroundimage.asp to hook on to WM_SIZING and it worked. But i was wondering whether there was any other way, any msg i could overload? tried all the PreTranslateMessage and ProcessMessageFilter message map, but it did'nt work. This is a slightly modified one from winamp plugin. very slightly. i just wanted
WNDPROC pfnOldWndProc;
// new one
LRESULT CALLBACK pfnNewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
CRect rect;switch (uMsg) { case WM\_SIZING : if ((wParam==WMSZ\_BOTTOMLEFT) || (wParam==WMSZ\_BOTTOMRIGHT)) wParam=WMSZ\_BOTTOM; else if ((wParam==WMSZ\_TOPLEFT) || (wParam==WMSZ\_TOPRIGHT)) wParam=WMSZ\_TOP; GetWindowRect(hwnd,rect); ((RECT\*)lParam)->left= rect.left; ((RECT\*)lParam)->right = rect.right; break; } return CallWindowProc(pfnOldWndProc, hwnd, uMsg, wParam, lParam);
}
and in InitInstance()
HWND hMain = GetActiveWindow(); pfnOldWndProc = (WNDPROC)GetWindowLong(hMain, GWL\_WNDPROC); SetWindowLong(hMain, GWL\_WNDPROC, (long)pfnNewWndProc);
-
I need to restrict the resizing of the SDI application. I tried the method found in http://www.codeproject.com/useritems/mdibackgroundimage.asp to hook on to WM_SIZING and it worked. But i was wondering whether there was any other way, any msg i could overload? tried all the PreTranslateMessage and ProcessMessageFilter message map, but it did'nt work. This is a slightly modified one from winamp plugin. very slightly. i just wanted
WNDPROC pfnOldWndProc;
// new one
LRESULT CALLBACK pfnNewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
CRect rect;switch (uMsg) { case WM\_SIZING : if ((wParam==WMSZ\_BOTTOMLEFT) || (wParam==WMSZ\_BOTTOMRIGHT)) wParam=WMSZ\_BOTTOM; else if ((wParam==WMSZ\_TOPLEFT) || (wParam==WMSZ\_TOPRIGHT)) wParam=WMSZ\_TOP; GetWindowRect(hwnd,rect); ((RECT\*)lParam)->left= rect.left; ((RECT\*)lParam)->right = rect.right; break; } return CallWindowProc(pfnOldWndProc, hwnd, uMsg, wParam, lParam);
}
and in InitInstance()
HWND hMain = GetActiveWindow(); pfnOldWndProc = (WNDPROC)GetWindowLong(hMain, GWL\_WNDPROC); SetWindowLong(hMain, GWL\_WNDPROC, (long)pfnNewWndProc);
aldeba wrote: I need to restrict the resizing of the SDI application. WM_MINMAXINFO is what you need Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002 Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
-
I need to restrict the resizing of the SDI application. I tried the method found in http://www.codeproject.com/useritems/mdibackgroundimage.asp to hook on to WM_SIZING and it worked. But i was wondering whether there was any other way, any msg i could overload? tried all the PreTranslateMessage and ProcessMessageFilter message map, but it did'nt work. This is a slightly modified one from winamp plugin. very slightly. i just wanted
WNDPROC pfnOldWndProc;
// new one
LRESULT CALLBACK pfnNewWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
CRect rect;switch (uMsg) { case WM\_SIZING : if ((wParam==WMSZ\_BOTTOMLEFT) || (wParam==WMSZ\_BOTTOMRIGHT)) wParam=WMSZ\_BOTTOM; else if ((wParam==WMSZ\_TOPLEFT) || (wParam==WMSZ\_TOPRIGHT)) wParam=WMSZ\_TOP; GetWindowRect(hwnd,rect); ((RECT\*)lParam)->left= rect.left; ((RECT\*)lParam)->right = rect.right; break; } return CallWindowProc(pfnOldWndProc, hwnd, uMsg, wParam, lParam);
}
and in InitInstance()
HWND hMain = GetActiveWindow(); pfnOldWndProc = (WNDPROC)GetWindowLong(hMain, GWL\_WNDPROC); SetWindowLong(hMain, GWL\_WNDPROC, (long)pfnNewWndProc);
Ur Requirement is to limit resizing. U should go for the message WM_GETMINMAXINFO. OnGetMinMaxInfo(MINMAXINFO *mmi) message handler, mmi->ptMaxSize, mmi->ptMaxTrackSize, mmi->ptMaxTrackSize are the relevent member to be filled to limit resizing. mmi->ptMaxTrackSize is SIZE u want to restrict.