I have explained my problem step by step:
1. Firstly I have sub-classed the winword with my windows procedure
with appropriate sub-classing requirement (rules).
2. After sub-classing, from my own application i am sending WM_USER +
40 message with character 'x' to winword.
3. As i have sub-classed first this 'x' will come to my WndProc then i
will do some operation on 'x' and processed 'x' will forward to
original winwords 's WndProc. See following my WndProc
LRESULT CALLBACK
NewWndProcFocused(
HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
{
LRESULT lResult;
switch (message)
{
case WM_USER + 40:
message = WM_CHAR;
break;
}
//
// Calling original focused window procedure.
//
lResult = CallWindowProc(
g_WndProcFocusedOrignl,
hwnd,
message,
wParam,
lParam
);
return lResult;
}
4. Now words WndProc supposed to write 'x' at ms-word .
5. But i am not seeing any result.
But for other application's like Internet Explore, Notepad, Wordpad
every where it is working.
Thanks and Regards
Joseph.
> 1. Firstly I have sub-classed the winword with my windows procedure
> with appropriate sub-classing requirement (rules).
You must use OLE Automation to automate Winword
Ohh !
But when i use SendMessage(); to send a character to word it succeeds
and writes that character to ms-word.
Then in this case whether it uses OEL automation.
Thanks.
Subclassing works only in the address space of the same process:
http://msdn.microsoft.com/en-us/library/ms997565.aspx
If you do a SendMessage, and you send a value, and not an address, this
works.
For WM_GETTEXT and WM_SETTEXT Microsoft implemented a transfer of the
string to annother address space, thus this works, too.
HTH,
Friedel
Yes Friedel, i have sub-classed the window procedure into target
process only. And then i have sent a MSG to my window proc and then i
am calling CallWindowProc();
You posted:
>>>>> 1. Firstly I have sub-classed the winword with my windows procedure
>>>>> with appropriate sub-classing requirement (rules).
This cannot work, for your application and WinWord are different processes
with separate address spaces. The WinWord window cannot access a procedure
in your process and vice versa.
Please read the link I posted, it gives useful information on subclassing:
http://msdn.microsoft.com/en-us/library/ms997565.aspx
HTH,
Friedel
I understood the OP to be saying he had subclassed the window
procedure by injecting code into the remote process, presumably using
WriteProcessMemory and CreateRemoteThread, which is legitimate (though
tricky to do correctly). It may well not be possible to achieve what
he wants with WinWord that way, but the subclassing itself should
work.
Richard.
http://www.rtrussell.co.uk/
Yes Richard, i have used CreateRemoteThread() for injecting a DLL into
target application.
Once the DLL is loaded i have sub-classed a window who is having caret
blinking.
And now i am calling CallWindowProc() to write a character to focused
window. And this is working for wordpad, notepad, other windows but
NOT winword, power point, excel.
Thanks,
> On Jan 20, 3:14�pm, Richard Russell <n...@rtrussell.co.uk> wrote:
>> On Jan 20, 7:14�am, Friedel Jantzen <nospam_...@freenet.de> wrote:
>>
>>> This cannot work, for your application and WinWord are different processes
>>> with separate address spaces. The WinWord window cannot access a procedure
>>> in your process and vice versa.
>>
>> I understood the OP to be saying he had subclassed the window
>> procedure by injecting code into the remote process, presumably using
>> WriteProcessMemory and CreateRemoteThread, which is legitimate (though
>> tricky to do correctly). �It may well not be possible to achieve what
>> he wants with WinWord that way, but the subclassing itself should
>> work.
>>
>> Richard.http://www.rtrussell.co.uk/
>
> Yes Richard, i have used CreateRemoteThread() for injecting a DLL into
> target application.
Sorry, I missed this point.
> Once the DLL is loaded i have sub-classed a window who is having caret
> blinking.
> And now i am calling CallWindowProc() to write a character to focused
> window. And this is working for wordpad, notepad, other windows but
> NOT winword, power point, excel.
It would be interesting, if the target window of WinWord processes WM_CHAR
(rsp. what you send) on regular keyboard input.
IMO dll injecting with subclassing is useful for debugging and
experimenting, but could break with the next update.
Regards,
Friedel
Yes this is main doubt when we press any key on physical keyboard then
KEYDOWN->CHAR->KEYUP is sent and it is processed by WinWord but this
is failing. Also i have not understood your two lines:
> IMO dll injecting with subclassing is useful for debugging and
> experimenting, but could break with the next update.
Thanks
Joseph.
Does the window you subclassed receive WM_CHAR when you press a key on the
keyboard with the pressed char code in wParam and the key data in lParam?
(I cannot test it, because I use OpenOffice.org.)
> Also i have not understood your two lines:
>
>> IMO dll injecting with subclassing is useful for debugging and
>> experimenting, but could break with the next update.
Microsoft can change the design of WinWord any time, and we cannot be sure
to subclass the correct window in the future.
So even if it works with a version, it could break with the next.
Microsoft thinks, we should use OLE or macros. (BTW Macros can call
functions in a dll.)
Regards,
Friedel
Yes the window i have subclassed receives a WM_CHAR when i press a key
on the keyboard with the pressed char code in wParam and key data in
lParam.
> > Also i have not understood your two lines:
>
> >> IMO dll injecting with subclassing is useful for debugging and
> >> experimenting, but could break with the next update.
>
> Microsoft can change the design of WinWord any time, and we cannot be sure
> to subclass the correct window in the future.
> So even if it works with a version, it could break with the next.
> Microsoft thinks, we should use OLE or macros. (BTW Macros can call
> functions in a dll.)
>
> Regards,
> Friedel
Regards,
Joseph.