Sign in to follow this  
Followers 0
adamski

SOLVED: Redrawing Child GUI

3 posts in this topic

#1 ·  Posted (edited)

Hello,

I am trying to create a simple Tabbed Document Interface for the various windows of an irritating application. I have the basics working (using demo apps) but can't figure out how to force an application to redraw when switching tabs. Can anybody help in this area?

I am open to any alternative solutions too.

Thanks

; Example of APPLICATIONS in TAB ctrl by aec and adamski
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>


Run("notepad")
Run("explorer")

Global $main_GUI,$ok_button,$cancel_button

;This window has 2 ok/cancel-buttons
$main_GUI       = GUICreate("APPLICATIONS in TAB",800,600,-1,-1, BitOr($WS_POPUP, $GUI_SS_DEFAULT_GUI,$WS_CLIPCHILDREN,$WS_SIZEBOX))
$ok_button      = GUICtrlCreateButton("OK",40,560,70,20)
$cancel_button  = GUICtrlCreateButton("Cancel",150,560,70,20)

; Create the first child window that is implemented into the main GUI
$child1         = GUICreate("",770,500,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)

GUISetState()

; Create the second child window that is implemented into the main GUI
$child2         = GUICreate("",770,500,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI)

; Switch back the main GUI and create the tabs
GUISwitch($main_GUI)
$main_tab       = GUICtrlCreateTab(10,10,780,532)
$child1tab      = GUICtrlCreateTabItem("Child1")
$child2tab      = GUICtrlCreateTabItem("Child2")
GUICtrlCreateTabItem("")

; Set Application 1 to Child GUI 1
WinWaitActive("[CLASS:Notepad]")
$Notepad = WinGetHandle("[CLASS:Notepad]")
_SetParent($Notepad, $child1)
WinSetState($Notepad, "", @SW_MAXIMIZE)

; Set Application 2 to Child GUI 2
WinWaitActive("My Documents")
$Explorer = WinGetHandle("My Documents")
_SetParent($Explorer, $child2)
WinSetState($Explorer, "", @SW_MAXIMIZE)

GUISetState()

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE, $cancel_button
            ExitLoop
           
       Case $main_tab
           Switch GUICtrlRead($main_tab)
                Case 0
                    GUISetState(@SW_HIDE,$child2)
                    GUISetState(@SW_SHOW,$child1)
                Case 1
                    GUISetState(@SW_HIDE,$child1)
                    GUISetState(@SW_SHOW,$child2)
            EndSwitch
            _WinAPI_RedrawWindow($main_GUI, 0, 0, $RDW_ALLCHILDREN) ; force redraw of GUI
    EndSwitch
WEnd


Func _SetParent($id_child, $h_parent)
    If Not IsHWnd($h_parent) Then $h_parent = HWnd($h_parent)
    If Not IsHWnd($id_child) Then $id_child = GUICtrlGetHandle($id_child)
    If DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $id_child, "hwnd", $h_parent) <> 0 Then
        Return 1
    Else
        seterror(1)
        Return 0
    EndIf
EndFunc
Edited by adamski

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Thanks Yashied, but it still sometimes needs redrawing when switching back and forth between the tabs. Sometimes the tab is just gray until moseovered. Think I may have some of the widow states wrong.

Edit:

Think I've found the problem - just a focus issue

Cheers

Edited by adamski

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0