Question

This question for people who knows WTL! Tell me please, how to deny window to change its own size using WTL? Or how to create window with fixed size using WTL?

This is a part of my code in MainFrm.cpp, if I don't mistake it creates window:

m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILDWINDOW | WS_VISIBLE);

This is a part of my code in ...View.cpp file, it proccesses the window resizing :

LRESULT CPictureInCenterView::OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM 
/*lParam*/, BOOL& /*bHandled*/) 
{ 
  CRect rcClient;
  GetClientRect(&rcClient);
  clientWidth = rcClient.Width(); 
  clientHeight = rcClient.Height();

  if (!m_pBackBuffer.get() || 
  (clientWidth > m_pBackBuffer->GetWidth()) || 
  (clientHeight > m_pBackBuffer->GetHeight()) 
  ) 
  { 
    m_pBackBuffer.reset( 
    new Gdiplus::Bitmap(clientWidth, clientHeight, PixelFormat32bppARGB)); 
  }  
  return 0; 
}

Thanks!!!

Was it helpful?

Solution

The easiest is to change window style and remove sizing frame style from there:

Window.ModifyStyle(WS_THICKFRAME, 0);

Otherwise you can also handle WM_WINDOWPOSCHANGING, WM_GETMINMAXINFO messages on the window and restrict window sizing as it goes.

Note that window creation you quoted in the question above is for view, that is, for child window. This is not the window you want to prevent sizing of.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top