|
// FreeFormPPCDlg.cpp : implementation file
//
#include "stdafx.h"
#include "FreeFormPPC.h"
#include "FreeFormPPCDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include "RegionBuilder.h"
// CFreeFormPPCDlg dialog
CFreeFormPPCDlg::CFreeFormPPCDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFreeFormPPCDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CFreeFormPPCDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CFreeFormPPCDlg, CDialog)
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CFreeFormPPCDlg message handlers
BOOL CFreeFormPPCDlg::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
HBITMAP hBmp;
hBmp= (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0, 0, 0);
DWORD t1, t2;
t1=GetTickCount();
if(hBmp != NULL)
{
CRegionBuilder rb;
if(rbeOK == rb.BuildRegion(hBmp, &m_hRgn))
{
SetWindowRgn(m_hRgn, TRUE);
}
}
t2=GetTickCount();
t2-=t1;
if(m_hRgn != NULL)
{
CString str;
str.Format(_T("Mask build time: %d ms"), t2);
AfxMessageBox(str);
}
return TRUE; // return TRUE unless you set the focus to a control
}
//////////////////////////////////////////////////////////////////////////
BOOL CFreeFormPPCDlg::OnEraseBkgnd(CDC* pDC)
{
CRect rect;
GetClientRect(&rect);
CBrush NewBrush(RGB(0, 255, 0));
pDC->SetBrushOrg(0,0);
HGDIOBJ hOldBrush = pDC->SelectObject(&NewBrush);
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
pDC->SelectObject(hOldBrush);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
void CFreeFormPPCDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
//set dragging pos
m_ptLast=point;
m_bDrag=TRUE;
SetCapture();
Default();
}
//////////////////////////////////////////////////////////////////////////
void CFreeFormPPCDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CRect rc;
CPoint ptCurr, ptCursorPos;
//move window
if(nFlags & MK_LBUTTON)
{
if(m_bDrag == TRUE)
{
if(abs(m_ptLast.x - point.x) > 5 || abs(m_ptLast.y - point.y) > 5)
{
ptCurr = point - m_ptLast;
GetWindowRect(&rc);
rc.OffsetRect(ptCurr);
MoveWindow(rc);
}
}
}
CDialog::OnMouseMove(nFlags, point);
}
//////////////////////////////////////////////////////////////////////////
void CFreeFormPPCDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
//reset draggin pos
m_ptLast.x=m_ptLast.y=0;
m_bDrag=FALSE;
ReleaseCapture();
Invalidate();
CDialog::OnLButtonUp(nFlags, point);
}
|
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.
I'm a 29-year old software developer. I began programming on a ZX Spectrum many years ago. I've programmed a number of high level languages (Basic, Pascal, C/C++, Java, Php, Perl, C#). I also like reverse-engineering and assembler programming.
I'm interested in handheld devices programming, especially Windows Mobile devices.