From: jayMFC on 16 May 2008 03:38 We are trying to use the CMFCDesktopAlertWnd class in our project, but we cannot find a way to update the message on the Alerts dialog when using the custom dialog. Please, if anybody has any idea on how to dynamically update the message displayed at runtime, it will be greatly appreciated. Thanks, jayMFC
From: ChrisN on 17 May 2008 15:00 On Fri, 16 May 2008 00:38:00 -0700, jayMFC <jayMFC(a)discussions.microsoft.com> wrote: >We are trying to use the CMFCDesktopAlertWnd class in our project, but we >cannot find a way to update the message on the Alerts dialog when using the >custom dialog. Please, if anybody has any idea on how to dynamically update >the message displayed at runtime, it will be greatly appreciated. > >Thanks, >jayMFC Hi there, To do this, you need to access the m_pWndDlg member variable of CMFCDesktopAlertWnd, which is a pointer to the dialog box object within the alert window. Because m_pWndDlg is declared protected, you should derive a class from CMFCDesktopAlertWnd. class CMyDesktopAlertWnd : public CMFCDesktopAlertWnd { public: void SetMessage(LPCTSTR pszMessage); }; When you create the CMyDesktopAlertWnd object, you should specify the RUNTIME_CLASS of your dialog class. In the following code, I'm assuming the dialog class is CMyPopupDlg (from the DesktopAlertDemo sample application). CMyDesktopAlertWnd* pPopup = new CMyDesktopAlertWnd; pPopup->Create(..., RUNTIME_CLASS(CMyPopupDlg)); Then you can implement SetMessage to access your dialog class, eg: void CMyDesktopAlertWnd::SetMessage(LPCTSTR pszMessage) { CMyPopupDlg* pDlg = DYNAMIC_DOWNCAST(CMyPopupDlg, m_pWndDlg); if (pDlg != NULL) { pDlg->m_btnRL.SetWindowText(pszMessage); } } Now you can write: pPopup->SetMessage(_T("Testing...")); I hope this helps, Chris
From: jayMFC on 19 May 2008 04:03 Dear ChrisN, Thanks for the information, however I am not sure how to implement the SendMessage function. I am having difficulty in declaring the CMyPopupDlg in this function, please help. Thanks jayMFC > void CMyDesktopAlertWnd::SetMessage(LPCTSTR pszMessage) > { > CMyPopupDlg* pDlg = DYNAMIC_DOWNCAST(CMyPopupDlg, m_pWndDlg); > > if (pDlg != NULL) > { > pDlg->m_btnRL.SetWindowText(pszMessage); > } > } "ChrisN" wrote: > On Fri, 16 May 2008 00:38:00 -0700, jayMFC > <jayMFC(a)discussions.microsoft.com> wrote: > > >We are trying to use the CMFCDesktopAlertWnd class in our project, but we > >cannot find a way to update the message on the Alerts dialog when using the > >custom dialog. Please, if anybody has any idea on how to dynamically update > >the message displayed at runtime, it will be greatly appreciated. > > > >Thanks, > >jayMFC > > Hi there, > > To do this, you need to access the m_pWndDlg member variable of > CMFCDesktopAlertWnd, which is a pointer to the dialog box object > within the alert window. Because m_pWndDlg is declared protected, you > should derive a class from CMFCDesktopAlertWnd. > > class CMyDesktopAlertWnd : public CMFCDesktopAlertWnd > { > public: > void SetMessage(LPCTSTR pszMessage); > }; > > When you create the CMyDesktopAlertWnd object, you should specify the > RUNTIME_CLASS of your dialog class. In the following code, I'm > assuming the dialog class is CMyPopupDlg (from the DesktopAlertDemo > sample application). > > CMyDesktopAlertWnd* pPopup = new CMyDesktopAlertWnd; > > pPopup->Create(..., RUNTIME_CLASS(CMyPopupDlg)); > > Then you can implement SetMessage to access your dialog class, eg: > > void CMyDesktopAlertWnd::SetMessage(LPCTSTR pszMessage) > { > CMyPopupDlg* pDlg = DYNAMIC_DOWNCAST(CMyPopupDlg, m_pWndDlg); > > if (pDlg != NULL) > { > pDlg->m_btnRL.SetWindowText(pszMessage); > } > } > > Now you can write: > > pPopup->SetMessage(_T("Testing...")); > > I hope this helps, > > Chris >
From: ChrisN on 19 May 2008 05:03 On Mon, 19 May 2008 01:03:29 -0700, jayMFC <jayMFC(a)discussions.microsoft.com> wrote: >Dear ChrisN, > >Thanks for the information, however I am not sure how to implement the >SendMessage function. I am having difficulty in declaring the CMyPopupDlg in >this function, please help. > >Thanks >jayMFC Hi JayMFC, I'd recommend you look at the DesktopAlertDemo sample. The samples are in a zip file AllVCLanguageSamples.zip in the Program Files\Microsoft Visual Studio 9.0\Samples folder. CMyPopupDlg is a class in the DesktopAlertDemo project that uses a dialog box (IDD_DIALOG1) for the alert window. You could copy the CMyPopupDlg code from the sample into your project, and also the IDD_DIALOG1 resource. The code is in MyAlertDlg.cpp and MyAlertDlg.h. Chris
|
Pages: 1 Prev: link error with afxGlobalUtils of MFC9.0 Next: Memory leaks |