|
-
May 6th, 1999, 09:16 PM
#1
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
[email protected]
-
May 6th, 1999, 11:42 PM
#2
Re: Getting a handle to the OK button
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
-
May 7th, 1999, 03:26 AM
#3
Re: Getting a handle to the OK button
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.
-
May 7th, 1999, 09:29 AM
#4
Re: Getting a handle to the OK button
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
-
May 7th, 1999, 05:20 PM
#5
Re: Getting a handle to the OK button
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;
-
May 7th, 1999, 07:21 PM
#6
Re: Getting a handle to the OK button
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..)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|