|
David,
When the "Class Wizard" creates a class for the Property Page is creates the constructor, and several other functions for the class. If I select ON_EN_SETFOCUS, ON_EN_CHANGE, ON_EN_KILLFOCUS, the Wizard gladly creates these functions - all have "return"s as the last statement. Again, neither of these functions would give me control of the page. Once the User has selected(clicked on) the editbox a ON_EN_SETFOCUS message is sent to the page, the same once the User selects another editbox on the page a ON_EN_KILLFOCUS message and another ON_EN_SETFOCUS message is sent ALL WITH RETURNS. I at no point receive control of the page on either selection. I need to be able to know (1): that the User is using a editbox (ON_EN_SETFOCUS does that), (2) That the User has finished entering the data (ON_EN_KILLFOCUS does that - IF ANOTHER editbox is selected). but I don't kn ow how to capture those messages and use them to collect the data. Can you show me with code as to how I would get the data? I'm sorry, but I just cannot fiquire out how to use the messages to transfer the messages into a function of my own to capture the data. Please explain with code examples.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: Again, neither of these functions would give me control of the page.
I have no idea what this means.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What I'm trying to say (and don't know how) is I don't know how to get the data, if nany, once the User is finished. There is no [Finished] or [OK] button or any other type of button on the page. Just the 8-10 editboxes. I know I can know when a User has clicked on a editbox(ON_EN_SETFOCUS), and I know I will know when the User clicks on something else (ON_EN_KILLFOCUS); but how do I trap(capture) these messages and have the page jump to a function of my creation, ie.:"CPage2::GetDataFromEditBox()". I'm no understanding the "return" statements of ON_EN_SETFOCUS" and ON_EN_KILLFOCUS. I can't, anywhere on the page say, "If ON_EN_SETFOCUS == TRUE then go here; because I don't have a method in place to be able to say that. In other words, the page is running without control until such a time as I can get the page to go to a function of my creation? Understand? Afterall, on a page there can be no "OnCommand" function to release control to a function.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: ...but how do I trap(capture) these messages and have the page jump to a function of my creation, ie.:"CPage2::GetDataFromEditBox()".
Use ClassWizard (Ctrl+W) to create handler functions for those messages.
Larry Mills Sr wrote: In other words, the page is running without control until such a time as I can get the page to go to a function of my creation? Understand?
No, but don't get discouraged just yet.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I tried that and nothing is done. The function the Wizard made is there, but since a property page cannot have (at lease it's not present in the class wizard ie WM_COMMAND) a OnCommand function the function is ignored when the User selects it. I checked under DeBug, the function is not called at all. Create a property page yourself and check it out, then you'll understand what I'm saying. The Class Wizard creates the function for IDC_TIRE ("CPage2::OnTire()"), but the program does not go there when IDC_TIRE is selected.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: I tried that...
Tell me exactly what you tried.
Larry Mills Sr wrote: The function the Wizard made is there...
But what message is it handing?
Larry Mills Sr wrote: but since a property page cannot have (at lease it's not present in the class wizard ie WM_COMMAND) a OnCommand function...
Why do you need, or even care about, an OnCommand() function? What are you wanting to use it for?
Larry Mills Sr wrote: ...but the program does not go there when IDC_TIRE is selected.
Are handling the EN_SETFOCUS message?
What does the message map look like?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
My message map is as follows:
// Generated message map functions
//{{AFX_MSG(CTrl_Pg2)
afx_msg void OnSetfocusFwdLtInsideTire();
afx_msg void OnMaxtextFwdLtInsideRim();
afx_msg void OnSetfocusFwdLtInsideRim();
afx_msg void OnMaxtextFwdLtInsideTire();
afx_msg void OnMaxtextFwdLtOutsideRim();
afx_msg void OnSetfocusFwdLtOutsideRim();
afx_msg void OnMaxtextFwdLtOutsideTire();
afx_msg void OnSetfocusFwdLtOutsideTire();
afx_msg void OnMaxtextFwdRtInsideRim();
afx_msg void OnSetfocusFwdRtInsideRim();
afx_msg void OnMaxtextFwdRtInsideTire();
afx_msg void OnSetfocusFwdRtInsideTire();
afx_msg void OnMaxtextFwdRtOutsideRim();
afx_msg void OnSetfocusFwdRtOutsideRim();
afx_msg void OnMaxtextFwdRtOutsideTire();
afx_msg void OnSetfocusFwdRtOutsideTire();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnKillfocusFwdLtInsideRim();
afx_msg void OnChangeFwdLtInsideRim();
afx_msg void OnChangeFwdLtInsideTire();
afx_msg void OnKillfocusFwdLtInsideTire();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CTrl_Pg2, CNewWizPage)
//{{AFX_MSG_MAP(CTrl_Pg2)
ON_EN_SETFOCUS(IDC_FWD_LT_INSIDE_TIRE, OnSetfocusFwdLtInsideTire)
ON_EN_MAXTEXT(IDC_FWD_LT_INSIDE_RIM, OnMaxtextFwdLtInsideRim)
ON_EN_SETFOCUS(IDC_FWD_LT_INSIDE_RIM, OnSetfocusFwdLtInsideRim)
ON_EN_MAXTEXT(IDC_FWD_LT_INSIDE_TIRE, OnMaxtextFwdLtInsideTire)
ON_EN_MAXTEXT(IDC_FWD_LT_OUTSIDE_RIM, OnMaxtextFwdLtOutsideRim)
ON_EN_SETFOCUS(IDC_FWD_LT_OUTSIDE_RIM, OnSetfocusFwdLtOutsideRim)
ON_EN_MAXTEXT(IDC_FWD_LT_OUTSIDE_TIRE, OnMaxtextFwdLtOutsideTire)
ON_EN_SETFOCUS(IDC_FWD_LT_OUTSIDE_TIRE, OnSetfocusFwdLtOutsideTire)
ON_EN_MAXTEXT(IDC_FWD_RT_INSIDE_RIM, OnMaxtextFwdRtInsideRim)
ON_EN_SETFOCUS(IDC_FWD_RT_INSIDE_RIM, OnSetfocusFwdRtInsideRim)
ON_EN_MAXTEXT(IDC_FWD_RT_INSIDE_TIRE, OnMaxtextFwdRtInsideTire)
ON_EN_SETFOCUS(IDC_FWD_RT_INSIDE_TIRE, OnSetfocusFwdRtInsideTire)
ON_EN_MAXTEXT(IDC_FWD_RT_OUTSIDE_RIM, OnMaxtextFwdRtOutsideRim)
ON_EN_SETFOCUS(IDC_FWD_RT_OUTSIDE_RIM, OnSetfocusFwdRtOutsideRim)
ON_EN_MAXTEXT(IDC_FWD_RT_OUTSIDE_TIRE, OnMaxtextFwdRtOutsideTire)
ON_EN_SETFOCUS(IDC_FWD_RT_OUTSIDE_TIRE, OnSetfocusFwdRtOutsideTire)
ON_WM_LBUTTONDOWN()
ON_EN_KILLFOCUS(IDC_FWD_LT_INSIDE_RIM, OnKillfocusFwdLtInsideRim)
ON_EN_CHANGE(IDC_FWD_LT_INSIDE_RIM, OnChangeFwdLtInsideRim)
ON_EN_CHANGE(IDC_FWD_LT_INSIDE_TIRE, OnChangeFwdLtInsideTire)
ON_EN_KILLFOCUS(IDC_FWD_LT_INSIDE_TIRE, OnKillfocusFwdLtInsideTire)
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Here 's an example of a function:
void CTrl_Pg2::OnSetfocusFwdLtInsideTire()
{
// TODO: Add your control notification handler code here
// BOOL m_bFwdLtATire in header
if(!m_bFwdLtTire)
{
DoFwdLeftTire();
}
m_bFwdLtTire = TRUE;
return;
}
and
void CTrl_Pg2::OnKillfocusFwdLtInsideTire()
{
// TODO: Add your control notification handler code here
m_bFwdLtTire = FALSE;
return;
}
A C++ programming language novice, but striving to learn
|
|
|
|
|
Ok, when IDC_FWD_LT_INSIDE_TIRE gets focus, OnSetfocusFwdLtInsideTire() is called, and when IDC_FWD_LT_INSIDE_TIRE loses focus, OnKillfocusFwdLtInsideTire() is called. Correct? What are you wanting to do in those functions?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Figure out how to get the data. OnKillfocusFwdLtInsideTire() I know tells me the User has clicked somewhere else. I simply don't know where to collect the data at.
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_FWD_LT_INSIDE_TIRE );
CString str = "";
pEdit->GetWindowText(str);// get the data
Where do I put the above code to get the data?
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: Where do I put the above code to get the data?
In OnKillfocusFwdLtInsideTire() , if that is the point at which you want the data.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Okay, I'll try it there. Question: If the User enters the data then selects [Next] or [Back] on the property sheet does the OnKillfocusFwdLtInsideTire() function still get called before the page becomes inactive?
Also Must you always have to have an ON_EN_SETFOCUS and an ON_EN_KILLFOCUS or can you just have an ON_EN_KILLFOCUS function.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: If the User enters the data then selects [Next] or [Back] on the property sheet does the OnKillfocusFwdLtInsideTire() function still get called before the page becomes inactive?
The best way to find the answer to this is just to try it and see. Set a breakpoint in the handler for EN_KILLFOCUS and PSN_KILLACTIVE to see which is called first.
Larry Mills Sr wrote: Also Must you always have to have an ON_EN_SETFOCUS and an ON_EN_KILLFOCUS or can you just have an ON_EN_KILLFOCUS function.
That depends on what you want to be notified of. If you only have a handler for the ON_EN_KILLFOCUS message, you will not know when the associated control gains focus.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thank you very much for all of your help. I tried the code and it works great in the ON_EN_KILLFOCUS function. I've been trying to solve this problem for 3 weeks.
Thanks again for your help.
A C++ programming language novice, but striving to learn
|
|
|
|
|
|
Looks Great Mark,
What's it supposed to do?
Bram van Kampen
|
|
|
|
|
Maybe you didn't read the post...
It does everything I want it to do...that changes several times a day.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
She sure is Sexxy
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
Hello,
I have a class which i created, it calculates some mathematical functions, Can i use or create "_beginthread" in the class?
i tried to do it, but i got this error:
error C2664: '_beginthread' : cannot convert parameter 1 from 'void (void *)' to 'void (__cdecl *)(void *)'
class CMaClasse<br />
{<br />
public:<br />
void FoncAppnt(void* args);<br />
void FoncApp(void* arg);<br />
};<br />
<br />
void CMaClasse::FoncAppnt(void* args)<br />
{<br />
_beginthread(FoncApp,0,(void*)a); <br />
}<br />
<br />
<br />
void CMaClasse::FoncApp(void* arg)<br />
{<br />
}
-- modified at 18:18 Friday 9th November, 2007
|
|
|
|
|
Gofur Halmurat wrote: Can i use or create "_beginthread" in the class?
Sure. But, if your thread proc is a class method, that method needs to be static...
class CMaClasse<br />
{<br />
public:<br />
void FoncAppnt(void* args);<br />
static void FoncApp(void* arg);<br />
};<br />
<br />
void CMaClasse::FoncAppnt(void* args)<br />
{<br />
_beginthread(& CMaClasse::
FoncApp,0,(void*)a); <br />
}<br />
<br />
<br />
void CMaClasse::FoncApp(void* arg)<br />
{<br />
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Can I use public variable in static function?
because i have some public variables in the class
|
|
|
|
|
A static method can only access static class members.
To get around this, typically a pointer to an object of the class is passed
to the thread proc. Then the thread proc can use that pointer to access
non static members of the class.
Here's an example (my changes are in red)...
class CMaClasse
{
<font color="Red">void *pThreadArgs;</font>
public:
void FoncAppnt(void* args);
static void FoncApp(void* arg);
};
void CMaClasse::FoncAppnt(void* args)
{
<font color="Red">pThreadArgs = args;</font>
_beginthread(&CMaClasse::FoncApp,0,<font color="Red">this</font>);
}
void CMaClasse::FoncApp(void* arg)
{
<font color="Red">
CMaClasse *pThis = (CMaClasse *)arg;
pThis->pThreadArgs->...</font>
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanks Mark,
It helped me alot!!!
|
|
|
|
|
|
Just to explain this behavior see: http://www.parashift.com/c++-faq-lite/pointers-to-members.html.
Briefly, the type of pointer-to-member-function is different from pointer-to-function .There is not cast (new in VC++2005).
|
|
|
|
|
george.dumitru wrote: There is not cast (new in VC++2005).
I never heard of "not cast"!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|