Update-Installer/external/win32cpp/tutorials/Tutorial3/View.cpp
Robert Knight d16da069e9 Add Win++ library to external
This is a thin wrapper around the Win32 API used in the Win32
Updater Dialog implementation.
2011-08-23 19:54:52 +01:00

71 lines
1.2 KiB
C++

//////////////////////////////////////////////
// View.cpp
// Definitions for the CView class
#include "view.h"
CView::CView()
{
}
void CView::DrawLine(int x, int y)
{
CDC* pDC = GetDC();
pDC->MoveTo(m_OldPt.x, m_OldPt.y);
pDC->LineTo(x, y);
}
void CView::OnLButtonDown(LPARAM lParam)
{
// Capture mouse input.
SetCapture();
m_OldPt.x = GET_X_LPARAM(lParam);
m_OldPt.y = GET_Y_LPARAM(lParam);
}
void CView::OnLButtonUp(LPARAM lParam)
{
{
//Release the capture on the mouse
ReleaseCapture();
}
}
void CView::OnMouseMove(WPARAM wParam, LPARAM lParam)
{
// hold down the left mouse button and move mouse to draw lines.
if (wParam & MK_LBUTTON)
{
DrawLine(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
m_OldPt.x = GET_X_LPARAM(lParam);
m_OldPt.y = GET_Y_LPARAM(lParam);
}
}
LRESULT CView::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_LBUTTONDOWN:
OnLButtonDown(lParam);
break;
case WM_MOUSEMOVE:
OnMouseMove(wParam, lParam);
break;
case WM_LBUTTONUP:
OnLButtonUp(lParam);
break;
case WM_DESTROY:
//End the program when window is destroyed
::PostQuitMessage(0);
break;
}
//Use the default message handling for remaining messages
return WndProcDefault(uMsg, wParam, lParam);
}