| |

VerySource

 Forgot password?
 Register
Search
Author: zhang_huayu

Ask the heroes for help: Why can't the simplest LButton messages respond?

[Copy link]

0

Threads

59

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-8-5 21:30:01
| Show all posts
Add the mouse message in which window class you want to capture the mouse message of which window! ! !
Reply

Use magic Report

2

Threads

18

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 Unknown

Post time: 2020-8-6 08:00:01
| Show all posts
It's normal to be hit.
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-6 11:45:01
| Show all posts
BOOL CMyApp::InitInstance()
{
CFrameWnd* p=new CFrameWnd;
p->Create(0,"yang");
p->ShowWindow(SW_SHOWDEFAULT);
p->UpdateWindow();
//AfxGetApp()->m_pMainWnd=p;
this->m_pMainWnd=p;
return TRUE;
}
--------------------
I don't understand why you want to write it like this. What's the use of such a  P? After this function exits, the pointer becomes invalid, and you also cause a memory leak
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-6 12:00:01
| Show all posts
And how can this->m_pMainWnd=p  ? ? Write like this? ? Really strong
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-4 20:15:01
| Show all posts
#include<afxwin.h> //MFC code and standard components
class CMinApp:public CWinApp
{public: virtual BOOL InitInstance();};
class CMainWnd:public CFrameWnd
{protected:
  afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
public: DECLARE_MESSAGE_MAP();
};

BEGIN_MESSAGE_MAP(CMainWnd, CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()

void CMainWnd::OnLButtonDown(UINT nFlags, CPoint point)
{CString szAboutLeft="This is a minimal WIndows MFC program.\n"
  "You've pressed the left mouse button!";
::MessageBeep(MB_ICONINFORMATION);
::MessageBox(GetSafeHwnd(),szAboutLeft,"About",MB_OK|MB_ICONINFORMATION);
CFrameWnd::OnLButtonDown(nFlags,point);
}

void CMainWnd::OnRButtonDown(UINT nFlags, CPoint point)
{CString szAboutRight="This is a minimal Windows MFC program.\n"
  "You've pressed the right mouse button!";
::MessageBeep(MB_ICONINFORMATION);
::MessageBox(GetSafeHwnd(),szAboutRight,"About",
MB_OK|MB_ICONINFORMATION);
CFrameWnd::OnRButtonDown(nFlags,point);
}

BOOL CMinApp::InitInstance()
{CFrameWnd* pFrame=new CFrameWnd;
  pFrame->Create(0,_T("Another Minimal MFC Program"));
  pFrame->ShowWindow(SW_SHOWMAXIMIZED);
  pFrame->UpdateWindow();
  AfxGetApp()->m_pMainWnd=pFrame;
  return TRUE;
}
CMinApp MyApp;
///////////////////////////////////////////////// /////////
Please help me. When I use SPY++ to watch, a message is generated, but the corresponding dialog box is not displayed?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list