lmcaveman Posted December 8, 2010 Posted December 8, 2010 I have an MFC app that has multiple windows within it (MDI), and I can get a handle to dialogs that these child windows generate, but I am unable to actually select the child window and bring it to the front. These child windows are not maximized, or minimized, so you can just grab the title bar of the document to bring it to the front. I found a few threads where people were doing something similar, like but I haven't found anything which exactly works well. I set Opt("WinSearchChildren", 1), but it doesn't seem to have any effect. I was hoping that WinActive would be able to hack the mission, but both that, as well as _WinAPI_ShowWindow fail to do what I need to do. I finally found a workaround, as I am writing this. The trick is to maximize, and then shownormal. I don't understand why I can't use Opt("WinSearchChildren", 1) with WinActive($title,$text) to do the same thing. Thanks, and I hope this helps someone in the future. -Kevin Func ChildFormActivate($appTitle, $formName) $hWnd = WinGetHandle($appTitle, $formName) ;MsgBox(0, "AutoIt", "Hwnd="&$hWnd) $array = WinList($appTitle) WinActive($hWnd) ;MsgBox(0, "AutoIt", "Found array"&$array[0][0]) ;_WinAPI_ShowWindow($hWnd) $winarray = _WinAPI_EnumWindows(True, $hWnd) ;MsgBox(0, "AutoIt", "Found "&$winarray[0][0]&" array entries") For $i = 1 to $winarray[0][0] $title = _WinAPI_GetWindowText($winarray[$i][0]) ;MsgBox(0, "AutoIt", $i&" - "&$winarray[$i][1]&" Window text="&$title) ;If $winarray[$i][1] == "#32770" Then If ($title == $formName) or ($title == $formName&" *") Then ;MsgBox(0, "AutoIt", "Found a child window - "&$title) ;WinActive($appTitle, $title) _WinAPI_ShowWindow($winarray[$i][0], @SW_MAXIMIZE) _WinAPI_ShowWindow($winarray[$i][0], @SW_SHOWNORMAL) EndIf Next EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now