Click to See Complete Forum and Search --> : Getting a handle to the OK button
On a standard OK MessageBox, how would you get the handle to the OK button? I need to be able to press the OK button programmaitcally (which I can do with dialogs I've made) but I need to be able to get the handle of a MessageBox button. How do I do this?
Regards,
-Tim Manchester
tim@softwarewolf.com
shridhar rao
May 6th, 1999, 11:42 PM
Hi Tim,
I am not very clear about exactly what you want. If you could kindly be more clear I could try my level best to solve the problem
Thanks
Wayne Forget
May 7th, 1999, 03:26 AM
I am not quite sure what you want but here are a few attempts at solving your problem.
1. Just call your OnOK() fuction if that is where you want the code to go else
2. if you need all the CButton member functions then just add a variable to you button.
If this is not what you want then please try and explain again so I know exactly what you need to do.
Safai Ma
May 7th, 1999, 09:29 AM
Well, OK buttons always have an ID of 'IDOK', at least the standard dialogs are.
So, if you have the handle to the window, you can call GetDlgItem(hWnd, IDOK) and it will return the HWND of the OK button.
-Safai
cwarez
May 7th, 1999, 05:20 PM
Try this:
CDialog* pDlg = (CDialog*)CWnd::FindWindow("32770(Dialog)","Put the Dialog Title Text Here");
CButton* pButOK = (CButton*)pDlg->GetDlgItem(IDOK);
HWND hWnd = pButOK->m_hWnd;
shellreef
May 7th, 1999, 07:21 PM
pWnd->GetDlgItem(IDOK);
pWnd->SendMessage(WM_LBUTTONDOWN);
Sleep(100);
pWnd->SendMessage(WM_LBUTTONUP);
That should work, of course 'pWnd' should point to the message box.
I've made a program called dismiss (http://ftp://shellreef.dynip.com/dismiss.zip) which can
automatically dismiss dialog boxes and more. You can download it from the address above
(it's on my comp and I go offline often so get it as soon as possible if you want it..)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.