Link to home
Start Free TrialLog in
Avatar of speke
speke

asked on

Using SetParent API

I've used the SetParent API to host various windows within in VB(6 sp5) MDI form, but I cannot seem to reference or set as active the created window(s). I've used ChildWindowFromPoint to return the hwnd of the child, but this is flaky at best.

Has anyone seen or have got a good example of how to do this?
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

First, you don't need an MDI.
Second, if you have the hwnd of those windows, use SetFocus Api to give focus to desired window.
Private Declare Function API_SetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long

'usage:
API_SetFocus hwnd
ASKER CERTIFIED SOLUTION
Avatar of kokoloko
kokoloko

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BrightGlobe
BrightGlobe

Okay,

This example works great with Calc and Notepad.

I am using 2 Visual Basic applications, one application is designed to be a master application, and the other an extension. When i try to use the above example to call my secondary application and contain it to the parent master application, it doesn't work. IE, the executed application still floats around and looses focus as usual. If i change the line back to calc or notepad, works great.

Is there a better way to getting a compiled VB app to Child to another VB app?