⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bench1.cpp

📁 WIN32高级程序设计书附源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}

// user defined code
BOOL BLD_RunWhetstoneUDCFunc (CWnd *pWnd)
{
	return RunBenchMarks(pWnd,FALSE,TRUE,FALSE,FALSE);
}

// user defined code
BOOL BLD_RunDiskUDCFunc (CWnd *pWnd)
{
	return RunBenchMarks(pWnd,FALSE,FALSE,TRUE,FALSE);
}

// user defined code
BOOL BLD_RunVideoUDCFunc (CWnd *pWnd)
{
	return RunBenchMarks(pWnd,FALSE,FALSE,FALSE,TRUE);
}

// user defined code
BOOL BLD_TextScrollingUDCFunc (CWnd *pWnd)
{
  CString answer;
  long Wtime;
  long TotalPixels;
  char temp[30]="Running Text Scrolling Test";

  pParent=pWnd;
  CWnd *pDlg = pWnd->GetTopWindow();
  pDlg->SetDlgItemText(id_tx_status,temp);

  //accumulate time in hundredths of a second

  SetCursor(LoadCursor(NULL,IDC_WAIT));
  Wtime = VideoTimes[0] = DoBench("V0","Create Window",video0,pDlg);
  Wtime+= VideoTimes[1] = DoBench("V1","Character Scrolling Test",video1,pDlg);
  //Wtime+= VideoTimes[2] = DoBench("V2","Line/Curve Drawing Test ",video2,pDlg);
  //Wtime+= VideoTimes[3] = DoBench("V3","Filled Object Test      ",video3,pDlg);
  //Wtime+= VideoTimes[4] = DoBench("V4","Color Display Test      ",video4,pDlg);
  //VideoTimes[2]=VideoTimes[3]=VideoTimes[4]=0;
  SetCursor(LoadCursor(NULL,IDC_ARROW));
  WaitMessage();
  Wtime+= VideoTimes[5] = DoBench("V5","Destroy Window",video5,pDlg);

  sprintf(temp,"Text scrolling test time %ld.%ld s",Wtime/100,Wtime%100);
  pDlg->SetDlgItemText(id_tx_status,temp);

  //turn time into KPixels/second
  if(Wtime<=0) Wtime=1000; //protect against divide by 0
  //count 1 screen each for window creation and destruction, plus
  //routines' record of number of pixels written
  TotalPixels=2L*screenarea + vid1pix;
  double kpixels_per_sec =(1.0e-3 * TotalPixels / ((double)Wtime/100.0));
  sprintf(temp,"%.4g",kpixels_per_sec);
  answer=temp;
  return TRUE;
}

// user defined code
BOOL BLD_LineDrawingUDCFunc (CWnd *pWnd)
{
  CString answer;
  long Wtime;
  long TotalPixels;
  char temp[30]="Running Line Drawing Test";

  pParent=pWnd;
  CWnd *pDlg = pWnd->GetTopWindow();
  pDlg->SetDlgItemText(id_tx_status,temp);

  //accumulate time in hundredths of a second

  SetCursor(LoadCursor(NULL,IDC_WAIT));
  Wtime = VideoTimes[0] = DoBench("V0","Create Window",video0,pDlg);
  //Wtime+= VideoTimes[1] = DoBench("V1","Character Scrolling Test",video1,pDlg);
  Wtime+= VideoTimes[2] = DoBench("V2","Line/Curve Drawing Test ",video2,pDlg);
  //Wtime+= VideoTimes[3] = DoBench("V3","Filled Object Test      ",video3,pDlg);
  //Wtime+= VideoTimes[4] = DoBench("V4","Color Display Test      ",video4,pDlg);
  //VideoTimes[1]=VideoTimes[3]=VideoTimes[4]=0;
  SetCursor(LoadCursor(NULL,IDC_ARROW));
  WaitMessage();
  Wtime+= VideoTimes[5] = DoBench("V5","Destroy Window",video5,pDlg);

  sprintf(temp,"Line/curve drawing test time %ld.%ld s",Wtime/100,Wtime%100);
  pDlg->SetDlgItemText(id_tx_status,temp);

  //turn time into KPixels/second
  if(Wtime<=0) Wtime=1000; //protect against divide by 0
  //count 1 screen each for window creation and destruction, plus
  //routines' record of number of pixels written
  TotalPixels=2L*screenarea + vid2pix;
  double kpixels_per_sec =(1.0e-3 * TotalPixels / ((double)Wtime/100.0));
  sprintf(temp,"%.4g",kpixels_per_sec);
  answer=temp;
  return TRUE;
}

// user defined code
BOOL BLD_FilledObjectsUDCFunc (CWnd *pWnd)
{
  CString answer;
  long Wtime;
  long TotalPixels;
  char temp[30]="Running Filled Object Test";

  pParent=pWnd;
  CWnd *pDlg = pWnd->GetTopWindow();
  pDlg->SetDlgItemText(id_tx_status,temp);

  //accumulate time in hundredths of a second

  SetCursor(LoadCursor(NULL,IDC_WAIT));
  Wtime = VideoTimes[0] = DoBench("V0","Create Window",video0,pDlg);
  //Wtime+= VideoTimes[1] = DoBench("V1","Character Scrolling Test",video1,pDlg);
  //Wtime+= VideoTimes[2] = DoBench("V2","Line/Curve Drawing Test ",video2,pDlg);
  Wtime+= VideoTimes[3] = DoBench("V3","Filled Object Test      ",video3,pDlg);
  //Wtime+= VideoTimes[4] = DoBench("V4","Color Display Test      ",video4,pDlg);
  //VideoTimes[2]=VideoTimes[1]=VideoTimes[4]=0;
  SetCursor(LoadCursor(NULL,IDC_ARROW));
  WaitMessage();
  Wtime+= VideoTimes[5] = DoBench("V5","Destroy Window",video5,pDlg);

  sprintf(temp,"Filled object test time %ld.%ld s",Wtime/100,Wtime%100);
  pDlg->SetDlgItemText(id_tx_status,temp);

  //turn time into KPixels/second
  if(Wtime<=0) Wtime=1000; //protect against divide by 0
  //count 1 screen each for window creation and destruction, plus
  //routines' record of number of pixels written
  TotalPixels=2L*screenarea + vid3pix;
  double kpixels_per_sec =(1.0e-3 * TotalPixels / ((double)Wtime/100.0));
  sprintf(temp,"%.4g",kpixels_per_sec);
  answer=temp;
  return TRUE;
}

// user defined code
BOOL BLD_ColorDisplayUDCFunc (CWnd *pWnd)
{
  CString answer;
  long Wtime;
  long TotalPixels;
  char temp[30]="Running Color Display Test";

  pParent=pWnd;
  CWnd *pDlg = pWnd->GetTopWindow();
  pDlg->SetDlgItemText(id_tx_status,temp);

  //accumulate time in hundredths of a second

  SetCursor(LoadCursor(NULL,IDC_WAIT));
  Wtime = VideoTimes[0] = DoBench("V0","Create Window",video0,pDlg);
  //Wtime+= VideoTimes[1] = DoBench("V1","Character Scrolling Test",video1,pDlg);
  //Wtime+= VideoTimes[2] = DoBench("V2","Line/Curve Drawing Test ",video2,pDlg);
  //Wtime+= VideoTimes[3] = DoBench("V3","Filled Object Test      ",video3,pDlg);
  Wtime+= VideoTimes[4] = DoBench("V4","Color Display Test      ",video4,pDlg);
  //VideoTimes[2]=VideoTimes[3]=VideoTimes[1]=0;
  SetCursor(LoadCursor(NULL,IDC_ARROW));
  WaitMessage();
  Wtime+= VideoTimes[5] = DoBench("V5","Destroy Window",video5,pDlg);

  sprintf(temp,"Color display test time %ld.%ld s",Wtime/100,Wtime%100);
  pDlg->SetDlgItemText(id_tx_status,temp);

  //turn time into KPixels/second
  if(Wtime<=0) Wtime=1000; //protect against divide by 0
  //count 1 screen each for window creation and destruction, plus
  //routines' record of number of pixels written
  TotalPixels=2L*screenarea + vid4pix;
  double kpixels_per_sec =(1.0e-3 * TotalPixels / ((double)Wtime/100.0));
  sprintf(temp,"%.4g",kpixels_per_sec);
  answer=temp;
  return TRUE;
}

// *********************************************************************
// CLASS DECLARATION FOR MODAL DIALOG BOX: Cwm_ShowDetailsDlg
// *********************************************************************

// The user modal dialog class Cwm_ShowDetailsDlg.  This dialog class inherits from
// the WindowsMAKER modal base dialog class.  This class provides all the
// user functionality for this specific dialog box.  You can override
// WindowsMAKER base functionality here, if desired.

class Cwm_ShowDetailsDlg : public Cwm_ShowDetailsBaseDlg
{
public:
	 Cwm_ShowDetailsDlg (LPSTR AName, CWnd* AParent)
	 : Cwm_ShowDetailsBaseDlg (AName, AParent) {} ;

	 virtual ~Cwm_ShowDetailsDlg () {} ;

// Overridables (special message map entries)
	 virtual BOOL OnInitDialog();
	 virtual void OnOK();
	 virtual void OnCancel();

	 WMPROTO_ShowDetailsDlg()

protected:

	 DECLARE_MESSAGE_MAP()
} ;

// *********************************************************************
// FUNCTIONS AND MESSAGE MAP FOR MODAL DIALOG BOX: Cwm_ShowDetailsDlg
// ************************************************************

// Startup procedure for modal dialog box
int BLD_ShowDetailsDlgFunc (CWnd* pWnd)
{
	 int iRet;
	 Cwm_ShowDetailsDlg	  TheDlg ("DETAILS",pWnd);

	 iRet=TheDlg.DoModal ();
	 if( -1 == iRet )
	 {
		  BLDDisplayMessage (::GetActiveWindow (), BLD_CannotCreate,
				"DETAILS", MB_OK | MB_ICONHAND);
	 }
	 return iRet;
}

// Below, you can define any custom processing you require
// for the modal dialog box DETAILS, which is in class Cwm_ShowDetailsDlg.

BEGIN_MESSAGE_MAP(Cwm_ShowDetailsDlg, Cwm_ShowDetailsBaseDlg)


END_MESSAGE_MAP()


BOOL Cwm_ShowDetailsDlg::OnInitDialog()
{
	char temp[30];
	long Wtime;

	Wtime=DiskTimes[1];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_seqwrite,temp);
	Wtime=DiskTimes[2];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_seqread,temp);
	Wtime=DiskTimes[3];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_randwrite,temp);
	Wtime=DiskTimes[4];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_randread,temp);
	Wtime=VideoTimes[1];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_textscroll,temp);
	Wtime=VideoTimes[2];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_linedraw,temp);
	Wtime=VideoTimes[3];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_filledobj,temp);
	Wtime=VideoTimes[4];
	sprintf(temp,"%ld.%ld",Wtime/100,Wtime%100);
	SetDlgItemText(id_tx_colordisp,temp);
	 // Base Class processing of Init Dialog
	 Cwm_ShowDetailsBaseDlg::OnInitDialog();
	 return TRUE;	  // set focus to first control
}


void Cwm_ShowDetailsDlg::OnOK()
{

	 // Base Class processing of Ok
	 Cwm_ShowDetailsBaseDlg::OnOK();
}


void Cwm_ShowDetailsDlg::OnCancel()
{

	 // Base Class processing of Cancel
	 Cwm_ShowDetailsBaseDlg::OnCancel();
}




// *********************************************************************
// CLASS DECLARATION FOR MODAL DIALOG BOX: Cwm_Menu41Dlg
// *********************************************************************

// The user modal dialog class Cwm_Menu41Dlg.  This dialog class inherits from
// the WindowsMAKER modal base dialog class.  This class provides all the
// user functionality for this specific dialog box.  You can override
// WindowsMAKER base functionality here, if desired.

class Cwm_Menu41Dlg : public Cwm_Menu41BaseDlg
{
public:
	 Cwm_Menu41Dlg (LPSTR AName, CWnd* AParent)
	 : Cwm_Menu41BaseDlg (AName, AParent) {} ;

	 virtual ~Cwm_Menu41Dlg () {} ;

// Overridables (special message map entries)
	 virtual BOOL OnInitDialog();
	 virtual void OnOK();
	 virtual void OnCancel();

	 WMPROTO_Menu41Dlg()

protected:

	 DECLARE_MESSAGE_MAP()
} ;




// *********************************************************************
// FUNCTIONS AND MESSAGE MAP FOR MODAL DIALOG BOX: Cwm_Menu41Dlg
// ************************************************************

// Startup procedure for modal dialog box
int BLD_Menu41DlgFunc (CWnd* pWnd)
{
	 int iRet;
	 Cwm_Menu41Dlg 	TheDlg ("DESCRIBE",pWnd);

	 iRet=TheDlg.DoModal ();
	 if( -1 == iRet )
	 {
		  BLDDisplayMessage (::GetActiveWindow (), BLD_CannotCreate,
				"DESCRIBE", MB_OK | MB_ICONHAND);
	 }
	 return iRet;
}

// Below, you can define any custom processing you require
// for the modal dialog box DESCRIBE, which is in class Cwm_Menu41Dlg.

BEGIN_MESSAGE_MAP(Cwm_Menu41Dlg, Cwm_Menu41BaseDlg)


END_MESSAGE_MAP()


BOOL Cwm_Menu41Dlg::OnInitDialog()
{
	SetDlgItemText(id_ed_describe,MachineDescription);
	 // Base Class processing of Init Dialog
	 Cwm_Menu41BaseDlg::OnInitDialog();
	 return TRUE;	  // set focus to first control
}


void Cwm_Menu41Dlg::OnOK()
{
	CWnd *cwed=GetDlgItem(id_ed_describe);
	cwed->GetWindowText(MachineDescription);
	 // Base Class processing of Ok
	 Cwm_Menu41BaseDlg::OnOK();
}


void Cwm_Menu41Dlg::OnCancel()
{

	 // Base Class processing of Cancel
	 Cwm_Menu41BaseDlg::OnCancel();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -