我做了一个光标显示的程序,可是显示不正常
大家帮我看一下:
//resource.h//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by cursor.rc
//
#define IDC_CURSOR1                     101
#define IDC_CURSOR2                     102
#define IDC_CURSOR3                     103
#define IDC_ARROWCOP                 105// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        104
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
//cursor.cpp
#include<afxwin.h>
#include<afxext.h>
#include"resource.h"class CMyApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};class CMainWnd:public CFrameWnd
{
protected:
int increment;
long count;
HICON m_hIcon;
HCURSOR m_hcur1,m_hcur2,m_hcur3;
HINSTANCE m_hInst;
public:
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
CMainWnd();
afx_msg void OnLButtonDown(UINT nFlag,CPoint point);
afx_msg void OnRButtonDown(UINT nFlag,CPoint point);
afx_msg void OnMouseMove(UINT nFlag,CPoint point);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP();
};BEGIN_MESSAGE_MAP(CMainWnd,CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_CREATE()
END_MESSAGE_MAP()CMainWnd::CMainWnd()
{
count=0;
increment=1;
}
BOOL CMainWnd::PreCreateWindow(CREATESTRUCT &cs)
{
// m_hIcon=(HICON)::LoadImage(cs.hInstance,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,32,32,LR_DEFAULTCOLOR);
m_hcur1=(HCURSOR)::LoadImage(cs.hInstance,MAKEINTRESOURCE(IDC_CURSOR1),IMAGE_CURSOR,32,32,LR_CREATEDIBSECTION);
m_hcur2=(HCURSOR)::LoadImage(cs.hInstance,MAKEINTRESOURCE(IDC_CURSOR2),IMAGE_CURSOR,32,32,LR_CREATEDIBSECTION);
m_hcur3=(HCURSOR)::LoadImage(cs.hInstance,MAKEINTRESOURCE(IDC_CURSOR3),IMAGE_CURSOR,32,32,LR_CREATEDIBSECTION);
return CFrameWnd::PreCreateWindow(cs);
}
int CMainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(m_hIcon)
{
SetIcon(m_hIcon,TRUE);
SetIcon(m_hIcon,FALSE);
::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,(LONG)m_hcur2);
}
return 0;
}
void CMainWnd::OnRButtonDown(UINT nFlag,CPoint point)
{
SetCursor(m_hcur3);
}
void CMainWnd::OnLButtonDown(UINT nFlag,CPoint point)
{
SetCursor(m_hcur3);
}
void CMainWnd::OnMouseMove(UINT nFlag,CPoint point)
{
if(count==-100)
{
SetCursor(m_hcur1);
}
if(count==100)
{
SetCursor(m_hcur2);
}
if(count>110)
{
count=-count;
}
count=count+increment;
}BOOL CMyApp::InitInstance()
{
CMainWnd*pFrame=new CMainWnd;
pFrame->Create(0,("XUFEI"),WS_POPUPWINDOW|WS_DLGFRAME,CRect(0,0,640,400));
this->m_pMainWnd=pFrame;
pFrame->ShowWindow(m_nCmdShow);
pFrame->UpdateWindow();
return TRUE;
}
CMyApp MyApp;