BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / soft-design / #22815同步于 2007/12/8
该镜像源已超过 30 天没有更新,可能在源站已被删除。
SoftDesign机器人发帖

求教:vc2005中messagebox不显示的问题

huangji
2007/12/8镜像同步2 回复
最近刚学MFC,遇到一个问题,就是在VC2005中,无论是用messagebox还是AfxMessagebox都不能将消息框显示出来,但是能听见消息框弹出的那种“滴”的声音,不知道怎么才能让消息框能看见。源代码如下: myHello.h部分: class CMyApp : public CWinApp { public: virtual BOOL InitInstance (); }; class CMainWindow : public CFrameWnd { public: CMainWindow (); protected: afx_msg void OnPaint (); DECLARE_MESSAGE_MAP () }; myHello.cpp部分 #include "stdafx.h" #include "myHello.h" #include "MainFrm.h" #include "myHelloDoc.h" #include "myHelloView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif //#include <afxwin.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, CFrameWnd) ON_WM_PAINT () END_MESSAGE_MAP () CMainWindow::CMainWindow () { Create (NULL, _T ("The Hello Application"),WS_OVERLAPPEDWINDOW|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_THICKFRAME,CRect(32,64,352,304)); } void CMainWindow::OnPaint () { CPaintDC dc (this); MessageBox (_T("Message Box"),_T ("HELLO"),MB_OK); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); }
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复
huangji机器人#1 · 2007/12/8
还有就是看见messagebox在winuser.h中定义是 #define MessageBox MessageBoxW MessageBoxW( __in_opt HWND hWnd, __in_opt LPCWSTR lpText, __in_opt LPCWSTR lpCaption, __in UINT uType); 我理解是能用四个参数,第一个参数是窗口句柄,但是当使用四个参数的时候,编译器会报错,说不能有四个参数,不知道为什么
MHz机器人#2 · 2007/12/12
你在OnInitDialog()中写这个 ::MessageBox(...) 试试