Click here to Skip to main content
15,885,435 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Populate list from database Pin
Germghost24-Jun-11 3:25
Germghost24-Jun-11 3:25 
QuestionMemory alignment changed from studio 2005 to 2010? Pin
William Engberts23-Jun-11 20:55
William Engberts23-Jun-11 20:55 
QuestionRe: Memory alignment changed from studio 2005 to 2010? Pin
CPallini23-Jun-11 22:04
mveCPallini23-Jun-11 22:04 
AnswerRe: Memory alignment changed from studio 2005 to 2010? Pin
William Engberts23-Jun-11 22:25
William Engberts23-Jun-11 22:25 
QuestionRe: Memory alignment changed from studio 2005 to 2010? Pin
CPallini23-Jun-11 22:28
mveCPallini23-Jun-11 22:28 
GeneralRe: Memory alignment changed from studio 2005 to 2010? Pin
William Engberts23-Jun-11 22:30
William Engberts23-Jun-11 22:30 
AnswerRe: Memory alignment changed from studio 2005 to 2010? Pin
Alain Rist24-Jun-11 5:14
Alain Rist24-Jun-11 5:14 
QuestionMFC: Message-only CWnd in an SDI application. [modified] Pin
Odysseas Z23-Jun-11 5:17
Odysseas Z23-Jun-11 5:17 
Hello everyone!

I am trying to alternate an SDI application which is used to operate a spectral camera as part of my diploma thesis. Since it's not my code entirely I tried to simulate a bit of the functionality I want add in a simpler example. So I created an MFC SDI application using Creation Wizard of Visual Studio 2005 (it's a bit old I know but what can you do...). The code I added implements a new class derived from CDialog which creates an invisible message-only, and posts/sends two user-defined messages. These two messages are supposed to be handled by an object of my class CInvisibleWnd. Everything seems to work fine (no errors and no warnings during building) and all my objects are successfully created but the code inside the event handlers is not reached! Do you have any suggestions?

Here's a code snippet of my added classes:
//==================================================================
// stdafx.h
// User-defined messages.
#define WM_MITSOS	(WM_APP + 14)
#define WM_TAKIS	(WM_APP + 15)
//==================================================================
// CDialogMsg.h
class CDialogMsg : public CDialog
{	DECLARE_DYNAMIC(CDialogMsg)
public:
	CDialogMsg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CDialogMsg();
// Dialog Data
	enum { IDD = IDD_DIALOG_MSG };
	CInvisibleWnd* pWnd;                // the invisible window
// Message Handlers declaration.
DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
	afx_msg void OnBnClickedCancel();
	afx_msg void OnBnClickedButtonCreate();
//=================================================================== 
// CDialogMsg.cpp
// ...after implementing constructor we have handler implementation...
BEGIN_MESSAGE_MAP(CDialogMsg, CDialog)
	ON_BN_CLICKED(IDOK, &CDialogMsg::OnBnClickedOk)
	ON_BN_CLICKED(IDCANCEL, &CDialogMsg::OnBnClickedCancel)
	ON_BN_CLICKED(IDC_BUTTON_CREATE, &CDialogMsg::OnBnClickedButtonCreate)
END_MESSAGE_MAP()

void CDialogMsg::OnBnClickedOk()
{  // Post first message with some ints for parameters
   SendMessage(WM_MITSOS, (WPARAM)1, (LPARAM)3);
}

void CDialogMsg::OnBnClickedCancel()
{  // Post second message with some ints for parameters
   SendMessage(WM_TAKIS, (WPARAM)2, (LPARAM)4);
}

void CDialogMsg::OnBnClickedButtonCreate()
{  // Create the message-only CWnd
   pWnd = new CInvisibleWnd;
}
//==================================================================
// CInvisibleWnd.h
class CInvisibleWnd : public CWnd
{	DECLARE_DYNAMIC(CInvisibleWnd)
public:
	CInvisibleWnd();
	virtual ~CInvisibleWnd();
protected:
	DECLARE_MESSAGE_MAP()
	afx_msg LRESULT OnMitsos(WPARAM w, LPARAM l);
	afx_msg LRESULT OnTakis(WPARAM w, LPARAM l);
};
//==================================================================
// CInvisibleWnd.cpp
// Construction/Creation:
IMPLEMENT_DYNAMIC(CInvisibleWnd, CWnd)

CInvisibleWnd::CInvisibleWnd()
{
CString wnd_class_name = ::AfxRegisterWndClass(NULL);
this->CreateEx(0,wnd_class_name,_T("CMyMessageOnlyWindowClass"),0 ,0 ,0 ,0 ,0 ,HWND_MESSAGE,0);
AfxMessageBox(_T("Invisible Window created!"));
}
// Message Map & Handler implementation
BEGIN_MESSAGE_MAP(CInvisibleWnd, CWnd)
   ON_MESSAGE(WM_MITSOS, &CInvisibleWnd::OnMitsos)
   ON_MESSAGE(WM_TAKIS, &CInvisibleWnd::OnTakis)
END_MESSAGE_MAP()
// CInvisibleWnd message handlers
LRESULT CInvisibleWnd::OnMitsos(WPARAM w, LPARAM l)
{
   AfxMessageBox(_T("Hi Mitsos"));
   return LRESULT(true);
}
LRESULT CInvisibleWnd::OnTakis(WPARAM w, LPARAM l)
{
   AfxMessageBox(_T("Hi Takis"));
   return LRESULT(true);
}


The CDialogMsg object is created by C"MyProjectName"Doc object...
I could not incorporate message-only CWnd to C"MyProjectName"Doc due to multiple inheritance which is, as I found out, very difficult to implement. The best source I found for message-only CWnd in MFC is here: How to make a Message Only Window

Any ideas?
Thank you very much!
Best Regards!
Ody -- Always look on the bright side of life --
modified on Thursday, June 23, 2011 11:40 AM

AnswerRe: MFC: Message-only CWnd in an SDI application. Pin
jeron123-Jun-11 6:23
jeron123-Jun-11 6:23 
GeneralRe: MFC: Message-only CWnd in an SDI application. Pin
Odysseas Z23-Jun-11 6:43
Odysseas Z23-Jun-11 6:43 
GeneralRe: MFC: Message-only CWnd in an SDI application. Pin
Albert Holguin23-Jun-11 8:37
professionalAlbert Holguin23-Jun-11 8:37 
AnswerRe: MFC: Message-only CWnd in an SDI application. Pin
Albert Holguin23-Jun-11 8:33
professionalAlbert Holguin23-Jun-11 8:33 
QuestionExample of List control with Report view in MFC Pin
Amrit Agr23-Jun-11 0:12
Amrit Agr23-Jun-11 0:12 
AnswerRe: Example of List control with Report view in MFC Pin
«_Superman_»23-Jun-11 0:23
professional«_Superman_»23-Jun-11 0:23 
AnswerRe: Example of List control with Report view in MFC Pin
David Crow23-Jun-11 4:15
David Crow23-Jun-11 4:15 
QuestionHow to read data from a text file based on a deleimiter like ; Pin
Amrit Agr22-Jun-11 21:29
Amrit Agr22-Jun-11 21:29 
AnswerRe: How to read data from a text file based on a deleimiter like ; Pin
«_Superman_»22-Jun-11 21:39
professional«_Superman_»22-Jun-11 21:39 
QuestionRe: How to read data from a text file based on a deleimiter like ; Pin
CPallini22-Jun-11 23:14
mveCPallini22-Jun-11 23:14 
AnswerRe: How to read data from a text file based on a deleimiter like ; Pin
«_Superman_»22-Jun-11 23:18
professional«_Superman_»22-Jun-11 23:18 
GeneralRe: How to read data from a text file based on a deleimiter like ; Pin
Amrit Agr23-Jun-11 0:10
Amrit Agr23-Jun-11 0:10 
AnswerRe: How to read data from a text file based on a deleimiter like ; Pin
User 742933823-Jun-11 1:43
professionalUser 742933823-Jun-11 1:43 
GeneralRe: How to read data from a text file based on a deleimiter like ; Pin
«_Superman_»23-Jun-11 1:46
professional«_Superman_»23-Jun-11 1:46 
AnswerRe: How to read data from a text file based on a deleimiter like ; Pin
David Crow23-Jun-11 4:39
David Crow23-Jun-11 4:39 
Questionhelp plz Pin
lolaaaa22-Jun-11 2:06
lolaaaa22-Jun-11 2:06 
AnswerRe: help plz Pin
CPallini22-Jun-11 2:22
mveCPallini22-Jun-11 2:22 

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.