Click here to Skip to main content
16,016,333 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Window resizing Pin
Christian Graus28-Sep-06 0:52
protectorChristian Graus28-Sep-06 0:52 
AnswerRe: Window resizing Pin
_AnsHUMAN_ 28-Sep-06 0:56
_AnsHUMAN_ 28-Sep-06 0:56 
GeneralRe: Window resizing Pin
SKMukherjee28-Sep-06 1:11
SKMukherjee28-Sep-06 1:11 
GeneralRe: Window resizing Pin
Parthi_Appu28-Sep-06 1:27
Parthi_Appu28-Sep-06 1:27 
AnswerRe: Window resizing Pin
David Crow28-Sep-06 3:01
David Crow28-Sep-06 3:01 
Questioncreating new window [modified] Pin
Anu_Bala28-Sep-06 0:24
Anu_Bala28-Sep-06 0:24 
AnswerRe: creating new window Pin
Hamid_RT28-Sep-06 2:49
Hamid_RT28-Sep-06 2:49 
QuestionButton wouldn't respond to SendMessage message Pin
ken11111127-Sep-06 23:21
ken11111127-Sep-06 23:21 
Hi,

I'm having some problem with SendMessage/PostMessage API simulating a "click" on the [SAVE] button on IE's Download Dialog Box. Would appreaciate any sort of suggestions. Thanks

Scenario:
Clicking on a hyperlink (link to a file, e.g Try.xls) in Internet Explorer. A Dialog appear with 3 options, [Open],[Save],[Cancel]

Code Snippets:

BOOL bResult = FALSE;
HWND MainDialog = NULL, SaveButton = NULL;
MainDialog = FindWindow(NULL,"File Download");
if (MainDialog == NULL)
printf("Cannot Find Main Save DialogBox.\n");
else
{
SaveButton = FindWindowEx(MainDialog, NULL, NULL, "&Save");
if (SaveButton == NULL)
{
printf("Cannot Find Save Button.\n");
exit(0);
}
else
{
SetFocus(SaveButton);
bResult = PostMessage(SaveButton, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(0,0));
if (!bResult) exit(0);
bResult = PostMessage(SaveButton, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(0,0));
if (!bResult) exit(0);
}
}

Problems:
When I'm stepping through this step: PostMessage(SaveButton, WM_LBUTTONDOWN.. , I can see the button in depressed mode, and the Focus has been changed to the [Save] Button. But on Buttonup, nothing happens.

Tested Method (But I might have done it wrongly):
1. Have tried SendDlgItemMessage API and using GetDlgCtrlID to get the ControlID of the [Save] Button (Have verified using Spy++, and they are same). But it doesn't work.
2. Tried to send TAB key to the DialogBox, and the focus shift to [SAVE] button. But sending "Space" keystroke to the dialog also have no effect. (Can see the button moving, but nothing happens after that)
4. Tried changing the Default button from [CANCEL] to [SAVE] and sending SPACE KEY. Doesnt work.
-- PostMessage(MainDialog, (UINT) DM_SETDEFID, (WPARAM) GetDlgCtrlID(SaveButton) , TRUE);
3. On the other hand, when I try to activate the [Cancel] button, it works correctly.

Findings: (using Spy++)
1. I noticed that the [CANCEL] button has a ControlID of 000002, whereas the [OPEN] button and [SAVE] button has ControlID of 00001147 and 00001148 respectively. This probably means that [OPEN] and [SAVE] are not "default buttons". Therefore using VBScript, I tried - Msgbox "HelloCodeProject",vbYesNoCancel. [YES] button has ControlID of 6, [NO] had ControlID of 7 and [CANCEL] had Control ID of 2.

Apart from IE's Download Dialog Box, there are several other application that cannot be controlled using the SendMessage. Would appreciate any sort of suggestion.
By the way, using VBScript AppActivate, and SendKeys method is able to successfully activate the [SAVE] button, but that's not the way I want.
QuestionRe: Button wouldn't respond to SendMessage message Pin
David Crow28-Sep-06 3:08
David Crow28-Sep-06 3:08 
AnswerRe: Button wouldn't respond to SendMessage message Pin
ken11111128-Sep-06 15:03
ken11111128-Sep-06 15:03 
QuestionRegarding Call Stack Pin
janadhana27-Sep-06 22:47
janadhana27-Sep-06 22:47 
AnswerRe: Regarding Call Stack Pin
Christian Graus28-Sep-06 0:17
protectorChristian Graus28-Sep-06 0:17 
GeneralRe: Regarding Call Stack Pin
nutkase28-Sep-06 0:44
nutkase28-Sep-06 0:44 
GeneralRe: Regarding Call Stack Pin
Christian Graus28-Sep-06 0:50
protectorChristian Graus28-Sep-06 0:50 
GeneralRe: Regarding Call Stack Pin
nutkase28-Sep-06 1:13
nutkase28-Sep-06 1:13 
GeneralRe: Regarding Call Stack Pin
Stephen Hewitt28-Sep-06 13:23
Stephen Hewitt28-Sep-06 13:23 
QuestionTreeView Pin
zizzzz27-Sep-06 22:27
zizzzz27-Sep-06 22:27 
AnswerRe: TreeView Pin
Waldermort27-Sep-06 23:07
Waldermort27-Sep-06 23:07 
AnswerRe: TreeView Pin
Hamid_RT29-Sep-06 8:23
Hamid_RT29-Sep-06 8:23 
GeneralRe: TreeView Pin
zizzzz29-Sep-06 22:01
zizzzz29-Sep-06 22:01 
GeneralRe: TreeView Pin
Hamid_RT30-Sep-06 4:56
Hamid_RT30-Sep-06 4:56 
QuestionNotepad application Pin
Ram Murali27-Sep-06 21:52
Ram Murali27-Sep-06 21:52 
AnswerRe: Notepad application [modified] Pin
_AnsHUMAN_ 27-Sep-06 21:56
_AnsHUMAN_ 27-Sep-06 21:56 
GeneralRe: Notepad application Pin
Ram Murali27-Sep-06 22:03
Ram Murali27-Sep-06 22:03 
GeneralRe: Notepad application Pin
_AnsHUMAN_ 27-Sep-06 22:11
_AnsHUMAN_ 27-Sep-06 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.