problem with adding About Diaglog
-
I want to create About dialog after created main dialog. All I did as follows: - create about dialog - in Resource.rc, I add this:
// create a line when right click dialog on taskbar
STRINGTABLE
BEGIN
IDS_ABOUTBOX "&About ..."
END- in CMyDlg.h, declare
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- in CMyDlg.cpp, implement this method:
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
/* set breakpoint to debug here */
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}- in CMyDlg.cpp, register notify
BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg)
ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()that's all, but it doesn't work. I try to debug and found that it doesn't come into OnSysComand() method. What do I miss here? Thank you very much, :)
-
I want to create About dialog after created main dialog. All I did as follows: - create about dialog - in Resource.rc, I add this:
// create a line when right click dialog on taskbar
STRINGTABLE
BEGIN
IDS_ABOUTBOX "&About ..."
END- in CMyDlg.h, declare
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- in CMyDlg.cpp, implement this method:
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
/* set breakpoint to debug here */
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}- in CMyDlg.cpp, register notify
BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg)
ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()that's all, but it doesn't work. I try to debug and found that it doesn't come into OnSysComand() method. What do I miss here? Thank you very much, :)
-
I guess you need to add the handler in the WinApp class. and by default MFC will add about dialog unless you explicitly removed the about dialog check box.
-
Thank you for reply me, SandipG. I don't have WinApp class, it's MFC project with Dialog based.
-
I want to create About dialog after created main dialog. All I did as follows: - create about dialog - in Resource.rc, I add this:
// create a line when right click dialog on taskbar
STRINGTABLE
BEGIN
IDS_ABOUTBOX "&About ..."
END- in CMyDlg.h, declare
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- in CMyDlg.cpp, implement this method:
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
/* set breakpoint to debug here */
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}- in CMyDlg.cpp, register notify
BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg)
ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()that's all, but it doesn't work. I try to debug and found that it doesn't come into OnSysComand() method. What do I miss here? Thank you very much, :)
tataxin wrote:
BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg) ON_WM_SYSCOMMAND() END_MESSAGE_MAP()
This is the wrong message map. It should be:
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
tataxin wrote:
BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg) ON_WM_SYSCOMMAND() END_MESSAGE_MAP()
This is the wrong message map. It should be:
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Thank you DavidCrow :) It works, but with a little strange. Whenever I right click application in taskbar and select "About ...", nothing happens. Then, I press Alt, the About dialog shows up. I don't know why???? :confused:
tataxin wrote:
It works, but with a little strange. Whenever I right click application in taskbar and select "About ...", nothing happens.
Does void
CMyDlg::OnSysCommand()
get called?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
tataxin wrote:
It works, but with a little strange. Whenever I right click application in taskbar and select "About ...", nothing happens.
Does void
CMyDlg::OnSysCommand()
get called?"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
yes, it does. Here is the source code of OnSysCommand:
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal(); // stop here (1)
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}When I try to debug, it stops at (1) until I press Alt. After that, the About dialog shows.
modified on Monday, June 2, 2008 3:51 AM