doshowyam 发表于 2010-4-20 12:51:00

skin 皮肤与tab 标签 不兼容的解决方案

本帖最后由 doshowyam 于 2010-4-20 16:00 编辑

在使用皮肤后,如果当前焦点在两edit 控件上时切换标签项到客户端时,当前的焦点控件不能隐藏。而且即使选其它焦点让他们隐藏后切换到客户端之后,用GUICtrlsetData()设置edit 控件数据,此控件也要在客户端标签上显示出来。#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

$skin = "D:\公共\au3\Au3皮肤\Skin\Gloss_ST.skf"
$SkinDll = "D:\公共\au3\Au3皮肤\Skin\SkinCrafterDll.dll"
Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
        $Dll = DllOpen($SkincrafterDll)
        DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1")
        DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
        DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
        DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25)
        DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc   ;==>_SkinGUI

$RootWindows = GUICreate("Server -- TCP Talke Server", @DesktopWidth * 0.6, @DesktopHeight * 0.6, @DesktopWidth * 0.2, @DesktopHeight * 0.2)
_SkinGUI($SkinDll, $skin, $RootWindows)

;========================================================================================
;                                                        各控件边界设置
;tab签
$tab_lf = 8
$tab_tp = 10
$tab_wd = @DesktopWidth * 0.6 - 20
$tab_ht = @DesktopHeight * 0.6 - 50
$tab_sty = ""
;接收栏
$RvEdit_lf = 11
$RvEdit_tp = 30
$RvEdit_wd = @DesktopWidth * 0.6 - 26
$RvEdit_ht = @DesktopHeight * 0.6 - 220
$RvEdit_sty = BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $ES_WANTRETURN, $ES_READONLY, $ws_VSCROLL)
;IP地址
$Ipedit_tp = @DesktopHeight * 0.6 - 180
$Ipedit_lf = 40
$Ipedit_sty = $ES_NUMBER
;发送栏
$SdEdit_tp = @DesktopHeight * 0.6 - 150
$SdEdit_lf = 11
$SdEdit_wd = @DesktopWidth * 0.6 - 26
$SdEdit_ht = 50
$SdEdit_sty = BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $ES_WANTRETURN, $ws_VSCROLL)
;按钮
$Bu_sd_tp = $SdEdit_tp + $SdEdit_ht + 10
$Bu_sd_lf = @DesktopWidth * 0.15 - 10
$Bu_ext_lf = @DesktopWidth * 0.45 - 150
;
;
;========================================================================================

$tab = GUICtrlCreateTab($tab_lf, $tab_tp, $tab_wd, $tab_ht, $tab_sty) ;创建TAB标签

$tb_Rs = GUICtrlCreateTabItem(" 收发信息 ") ; 收发 tab 标签

$RvEdit = GUICtrlCreateEdit("", $RvEdit_lf, $RvEdit_tp, $RvEdit_wd, $RvEdit_ht, $RvEdit_sty) ; 接收栏

$SdEdit = GUICtrlCreateEdit("", $SdEdit_lf, $SdEdit_tp, $SdEdit_wd, $SdEdit_ht, $SdEdit_sty) ; 发送栏

$Bu_sd = GUICtrlCreateButton("发送[&Enter]", $Bu_sd_lf, $Bu_sd_tp, 113, 25, 0)
$Bu_ext = GUICtrlCreateButton("退出[&Esc]", $Bu_ext_lf, $Bu_sd_tp, 113, 25, 0)
;                        tab 1
;---------------------------------------------------------------------------
$tb_cl = GUICtrlCreateTabItem(" 客户端 ")

$Bu_ext_cl = GUICtrlCreateButton("退出[&Esc]", $Bu_ext_lf, $Bu_sd_tp, 113, 25, 0)

GUICtrlCreateTabItem("") ; TAB 标签结束
GUICtrlSetState($tb_Rs, $GUI_SHOW)
GUISetState(@SW_SHOW)
GUICtrlSetState($RvEdit, $GUI_FOCUS)
GUICtrlSetState($SdEdit, $GUI_FOCUS)

GUIRegisterMsg($WM_SETFOCUS, "MSG_WM_SETFOCUS")
While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $tab Then tabhide()

WEnd

Func tabhide()
        Switch GUICtrlRead($tab, 1)
                Case $tb_Rs
                        GUICtrlSetState($RvEdit, $GUI_SHOW + $GUI_ENABLE + $GUI_FOCUS)
                        GUICtrlSetState($SdEdit, $GUI_SHOW + $GUI_ENABLE + $GUI_FOCUS)
                Case $tb_cl
                Case Else
                        Return
        EndSwitch
EndFunc   ;==>tabhide



Func MSG_WM_SETFOCUS($hWnd, $msg, $wParam, $lParam)       
        Local $sel_tab = GUICtrlRead($tab, 1)       
        If $sel_tab <> $tb_Rs And ($wParam = GUICtrlGetHandle($SdEdit) Or $wParam = GUICtrlGetHandle($RvEdit)) Then
                        ControlFocus ($RootWindows,"",$sel_tab)
                        GUICtrlSetState($sel_tab, $GUI_SHOW + $GUI_FOCUS)
        EndIf
        Return $GUI_RUNDEFMSG
EndFunc   ;==>MSG_WM_SETFOCUS

doshowyam 发表于 2010-4-20 12:51:57

好不容易解决

zhoujinshi520 发表于 2010-4-21 11:11:49

厉害 这都被你研究出来了
关键就是SkinCrafterDll 刷新问题

d5121226 发表于 2010-9-26 20:48:28

先收藏了,等要做皮肤的时候,在借鉴一下。

menfan 发表于 2010-9-27 16:55:08

用其他的皮肤哈

lvqin 发表于 2011-12-16 07:45:25

先收藏了,等要做皮肤的时候,在借鉴一下.谢谢

zhoujinshi 发表于 2012-3-13 13:38:55

收藏了,好东西

xugaohui 发表于 2012-8-20 16:36:21

收藏了.好好学习下

joyran 发表于 2013-10-28 07:46:21

学习了哦。。。
页: [1]
查看完整版本: skin 皮肤与tab 标签 不兼容的解决方案