Ok, I did a quick search on msdn an figured out,
class inherits from
which has a virtual base method
this is all you need, you should take a look at memory template to find out control ID which you pass into the
then here is pseudo code:
CDialog dlg("my_dialog_template", nullptr); // Constructs a CDialog object from template.
CWnd* btn = dlg.GetDlgItem(IDOK); // get pointer to ie. OK button
HWND hButton = btn->GetSafeHwnd(); // get handle to button
this is how to do it, but I guess the dialog you are talking about isn't created by you?
well in that case you don't know control ID (and you should not know it) and what that mean is you need to obtain this info somehow because template most likely isn't open source, here are few suggestions how to do it:
for description of these see:
if you need a handle you would call below method, and the use C API to "hack the MFC dialog":
see info here:
|Below is the code that I have tried|
No no, first the code isn't MFC, if you are using MFC then please avoid C style API, and use MFC functionality in a manner similar to my sample, and secondly,
doesn't look like maintanable solution for MFC, and it isn't FMC code or style either.
Instead make use of
on the dialog pointer/varaible to get focus to button, that should be better and it's MFC code too.
In your code, where is the dialog pointer you were talking about? or object variable? use that to get the handle.
HWND hDialog = dlg_pointer->GetSafeHwnd();
|Does it has any simple C++ code that I can try and test run in console before I apply it into MFC?|
I'm afraid not without googling out, but all information you need is really on msdn, you just need to take a read.
as I said I don't know MFC I just try to help you with this info here is from msdn, it's not that hard to understand. since MFC is just winapi and C++. known concepts. the rest belongs to reading the reference.