Set focus on a OLE control

The question.
I have a web-browser as an OLE Control on a Splitwindow, then I would like to put the focus in that control, when the window start. I put a SetFocus(oOLEControl:Handle()) in a postinit(), but that doesn't work.
BTW, I only have one pane in that SplitWindow and oSplitWindow:ShowPane(1) doesn't work too.

The SDK code for OleObjects does this:

CASE msg == WM_SETFOCUS
    hwndChild := GetWindow(hwnd, GW_CHILD)
    IF (hwndChild != NULL_PTR)
        SetFocus(hwndChild)
    ENDIF

This already takes care of the window that VO has created and sets the focus to the outer window of the control. But since the Web browser control is a bunch of nested windows this does
not work. I would call it a bug in the webbrowser control. The Webbrowser control should handle this and not we.
There is a workaround however.
The handle of the OleControl is the handle of a VO windows that is the parent of the OLE Control. Use this window handle to walk the list of nested windows. and then set the focus to the innermost window. Something like this:


hWin := MyOleControl:Handle()
hChild := hWin
do while hWin != NULL_PTR
   hWin  := GetWindow(hWin, GW_CHILD)
   if hWin != NULL_PTR
      hChild := hWin
   endif
enddo
SetFocus(hChild)


Robert van der Hulst
AKA Mr. Data
Vo2Jet & Vo2Ado Support
VO Development Team
www.sas-software.nl
mrdataREMOVE@sas-software.com

Geef feedback:

CAPTCHA image
Vul de bovenstaande code hieronder in
Verzend Commentaar