Question : how to avoid window resize programmatically using MFC for the drag event on title bar which occurs in windows 7 ?

in Windows 7,
when the drag event happen on title bar, window will be re-sized. this is occurring due to aero snap feature. if we disable aero snap feature then it will applicable to all windows.

is there any way to avoid pro-grammatically, only for the specified window?

the behavior is applicable to windows 7 only.

when drag event happen, windows generating the WM_SYSCOMMAND with wparam value 0xF012. and this command is leading to

WM_MOVE and WM_SIZE  when aero snap featue turned ON
only WM_MOVE when aero snap feature turned OFF.

if we suppress WM_SIZE, resizing is not happening but the window becomes not movable.

how to suppress WM_SIZE but making window as movable for the drag event on title bar for windows 7 OS, when the aero snap feature turned ON ?

Answer : how to avoid window resize programmatically using MFC for the drag event on title bar which occurs in windows 7 ?

Here is the solution for the issue:
  1.         switch(message) 
  2.      { 
  3.            case WM_SYSCOMMAND: 
    1.                  { 
    2.                        if(wParam == 0xf012 && IsZoomed() ) 
    3.                        { 
    4.                              m_lPrevState = wParam; 
    5.                        } 
    6.                        else 
    7.                              m_lPrevState = 0L; 
    8.                  } 
    9.                  break; 

  4.  
  5.            case WM_MOVING: 
  1.                  { 
  2.                        if(IsZoomed()) 
  3.                        {
     
  4. LPRECT lprc; 
  5.                              lprc = (LPRECT) lParam; 
  6.                              lprc->right = m_iDlgWidth + lprc->left; 
  7.                              lprc->bottom = m_iDlgHeight + lprc->top; 
  8.                        } 
  9.                  } 
  10.                  break; 

  1.  
  2.            case WM_WINDOWPOSCHANGING: 
    1.                  if(m_lPrevState == 0xf012) 
    2.                  { 
    3.                        WINDOWPOS * lpwndpos; 
    4.                        lpwndpos = (WINDOWPOS *)lParam; 
    5.                        lpwndpos->cx = m_iDlgWidth
    6.                        lpwndpos->cy = m_iDlgHeight
    7.                        ShowWindow(SW_MAXIMIZE); 
    8.                  } 
    9.                  break; 
  3.            }  
here, m_iDlgWidth and m_iDlgHeight specifies the maximum width and maximum height of the dialog.

with window can not be resized for the drag event on the title bar and at the same time it will be movable.
Random Solutions  
 
programming4us programming4us