testmapping.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 61KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2005-09-10 11:41
    上传日期
这是一个关于TestMappin的程序,可以直接调试通过,非常适合于学习使用
testmapping.rar
  • testmapping
  • res
  • icon1.ico
    318B
  • testmappinDoc.ico
    1.1KB
  • mappin6.ico
    318B
  • mappin5.ico
    318B
  • mappin4.ico
    318B
  • mappin2.ico
    766B
  • mappin3.ico
    318B
  • Toolbar.bmp
    1.1KB
  • mappin.ico
    1.1KB
  • testmappin.rc2
    402B
  • mappin1.ico
    318B
  • testmappin.ico
    1.1KB
  • testmappinView.h
    1.1KB
  • Resource.h
    963B
  • mappin.htm
    12KB
  • testmappinView.cpp
    4KB
  • testmappin.dsw
    545B
  • testmappin.001
    7.5KB
  • testmappin.rc
    10.2KB
  • testmappin.opt
    49.5KB
  • testmappin.ncb
    57KB
  • MapPin.h
    2KB
  • testmappin.h
    403B
  • mappin.gif
    313B
  • MapPin.cpp
    6.6KB
  • mappin2.gif
    18.8KB
  • StdAfx.cpp
    208B
  • MainFrm.cpp
    1.6KB
  • testmappinDoc.cpp
    839B
  • MainFrm.h
    571B
  • StdAfx.h
    245B
  • testmappin.plg
    2.1KB
  • testmappin.cpp
    3.2KB
  • testmappinDoc.h
    514B
  • testmappin.dsp
    7.6KB
  • testmappin.aps
    31.6KB
  • testmappin.clw
    2.1KB
  • www.pudn.com.txt
    218B
内容介绍
/* Module : MAPPIN.CPP Purpose: Implementation for an MFC class to draw map pins ala AutoRoute Express Created: PJN / 12-08-1998 History: PJN / 10-09-1998 Fixed a small redraw glitch in SetIcon Copyright (c) 1998 by PJ Naughter. All rights reserved. */ //////////////// Includes //////////////////////////////////////////// #include "stdafx.h" #include "MapPin.h" //////////////// Defines ///////////////////////////////////////////// #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //////////////// Implementation ////////////////////////////////////// BEGIN_MESSAGE_MAP(CMapPin, CWnd) //{{AFX_MSG_MAP(CMapPin) ON_WM_PAINT() ON_WM_CONTEXTMENU() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_MOUSEMOVE() ON_WM_TIMER() //}}AFX_MSG_MAP ON_MESSAGE(WM_SETTEXT, OnSetText) END_MESSAGE_MAP() CMapPin::CMapPin() { m_hIcon = NULL; m_nIconHeight = 0; m_nIconWidth = 0; m_bCaptured = FALSE; m_bAllowDrag = TRUE; } CMapPin::~CMapPin() { //Free the icon resource that we have loaded if (m_hIcon) { DestroyIcon(m_hIcon); m_hIcon = NULL; } } BOOL CMapPin::Create(LPCTSTR lpszTooltipText, DWORD dwStyle, const CPoint& p, CWnd* pParentWnd, UINT nID) { ASSERT(m_hIcon != NULL); //Icon must be setup before calling this function //Work out the size to create the window based on the icon size CRect r(p.x, p.y, p.x + m_nIconWidth, p.y + m_nIconHeight); //Let the parent do its thing BOOL bSuccess = CWnd::Create(NULL, lpszTooltipText, dwStyle, r, pParentWnd, nID); //Fire off a timer to setup the tooltip for the control m_nTimerID = SetTimer(1, 0, NULL); return bSuccess; } BOOL CMapPin::SetIcon(HINSTANCE hModule, UINT nIDResource, BOOL bSmallIcon) { return SetIcon(hModule, MAKEINTRESOURCE(nIDResource), bSmallIcon); } BOOL CMapPin::SetIcon(HINSTANCE hModule, LPCTSTR lpszResourceName, BOOL bSmallIcon) { //Release the old icon we may have if (m_hIcon != NULL) { DestroyIcon(m_hIcon); m_hIcon = NULL; } //Work out the metrics of the icon we are about to load if (bSmallIcon) { m_nIconWidth = GetSystemMetrics(SM_CXSMICON); m_nIconHeight = GetSystemMetrics(SM_CYSMICON); } else { m_nIconWidth = GetSystemMetrics(SM_CXICON); m_nIconHeight = GetSystemMetrics(SM_CYICON); } //Load up the new icon if (bSmallIcon) m_hIcon = (HICON) LoadImage(hModule, lpszResourceName, IMAGE_ICON, m_nIconWidth, m_nIconHeight, LR_DEFAULTCOLOR); else m_hIcon = LoadIcon(hModule, lpszResourceName); //With an icon change, force a repaint if (GetSafeHwnd()) { //First the parent CRect r; GetClientRect(&r); ClientToScreen(&r); CWnd* pParent = GetParent(); pParent->ScreenToClient(&r); pParent->InvalidateRect(r, FALSE); //Now this window Invalidate(); } //return success indicator return (m_hIcon != NULL); } void CMapPin::SetPopupMenu(LPCTSTR lpszResourceName) { m_lpszMenuResourceName = lpszResourceName; } void CMapPin::SetPopupMenu(UINT nIDResource) { m_lpszMenuResourceName = MAKEINTRESOURCE(nIDResource); } HICON CMapPin::GetIcon() const { return m_hIcon; } void CMapPin::OnPaint() { CPaintDC dc(this); ASSERT(m_hIcon != NULL); //You forget to setup an icon //Just draw the icon ::DrawIconEx(dc.GetSafeHdc(), 0, 0, m_hIcon, m_nIconWidth, m_nIconHeight, 0, NULL, DI_NORMAL); } void CMapPin::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { //Load up the specified menu CMenu menu; VERIFY(menu.LoadMenu(m_lpszMenuResourceName)); //Pull out the first popup menu from it CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); //Owner is the first non child window in the hierarchy above this window CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); //Track the menu pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } void CMapPin::OnLButtonDown(UINT nFlags, CPoint point) { if (m_bAllowDrag) { SetCapture(); m_bCaptured = TRUE; m_nDragOffset = point; } //Let the parent do its thing CWnd::OnLButtonDown(nFlags, point); } void CMapPin::OnLButtonUp(UINT nFlags, CPoint point) { ReleaseCapture(); m_bCaptured = FALSE; //let the parent do its thing CWnd::OnLButtonUp(nFlags, point); } void CMapPin::OnMouseMove(UINT nFlags, CPoint point) { if (m_bCaptured) { CWnd* pParent = GetParent(); //Retrieve the old postion (in parent client coordinates) CRect oldPos; GetClientRect(&oldPos); ClientToScreen(oldPos); pParent->ScreenToClient(&oldPos); //Work out the new position (in parent client coordinates) CRect newPos(point.x - m_nDragOffset.x, point.y - m_nDragOffset.y, point.x - m_nDragOffset.x + m_nIconWidth, point.y - m_nDragOffset.y + m_nIconHeight); ClientToScreen(&newPos); pParent->ScreenToClient(&newPos); //Only move the pin if it is inside the client rect of the parent window CRect clientRect; pParent->GetClientRect(&clientRect); if (newPos.left >= clientRect.left && newPos.top >= clientRect.top && newPos.right < clientRect.right && newPos.bottom < clientRect.bottom) { MoveWindow(newPos, FALSE); pParent->InvalidateRect(oldPos, FALSE); Invalidate(TRUE); CWnd::OnMouseMove(nFlags, point); //Let the parent do its thing } } else CWnd::OnMouseMove(nFlags, point); //Let the parent do its thing } void CMapPin::SetAllowDrag(BOOL bAllowDrag) { m_bAllowDrag = bAllowDrag; } BOOL CMapPin::GetAllowDrag() const { return m_bAllowDrag; } BOOL CMapPin::PreTranslateMessage(MSG* pMsg) { //Relay the message to the tooltip if its around if (IsWindow(m_ctrlToolTip.GetSafeHwnd())) m_ctrlToolTip.RelayEvent(pMsg); return CWnd::PreTranslateMessage(pMsg); } void CMapPin::OnTimer(UINT nIDEvent) { if (nIDEvent == m_nTimerID) { //Timer is being used as a once off, so kill it KillTimer(m_nTimerID); //Create the tooltip for the control BOOL bSuccess = m_ctrlToolTip.Create(GetParent()); m_ctrlToolTip.Activate(TRUE); CString sCaption; GetWindowText(sCaption); bSuccess = m_ctrlToolTip.AddTool(this, sCaption); } CWnd::OnTimer(nIDEvent); } LRESULT CMapPin::OnSetText(WPARAM /*wParam*/, LPARAM lParam) { //Update the tooltip text whenever the caption changes LPCTSTR pszText = (LPCTSTR) lParam; m_ctrlToolTip.UpdateTipText(pszText, this); return Default(); }
评论
    相关推荐
    • 数据库课程设计
      一个数据库课程设计,access管理工具实现,用的是窗体!
    • 数据库课程设计
      数据库课程设计十分完整有需要的请下载啊谢谢
    • 数据库课程设计
      广东工业大学数据库课程设计,可视化界面连接数据库,delphi7
    • 数据库课程设计
      数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述
    • 数据库课程设计
      数据库课程设计》由周爱武、汪海威、肖云编著,遵循数据库课程设计的具体要求,独立于具体的数据库教材,从实际应用系统的需求着手,引导读者逐步完成数据库设计全过程,重点讲解数据库系统的需求分析、概念设计、...
    • 数据库课程设计
      数据库课程设计人事管理系统 数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计...
    • 数据库课程设计
      数据库课程设计,基于visual basic自助银行管理系统,界面很清爽,实用。同学都说好,所以就上传了!!!
    • 数据库课程设计
      数据库课程设计 里面有详细的文档资料 包含数据库一切的图 以及生成的数据库表文件 期末得分为优秀
    • 数据库课程设计
      可以作为数据库课程设计,也可以作为Java的课程设计,内容全面。本资源转载的,非本人原创。用于交流学习,特此申明!
    • 数据库课程设计
      数据库课程设计蓝天大学学生管理系统 2.商店信息管理系统 3.实验室机房收费管理系统 4.图书馆资料检索系统 5.企业库存管理系统 6.仓库管理系统 7.工程项目管理系统 8.教材管理系统 9.企业人事管理系统 10.企业财务...