Click here to Skip to main content
15,914,500 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDon't understand code snippet Pin
Programm3r15-Mar-07 20:19
Programm3r15-Mar-07 20:19 
AnswerRe: Don't understand code snippet Pin
prasad_som15-Mar-07 23:08
prasad_som15-Mar-07 23:08 
QuestionRe: Don't understand code snippet Pin
David Crow16-Mar-07 3:02
David Crow16-Mar-07 3:02 
QuestionRe: Don't understand code snippet Pin
Mark Salsbery16-Mar-07 8:24
Mark Salsbery16-Mar-07 8:24 
Questionget data values from a dataGrid Pin
webHamlet15-Mar-07 19:40
webHamlet15-Mar-07 19:40 
AnswerRe: get data values from a dataGrid Pin
ThatsAlok15-Mar-07 23:17
ThatsAlok15-Mar-07 23:17 
GeneralRe: get data values from a dataGrid Pin
webHamlet16-Mar-07 4:33
webHamlet16-Mar-07 4:33 
QuestionSendMessage() to a tabbed dialog Pin
Trevy15-Mar-07 19:38
Trevy15-Mar-07 19:38 
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 windowCount = 2; //Uses two windows
if ((number >= 0) && (number < windowCount))
{
m_dPointer[0] = &moteDataDlg;
m_dPointer[1] = &databaseDlg;

// Hide every window except for the chosen one
for (int count = 0; count < windowCount; count++)
{
if (count != number)
m_dPointer[count]->HideEmbedded(); //Hide the embedded dialog
else if (count == number)
{
// Show the chosen window and set it's location
m_dPointer[count]->SetWindowPos(&wndTop, embeddedDialogRect.left,
embeddedDialogRect.top, embeddedDialogRect.right,
embeddedDialogRect.bottom, SWP_SHOWWINDOW);
dialogTabCtrl.SetCurSel(count); // Update selection tab
m_dPointer[count]->ShowEmbedded(); // Show the embedded dialog
}
}
void CMotionAnalyzerDlg::OnTemperatureCelsius()
{
//m_dPointer[0]->SendMessage(WM_MENU_CELSIUS,0,0);
//SendMessage(m_dPointer[0], WM_MENU_CELSIUS);
//SendMessage(m_dPointer[0]->m_hWnd, WM_MENU_CELSIUS);
}
-----------------------------------------------------------------------------------------
//3DSEMBEDDEDDIALOG FILE
3DSEmbeddedDialog::_3DSEmbeddedDialog(UINT nIDTemplate, CWnd* pParent)
: CDialog(nIDTemplate, pParent)
{
display = false;
}

void _3DSEmbeddedDialog::ShowEmbedded()
{
if(!display)
{
ShowWindow(SW_SHOW);
OnEmbeddedDisplay(display = true);
}
}

void _3DSEmbeddedDialog::HideEmbedded()
{
if(display)
{
ShowWindow(SW_HIDE);
OnEmbeddedDisplay(display = false);
}
}
-------------------------------------------------------------------------------------
//MOTEDATADLG (EMBEDDED DIALOG) HEADER FILE
#define WM_MENU_CELSIUS WM_APP + 100
class MoteDataDlg : public _3DSEmbeddedDialog //public CDialog
{
...
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
...
}
---------------------------------------------------------------------------------
//MOTEDATADLG (EMBEDDED DIALOG) .CPP FILE
LRESULT MoteDataDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message==WM_MENU_CELSIUS)
{
celsiusFlag = !celsiusFlag;
AfxBeginThread(MyThreadProc, this);
}
return 0;
}


Trevy

AnswerRe: SendMessage() to a tabbed dialog Pin
prasad_som15-Mar-07 19:52
prasad_som15-Mar-07 19:52 
Questiondisable button Pin
janpoo15-Mar-07 19:35
janpoo15-Mar-07 19:35 
AnswerRe: disable button Pin
prasad_som15-Mar-07 19:39
prasad_som15-Mar-07 19:39 
GeneralRe: disable button Pin
janpoo15-Mar-07 20:15
janpoo15-Mar-07 20:15 
AnswerRe: disable button Pin
prasad_som15-Mar-07 20:18
prasad_som15-Mar-07 20:18 
GeneralRe: disable button Pin
janpoo15-Mar-07 20:29
janpoo15-Mar-07 20:29 
GeneralRe: disable button Pin
Hamid_RT15-Mar-07 20:29
Hamid_RT15-Mar-07 20:29 
GeneralRe: disable button Pin
janpoo15-Mar-07 20:56
janpoo15-Mar-07 20:56 
GeneralRe: disable button Pin
Hamid_RT16-Mar-07 0:42
Hamid_RT16-Mar-07 0:42 
AnswerRe: disable button Pin
ThatsAlok16-Mar-07 0:01
ThatsAlok16-Mar-07 0:01 
QuestionProblem starting application by drag-drop file [modified] Pin
Jim_Csoft15-Mar-07 18:07
Jim_Csoft15-Mar-07 18:07 
QuestionRe: Problem starting application by drag-drop file Pin
prasad_som15-Mar-07 18:55
prasad_som15-Mar-07 18:55 
AnswerRe: Problem starting application by drag-drop file Pin
Jim_Csoft16-Mar-07 4:05
Jim_Csoft16-Mar-07 4:05 
Questionlist control Pin
Chen-XuNuo15-Mar-07 17:06
Chen-XuNuo15-Mar-07 17:06 
AnswerRe: list control Pin
Owner drawn15-Mar-07 17:42
Owner drawn15-Mar-07 17:42 
GeneralRe: list control Pin
Rajesh R Subramanian5-Aug-08 23:22
professionalRajesh R Subramanian5-Aug-08 23:22 
AnswerRe: list control Pin
harsh_296115-Mar-07 18:29
harsh_296115-Mar-07 18:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.