SendMessage() to a tabbed dialog
-
I created a tabbed dialog (with 2 tabs) without property sheets. I created a menu on the main dialog that I want to associate with one of the tabs of the tabbed dialog. I want to convert temperature on the embedded dialog to a celsius value when selecting the option from the menu. I have an error when using the SendMessage function. The commented statements are different ways I have attempted to send a message but they are incorrect. A pointer references each embedded dialog. Following this function are excerpts from my code (main dialog file, embedded dialog file). Does anyone have any suggestions? void CMotionAnalyzerDlg::OnTemperatureCelsius() { /* linking error ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));*/ //m_dPointer[0]->SendMessage(WM_MENU_CELSIUS,0,0); /* errorC2664: caanot convert parameter 1 from _3DSEmbeddedDialog* to UINT */ //SendMessage(m_dPointer[0], WM_MENU_CELSIUS); /* errorC2664: caanot convert parameter 1 from HWND to UINT */ //SendMessage(m_dPointer[0]->m_hWnd, WM_MENU_CELSIUS); } --------------------------------------------------------------------------------------- //MAIN DIALOG HEADER FILE class CMotionAnalyzerDlg : public CDialog { public: ... MoteDataDlg moteDataDlg; //mote data dialog object (embedded) DatabaseDlg databaseDlg; //database dialog object (embedded) void ShowEmbeddedDialog(int number); //shows the proper embedded dialog CTabCtrl dialogTabCtrl; //Create instance of the child window class; tab control for embedded dialogs ... protected: // Generated message map functions ... afx_msg void OnTemperatureCelsius(); DECLARE_MESSAGE_MAP() private: CRect embeddedDialogRect; //structure to hold the position of child windows _3DSEmbeddedDialog *m_dPointer[2]; //Create and assign pointers to each window ... }; ----------------------------------------------------------------------------------------- //MAIN DIALOG .CPP FILE BEGIN_MESSAGE_MAP(CMotionAnalyzerDlg, CDialog) ... ON_COMMAND(ID_TEMPERATURE_CELSIUS, OnTemperatureCelsius) END_MESSAGE_MAP() BOOL CMotionAnalyzerDlg::OnInitDialog() { ... //Create all embedded dialogs for the main window class moteDataDlg.Create(IDD_MOTE_DATA_DIALOG, this); databaseDlg.Create(IDD_DATABASE_DIALOG, this); ... } //Shows the proper embedded dialog void CMotionAnalyzerDlg::ShowEmbeddedDialog(int number) { int window
-
I created a tabbed dialog (with 2 tabs) without property sheets. I created a menu on the main dialog that I want to associate with one of the tabs of the tabbed dialog. I want to convert temperature on the embedded dialog to a celsius value when selecting the option from the menu. I have an error when using the SendMessage function. The commented statements are different ways I have attempted to send a message but they are incorrect. A pointer references each embedded dialog. Following this function are excerpts from my code (main dialog file, embedded dialog file). Does anyone have any suggestions? void CMotionAnalyzerDlg::OnTemperatureCelsius() { /* linking error ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));*/ //m_dPointer[0]->SendMessage(WM_MENU_CELSIUS,0,0); /* errorC2664: caanot convert parameter 1 from _3DSEmbeddedDialog* to UINT */ //SendMessage(m_dPointer[0], WM_MENU_CELSIUS); /* errorC2664: caanot convert parameter 1 from HWND to UINT */ //SendMessage(m_dPointer[0]->m_hWnd, WM_MENU_CELSIUS); } --------------------------------------------------------------------------------------- //MAIN DIALOG HEADER FILE class CMotionAnalyzerDlg : public CDialog { public: ... MoteDataDlg moteDataDlg; //mote data dialog object (embedded) DatabaseDlg databaseDlg; //database dialog object (embedded) void ShowEmbeddedDialog(int number); //shows the proper embedded dialog CTabCtrl dialogTabCtrl; //Create instance of the child window class; tab control for embedded dialogs ... protected: // Generated message map functions ... afx_msg void OnTemperatureCelsius(); DECLARE_MESSAGE_MAP() private: CRect embeddedDialogRect; //structure to hold the position of child windows _3DSEmbeddedDialog *m_dPointer[2]; //Create and assign pointers to each window ... }; ----------------------------------------------------------------------------------------- //MAIN DIALOG .CPP FILE BEGIN_MESSAGE_MAP(CMotionAnalyzerDlg, CDialog) ... ON_COMMAND(ID_TEMPERATURE_CELSIUS, OnTemperatureCelsius) END_MESSAGE_MAP() BOOL CMotionAnalyzerDlg::OnInitDialog() { ... //Create all embedded dialogs for the main window class moteDataDlg.Create(IDD_MOTE_DATA_DIALOG, this); databaseDlg.Create(IDD_DATABASE_DIALOG, this); ... } //Shows the proper embedded dialog void CMotionAnalyzerDlg::ShowEmbeddedDialog(int number) { int window
Trevy wrote:
/* linking error ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));*/ //m_dPointer[0]->SendMessage(WM_MENU_CELSIUS,0,0);
This means that tabbed window you are talking about, is not considered as window, thats why
ASSERT
.Trevy wrote:
/* errorC2664: caanot convert parameter 1 from HWND to UINT */ //SendMessage(m_dPointer[0]->m_hWnd, WM_MENU_CELSIUS);
You need to modify this to,
::SendMessage(m_dPointer[0]->m_hWnd, WM_MENU_CELSIUS,0,0);
But, again it should be valid window.. p.s. Its better to divide problem in small sub problem. Nobody like to read such huge code, like me( posted without using
<pre>
tags).Prasad Notifier using ATL | Operator new[],delete[][^]