找回密码
 加入
搜索
查看: 4167|回复: 5

[GUI管理] 怎样实现窗口分层显示

  [复制链接]
发表于 2010-10-16 21:28:17 | 显示全部楼层 |阅读模式
在不隐藏窗口的情况怎样使窗口2显示出来
麻烦各位老师帮帮忙啊,我实在搞不懂了
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <GuiToolbar.au3>
#include <GuiReBar.au3>
#include <SendMessage.au3>
#include <GuiButton.au3>
#include <Constants.au3>

Opt('GUIOnEventMode', 1)

HotKeySet("{ESC}", "quit")
Func quit()
        Exit
EndFunc   ;==>quit


$rootwin = GUICreate("DMZ SMS 系统。。", 800, 544, 0, 0, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetOnEvent($GUI_EVENT_CLOSE, "sysbufun")
GUISetState()
$rw_WH = WinGetClientSize($rootwin)
Global $cltoptw = 36, $clbottw = 60, $funSep = 8
$clwin_W = $rw_WH[0]
$clwin_H = $rw_WH[1] - $clbottw
$funwin_W = 130
$funwin_H = 0.5
$DPwin_W = $clwin_W - $funwin_W - 150 - $funSep * 2
$DPwin_H = $clwin_H - $funSep * 2
$STwin_W = 150
$STwin_H = $clwin_H - $funSep * 2

$clwin = GUICreate("客户区。", $clwin_W, $clwin_H, 0, $cltoptw, BitOR($WS_BORDER, $WS_CHILD), 0, $rootwin)
GUISetBkColor(0x123456)
GUISetState()
$funwin = GUICreate("功能区。", $funwin_W, ($clwin_H - $funSep * 3) * $funwin_H, 0, $funSep, $WS_CHILD, 0, $clwin)
$fbucont = 6
$fbu_W = 100
$fbu_H = 30
$fbu_s = (($clwin_H - $funSep * 3) * $funwin_H - $fbucont * $fbu_H) / ($fbucont + 1)

$fun1 = GUICtrlCreateButton("切换子窗口显示", ($funwin_W - $fbu_W) / 2, $fbu_s, $fbu_W, $fbu_H)
GUISetState(@SW_SHOW)

$DPwin = GUICreate("窗口1。", $DPwin_W, $DPwin_H, $funwin_W + $funSep, $funSep, $WS_CHILD, 0, $clwin)
GUISetBkColor(0x905567)
GUICtrlCreateLabel("窗口1。",150,150)

GUISetState(@SW_SHOW)

$DPwin2 = GUICreate("窗口2。", $DPwin_W, $DPwin_H, $funwin_W + $funSep, $funSep, $WS_CHILD, 0, $clwin)
GUISetBkColor(0x119977)
GUICtrlCreateLabel("窗口2。",150,150)
GUISetState(@SW_SHOW)
WinSetOnTop($DPwin2,"",1)
WinActivate($DPwin2)
MsgBox(0,"",WinActive($DPwin2))


Do
Until 0


Func sysbufun()
        Select
                Case @GUI_CtrlId = $GUI_EVENT_CLOSE
                        If @GUI_WinHandle = $rootwin Then
                                Exit
                        EndIf

                Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
                        MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

                Case @GUI_CtrlId = $GUI_EVENT_RESTORE
                        MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

        EndSelect
EndFunc   ;==>sysbufun
发表于 2010-10-16 22:52:58 | 显示全部楼层
不隐藏窗口,分层,前提条件起码需要背景透明吧,都设置了背景色还怎么透明呢
 楼主| 发表于 2010-10-17 00:23:42 | 显示全部楼层
本帖最后由 doshowyam 于 2010-10-17 00:25 编辑

回复 2# afan


就是要窗口2在窗口1的上面显示。。就像是按ALT+TAB切换窗口的那样。。不是说只要看得到。
其实去掉child 样式后就好实现。。但现在就是要用这个样式。。
总的来说就是guictrlcreatetabel 那样按标签就能实现的切换

在上面
WinActivate($DPwin2)
这句没有成功。为什么呢?
发表于 2010-10-17 23:38:34 | 显示全部楼层
回复 1# doshowyam
给个参考代码,看看合不合用:
#include <GUIConstants.au3>
#include <windowsconstants.au3>
#include <editconstants.au3>
#include <sendmessage.au3>
#include <ButtonConstants.au3>
#include <winapi.au3>

#region - GUI Create
$gui1 = GUICreate("Parent GUI", 800, 500, 100, 100)
GUICtrlCreatePic(@ScriptDir&"\2.jpg", 0, 50, 800, 450)
GUICtrlSetState(-1,$GUI_DISABLE)
$button1=GUICtrlCreateButton("ok",0,0,50,50,$BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 22)
$button2=GUICtrlCreateButton("ok",80,0,50,50,$BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 23)
$button3=GUICtrlCreateButton("ok",160,0,50,50,$BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 24)
$button4=GUICtrlCreateButton("ok",240,0,50,50,$BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 25)
$button5=GUICtrlCreateButton("ok",320,0,50,50,$BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 26)


GUISetState()
$gui2 = GUICreate("child", 800, 448, 103, 180, $WS_POPUP, BitOR(0x2000000, $WS_EX_LAYERED), $gui1);$WS_EX_COMPOSITED
$ed1 = GUICtrlCreateEdit("", -2, -2, 804, 452, BitOR($ES_READONLY, $ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetBkColor(-1, 0xABCDEF)
GUICtrlSetFont(-1, 12, 800, 1, "Arail")
;GUICtrlSetColor(-1, 0xffff00)
GUICtrlSetCursor(-1,2)
$text = FileRead(@ScriptFullPath)
GUICtrlSetData(-1, $text)
_WinAPI_SetLayeredWindowAttributes($gui2, 0xABCDEF, 255)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "WM_COMMANDER")
GUIRegisterMsg($WM_MOVE, "shift_child")
#endregion
_SendMessage($gui1, $WM_NCACTIVATE, 1)
#region - GUI SelectLoop
controlsend($gui2,"",$ed1,"^{HOME}")
While 1
    $extMsg = GUIGetMsg(1)
    $msg = $extMsg[0]
    Switch $extMsg[1]
        Case $gui1
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    Exit
                Case $msg =$button1
                    $file=FileOpenDialog("",@ScriptDir&"","所有文件(*.*) |文本文档(*.txt)" )
                    $text=FileRead($file)
                    GUICtrlSetData($ed1,$text)
                    GUICtrlSetState($ed1,$GUI_FOCUS)
                    ;GUISwitch($gui2,$ed1)
                Case $msg =$button2
                    GUICtrlSetFont($ed1,-1, 18, 400, 4, "mshei")
                Case $msg =$button3
                    
                Case $msg =$button4
                    
                Case $msg =$button5
                    
            EndSelect

    EndSwitch
WEnd
#endregion

Func shift_child($hwnd, $msg, $wparam, $lparam)
    If $hwnd = $gui1 Then
        Local $wp = WinGetPos($gui1)
        WinMove($gui2, '', $wp[0] + 3, $wp[1] + 80)
    EndIf
    
EndFunc  ;==>shift_child

Func WM_COMMANDER($hwnd, $msg, $wparam, $lparam)
    $nNotifyCode = BitShift($wparam, 16)
    $nID = BitAND($wparam, 0x0000FFFF)
    $hCtrl = $lparam
    If $nID = $ed1 Then
        If $nNotifyCode = $EN_SETFOCUS Then 
            _SendMessage($gui1, $WM_NCACTIVATE, 1);, 0)
            Send("{HOME}")
        EndIf
        
        If $nNotifyCode = $EN_KILLFOCUS and _
            wingettitle("") <> "Parent GUI" _
             Then _SendMessage($gui1, $WM_NCACTIVATE, 0);, 0)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc  ;==>setparentactive

评分

参与人数 1金钱 +30 收起 理由
afan + 30

查看全部评分

 楼主| 发表于 2010-10-18 00:06:09 | 显示全部楼层
回复 4# 3mile


    不是这种。。
我要的是用TAB标签控制制几个重叠的窗口的显示与隐藏。但出来的效果要像TAB标签那平滑。
我用了显示与隐藏窗口,但中间的闪烁太久了,点了标签后总要等一会才出来,没有TAB控件那么快,也没有闪烁的现像
发表于 2010-10-18 08:49:15 | 显示全部楼层
呵呵,学习一下。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-21 01:13 , Processed in 0.088980 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表