www.pudn.com > DialogResizeable.zip > CTestDlg.cpp, change:2001-10-08,size:4854b


// 
// CTestDlg 
// 
// Written by Laurent Kempé (lkempe@netcourrier.com) for Tech Head WebSite 
// Copyright (c) 2001 Laurent Kempé. 
// 
// This code may be used in compiled form in any way you desire. This 
// file may be redistributed by any means PROVIDING it is  
// not sold for profit without the authors written consent, and  
// providing that this notice and the authors name is included.  
// 
// This file is provided "as is" with no expressed or implied warranty. 
// The author accepts no liability if it causes any damage to you or your 
// computer whatsoever. It's free, so don't hassle me about it. 
// 
 
#include "stdafx.h" 
#include "CTestDlg.h" 
 
//+---------------------------------------------------------------------------- 
// Window map 
//----------------------------------------------------------------------------- 
BEGIN_WINDOW_MAP(TestDlgMap) 
BEGINROWS(WRCT_REST,0,RCMARGINS(8,8)) 
 BEGINCOLS(WRCT_REST,0,0) 
  BEGINROWS(WRCT_REST,4,RCMARGINS(-4,-4)) 
   RCTOFIT(IDC_STATIC1) 
   RCSPACE(-4) 
    BEGINROWS(WRCT_TOFIT,IDC_GROUP1,RCMARGINS(-8,-8)) 
     RCSPACE(-10) 
    RCTOFIT(IDC_RADIO1) 
    RCTOFIT(IDC_RADIO2) 
    ENDGROUP() 
  ENDGROUP() 
  RCPERCENT(IDC_EDIT1,50) 
 ENDGROUP() 
 RCSPACE(-4) 
 RCTOFIT(IDC_STATIC2) 
 RCTOFIT(IDC_SLIDER1) 
 BEGINCOLS(WRCT_TOFIT,0,0) 
  RCREST(-1) 
  BEGINROWS(WRCT_TOFIT,0,0) 
    RCTOFIT(IDOK) 
    RCSPACE(-2) 
    RCTOFIT(IDCANCEL) 
  ENDGROUP() 
 ENDGROUP() 
ENDGROUP() 
END_WINDOW_MAP() 
 
//+---------------------------------------------------------------------------- 
// 
// Function   : CCOMCategoriesComboBox::CCOMCategoriesComboBox 
// 
// Synopsis	  : Constructor 
// 
//----------------------------------------------------------------------------- 
CTestDlg::CTestDlg( ) :  
	CDialogSizeable<CTestDlg>( TestDlgMap ), 
	m_szMinButton(SIZEZERO) 
{ 
}; 
 
CTestDlg::~CTestDlg() 
{ 
} 
 
//+---------------------------------------------------------------------------- 
// 
// Function   : CTestDlg::OnInitDialog 
// 
// Synopsis	  :  
// 
// Return type: [LRESULT] --  
// 
// Argument   :  
// 
//  [HWND hwnd] --  
//  [LPARAM lParam] --  
// 
// Notes:  
// 
//----------------------------------------------------------------------------- 
LRESULT CTestDlg::OnInitDialog( HWND hwnd, LPARAM  lParam) 
{ 
	BOOL bRet = CDialogSizeable<CTestDlg>::OnInitDialog( hwnd, lParam ); 
 
	// center the dialog on the screen 
	CenterWindow(); 
 
	// set icons 
	HICON hIcon = (HICON)::LoadImage( _Module.GetResourceInstance(),  
									  MAKEINTRESOURCE(IDR_MAINFRAME),  
									  IMAGE_ICON,  
									  ::GetSystemMetrics(SM_CXICON),  
									  ::GetSystemMetrics(SM_CYICON),  
									  LR_DEFAULTCOLOR 
									); 
	SetIcon(hIcon, TRUE); 
 
	HICON hIconSmall = (HICON)::LoadImage( _Module.GetResourceInstance(),  
										   MAKEINTRESOURCE(IDR_MAINFRAME),  
										   IMAGE_ICON,  
										   ::GetSystemMetrics(SM_CXSMICON),  
										   ::GetSystemMetrics(SM_CYSMICON),  
										   LR_DEFAULTCOLOR 
										 ); 
	SetIcon(hIconSmall, FALSE); 
 
	// save min size for OK/Cancel buttons 
	CSize sz = m_winMgr.GetRect(IDOK).Size(); 
	m_szMinButton = CSize(sz.cx,sz.cy); // use half width 
 
	return bRet; 
} 
 
//+---------------------------------------------------------------------------- 
// 
// Function   : CTestDlg::OnOK 
// 
// Synopsis	  :  
// 
// Return type: [void] --  
// 
// Argument   :  
// 
//  [ UINT notificationcode] --  
//  [int id] --  
//  [HWND hwnd] --  
// 
// Notes:  
// 
//----------------------------------------------------------------------------- 
void CTestDlg::OnOK( UINT notificationcode, int id, HWND hwnd ) 
{ 
	CloseDialog(id); 
} 
 
//+---------------------------------------------------------------------------- 
// 
// Function   : CTestDlg::OnCancel 
// 
// Synopsis	  :  
// 
// Return type: [void] --  
// 
// Argument   :  
// 
//  [UINT notificationcode] --  
//  [int id] --  
//  [HWND hwnd] --  
// 
// Notes:  
// 
//----------------------------------------------------------------------------- 
void CTestDlg::OnCancel( UINT notificationcode, int id, HWND hwnd ) 
{ 
	CloseDialog(id); 
} 
 
//+---------------------------------------------------------------------------- 
// 
// Function   : CTestDlg::OnWinMgr 
// 
// Synopsis	  :  
// 
// Return type: [LRESULT] --  
// 
// Argument   :  
// 
//  [UINT uMsg] --  
//  [WPARAM wp] --  
//  [LPARAM lp] --  
// 
// Notes: Handle WM_WINMGR: return min size for OK/Cancel buttons 
// 
//----------------------------------------------------------------------------- 
LRESULT CTestDlg::OnWinMgr(UINT uMsg, WPARAM wp, LPARAM lp) 
{ 
	ATLASSERT(lp); 
	NMWINMGR& nmw = *(NMWINMGR*)lp; 
 
	if ( nmw.code == NMWINMGR::GET_SIZEINFO ) 
	{ 
		if ( wp==IDOK || wp==IDCANCEL ) 
		{ 
			nmw.sizeinfo.szMin = m_szMinButton; 
			return TRUE; 
		} 
	} 
	return 0; 
}