In my BHO, how to react to window move or resize?
-
Hi again, I discovered a new problem and I have to share this with you as I can't solve this on my own... :( My Browser Helper Object creates a window (inherits from CDialogImpl). I've managed to position this window in the lower right corner of Internet Explorer but the problem is that whenever the user resizes or moves Internet Explorer, my window stays put. I would like to move my little window as the parent window (IE) moves. How can my window react upon move/resize messages from the parent window (IE)? BTW: My window steals the focus once it's displayed, how can I give the focus back to IE? All help is grea... well, you know I love you guys! /T
-
Hi again, I discovered a new problem and I have to share this with you as I can't solve this on my own... :( My Browser Helper Object creates a window (inherits from CDialogImpl). I've managed to position this window in the lower right corner of Internet Explorer but the problem is that whenever the user resizes or moves Internet Explorer, my window stays put. I would like to move my little window as the parent window (IE) moves. How can my window react upon move/resize messages from the parent window (IE)? BTW: My window steals the focus once it's displayed, how can I give the focus back to IE? All help is grea... well, you know I love you guys! /T
Tommy Svensson wrote:
BTW: My window steals the focus once it's displayed, how can I give the focus back to IE?
I can answer this part of your qestion. Get handle to browser, as stated in last reply. And use SendMessage.
i.e.
SendMessage(hWnd,WM_SETFOCUS,0,0);//hWnd is handle to browserPrasad Notifier using ATL | Operator new[],delete[][^]
-
Tommy Svensson wrote:
BTW: My window steals the focus once it's displayed, how can I give the focus back to IE?
I can answer this part of your qestion. Get handle to browser, as stated in last reply. And use SendMessage.
i.e.
SendMessage(hWnd,WM_SETFOCUS,0,0);//hWnd is handle to browserPrasad Notifier using ATL | Operator new[],delete[][^]
Thx Prasad, the latter part now solved! Thx. Still, this question remains unanswered: My Browser Helper Object creates a window (inherits from CDialogImpl). I've managed to position this window in the lower right corner of Internet Explorer but the problem is that whenever the user resizes or moves Internet Explorer, my window stays put. I would like to move my little window as the parent window (IE) moves. How can my window react upon move/resize messages from the parent window (IE)? /Tommy
-
Thx Prasad, the latter part now solved! Thx. Still, this question remains unanswered: My Browser Helper Object creates a window (inherits from CDialogImpl). I've managed to position this window in the lower right corner of Internet Explorer but the problem is that whenever the user resizes or moves Internet Explorer, my window stays put. I would like to move my little window as the parent window (IE) moves. How can my window react upon move/resize messages from the parent window (IE)? /Tommy
Tommy Svensson wrote:
How can my window react upon move/resize messages from the parent window (IE)?
If you manage to get a handle to IE's main window (a HWND), then you have the alternative to subclass that window, and trap relevant messages. Please have a look at CContainedWindowT<Tbase, TWinTraits>, ALT_MSG_MAP(), and Subclass(). Here's the pseudo code:
class YourControl {
...
CContainedWindow m_wndIE;BEGIN_MSG_MAP(YourControl)
...
ALT_MSG_MAP(1)
// Message handlers
MESSAGE_HANDLER(WM_SIZE, OnIESize)
END_MSG_MAP()
};YourControl::YourControl() : m_wndIE(this, 1 /* Message map ID - see ALT_MSG_MAP())
{
}void YourControl::SomeMethod()
{
HWND hWndIE = ...;
m_wndIE.SubclassWindow(hWndIE);
}LRESULT YourControl::OnIESize(...)
{
// Do stuff BEFORE IE gets the message here
LRESULT lResult = DefWindowProc(); // Call IEs handler
// Do stuff AFTER IE gets the message here
return lResult; // Patch through whatever IE returned
}Unless IE is doing something totally radical, this approach should work. I'm assuming that IEs message pump is the same thread as your control. If it's not, well, then I'm not so sure that it'll work.. Lycka till!
-- Verletzen zerfetzen zersetzen zerstören Doch es darf nicht mir gehören Ich muss zerstören