#include-once #cs Author: funkey Version: 0.0.0.4 Date: 2011, Feb 10 Version info: 0.0.0.4 - 2011, Feb 10 - Added round corners and reduced bugs 0.0.0.3 - 2011, Feb 09 - Added simple picture skin support 0.0.0.2 - 2011, Feb 09 - Reduced flickering when moving 0.0.0.1 - 2011, Feb 07 - First release #ce #include #include #include Global Const $tagNCCALCSIZE_PARAMS = $tagRECT & ";" & $tagRECT & ";" & $tagRECT & ";ptr PWINDOWPOS" ; ptr is pointer to $tagWINDOWPOS If Not IsDeclared("SC_SIZE") Then Global Const $SC_SIZE = 0xF000 Global Const $SC_MOVE = 0xF010 Global Const $SC_MINIMIZE = 0xF020 Global Const $SC_MAXIMIZE = 0xF030 Global Const $SC_CLOSE = 0xF060 EndIf Global $FS_Debug = False Global $FS_Style_old, $FS_StyleDlg_old Global $FS_TitlebarY_Orig = _WinAPI_GetSystemMetrics(4) ; SM_CYCAPTION Global $FS_BorderX_Orig = _WinAPI_GetSystemMetrics(5) + _WinAPI_GetSystemMetrics(45) ; SM_CXBORDER + SM_CXEDGE Global $FS_BorderY_Orig = _WinAPI_GetSystemMetrics(6) + _WinAPI_GetSystemMetrics(46) ; SM_CYBORDER + SM_CYEDGE Global $FS_TitlebarY, $FS_BorderX, $FS_BorderY Global $FS_RoundCorner Global $FS_tRECT_CLOSE, $FS_tRECT_MIN, $FS_tRECT_MAX Global $FS_Close, $FS_Close_Std, $FS_Close_Hover, $FS_Close_Pressed Global $FS_Min, $FS_Min_Std, $FS_Min_Hover, $FS_Min_Pressed Global $FS_Max, $FS_Max_Std, $FS_Max_Hover, $FS_Max_Pressed Global $FS_Max2, $FS_Max2_Std, $FS_Max2_Hover, $FS_Max2_Pressed Global $FS_hBmp_Top_L, $FS_hBmp_Top_M, $FS_hBmp_Top_R Global $FS_hBmp_Border_L, $FS_hBmp_Border_R Global $FS_hBmp_Bottom_L, $FS_hBmp_Bottom_M, $FS_hBmp_Bottom_R Global $FS_hBmp_Top_M_Dlg Global $FS_hBmp_Border_L_Dlg, $FS_hBmp_Border_R_Dlg Global $FS_hBmp_Bottom_M_Dlg Global $FS_sBmp_Top_L, $FS_sBmp_Top_M, $FS_sBmp_Top_R Global $FS_sBmp_Border_L, $FS_sBmp_Border_R Global $FS_sBmp_Bottom_L, $FS_sBmp_Bottom_M, $FS_sBmp_Bottom_R Global $FS_iBmp_Top_L_W, $FS_iBmp_Top_R_W Global $FS_iBmp_Bottom_L_W, $FS_iBmp_Bottom_R_W Global $FS_Typ, $FS_TitleTextColor Global $FS_CloseDlg, $FS_tRECT_CLOSEDlg Global $FS_CloseDown = False, $FS_CloseUp = False, $FS_CloseHover = False Global $FS_CloseDownDlg = False, $FS_CloseUpDlg = False, $FS_CloseHoverDlg = False Global $FS_MinDown = False, $FS_MinUp = False, $FS_MinHover = False Global $FS_MaxDown = False, $FS_MaxUp = False, $FS_MaxHover = False Global $FS_Max2Down = False, $FS_Max2Up = False, $FS_Max2Hover = False Global $FS_hWnd, $FS_DlgWnd, $FS_hDC, $FS_hDC2 Global $FS_hCDC, $FS_hCDC2, $FS_hCBmp, $FS_hCBmp2, $FS_hCBmp_old, $FS_hCBmp2_old Global $FS_hDLL, $FS_hDLL2, $FS_pDLL, $FS_pDLL2, $FS_hProc, $FS_hProc2, $FS_TID, $FS_hHook Global $FS_CloseButtonX, $FS_CloseButtonY, $FS_CloseButtonW, $FS_CloseButtonH Global $FS_MinimizeButtonX, $FS_MinimizeButtonY, $FS_MinimizeButtonW, $FS_MinimizeButtonH Global $FS_MaximizeButtonX, $FS_MaximizeButtonY, $FS_MaximizeButtonW, $FS_MaximizeButtonH Global $FS_GradientCol1, $FS_GradientCol2 Global $FS_hFont, $FS_hOldFont Global $FS_TitlebarFont, $FS_TitlebarFontSize, $FS_TitlebarFontWeight Global $FS_hFontDlg, $FS_hOldFontDlg Global $FS_hRgn, $FS_hRgn2 Global $FS_Dlg_Width, $FS_Dlg_Height Global $FS_Dlg_active = False Func _FunSkin_Start($SkinPath) If $FS_hWnd <> 0 Then Return SetError(1) $FS_TitlebarY = IniRead($SkinPath & "\FunSkin.ini", "Settings", "TitlebarHeight", 25) $FS_TitlebarFont = IniRead($SkinPath & "\FunSkin.ini", "Settings", "TitlebarFont", "Tahoma") $FS_TitlebarFontSize = IniRead($SkinPath & "\FunSkin.ini", "Settings", "TitlebarFontSize", 16) $FS_TitlebarFontWeight = IniRead($SkinPath & "\FunSkin.ini", "Settings", "TitlebarFontWeight", 500) $FS_BorderX = IniRead($SkinPath & "\FunSkin.ini", "Settings", "BorderX", 3) $FS_BorderY = IniRead($SkinPath & "\FunSkin.ini", "Settings", "BorderY", 3) $FS_RoundCorner = IniRead($SkinPath & "\FunSkin.ini", "Settings", "RoundCorner", 10) $FS_CloseButtonX = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "CloseButtonX", 35) $FS_CloseButtonY = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "CloseButtonY", 5) $FS_CloseButtonW = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "CloseButtonW", 20) $FS_CloseButtonH = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "CloseButtonH", 20) $FS_MinimizeButtonX = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MinimizeButtonX", 85) $FS_MinimizeButtonY = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MinimizeButtonY", 5) $FS_MinimizeButtonW = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MinimizeButtonW", 20) $FS_MinimizeButtonH = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MinimizeButtonH", 20) $FS_MaximizeButtonX = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MaximizeButtonX", 55) $FS_MaximizeButtonY = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MaximizeButtonY", 5) $FS_MaximizeButtonW = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MaximizeButtonW", 20) $FS_MaximizeButtonH = IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MaximizeButtonH", 20) $FS_Typ = IniRead($SkinPath & "\FunSkin.ini", "Settings", "Typ", "Gradient") $FS_GradientCol1 = IniRead($SkinPath & "\FunSkin.ini", "Gradient", "Color1", 0x0) $FS_GradientCol2 = IniRead($SkinPath & "\FunSkin.ini", "Gradient", "Color2", 0x999999) Switch $FS_Typ Case "Gradient" $FS_TitleTextColor = _ColorInverse($FS_GradientCol1) Case "Picture" $FS_TitleTextColor = IniRead($SkinPath & "\FunSkin.ini", "Picture", "Color", 0) EndSwitch $FS_Close_Std = _WinAPI_LoadFunIcon($SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Buttons", "CloseButton1", ""), 0) $FS_Close_Hover = _WinAPI_LoadFunIcon($SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Buttons", "CloseButton2", ""), 0) $FS_Close_Pressed = _WinAPI_LoadFunIcon($SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Buttons", "CloseButton3", ""), 0) $FS_Close = $FS_Close_Std $FS_CloseDlg = $FS_Close_Std $FS_Min_Std = _WinAPI_LoadFunIcon($SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MinimizeButton1", ""), 0) $FS_Min_Hover = _WinAPI_LoadFunIcon($SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MinimizeButton2", ""), 0) $FS_Min_Pressed = _WinAPI_LoadFunIcon($SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Buttons", "MinimizeButton3", ""), 0) $FS_Min = $FS_Min_Std $FS_sBmp_Top_L = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Top_L", "") $FS_sBmp_Top_M = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Top_M", "") $FS_sBmp_Top_R = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Top_R", "") $FS_iBmp_Top_L_W = IniRead($SkinPath & "\FunSkin.ini", "Picture", "Top_L_W", "5") $FS_iBmp_Top_R_W = IniRead($SkinPath & "\FunSkin.ini", "Picture", "Top_R_W", "5") $FS_sBmp_Border_L = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Border_L", "") $FS_sBmp_Border_R = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Border_R", "") $FS_sBmp_Bottom_L = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Bottom_L", "") $FS_sBmp_Bottom_M = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Bottom_M", "") $FS_sBmp_Bottom_R = $SkinPath & "\" & IniRead($SkinPath & "\FunSkin.ini", "Picture", "Bottom_R", "") $FS_iBmp_Bottom_L_W = IniRead($SkinPath & "\FunSkin.ini", "Picture", "Bottom_L_W", "5") $FS_iBmp_Bottom_R_W = IniRead($SkinPath & "\FunSkin.ini", "Picture", "Bottom_R_W", "5") $FS_hDLL2 = DllCallbackRegister("_FS_CbtHookProc", "int", "int;int;int") $FS_TID = _WinAPI_GetCurrentThreadId() $FS_hHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($FS_hDLL2), 0, $FS_TID) EndFunc ;==>_FunSkin_Start Func _FunSkin_Stop() _WinAPI_UnhookWindowsHookEx($FS_hHook) _WinAPI_DestroyIcon($FS_Close_Std) _WinAPI_DestroyIcon($FS_Close_Hover) _WinAPI_DestroyIcon($FS_Close_Pressed) _WinAPI_DestroyIcon($FS_Min_Std) _WinAPI_DestroyIcon($FS_Min_Hover) _WinAPI_DestroyIcon($FS_Min_Pressed) ;~ _WinAPI_DestroyIcon($FS_Max_Std) ;~ _WinAPI_DestroyIcon($FS_Max_Hover) ;~ _WinAPI_DestroyIcon($FS_Max_Pressed) ;~ _WinAPI_DestroyIcon($FS_Max2_Std) ;~ _WinAPI_DestroyIcon($FS_Max2_Hover) ;~ _WinAPI_DestroyIcon($FS_Max2_Pressed) _WinAPI_SetWindowLong($FS_hWnd, 0xFFFFFFFC, $FS_hProc) ;$GWL_WNDPROC DllCallbackFree($FS_hDLL) _WinAPI_DeleteObject($FS_hBmp_Top_L) _WinAPI_DeleteObject($FS_hBmp_Top_M) _WinAPI_DeleteObject($FS_hBmp_Top_R) _WinAPI_DeleteObject($FS_hBmp_Border_L) _WinAPI_DeleteObject($FS_hBmp_Border_R) _WinAPI_DeleteObject($FS_hBmp_Bottom_L) _WinAPI_DeleteObject($FS_hBmp_Bottom_M) _WinAPI_DeleteObject($FS_hBmp_Bottom_R) _WinAPI_SelectObject($FS_hCDC, $FS_hOldFont) _WinAPI_DeleteObject($FS_hFont) _WinAPI_DeleteObject($FS_hRgn) _WinAPI_DeleteObject($FS_hCBmp) _WinAPI_SelectObject($FS_hCDC, $FS_hCBmp_old) _WinAPI_DeleteDC($FS_hCDC) _WinAPI_ReleaseDC($FS_hWnd, $FS_hDC) $FS_hWnd = 0 $FS_hProc = 0 $FS_tRECT_CLOSE = 0 $FS_Close = $FS_Close_Std EndFunc ;==>_FunSkin_Stop Func _FS_WinProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_NCHITTEST Local $tPoint = DllStructCreate($tagPOINT) DllStructSetData($tPoint, 1, BitAND($lParam, 0x0000FFFF)) DllStructSetData($tPoint, 2, BitShift($lParam, 16)) _WinAPI_ScreenToClient($hWnd, $tPoint) DllStructSetData($tPoint, 1, DllStructGetData($tPoint, 1) + $FS_BorderX) DllStructSetData($tPoint, 2, DllStructGetData($tPoint, 2) + $FS_TitlebarY); - $FS_BorderY) If _WinAPI_PtInRect($FS_tRECT_CLOSE, $tPoint) Then If $FS_CloseHover = False Then _FS_ConsoleWrite("Hover Close-Button" & @CR) $FS_CloseHover = True $FS_MinHover = False $FS_Close = $FS_Close_Hover _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_CLOSE, 1), DllStructGetData($FS_tRECT_CLOSE, 2), $FS_Close, _ DllStructGetData($FS_tRECT_CLOSE, 3) - DllStructGetData($FS_tRECT_CLOSE, 1), _ DllStructGetData($FS_tRECT_CLOSE, 4) - DllStructGetData($FS_tRECT_CLOSE, 2)) EndIf Return $HTBORDER ElseIf $FS_CloseHover = True Then $FS_CloseHover = False $FS_Close = $FS_Close_Std _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_CLOSE, 1), DllStructGetData($FS_tRECT_CLOSE, 2), $FS_Close, _ DllStructGetData($FS_tRECT_CLOSE, 3) - DllStructGetData($FS_tRECT_CLOSE, 1), _ DllStructGetData($FS_tRECT_CLOSE, 4) - DllStructGetData($FS_tRECT_CLOSE, 2)) EndIf If _WinAPI_PtInRect($FS_tRECT_MIN, $tPoint) Then If $FS_MinHover = False Then _FS_ConsoleWrite("Hover Min-Button" & @CR) $FS_CloseHover = False $FS_MinHover = True $FS_Min = $FS_Min_Hover _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_MIN, 1), DllStructGetData($FS_tRECT_MIN, 2), $FS_Min, _ DllStructGetData($FS_tRECT_MIN, 3) - DllStructGetData($FS_tRECT_MIN, 1), _ DllStructGetData($FS_tRECT_MIN, 4) - DllStructGetData($FS_tRECT_MIN, 2)) EndIf Return $HTBORDER ElseIf $FS_MinHover = True Then $FS_MinHover = False $FS_Min = $FS_Min_Std _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_MIN, 1), DllStructGetData($FS_tRECT_MIN, 2), $FS_Min, _ DllStructGetData($FS_tRECT_MIN, 3) - DllStructGetData($FS_tRECT_MIN, 1), _ DllStructGetData($FS_tRECT_MIN, 4) - DllStructGetData($FS_tRECT_MIN, 2)) EndIf Case $WM_NCLBUTTONUP $FS_CloseUp = True $FS_CloseDown = False $FS_MinUp = True $FS_MinDown = False If $FS_CloseHover = True Then _FS_ConsoleWrite("Released Close-Button" & @CR) $FS_Close = $FS_Close_Hover _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_CLOSE, 1), DllStructGetData($FS_tRECT_CLOSE, 2), $FS_Close, _ DllStructGetData($FS_tRECT_CLOSE, 3) - DllStructGetData($FS_tRECT_CLOSE, 1), _ DllStructGetData($FS_tRECT_CLOSE, 4) - DllStructGetData($FS_tRECT_CLOSE, 2)) Return _WinAPI_CallWindowProc($FS_hProc, $hWnd, $WM_SYSCOMMAND, $SC_CLOSE, 0) EndIf If $FS_MinHover = True Then _FS_ConsoleWrite("Released Min-Button" & @CR) $FS_Min = $FS_Min_Hover _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_MIN, 1), DllStructGetData($FS_tRECT_MIN, 2), $FS_Min, _ DllStructGetData($FS_tRECT_MIN, 3) - DllStructGetData($FS_tRECT_MIN, 1), _ DllStructGetData($FS_tRECT_MIN, 4) - DllStructGetData($FS_tRECT_MIN, 2)) Return _WinAPI_CallWindowProc($FS_hProc, $hWnd, $WM_SYSCOMMAND, $SC_MINIMIZE, 0) ; EndIf Case $WM_NCLBUTTONDOWN, $WM_NCLBUTTONDBLCLK $FS_CloseUp = False $FS_CloseDown = True $FS_MinUp = False $FS_MinDown = True If $FS_CloseHover = True Then _FS_ConsoleWrite("Pressed Close-Button" & @CR) $FS_Close = $FS_Close_Pressed _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_CLOSE, 1), DllStructGetData($FS_tRECT_CLOSE, 2), $FS_Close, _ DllStructGetData($FS_tRECT_CLOSE, 3) - DllStructGetData($FS_tRECT_CLOSE, 1), _ DllStructGetData($FS_tRECT_CLOSE, 4) - DllStructGetData($FS_tRECT_CLOSE, 2)) EndIf If $FS_MinHover = True Then _FS_ConsoleWrite("Pressed Min-Button" & @CR) $FS_Min = $FS_Min_Pressed _WinAPI_DrawIconEx($FS_hDC, DllStructGetData($FS_tRECT_MIN, 1), DllStructGetData($FS_tRECT_MIN, 2), $FS_Min, _ DllStructGetData($FS_tRECT_MIN, 3) - DllStructGetData($FS_tRECT_MIN, 1), _ DllStructGetData($FS_tRECT_MIN, 4) - DllStructGetData($FS_tRECT_MIN, 2)) EndIf Case $WM_NCCALCSIZE Local $FS_NCArea = DllStructCreate($tagNCCALCSIZE_PARAMS, $lParam) DllStructSetData($FS_NCArea, 1, DllStructGetData($FS_NCArea, 1) + $FS_BorderX - $FS_BorderX_Orig) ;left border DllStructSetData($FS_NCArea, 2, DllStructGetData($FS_NCArea, 2) + $FS_TitlebarY - $FS_TitlebarY_Orig - $FS_BorderY_Orig) DllStructSetData($FS_NCArea, 3, DllStructGetData($FS_NCArea, 3) - $FS_BorderX + $FS_BorderX_Orig) ;right border DllStructSetData($FS_NCArea, 4, DllStructGetData($FS_NCArea, 4) - $FS_BorderY + $FS_BorderY_Orig) ;bottom border EndSwitch Local $Res = _WinAPI_CallWindowProc($FS_hProc, $hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_NCACTIVATE, $WM_NCPAINT Local $FS_aPos, $FS_Width, $FS_Height $FS_aPos = WinGetPos($hWnd) $FS_Width = $FS_aPos[2] $FS_Height = $FS_aPos[3] Local $aVertex[8][3] = [[0, 0, $FS_GradientCol1],[$FS_Width, $FS_TitlebarY, $FS_GradientCol2], _ [0, $FS_TitlebarY, $FS_GradientCol1],[$FS_BorderX, $FS_Height, $FS_GradientCol2], _ [$FS_Width - $FS_BorderX, $FS_TitlebarY, $FS_GradientCol2],[$FS_Width, $FS_Height, $FS_GradientCol1], _ [$FS_BorderX, $FS_Height - $FS_BorderY, $FS_GradientCol2],[$FS_Width - $FS_BorderX, $FS_Height, $FS_GradientCol1]] Switch $FS_Typ Case "Gradient" _WinAPI_GradientFill($FS_hCDC, $aVertex, 0, 1, 1) _WinAPI_GradientFill($FS_hDC, $aVertex, 2, 3, 0) _WinAPI_GradientFill($FS_hDC, $aVertex, 4, 5, 0) _WinAPI_GradientFill($FS_hDC, $aVertex, 6, 7, 1) Case "Picture" _WinAPI_DrawBitmap($FS_hCDC, 0, 0, $FS_hBmp_Top_L) _WinAPI_DrawBitmap($FS_hCDC, $FS_iBmp_Top_L_W, 0, $FS_hBmp_Top_M) _WinAPI_DrawBitmap($FS_hCDC, $FS_Width - $FS_iBmp_Top_R_W, 0, $FS_hBmp_Top_R) _WinAPI_DrawBitmap($FS_hDC, 0, $FS_TitlebarY, $FS_hBmp_Border_L) _WinAPI_DrawBitmap($FS_hDC, $FS_Width - $FS_BorderX, $FS_TitlebarY, $FS_hBmp_Border_R) _WinAPI_DrawBitmap($FS_hDC, 0, $FS_Height - $FS_BorderY, $FS_hBmp_Bottom_L) _WinAPI_DrawBitmap($FS_hDC, $FS_iBmp_Bottom_L_W, $FS_Height - $FS_BorderY, $FS_hBmp_Bottom_M) _WinAPI_DrawBitmap($FS_hDC, $FS_Width - $FS_iBmp_Bottom_R_W, $FS_Height - $FS_BorderY, $FS_hBmp_Bottom_R) EndSwitch Local $FS_tRECT_Title = _WinAPI_CreateRectEx(28, 0, $FS_Width, $FS_TitlebarY) _WinAPI_DrawText($FS_hCDC, WinGetTitle($hWnd), $FS_tRECT_Title, $DT_VCENTER + $DT_SINGLELINE) _WinAPI_DrawIconEx($FS_hCDC, DllStructGetData($FS_tRECT_CLOSE, 1), DllStructGetData($FS_tRECT_CLOSE, 2), $FS_Close, _ DllStructGetData($FS_tRECT_CLOSE, 3) - DllStructGetData($FS_tRECT_CLOSE, 1), _ DllStructGetData($FS_tRECT_CLOSE, 4) - DllStructGetData($FS_tRECT_CLOSE, 2)) _WinAPI_DrawIconEx($FS_hCDC, DllStructGetData($FS_tRECT_MIN, 1), DllStructGetData($FS_tRECT_MIN, 2), $FS_Min, _ DllStructGetData($FS_tRECT_MIN, 3) - DllStructGetData($FS_tRECT_MIN, 1), _ DllStructGetData($FS_tRECT_MIN, 4) - DllStructGetData($FS_tRECT_MIN, 2)) _WinAPI_BitBlt($FS_hDC, 0, 0, $FS_Width, $FS_TitlebarY, $FS_hCDC, 0, 0, $SRCCOPY) EndSwitch Return $Res EndFunc ;==>_FS_WinProc Func _FS_WinProcDlg($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_NCHITTEST Local $tPoint = DllStructCreate($tagPOINT) DllStructSetData($tPoint, 1, BitAND($lParam, 0x0000FFFF)) DllStructSetData($tPoint, 2, BitShift($lParam, 16)) _WinAPI_ScreenToClient($hWnd, $tPoint) DllStructSetData($tPoint, 1, DllStructGetData($tPoint, 1) + $FS_BorderX) DllStructSetData($tPoint, 2, DllStructGetData($tPoint, 2) + $FS_TitlebarY) If _WinAPI_PtInRect($FS_tRECT_CLOSEDlg, $tPoint) Then If $FS_CloseHoverDlg = False Then $FS_CloseHoverDlg = True $FS_CloseDlg = $FS_Close_Hover _WinAPI_DrawIconEx($FS_hDC2, DllStructGetData($FS_tRECT_CLOSEDlg, 1), DllStructGetData($FS_tRECT_CLOSEDlg, 2), $FS_CloseDlg, _ DllStructGetData($FS_tRECT_CLOSEDlg, 3) - DllStructGetData($FS_tRECT_CLOSEDlg, 1), _ DllStructGetData($FS_tRECT_CLOSEDlg, 4) - DllStructGetData($FS_tRECT_CLOSEDlg, 2)) EndIf Return $HTBORDER ElseIf $FS_CloseHoverDlg = True Then $FS_CloseHoverDlg = False $FS_CloseDlg = $FS_Close_Std _WinAPI_DrawIconEx($FS_hDC2, DllStructGetData($FS_tRECT_CLOSEDlg, 1), DllStructGetData($FS_tRECT_CLOSEDlg, 2), $FS_CloseDlg, _ DllStructGetData($FS_tRECT_CLOSEDlg, 3) - DllStructGetData($FS_tRECT_CLOSEDlg, 1), _ DllStructGetData($FS_tRECT_CLOSEDlg, 4) - DllStructGetData($FS_tRECT_CLOSEDlg, 2)) EndIf Case $WM_SIZE If $FS_Dlg_active = True Then WinMove($FS_DlgWnd, "", Default, Default, $FS_Dlg_Width, $FS_Dlg_Height) EndIf Case $WM_NCLBUTTONUP $FS_CloseUpDlg = True $FS_CloseDownDlg = False If $FS_CloseHoverDlg = True Then $FS_CloseDlg = $FS_Close_Hover _WinAPI_DrawIconEx($FS_hDC2, DllStructGetData($FS_tRECT_CLOSEDlg, 1), DllStructGetData($FS_tRECT_CLOSEDlg, 2), $FS_CloseDlg, _ DllStructGetData($FS_tRECT_CLOSEDlg, 3) - DllStructGetData($FS_tRECT_CLOSEDlg, 1), _ DllStructGetData($FS_tRECT_CLOSEDlg, 4) - DllStructGetData($FS_tRECT_CLOSEDlg, 2)) Return _WinAPI_CallWindowProc($FS_hProc2, $hWnd, $WM_SYSCOMMAND, $SC_CLOSE, 0) EndIf Case $WM_NCLBUTTONDOWN, $WM_NCLBUTTONDBLCLK $FS_CloseUpDlg = False $FS_CloseDownDlg = True If $FS_CloseHoverDlg = True Then $FS_CloseDlg = $FS_Close_Pressed _WinAPI_DrawIconEx($FS_hDC2, DllStructGetData($FS_tRECT_CLOSEDlg, 1), DllStructGetData($FS_tRECT_CLOSEDlg, 2), $FS_CloseDlg, _ DllStructGetData($FS_tRECT_CLOSEDlg, 3) - DllStructGetData($FS_tRECT_CLOSEDlg, 1), _ DllStructGetData($FS_tRECT_CLOSEDlg, 4) - DllStructGetData($FS_tRECT_CLOSEDlg, 2)) EndIf Case $WM_NCCALCSIZE Local $FS_NCArea = DllStructCreate($tagNCCALCSIZE_PARAMS, $lParam) DllStructSetData($FS_NCArea, 1, DllStructGetData($FS_NCArea, 1) + $FS_BorderX - $FS_BorderX_Orig) ;left border DllStructSetData($FS_NCArea, 2, DllStructGetData($FS_NCArea, 2) + $FS_TitlebarY - $FS_TitlebarY_Orig - $FS_BorderY_Orig - 1) ;titlebar DllStructSetData($FS_NCArea, 3, DllStructGetData($FS_NCArea, 3) - $FS_BorderX + $FS_BorderX_Orig) ;right border DllStructSetData($FS_NCArea, 4, DllStructGetData($FS_NCArea, 4) - $FS_BorderY + $FS_BorderY_Orig) ;bottom border EndSwitch Local $Res = _WinAPI_CallWindowProc($FS_hProc2, $hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_NCACTIVATE, $WM_NCPAINT Local $FS_aPos, $FS_Width, $FS_Height $FS_aPos = WinGetPos($hWnd) $FS_Width = $FS_aPos[2] $FS_Height = $FS_aPos[3] Local $aVertex[8][3] = [[0, 0, $FS_GradientCol1],[$FS_Width, $FS_TitlebarY + $FS_BorderY_Orig, $FS_GradientCol2], _ [0, $FS_TitlebarY, $FS_GradientCol1],[$FS_BorderX, $FS_Height, $FS_GradientCol2], _ [$FS_Width - $FS_BorderX, $FS_TitlebarY, $FS_GradientCol2],[$FS_Width, $FS_Height, $FS_GradientCol1], _ [$FS_BorderX, $FS_Height - $FS_BorderY, $FS_GradientCol2],[$FS_Width - $FS_BorderX, $FS_Height, $FS_GradientCol1]] Switch $FS_Typ Case "Gradient" _WinAPI_GradientFill($FS_hCDC2, $aVertex, 0, 1, 1) _WinAPI_GradientFill($FS_hDC2, $aVertex, 2, 3, 0) _WinAPI_GradientFill($FS_hDC2, $aVertex, 4, 5, 0) _WinAPI_GradientFill($FS_hDC2, $aVertex, 6, 7, 1) Case "Picture" _WinAPI_DrawBitmap($FS_hCDC2, 0, 0, $FS_hBmp_Top_L) _WinAPI_DrawBitmap($FS_hCDC2, $FS_iBmp_Top_L_W, 0, $FS_hBmp_Top_M_Dlg) _WinAPI_DrawBitmap($FS_hCDC2, $FS_Width - $FS_iBmp_Top_R_W, 0, $FS_hBmp_Top_R) _WinAPI_DrawBitmap($FS_hDC2, 0, $FS_TitlebarY, $FS_hBmp_Border_L_Dlg) _WinAPI_DrawBitmap($FS_hDC2, $FS_Width - $FS_BorderX, $FS_TitlebarY, $FS_hBmp_Border_R_Dlg) _WinAPI_DrawBitmap($FS_hDC2, 0, $FS_Height - $FS_BorderY, $FS_hBmp_Bottom_L) _WinAPI_DrawBitmap($FS_hDC2, $FS_iBmp_Bottom_L_W, $FS_Height - $FS_BorderY, $FS_hBmp_Bottom_M_Dlg) _WinAPI_DrawBitmap($FS_hDC2, $FS_Width - $FS_iBmp_Bottom_R_W, $FS_Height - $FS_BorderY, $FS_hBmp_Bottom_R) EndSwitch Local $FS_tRECT_Dlg_Title = _WinAPI_CreateRectEx(7, 0, $FS_Width, $FS_TitlebarY) _WinAPI_SetTextColor($FS_hCDC2, $FS_TitleTextColor) _WinAPI_SetBkMode($FS_hCDC2, $TRANSPARENT) _WinAPI_DrawText($FS_hCDC2, WinGetTitle($hWnd), $FS_tRECT_Dlg_Title, $DT_VCENTER + $DT_SINGLELINE) _WinAPI_DrawIconEx($FS_hCDC2, DllStructGetData($FS_tRECT_CLOSEDlg, 1), DllStructGetData($FS_tRECT_CLOSEDlg, 2), $FS_CloseDlg, _ DllStructGetData($FS_tRECT_CLOSEDlg, 3) - DllStructGetData($FS_tRECT_CLOSEDlg, 1), _ DllStructGetData($FS_tRECT_CLOSEDlg, 4) - DllStructGetData($FS_tRECT_CLOSEDlg, 2)) _WinAPI_BitBlt($FS_hDC2, 0, 0, $FS_Width, $FS_TitlebarY, $FS_hCDC2, 0, 0, $SRCCOPY) EndSwitch Return $Res EndFunc ;==>_FS_WinProcDlg Func _FS_CbtHookProc($nCode, $wParam, $lParam) Local $Ret = _WinAPI_CallNextHookEx($FS_hHook, $nCode, $wParam, $lParam) If $nCode < 0 Then Return $Ret Switch _WinAPI_GetClassName(HWnd($wParam)) Case "AutoIt v3 GUI" Switch $nCode Case 3 ;3=HCBT_CREATEWND If $FS_hProc = 0 And $wParam <> 0 Then $FS_hWnd = HWnd($wParam) $FS_hDC = _WinAPI_GetWindowDC($FS_hWnd) $FS_Style_old = _WinAPI_GetWindowLong($FS_hWnd, 0xFFFFFFF0) ;$GWL_STYLE _WinAPI_SetWindowLong($FS_hWnd, 0xFFFFFFF0, BitAND($FS_Style_old, BitNOT(0xC0000))) $FS_hDLL = DllCallbackRegister('_FS_WinProc', 'ptr', 'hwnd;uint;long;ptr') $FS_pDLL = DllCallbackGetPtr($FS_hDLL) $FS_hProc = _WinAPI_SetWindowLong($FS_hWnd, 0xFFFFFFFC, $FS_pDLL) ;$GWL_WNDPROC EndIf Case 4 ;4=HCBT_DESTROYWND ;*********************************************************** ConsoleWrite("This message is never send ?? Why ??" & @CRLF) ;*********************************************************** Case 5 ;5=HCBT_ACTIVATE DllStructGetData($FS_tRECT_CLOSE, 4) If @error Then $FS_aPos = WinGetPos($FS_hWnd) $FS_Width = $FS_aPos[2] + 2 * $FS_BorderX - 2 * $FS_BorderX_Orig $FS_Height = $FS_aPos[3] + $FS_TitlebarY - $FS_TitlebarY_Orig + $FS_BorderY - 1 WinMove($FS_hWnd, "", Default, Default, $FS_Width, $FS_Height) $FS_hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $FS_Width, $FS_Height + $FS_RoundCorner, $FS_RoundCorner, $FS_RoundCorner) _WinAPI_SetWindowRgn($FS_hWnd, $FS_hRgn) $FS_tRECT_CLOSE = _WinAPI_CreateRectEx($FS_Width - $FS_CloseButtonX, $FS_CloseButtonY, $FS_CloseButtonW, $FS_CloseButtonH) $FS_tRECT_MIN = _WinAPI_CreateRectEx($FS_Width - $FS_MinimizeButtonX, $FS_MinimizeButtonY, $FS_MinimizeButtonW, $FS_MinimizeButtonH) $FS_hCDC = _WinAPI_CreateCompatibleDC($FS_hDC) $FS_hCBmp = _WinAPI_CreateCompatibleBitmap($FS_hDC, $FS_Width, $FS_TitlebarY);$FS_Height) $FS_hCBmp_old = _WinAPI_SelectObject($FS_hCDC, $FS_hCBmp) _WinAPI_SetTextColor($FS_hCDC, $FS_TitleTextColor) _WinAPI_SetBkMode($FS_hCDC, $TRANSPARENT) $FS_hFont = _WinAPI_CreateFont($FS_TitlebarFontSize, 0, 0, 0, $FS_TitlebarFontWeight, False, False, False, 1, 0, 0, 0, 0, $FS_TitlebarFont) $FS_hOldFont = _WinAPI_SelectObject($FS_hCDC, $FS_hFont) $FS_hBmp_Top_L = _WinAPI_LoadImage(0, $FS_sBmp_Top_L, 0, 0, 0, $LR_LOADFROMFILE) $FS_hBmp_Top_M = _WinAPI_LoadImage(0, $FS_sBmp_Top_M, 0, $FS_Width - $FS_iBmp_Top_R_W - $FS_iBmp_Top_L_W, 0, $LR_LOADFROMFILE) $FS_hBmp_Top_R = _WinAPI_LoadImage(0, $FS_sBmp_Top_R, 0, 0, 0, $LR_LOADFROMFILE) $FS_hBmp_Border_L = _WinAPI_LoadImage(0, $FS_sBmp_Border_L, 0, 0, $FS_Height - $FS_TitlebarY - $FS_BorderY, $LR_LOADFROMFILE) $FS_hBmp_Border_R = _WinAPI_LoadImage(0, $FS_sBmp_Border_R, 0, 0, $FS_Height - $FS_TitlebarY - $FS_BorderY, $LR_LOADFROMFILE) $FS_hBmp_Bottom_L = _WinAPI_LoadImage(0, $FS_sBmp_Bottom_L, 0, 0, 0, $LR_LOADFROMFILE) $FS_hBmp_Bottom_M = _WinAPI_LoadImage(0, $FS_sBmp_Bottom_M, 0, $FS_Width - $FS_iBmp_Bottom_R_W - $FS_iBmp_Bottom_L_W, 0, $LR_LOADFROMFILE) $FS_hBmp_Bottom_R = _WinAPI_LoadImage(0, $FS_sBmp_Bottom_R, 0, 0, 0, $LR_LOADFROMFILE) EndIf EndSwitch Case "#32770" Switch $nCode Case 3 ;3=HCBT_CREATEWND If $FS_hProc2 = 0 And $wParam <> 0 Then $FS_DlgWnd = HWnd($wParam) $FS_hDC2 = _WinAPI_GetWindowDC($FS_DlgWnd) $FS_StyleDlg_old = _WinAPI_GetWindowLong($FS_DlgWnd, 0xFFFFFFF0) ;$GWL_STYLE _WinAPI_SetWindowLong($FS_DlgWnd, 0xFFFFFFF0, BitAND($FS_StyleDlg_old, BitNOT(0xC0000))) $FS_hDLL2 = DllCallbackRegister('_FS_WinProcDlg', 'ptr', 'hwnd;uint;long;ptr') $FS_pDLL2 = DllCallbackGetPtr($FS_hDLL2) $FS_hProc2 = _WinAPI_SetWindowLong($FS_DlgWnd, 0xFFFFFFFC, $FS_pDLL2) EndIf Case 4 ;4=HCBT_DESTROYWND If $wParam = $FS_DlgWnd Then _WinAPI_SetWindowLong($FS_DlgWnd, 0xFFFFFFFC, $FS_hProc2) DllCallbackFree($FS_hDLL2) _WinAPI_SelectObject($FS_hCDC2, $FS_hOldFontDlg) _WinAPI_DeleteObject($FS_hFontDlg) _WinAPI_DeleteObject($FS_hRgn2) _WinAPI_DeleteObject($FS_hCBmp2) _WinAPI_SelectObject($FS_hCDC2, $FS_hCBmp2_old) _WinAPI_DeleteObject($FS_hBmp_Top_M_Dlg) _WinAPI_DeleteObject($FS_hBmp_Border_L_Dlg) _WinAPI_DeleteObject($FS_hBmp_Border_R_Dlg) _WinAPI_DeleteObject($FS_hBmp_Bottom_M_Dlg) _WinAPI_ReleaseDC($FS_DlgWnd, $FS_hDC2) _WinAPI_DeleteDC($FS_hCDC2) $FS_hProc2 = 0 $FS_tRECT_CLOSEDlg = 0 $FS_CloseDlg = $FS_Close_Std $FS_Dlg_active = False EndIf Case 5 ;5=HCBT_ACTIVATE DllStructGetData($FS_tRECT_CLOSEDlg, 4) If @error Then Local $FS_aPos, $FS_Width, $FS_Height $FS_aPos = WinGetPos($FS_DlgWnd) $FS_Width = $FS_aPos[2] + 2 * $FS_BorderX - 2 * $FS_BorderX_Orig $FS_Height = $FS_aPos[3] + $FS_TitlebarY - $FS_TitlebarY_Orig + $FS_BorderY - 1 $FS_Dlg_Width = $FS_Width $FS_Dlg_Height = $FS_Height WinMove($FS_DlgWnd, "", Default, Default, $FS_Width, $FS_Height) $FS_Dlg_active = True $FS_hRgn2 = _WinAPI_CreateRoundRectRgn(0, 0, $FS_Width, $FS_Height + $FS_RoundCorner, $FS_RoundCorner, $FS_RoundCorner) _WinAPI_SetWindowRgn($FS_DlgWnd, $FS_hRgn2) $FS_tRECT_CLOSEDlg = _WinAPI_CreateRectEx($FS_Width - $FS_CloseButtonX, $FS_CloseButtonY, $FS_CloseButtonW, $FS_CloseButtonH) $FS_hCDC2 = _WinAPI_CreateCompatibleDC($FS_hDC2) $FS_hCBmp2 = _WinAPI_CreateCompatibleBitmap($FS_hDC2, $FS_Width, $FS_TitlebarY);$FS_Height) $FS_hCBmp2_old = _WinAPI_SelectObject($FS_hCDC2, $FS_hCBmp2) $FS_hFontDlg = _WinAPI_CreateFont($FS_TitlebarFontSize, 0, 0, 0, $FS_TitlebarFontWeight, False, False, False, 1, 0, 0, 0, 0, $FS_TitlebarFont) $FS_hOldFontDlg = _WinAPI_SelectObject($FS_hCDC2, $FS_hFontDlg) $FS_hBmp_Top_M_Dlg = _WinAPI_LoadImage(0, $FS_sBmp_Top_M, 0, $FS_Width - $FS_iBmp_Top_R_W - $FS_iBmp_Top_L_W, 0, $LR_LOADFROMFILE) $FS_hBmp_Border_L_Dlg = _WinAPI_LoadImage(0, $FS_sBmp_Border_L, 0, 0, $FS_Height - $FS_TitlebarY - $FS_BorderY, $LR_LOADFROMFILE) $FS_hBmp_Border_R_Dlg = _WinAPI_LoadImage(0, $FS_sBmp_Border_R, 0, 0, $FS_Height - $FS_TitlebarY - $FS_BorderY, $LR_LOADFROMFILE) $FS_hBmp_Bottom_M_Dlg = _WinAPI_LoadImage(0, $FS_sBmp_Bottom_M, 0, $FS_Width - $FS_iBmp_Bottom_R_W - $FS_iBmp_Bottom_L_W, 0, $LR_LOADFROMFILE) EndIf EndSwitch Case Else ;~ Return $Ret EndSwitch Return ;$Ret EndFunc ;==>_FS_CbtHookProc ;#cs Func _WinAPI_LoadFunIcon($sFile, $iIconID = 0) Local $tIcons = DllStructCreate("ptr Data") Local $pIcons = DllStructGetPtr($tIcons) Local $iIcons = _WinAPI_ExtractIconEx($sFile, $iIconID, $pIcons, 0, 1) If @error Then Return SetError(@error, @extended, 0) If $iIcons <= 0 Then Return SetError(1, 0, 0) Return DllStructGetData($tIcons, "Data") EndFunc ;==>_WinAPI_LoadFunIcon ;#ce Func _ColorInverse($nColor) Return BitXOR($nColor, 0xFFFFFF) EndFunc ;==>_ColorInverse Func _FS_ConsoleWrite($sDebug) If $FS_Debug Then ConsoleWrite($sDebug & @CRLF) EndFunc