資源簡介
編程要點
/////坐標轉換/////////////
CClientDC dc(this); //定義設備對象
OnPrepareDC(&dc); //初始化設備對象
CPoint local=point; //定義CPoint類實體,并初始化為設備坐標
dc.DPtoLP(&local); //將設備坐標轉為邏輯坐標
//將該段程序放入OnLButtonDown(UINT nFlags, CPoint point)
//和OnMouseMove(UINT nFlags, CPoint point)中
//////////////////////////顯示光標位置
CString msg;
msg.Format(" X = %4d, Y = %4d ",
local.x,local.y);
CMainFrame* pAppFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
pAppFrame->m_wndStatusBar.SetPaneText(0,msg);
pAppFrame->m_wndStatusBar.UpdateWindow();
/////改變光標/////////////
CSize ScrollSize=GetTotalSize();
CRect ScrollRect(0,0,ScrollSize.cx,ScrollSize.cy);
if(m_SelectFunction!=13)
{
if(!ScrollRect.PtInRect(local))
::SetCursor(m_HCross);
else
::SetCursor(m_HArrow);
//將該段程序放入OnMouseMove(UINT nFlags, CPoint point)中,并放在坐標轉換的后面
//在視圖類的頭文件的public:后面加上兩個光標句柄
HCURSOR m_HArrow;
HCURSOR m_HCross;
//在視圖類的CCP文件的類構造器中加入以下兩句
m_HArrow=AfxGetApp()->LoadStandardCursor(IDC_ARROW);
m_HCross=AfxGetApp()->LoadStandardCursor(IDC_CROSS);

代碼片段和文件信息
//??dibapi.cpp
//
//??Source?file?for?Device-Independent?Bitmap?(DIB)?API.??Provides
//??the?following?functions:
//
//??PaintDIB()??????????-?Painting?routine?for?a?DIB
//??CreateDIBPalette()??-?Creates?a?palette?from?a?DIB
//??FindDIBBits()???????-?Returns?a?pointer?to?the?DIB?bits
//??DIBWidth()??????????-?Gets?the?width?of?the?DIB
//??DIBHeight()?????????-?Gets?the?height?of?the?DIB
//??PaletteSize()???????-?Gets?the?size?required?to?store?the?DIB‘s?palette
//??DIBNumColors()??????-?Calculates?the?number?of?colors
//????????????????????????in?the?DIB‘s?color?table
//??CopyHandle()????????-?Makes?a?copy?of?the?given?global?memory?block
//
//?This?is?a?part?of?the?Microsoft?Foundation?Classes?C++?library.
//?Copyright?(C)?1992-1997?Microsoft?Corporation
//?All?rights?reserved.
//
//?This?source?code?is?only?intended?as?a?supplement?to?the
//?Microsoft?Foundation?Classes?Reference?and?related
//?electronic?documentation?provided?with?the?library.
//?See?these?sources?for?detailed?information?regarding?the
//?Microsoft?Foundation?Classes?product.
#include?“stdafx.h“
#include?“dibapi.h“
#include?
#include?
/*************************************************************************
?*
?*?PaintDIB()
?*
?*?Parameters:
?*
?*?HDC?hDC??????????-?DC?to?do?output?to
?*
?*?LPRECT?lpDCRect??-?rectangle?on?DC?to?do?output?to
?*
?*?HDIB?hDIB????????-?handle?to?global?memory?with?a?DIB?spec
?*????????????????????in?it?followed?by?the?DIB?bits
?*
?*?LPRECT?lpDIBRect?-?rectangle?of?DIB?to?output?into?lpDCRect
?*
?*?CPalette*?pPal???-?pointer?to?CPalette?containing?DIB‘s?palette
?*
?*?Return?Value:
?*
?*?BOOL?????????????-?TRUE?if?DIB?was?drawn?FALSE?otherwise
?*
?*?Description:
?*???Painting?routine?for?a?DIB.??Calls?StretchDIBits()?or
?*???SetDIBitsToDevice()?to?paint?the?DIB.??The?DIB?is
?*???output?to?the?specified?DC?at?the?coordinates?given
?*???in?lpDCRect.??The?area?of?the?DIB?to?be?output?is
?*???given?by?lpDIBRect.
?*
?************************************************************************/
BOOL?WINAPI?PaintDIB(HDC?????hDC
LPRECT??lpDCRect
HDIB????hDIB
LPRECT??lpDIBRect
CPalette*?pPal)
{
LPSTR????lpDIBHdr;????????????//?Pointer?to?BITMAPINFOHEADER
LPSTR????lpDIBBits;???????????//?Pointer?to?DIB?bits
BOOL?????bSuccess=FALSE;??????//?Success/fail?flag
HPALETTE?hPal=NULL;???????????//?Our?DIB‘s?palette
HPALETTE?hOldPal=NULL;????????//?Previous?palette
/*?Check?for?valid?DIB?handle?*/
if?(hDIB?==?NULL)
return?FALSE;
/*?Lock?down?the?DIB?and?get?a?pointer?to?the?beginning?of?the?bit
?*??buffer
?*/
lpDIBHdr??=?(LPSTR)?::GlobalLock((HGLOBAL)?hDIB);
lpDIBBits?=?::FindDIBBits(lpDIBHdr);
//?Get?the?DIB‘s?palette?then?select?it?into?DC
if?(pPal?!=?NULL)
{
hPal?=?(HPALETTE)?pPal->m_hobject;
//?Select?as?background?since?we?have
//?already?realized?in?forground?if?needed
hOldPal?=?::SelectPalette(hDC?hPa
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????14260??1998-08-22?16:42??Diblook2\dibapi.cpp
?????文件???????1663??1998-08-22?16:42??Diblook2\dibapi.h
?????文件???????5009??2003-05-24?16:17??Diblook2\dibdoc.cpp
?????文件???????1464??1998-08-22?16:42??Diblook2\dibdoc.h
?????文件???????8899??1998-08-22?16:42??Diblook2\diblmac.r
?????文件???????4736??1998-08-22?16:42??Diblook2\diblook.001
?????文件??????37164??2011-05-12?15:15??Diblook2\DibLook.aps
?????文件???????7836??2011-05-12?15:17??Diblook2\diblook.clw
?????文件???????4384??2003-05-28?12:19??Diblook2\diblook.cpp
?????文件???????5375??2010-01-06?21:22??Diblook2\diblook.dsp
?????文件????????539??2001-03-08?16:34??Diblook2\diblook.dsw
?????文件?????278528??1998-08-22?16:42??Diblook2\diblook.exe
?????文件???????1211??1998-08-22?16:42??Diblook2\diblook.h
?????文件??????28560??1998-08-22?16:42??Diblook2\diblook.mak
?????文件??????80896??2011-05-12?15:19??Diblook2\diblook.opt
?????文件???????2245??2011-05-12?09:36??Diblook2\diblook.plg
?????文件??????19616??2011-05-12?09:36??Diblook2\DibLook.rc
?????文件???????9333??1998-08-22?16:42??Diblook2\diblook.rcm
?????文件??????15497??2011-05-12?09:36??Diblook2\dibview.cpp
?????文件???????2347??2011-05-12?09:35??Diblook2\dibview.h
?????文件???????1759??2010-01-04?21:31??Diblook2\InputKB.cpp
?????文件???????1399??2010-01-04?21:31??Diblook2\InputKB.h
?????文件???????9721??1998-08-22?16:42??Diblook2\l.jpn\diblook.rc
?????文件???????3355??1998-08-22?16:42??Diblook2\mainfrm.cpp
?????文件???????1181??2009-12-29?21:16??Diblook2\mainfrm.h
?????文件????????625??1998-08-22?16:42??Diblook2\makefile
?????文件???????2621??2010-01-08?18:43??Diblook2\matrix.cpp
?????文件????????350??2010-01-08?18:41??Diblook2\matrix.h
?????文件???????8298??1998-08-22?16:42??Diblook2\myfile.cpp
?????文件??????36270??2010-10-31?20:27??Diblook2\RCa03396
............此處省略37個文件信息
評論
共有 條評論