Click here to Skip to main content
15,897,371 members

how to call dialog method from tabControl item

Member 7909353 asked:

Open original thread
I have a dialog box and a tab control on it.
class for dialog box is MyDlg and class for tab control is MyTabCtr.
MyDlg.h
C++
class MyDlg: public CDialog
{
enum { IDD = IDD_ZF1SDKLIGHTTUTORIAL_DIALOG };
public:
MyDlg(CWnd* pParent = NULL);// standard constructor
LRESULT ButtonPressed(WPARAM w, LPARAM l);////do this
MyTabCtrl m_cTab; //Reference for tab control class
protected:
virtual void DoDataExchange(CDataExchange* pDX);// DDX/DDV support
}

MyDlg.cpp
C++
BEGIN_MESSAGE_MAP(CZF1SDKLightTutorialDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_MESSAGE(WM_BUTTONPRESSED,ButtonPressed) ////do this
ON_WM_TIMER()
END_MESSAGE_MAP()

BOOL Mylg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE);			// Set big icon
m_cTab.Init();
m_cTab.InsertItem(0,"Register new user");
m_cTab.InsertItem(1,"Identify fingerprints");
m_cTab.CreateButton("Register User",24,0,0,520, 450,80);
return TRUE;  // return TRUE  unless you set the focus to a control
}
LRESULT MyDlg::ButtonPressed(WPARAM w, LPARAM l)////do this
{
int a=3,b=6,c;
c=a+b;
return 0;
}

void MyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB1, m_cTab);
}


MyTabCtrl .h
C++
class MyTabCtrl : public CTabCtrl
{
	DECLARE_DYNAMIC(MyTabCtrl)
public:
	int m_DialogID,ControlID;;
	MyTabCtrl();
	virtual ~MyTabCtrl();
LRESULT ButtonPressed(WPARAM w, LPARAM l);	//mouse button clicked on a button control
void CreateButton(LPCTSTR sCaption, int nID, int iTab, UINT uLocation = 0, int iX = 0, int iY = 0, int iLen = 50);


MyTabCtrl .cpp
C++
BEGIN_MESSAGE_MAP(MyTabCtrl, CTabCtrl)
	ON_MESSAGE(WM_BUTTONPRESSED,ButtonPressed)
	END_MESSAGE_MAP()
LRESULT MyTabCtrl::ButtonPressed(WPARAM w, LPARAM l)
{
	//to do
	return 0;
}

When I click the button "Register User" it run the code of MyTabCtrl::ButtonPressed(WPARAM w, LPARAM l) does not run MyDlg::ButtonPressed(WPARAM w, LPARAM l)
But I want to run of MyDlg::ButtonPressed(WPARAM w, LPARAM l)(How?)
Tags: VC++, Visual Studio (Visual Studio 2008), MFC

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900