|
kiran janaswamy wrote: 1)first function to be called in the dialog based application?
ANS) OnInitDialog(...)
Depends of what the reference is: the dialog, the application or MFC core. InitInstance of the Application class is called before OnInitDialog and take care of the creation of the dialog.
kiran janaswamy wrote: 2)can we change modal to modeless?
ANS) ModelDilag -> DoModel(..)
ModelLess -> Create(IDD_DIALOGRESOUCE,this)
->Show(SW_SHOW);
It is not really changing from Modal to modeless, it is just creating a modal and a modeless dialog separately.
|
|
|
|
|
Cedric Moonen wrote: Depends of what the reference is: the dialog, the application or MFC core.
i'd say that for any case, the first method called is the constructor of the object to be created
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
For me, the first method to be called is the main function . That's why it's important to see what they mean by 'first': first function (at all), first app function (with or without constructor included), ... So, it is very vague
|
|
|
|
|
|
Cedric Moonen wrote: For me, the first method to be called is the main function
One doubt?
In a MFC Dialog based application there is global varaible of app class.. So before calling the main funtion surely its constructor is called..isn't it?
nave
|
|
|
|
|
|
toxcct wrote: but it exists, within the framework.
I agree with that one..
But "Cedric Moonen " say the first function called is main. Before calling the main the constructor of the app class is called isn't it?
nave
|
|
|
|
|
i don't think so... the constructor of the app is called after main() started...
unless the application is a global object
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-- modified at 8:07 Thursday 11th May, 2006
|
|
|
|
|
Nope, not if the App class is global. Then, first the instance of the class will be created (resulting in calling the constructor).
-- modified at 7:58 Thursday 11th May, 2006
|
|
|
|
|
|
How's that possible.. Global variables are initialize first then only main function is called... Try creating a simple console application.. with a global variable..
nave
|
|
|
|
|
|
Naveen R wrote: In a MFC Dialog based application there is global varaible of app class.. So before calling the main funtion surely its constructor is called..isn't it?
Yes, constructor will be called first, you are right. I didn't remember that the application was global. When I write a console app with a kind of app object, I aleays declare it inside the main function, that's why I didn't think of that
|
|
|
|
|
kiran janaswamy wrote: OnInitDialog(...)
How can u say that OnInitDialog is the first function that is been called in a dialog based application?
I think it is the constructor of the app class that is been called first...
Even if ur saying about a Dialog class there are so many other functions that gets called before OnInitDialog..say PreSubClassWindow(), etc including the constructor of the dialog class;)
nave
|
|
|
|
|
Naveen R wrote: I think it is the constructor of the app class that is been called first...
What About CWinApp or CDialog Derived Class Constructor
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ya I mean the same, not CWinApp constrcutor
nave
|
|
|
|
|
Naveen R wrote: ya I mean the same, not CWinApp constrcutor
i am jokin buddy!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
1.)How is the message being transformed from one class to other? Diagrammatically show which class is getting the message first.
Ans
In MFC ,CCmdTarget is the class responsible for message routing
4.)what would be the first function called if we create a mfc application if it is a dialog based and not a dialog based?
Ans
What ever may be the application type the first method to be called is Constructor followed by InitInstace.Inorder to understand what happens inside have a look over this article http://www.codeproject.com/cpp/mfcprogflow.asp[^]
AppU
|
|
|
|
|
|
I create a button in a flexgrid, and want to get the BN_CLICKED message of the button. though I add the ON_BN_CLICKED in MESSAGE_MAP,still can't run into onbutton1().
is it the only way that Override OnCommand()?
.h class
class CProjDlg : public CDialog
{
...
public:
CMSFlexGrid m_FlexGrid;
private:
CButton m_btn;
....
<big>afx_msg void OnButton1();</big>
}
#define IDC_MYBUTTON 1999
.cpp creat button
BEGIN_MESSAGE_MAP(CProg5Dlg, CDialog)
//{{AFX_MSG_MAP(CProg5Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
<big>ON_BN_CLICKED(IDC_BUTTON1, OnButton1)</big>
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
create the button from the flexgrid
void CProg5Dlg::InitControls()
{
....
m_btn.Create("btn",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(100,40,140,120<big>),&m_FlexGrid</big>,1999);
..
}
void CProjDlg::OnButton1()
{
// TODO: Add your control notification handler code here
AfxMessageBox("button click");
}
|
|
|
|
|
You shouldn't specify the FlexGrid as parent (all the commands will be sent to this window instead of your dialog). Replace &m_FlexGrid by this .
|
|
|
|
|
if the parent is this, the button will be covered by flexgrid.
even if I use m_btn.ShowWindow(SW_SHOW), the button can't click at all.
|
|
|
|
|
Use m_btn.BringWindowToTop(); to bring the button on top of the flexgrid.
|
|
|
|
|
okey,I'll have a try;
You are real my saviour and teacher!
thank you very much!
|
|
|
|
|
that's wonderful!
and I thought another way, but there is still a small problem.
I use ClassWizard to create a new CButton-derived class named CFButton.and then create CBTGrid class derived from the MSFlexGrid class.
in CBTGrid class, define CFButton m_fButton;
and create the button in void CBTGrid::::PreSubclassWindow()
m_fButton.Create("button",WS_CHILD|BS_PUSHBUTTON|WS_VISIBLE,CRect(0,0,100,100),this,2000);
in CFButton class,add BN_CLICKED in message map below:
ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
void CFButton::OnClicked()
{
AfxMessageBox("ok now");
}
It is basically ok now. the only problem is tcan't catch the first time clike.
for example, I use CFButton create a batch of button in flexgrid;
after the first time click on any of the button, every click are ok;
what's the first time click do? how to avoid it?
|
|
|
|