|
// CPPDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CPP.h"
#include "CPPDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CCPPDlg dialog
CCPPDlg::CCPPDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCPPDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCPPDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CCPPDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, &CCPPDlg::OnBnClickedOk)
ON_BN_CLICKED(IDD_CPP_DIALOG, &CCPPDlg::OnBnClickedCppDialog)
ON_BN_CLICKED(IDD_CPP_DIALOG2, &CCPPDlg::OnBnClickedCppDialog2)
ON_BN_CLICKED(IDD_CPP_DIALOG3, &CCPPDlg::OnBnClickedCppDialog3)
END_MESSAGE_MAP()
// CCPPDlg message handlers
BOOL CCPPDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCPPDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCPPDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CCPPDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
OnOK();
}
void CCPPDlg::OnBnClickedCppDialog()
{
LogPerformance(L"CPPPERF1", 1, rand() * 1000);
}
void CCPPDlg::OnBnClickedCppDialog2()
{
LogPerformance(L"CPPPERF2", 2, rand() * 2000);
}
void CCPPDlg::LogPerformance(LPCWSTR bsMeterName, int iResult1, int iResult2)
{
int iMessageID = RegisterWindowMessage(bsMeterName);
PostMessageA(HWND_BROADCAST, iMessageID, iResult1, iResult2);
}
void CCPPDlg::OnBnClickedCppDialog3()
{
// TODO: Add your control notification handler code here
OnOK();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Technologist & Executive.
Specializes in .NET, COM and the gray material between them. Intimately familiar with most MS technologies.
Developing software for a living for the last 10 years, focusing on web based enterprise software as a service for the last 8.