简单的MFC小程序在xp上可以, 在win7上不行,请教各位高手
TicTac.h:程序代码:
class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CWnd { public: CMainWindow (); protected: afx_msg void OnLButtonDown (UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP () };
TicTac.cpp:
程序代码:
#include <afxwin.h> #include "TicTac.h" CMyApp myApp; ///////////////////////////////////////////////////////////////////////// // CMyApp member functions BOOL CMyApp::InitInstance () { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow (m_nCmdShow); m_pMainWnd->UpdateWindow (); return TRUE; } ///////////////////////////////////////////////////////////////////////// // CMainWindow message map and member functions BEGIN_MESSAGE_MAP (CMainWindow, CWnd) ON_WM_LBUTTONDOWN () END_MESSAGE_MAP () CMainWindow::CMainWindow () { // // Register a WNDCLASS. // CString strWndClass = AfxRegisterWndClass ( CS_DBLCLKS, // Class style AfxGetApp ()->LoadStandardCursor (IDC_ARROW), // Class cursor (HBRUSH) (COLOR_3DFACE + 1), // Background brush AfxGetApp ()->LoadStandardIcon (IDI_WINLOGO) // Class icon ); // // Create a window. // CreateEx (0, strWndClass, _T ("Tic-Tac-Toe"), WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL); } void CMainWindow::OnLButtonDown (UINT nFlags, CPoint point) { CClientDC dc (this); dc.MoveTo(0, 0); dc.LineTo(100, 100); }
目的就是点击鼠标左键,画一条线. 在xp上点击后,画的线立马显示, 在win7上点击后,画的线不出现,除非我将鼠标移到其它窗口上点击一下,再回来才显示,到底怎么回事呢?