ResizableDialog.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * ResizableDialog.cpp
  3. * -------------------
  4. * Purpose: A wrapper for resizable MFC dialogs that fixes the dialog's minimum size
  5. * (as MFC does not scale controls properly if the user makes the dialog smaller than it originally was)
  6. * Notes : (currently none)
  7. * Authors: OpenMPT Devs
  8. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  9. */
  10. #include "stdafx.h"
  11. #include "ResizableDialog.h"
  12. #include "resource.h"
  13. OPENMPT_NAMESPACE_BEGIN
  14. BEGIN_MESSAGE_MAP(ResizableDialog, CDialog)
  15. ON_WM_GETMINMAXINFO()
  16. END_MESSAGE_MAP()
  17. ResizableDialog::ResizableDialog(UINT nIDTemplate, CWnd *pParentWnd)
  18. : CDialog(nIDTemplate, pParentWnd)
  19. { }
  20. BOOL ResizableDialog::OnInitDialog()
  21. {
  22. CRect rect;
  23. GetWindowRect(rect);
  24. m_minSize = rect.Size();
  25. HICON icon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MODULETYPE));
  26. SetIcon(icon, FALSE);
  27. SetIcon(icon, TRUE);
  28. return CDialog::OnInitDialog();
  29. }
  30. void ResizableDialog::OnGetMinMaxInfo(MINMAXINFO *mmi)
  31. {
  32. mmi->ptMinTrackSize = m_minSize;
  33. CDialog::OnGetMinMaxInfo(mmi);
  34. }
  35. OPENMPT_NAMESPACE_END