www.pudn.com > my2cadtest07261930.rar > SetPolyNum.cpp, change:2006-07-22,size:1771b


// SetPolyNum.cpp: implementation of the CSetPolyNum class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "SetPolyNum.h" 
#include "commctrl.h" 
#pragma comment(lib, "comctl32.lib") 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CSetPolyNum::CSetPolyNum(HWND hWnd):m_polynum(5) 
{ 
  ::DialogBoxParam(hInst,(LPCTSTR)IDD_POLYNUM, hWnd, (DLGPROC)PolyNum,(LPARAM)this); 
	 
} 
 
CSetPolyNum::~CSetPolyNum() 
{ 
 
} 
 
BOOL CSetPolyNum::PolyNum(HWND hPolyDlg,UINT msg, WPARAM wParam, LPARAM lParam) 
{ 
  static CSetPolyNum *pthis = NULL; 
 
  HWND hEdit= ::GetDlgItem(hPolyDlg,IDC_EDITPOLYNUM); 
  char buffer[10]=""; 
 
	switch( msg ) 
	{ 
		case WM_INITDIALOG:	 
			 
			pthis = (CSetPolyNum *)lParam; 
				 
			 sprintf(buffer,"%d",pthis->m_polynum); 
			::SetWindowText(hEdit,buffer); 
 
				return TRUE;			 
		case WM_VSCROLL: 
			{	 
 
			} 
			break; 
		 
		case WM_COMMAND: 
			{ 
				if (LOWORD(wParam) == IDOK)  
					{ 
                       ::GetWindowText( hEdit,buffer,10);				 
				       sscanf(buffer,"%d",&(pthis->m_polynum)); 
					   if(pthis->m_polynum<3) 
                       { 
                         ::MessageBox( NULL,"边数不能少于3!将默认为三角形~","警告!",MB_OK); 
                         pthis->m_polynum=3; 
                       } 
                        
						EndDialog(hPolyDlg, LOWORD(wParam)); 
						return TRUE; 
					} 
				if(LOWORD(wParam) == IDCANCEL) 
					{ 
					     (pthis->m_polynum)=5; 
						 EndDialog(hPolyDlg, LOWORD(wParam)); 
					     return TRUE; 
					} 
 
		break; 
			} 
		break; 
 
 
	} 
	return FALSE; 
 
 
	 
}