المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ON_COMMAND not working on mfc



C++ Programming
06-26-2011, 10:30 PM
Here is the scenario

I have developed a custom class as below:

InsertEdit.h
class CInsertEdit : public CWnd{DECLARE_DYNAMIC(CInsertEdit) ... protected: ... afx_msg void GetCustomerName(); afx_msg void GetInitialBalance(); afx_msg void GetPhoneNumber(); afx_msg void GetDateOfBirth(); afx_msg void GetCountry(); ...};
InsertEdit.cpp
#include "InsertEdit.h" #define INSERTWINDOWCLASS L"INSERTWINDOWCLASS"...BEGIN_MESSAGE_MAP( CInsertEdit, CWnd) ON_WM_CTLCOLOR() ON_WM_CREATE() ON_WM_PAINT() ON_COMMAND(TEXT_2,GetCustomerName) ON_COMMAND(TEXT_3,GetInitialBalance) ON_COMMAND(TEXT_4,GetPhoneNumber) ON_COMMAND(TEXT_5,GetDateOfBirth) ON_COMMAND(TEXT_6,GetCountry)END_MESSAGE_MAP()IMPLEMENT_DYNAMIC(CInsertEdit, CWnd)...afx_msg void CInsertEdit::GetCustomerName() { wchar_t cst[256]; UserName.GetWindowTextW(cst,256); MessageBox(cst,L"Test",MB_OK); }...
I am expecting that any type of command like "Click" or "key stroke" will call the GetCustomerName function called. but it is not.

CInsertEdit is a custom class with few edit class in it..

Am I missing anything?

Shall I have to add anything special on main Window class or anywhere else?