Jump to content

How to Resize GDI+ Layed Window?


Lakes
 Share

Recommended Posts

How to resize a transparent (layered window) when there`s no border or sizing controls to click on? (You can`t use WM_SIZE).

I tried to do it with a slider control, but I can`t get it to work.

; ============ React to slider movement ========================
Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    If $lParam = $Trans_Handle Then
        $TransValue = GUICtrlRead($Trans)
  DllStructSetData($tBlend, "Alpha", $TransValue)         ; Set Alpha (Transparency) Level
  DllStructSetData($tBlend, "Format", 1)
        ToolTip($TransValue)
    EndIf
;=============== ; Size Window? ==================
    If $lParam = $Size_Handle Then
        $SizeValue = GUICtrlRead($Size)
  DllStructSetData($tSize, "X", $iX - $SizeValue)
  DllStructSetData($tSize, "Y", $iY - $SizeValue)               
  
;Update layered Window
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_UpdateLayeredWindow($hGUI, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
_WinAPI_RedrawWindow($hGUI)
        ToolTip($SizeValue)
    EndIf
Return "GUI_RUNDEFMSG"
EndFunc
;===============================================================

Here`s the transparent version of UEZ Simple Clock...

#include <Date.au3>
#Include <Timers.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <String.au3>
#include <GuiMenu.au3>
#include <Misc.au3>
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $hGUI, $hGraphics, $hBackbuffer, $hBitmap, $hPen1, $hPen2, $hPen3, $hPen4
Global $iX = 600, $iY = $iX
Global Const $p2_hm = $iX / 35
Global Const $p3_hm = $iX / 35
Global Const $p4_hm = $iX / 100
Global $newY = $iX, $newX = $iY
Global Const $minSize = $iX * 0.25
Global Const $maxSize = $iX * 1.5
Global Const $cX = $iX * 0.5, $cY = $iY * 0.5
Global Const $deg = ACos(-1) / 180
Global Const $radius = $iX * 0.85, $cR = $radius * 0.50
Global Const $cR1 = $cR * 0.90, $cR2 = $cR * 0.20
Global Const $cR3 = $cR * 0.80, $cR4 = $cR * 0.15
Global Const $cR5 = $cR * 0.50, $cR6 = $cR * 0.10
Global $sek = @SEC * 6 - 90
Global $min = @MIN * 6 + (@SEC / 10) - 90
Global $std = @HOUR * 30 + (@MIN / 2) - 90
Global Const $fs = $iY / 30, $tms = $iY / 20, $tmh = $iY * 0.725
Global $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $x5, $x6, $y5, $y6, $tm
Global $T_Font, $T_Brush, $T_Format, $T_Family, $T_Layout, $T_String
Global $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint, $gdibitmap
Global $contextmenu, $button, $buttoncontext, $buttonitem
Global $newsubmenu, $textitem, $fileitem, $saveitem, $infoitem
Global  $SliderGUI,$Trans, $Trans_Handle, $Size, $Size_Handle, $TransValue, $SizeValue
Global Enum  $item1 = 1000, $item2, $item3
 
Global $title = "GDI+ Simple Clock by UEZ 2011 / "
Opt("GUIOnEventMode", 1)
; ====== Create Properties GUI but hide it =====================
$SliderGUI =GUICreate("Properties", 220, 150, 100, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "SliderGUIhide",$SliderGUI)
GUICtrlCreateLabel("Transparency",20,5)
$Trans = GUICtrlCreateSlider(10, 20, 200, 20)
$Trans_Handle = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 255, 0)  ; change min/max value
GUICtrlSetData($Trans, 125)  ; set cursor
GUICtrlCreateLabel("Size",20,50)
$Size = GUICtrlCreateSlider(10, 65, 200, 20)
$Size_Handle = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 500, 0)  ; change min/max value
GUICtrlSetData($Size, 250)   ; set cursor
 
GUISetState(@SW_HIDE, $SliderGUI)
GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider")
;==============================================================
; Initialize GDI+
_GDIPlus_Startup()
$hGUI = GUICreate($title, $iX, $iY, -1, -1, 0, $WS_EX_LAYERED + $WS_EX_TOPMOST)
;If @OSBuild < 7600 Then WinSetTrans($hGui,"", 0xFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") ;Adjust Trans
 
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $hGraphics)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
; _WinAPI_UpdateLayeredWindow parameters
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $iX)
DllStructSetData($tSize, "Y", $iY)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
Global $alpha = 200
Global $alpha_steps = 5
DllStructSetData($tBlend, "Alpha", $alpha)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT) ; For Custom Line Caps
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)
 
GuiSetState()
;GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU")
GUIRegisterMsg($WM_NCHITTEST,   "WM_NCHITTEST") ;Drag Window
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") ;Adjust Trans
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
$ScreenDc = _WinAPI_GetDC($hGUI)
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
_WinAPI_SelectObject($dc, $gdibitmap)
; Using antialiasing
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hBackbuffer, "int", 3)
; Create a Pen object
$hPen1 = _GDIPlus_PenCreate(0xFF800010, 4)
$hPen2 = _GDIPlus_PenCreate(0xA01010F0,  $p2_hm)
$hPen3 = _GDIPlus_PenCreate(0xA01010F0,  $p3_hm)
$hPen4 = _GDIPlus_PenCreate(0x9010D040,  $p4_hm)
Global Const  $LineCapRound = 2,  $LineCapTriangle = 3, $DashCapFlat = 0
Global $hPath, $hCustomLineCap, $avCaps
Global $avPoints[3][2] = [[2], [0, 0], [0, 0]]
$hPath = _GDIPlus_PathCreate()
_GDIPlus_PathAddLines($hPath, $avPoints)
$hCustomLineCap = _GDIPlus_CustomLineCapCreate(0, $hPath)
_GDIPlus_CustomLineCapSetStrokeCaps($hCustomLineCap, $LineCapTriangle, $LineCapRound)
$avCaps = _GDIPlus_CustomLineCapGetStrokeCaps($hCustomLineCap)
_GDIPlus_PenSetLineCap($hPen2, $avCaps[0], $avCaps[1], $DashCapFlat)
_GDIPlus_PenSetLineCap($hPen3, $avCaps[0], $avCaps[1], $DashCapFlat)
_GDIPlus_PenSetLineCap($hPen4, $avCaps[0], $avCaps[1], $DashCapFlat)
Global $ws = WinGetPos($hGUI)
Global $ratio = $ws[3] / $ws[2]
Global $font = "Comic Sans MS"
If FileExists(@WindowsDir & "\fonts\showg.ttf") Then $font = "Showcard Gothic"
 
;Time init
  $T_Brush = _GDIPlus_BrushCreateSolid(0xFF008080)
  $T_Format = _GDIPlus_StringFormatCreate()
  $T_Family = _GDIPlus_FontFamilyCreate("Verdana")
  $T_Font   = _GDIPlus_FontCreate ($T_Family, 32, 3)
  $T_Layout = _GDIPlus_RectFCreate(0, 0, $iX, 80)
 
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
AdlibRegister("Ticker", 50)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_SIZING, "WM_SIZING")
;GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
 
Global $timer = 100,  $speak = False, $speak_init = True, $SpeakingClock = True
Global $oVoice = ObjCreate("SAPI.SpVoice")
If @error Then
    $speak_init = False
Else
    $oVoice.Rate = -3
EndIf
GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $timer, "int", 0)
AdlibRegister( "SpeakingClock", 1000)
While Sleep(100000000)
WEnd
Func Draw()
    _GDIPlus_GraphicsClear($hBackbuffer, 0x00000000)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX - $cR, $cY, $cX - $cR + 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX + $cR, $cY, $cX + $cR - 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY - $cR, $cX, $cY - $cR + 35, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY + $cR, $cX, $cY + $cR - 35, $hPen1)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $cX - $cR, $cY - $cR, $radius, $radius, $hPen1)
    For $i = 0 To 11
        _GDIPlus_GraphicsDrawString($hBackbuffer, $i + 1, -$fs / 2 + $cX + Cos(-45 + $i * 29.7 * $deg) * $cR3, -$fs * 0.9 + $cY + Sin(-45 + $i * 29.7 * $deg) * $cR3, $font, $fs)
    Next
    If Int(StringLeft(_NowTime(4), 2) / 12) Then
        $tm = "PM"
    Else
        $tm = "AM"
    EndIf
    _GDIPlus_GraphicsDrawString($hBackbuffer, $tm,  -$tms * 1.1 + $cX, $tmh, $font, $tms)
    $x5 = $cX + Cos($std * $deg) * $cR5
    $y5 = $cY + Sin($std * $deg) * $cR5
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x5, $y5, $cX, $cY, $hPen2) ;hours
    $x3 = $cX + Cos($min * $deg) * $cR3
    $y3 = $cY + Sin($min * $deg) * $cR3
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x3, $y3, $cX, $cY, $hPen3) ;minutes
    $x1 = $cX + Cos($sek * $deg) * $cR1
    $y1 = $cY + Sin($sek * $deg) * $cR1
    $x2 = $cX + Cos(($sek + 180) * $deg) * $cR2
    $y2 = $cY + Sin(($sek + 180) * $deg) * $cR2
    _GDIPlus_GraphicsDrawLine($hBackbuffer, Floor($x1), Floor($y1), Floor($x2), Floor($y2), $hPen4) ;seconds
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $cX - 3, $cY - 3, 6, 6, $hPen1)
; _GDIPlus_GraphicsDrawString($hBackbuffer, @HOUR & ":" & @MIN & ":" & @SEC, 0, 0)
;   <<<< ================= Digital Time =======================
DrawTime()
;=================================================================
;Update layered Window
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_UpdateLayeredWindow($hGUI, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
 
;   _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iX, $iY)
    _WinAPI_RedrawWindow($hGUI)
EndFunc
;=================================================================
 
; ================== Draw the digital time =============================
Func DrawTime()
  Local $sString, $aSize
  ;   WinSetTitle($hGui, "", $title & @HOUR & ":" & @MIN & ":" & @SEC)
  $sString = StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
  $aSize   = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $T_Font, $T_Layout, $T_Format)
  DllStructSetData($T_Layout, "X", (DllStructGetData($aSize[0], "Width")* 0.77))       ; Middle of Window     
  DllStructSetData($T_Layout, "Y", (DllStructGetData($aSize[0], "Height")- 64 ))      ; Clock at Top
  _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $T_Font, $T_Layout, $T_Format, $T_Brush)
EndFunc
; ============= Handle the WM_NCHITTEST message  ===============
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
Local $hMenu, $Win, $WinX, $WinY, $mX, $mY
if $hWnD = $hGUI and _IsPressed (01) then Return $HTCAPTION
if $hWnd = $hGUI and _IsPressed (02) then
; ConsoleWrite($GUI &" HIT!! "&@CRLF)
#cs
  $WinPos = WingetPos($GUI)
  $WinX = $WinPos[0]
  $WinY = $WinPos[0]
 
     $aPos = MouseGetPos()
  $mX = $aPos [0]
  $mY = $aPos [1]
  ConsoleWrite("MouseCoords = " &$WinX + $mX &" " &$WinY + $mY &@CRLF)
#ce
$hMenu = _GUICtrlMenu_CreatePopup ()
_GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Properties", $item1)
_GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Item 2", $item2)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "", 0)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Exit", $item3)
_GUICtrlMenu_TrackPopupMenu ($hMenu, $hGUI, -1,-1 ,1,0 )
_GUICtrlMenu_DestroyMenu ($hMenu)
Return True
endif
EndFunc
;==========================================================================================
; =========  Handle WM_COMMAND messages =======================
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
Switch $iwParam
  Case $item1
   Properties()
   ConsoleWrite("Item 1 = " &$item1 &@CRLF)
  Case $item2
   ConsoleWrite("Item 2 = " &$item2 &@CRLF)  
  Case $item3
   _Exit()
   ConsoleWrite("Item 3 = " &$item3 &@CRLF) 
EndSwitch
EndFunc   ;==>WM_COMMAND
;=============================================================
Func Properties()
   GUISetState(@SW_SHOW, $SliderGUI)
EndFunc
Func SliderGUIhide()
GUISetState(@SW_HIDE, $SliderGUI)
EndFunc
; ============ React to slider movement ========================
Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    If $lParam = $Trans_Handle Then
        $TransValue = GUICtrlRead($Trans)
  DllStructSetData($tBlend, "Alpha", $TransValue)         ; Set Alpha (Transparency) Level
  DllStructSetData($tBlend, "Format", 1)
        ToolTip($TransValue)
    EndIf
 
    If $lParam = $Size_Handle Then
        $SizeValue = GUICtrlRead($Size)
  DllStructSetData($tSize, "X", $iX - $SizeValue)
  DllStructSetData($tSize, "Y", $iY - $SizeValue)   ; Size Window?
  
;Update layered Window
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_UpdateLayeredWindow($hGUI, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
_WinAPI_RedrawWindow($hGUI)
        ToolTip($SizeValue)
    EndIf
Return "GUI_RUNDEFMSG"
EndFunc
;===============================================================
 
; MouseWheel for Win Trans
Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
  Local $mouseData, $n1
      $mouseData = _WinAPI_HiWord($wParam) ;/ $WHEEL_DELTA
Select
;Case $wParam = $WM_MOUSEWHEEL And WinActive($GUI)
;WM_MOUSEWHEEL = 0x020A
Case WinActive($hGUI)
   If $mouseData > 0 Then ;wheel up
    If $alpha + $alpha_steps <= 512 Then $alpha += $alpha_steps
    Switch $alpha
     Case 0 To 255
      DllStructSetData($tBlend, "Alpha", $alpha)          ; Set Alpha (Transparency) Level
      DllStructSetData($tBlend, "Format", 1)
     Case 256 To 512
      DllStructSetData($tBlend, "Alpha", $alpha - 256)
      DllStructSetData($tBlend, "Format", 0)
    EndSwitch
   Else ;wheel down
    If $alpha - $alpha_steps > 0 Then $alpha -= $alpha_steps
    Switch $alpha
     Case 0 To 255
      DllStructSetData($tBlend, "Alpha", $alpha) ;wheel up
      DllStructSetData($tBlend, "Format", 1)
     Case 256 To 512
      DllStructSetData($tBlend, "Alpha", $alpha - 256) ;wheel up
      DllStructSetData($tBlend, "Format", 0)
    EndSwitch
   EndIf
   ConsoleWrite($alpha & @CRLF)
EndSelect
EndFunc ;==>WM_MOUSEWHEEL
Func SpeakingClock()
;   If  $min = -90.00 And $speak_init And $SpeakingClock Then $oVoice.Speak("It is " & Mod(@HOUR, 12) & " " & $tm, 1)
EndFunc
Func WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam)
    Local $hGraphicsTemp = _GDIPlus_GraphicsCreateFromHDC($wParam)
    _GDIPlus_GraphicsDrawImageRect($hGraphicsTemp, $hBitmap, 0, 0, $iX, $iY)
    _GDIPlus_GraphicsDispose($hGraphicsTemp)
    Return True
EndFunc   ;==>_WM_ERASEBKGND
Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    $iX = BitAND($lParam, 0x0000FFFF)
    $iY = BitShift(BitAND($lParam, 0xFFFF0000), 16)
ConsoleWrite("x: " & $iX & ", y: " & $iY & @CRLF)   ; <<< ===== Console Write =======
;   _WinAPI_RedrawWindow($hGUI)
    Return "GUI_RUNDEFMSG"
EndFunc
Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
    Local $sRect = DllStructCreate("Int[4]", $lParam)
    Local $left = DllStructGetData($sRect, 1, 1)
    Local $top = DllStructGetData($sRect, 1, 2)
    Local $right = DllStructGetData($sRect, 1, 3)
    Local $bottom = DllStructGetData($sRect, 1, 4)
    Switch $wParam ;drag side or corner
        Case 1, 2, 4, 7
            $newY = ($right - $left) * $ratio
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 2) + $newY, 4)
        Case Else
            $newX = ($bottom - $top) / $ratio
            DllStructSetData($sRect, 1, DllStructGetData($sRect, 1, 1) + $newX, 3)
  EndSwitch
 
;Update layered Window
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_UpdateLayeredWindow($hGUI, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_SIZING
Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam)
    Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $minSize) ; min X
    DllStructSetData($minmaxinfo, 8, $minSize) ; min Y
    DllStructSetData($minmaxinfo, 9, $maxSize) ; max X
    DllStructSetData($minmaxinfo, 10, $maxSize) ; max Y
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_GETMINMAXINFO
Func Ticker()
    $sek = @SEC * 6 - 90
    $min = @MIN * 6 + (@SEC * 0.10) - 90
    $std = @HOUR * 30 + (@MIN * 0.50) - 90
EndFunc
Func _Exit()
    AdlibUnRegister("Ticker")
    AdlibUnRegister("SpeakingClock")
    $oVoice = 0
    GUIRegisterMsg($WM_TIMER, "")
    GUIRegisterMsg($WM_GETMINMAXINFO, "")
    GUIRegisterMsg($WM_SIZE, "")
    GUIRegisterMsg($WM_ERASEBKGND, "")
    GUIRegisterMsg($WM_SIZING, "")
_WinAPI_DeleteDC($dc)
    _WinAPI_ReleaseDC($hGUI, $ScreenDc)
    ; Clean up GDI+ resources
    _GDIPlus_CustomLineCapDispose($hCustomLineCap)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_PenDispose($hPen3)
    _GDIPlus_PenDispose($hPen4)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
  _GDIPlus_FontDispose      ($T_Font  )
  _GDIPlus_FontFamilyDispose  ($T_Family)
  _GDIPlus_StringFormatDispose($T_Format)
  _GDIPlus_BrushDispose    ($T_Brush)
    ; Uninitialize GDI+
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc
Func _GDIPlus_PathCreate($iFillMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", $iFillMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[2]
EndFunc   ;==>_GDIPlus_PathCreate
Func _GDIPlus_PathAddLines($hPath, $aPoints)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult
    $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("float[" & $iCount * 2 & "]")
    $pPoints = DllStructGetPtr($tPoints)
    For $iI = 1 To $iCount
        DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1)
        DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2)
    Next
    $aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathLine2", "hwnd", $hPath, "ptr", $pPoints, "int", $iCount)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PathAddLines
Func _GDIPlus_PathDispose($hPath)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PathDispose
Func _GDIPlus_CustomLineCapCreate($hPathFill, $hPathStroke, $iLineCap = 0, $nBaseInset = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateCustomLineCap", "hwnd", $hPathFill, "hwnd", $hPathStroke, "int", $iLineCap, "float", $nBaseInset, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[5]
EndFunc   ;==>_GDIPlus_CustomLineCapCreate
Func _GDIPlus_CustomLineCapSetStrokeCaps($hCustomLineCap, $iStartCap, $iEndCap)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetCustomLineCapStrokeCaps", "hwnd", $hCustomLineCap, "int", $iStartCap, "int", $iEndCap)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_CustomLineCapSetStrokeCaps
Func _GDIPlus_CustomLineCapGetStrokeCaps($hCustomLineCap)
    Local $aCaps[2], $aResult
    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetCustomLineCapStrokeCaps", "hwnd", $hCustomLineCap, "int*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, -1)
    If $aResult[0] Then Return -1
    $aCaps[0] = $aResult[2]
    $aCaps[1] = $aResult[3]
    Return $aCaps
EndFunc   ;==>_GDIPlus_CustomLineCapGetStrokeCap
Func _GDIPlus_PenSetLineCap($hPen, $iStartCap, $iEndCap, $iDashCap)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetPenLineCap197819", "hwnd", $hPen, "int", $iStartCap, "int", $iEndCap, "int", $iDashCap)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PenSetLineCap

As you can see, the sizing does not work.... :D

EDIT: I could approch this in another way and just erase the window background, but I don`t want a windows border/titlebar around the clock.

This does not works either... :oops:

; ============ React to slider movement ========================
Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    If $lParam = $Trans_Handle Then
        $TransValue = GUICtrlRead($Trans)
  DllStructSetData($tBlend, "Alpha", $TransValue)         ; Set Alpha (Transparency) Level
  DllStructSetData($tBlend, "Format", 1)
        ToolTip($TransValue)
    EndIf
 
    If $lParam = $Size_Handle Then
        $SizeValue = GUICtrlRead($Size)
;  DllStructSetData($tSize, "X", $iX - $SizeValue)
;  DllStructSetData($tSize, "Y", $iY - $SizeValue)   ; Size Window?
  Resize()
    
;Update layered Window
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_UpdateLayeredWindow($hGUI, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
_WinAPI_RedrawWindow($hGUI)
        ToolTip($SizeValue)
    EndIf
Return "GUI_RUNDEFMSG"
EndFunc
;===============================================================
Func Resize()
  Local $hWindow ,$stRET, $sMsg, $pStruct, $iRET, $Left, $Right, $Top, $Bottom
$hWindow = WinGetHandle($hGUI)
;  WinMove($hGUI,"",Default,Default, $SizeValue, $SizeValue)
$stRET = _WinAPI_GetWindowPlacement($hWindow)
$Left = DllStructGetData($stRET, "rcNormalPosition"  , 1)
$Top = DllStructGetData($stRET, "rcNormalPosition"  , 2)
$Right = DllStructGetData($stRET, "rcNormalPosition" , 3)
$Bottom = DllStructGetData($stRET, "rcNormalPosition" , 4)
ConsoleWrite("left = " &$Left   &@CRLF)
ConsoleWrite("top =  " &$Top   &@CRLF)
ConsoleWrite("right = " &$Right  &@CRLF)
ConsoleWrite("bottom = "&$Bottom  &@CRLF &@CRLF)
 
DllStructSetData($stRET, "rcNormalPosition", $Left    ,1); left
DllStructSetData($stRET, "rcNormalPosition", $Top     ,2); top
DllStructSetData($stRET, "rcNormalPosition", 100 + $SizeValue  ,3); right
DllStructSetData($stRET, "rcNormalPosition", 100 + $SizeValue  ,4); bottom
$pStruct = DllStructGetPtr($stRET); Get pointer to the modified struct
 
$iRET = _WinAPI_SetWindowPlacement($hGUI, $pStruct)
; ConsoleWrite ("Error = " &@Error)
$stRET = _WinAPI_GetWindowPlacement($hWindow)
$Left = DllStructGetData($stRET, "rcNormalPosition", 1)
$Top = DllStructGetData($stRET, "rcNormalPosition", 2)
$Right = DllStructGetData($stRET, "rcNormalPosition", 3)
$Bottom = DllStructGetData($stRET, "rcNormalPosition", 4)
EndFunc

I`m stuck with the sizing thing, thanks for your help.

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

Try this:

#include <Date.au3>
#Include <Timers.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <String.au3>
#include <GuiMenu.au3>
#include <Misc.au3>
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $hGUI, $hGraphics, $hBackbuffer, $hBitmap, $hPen1, $hPen2, $hPen3, $hPen4
Global $iWidth = 600, $iHeight = $iWidth, $iW = $iWidth, $iH = $iHeight
Global Const $p2_hm = $iWidth / 35
Global Const $p3_hm = $iWidth / 35
Global Const $p4_hm = $iWidth / 100
Global $newY = $iWidth, $newX = $iHeight
Global Const $minSize = $iWidth * 0.25
Global Const $maxSize = $iWidth * 1.5
Global Const $cX = $iWidth * 0.5, $cY = $iHeight * 0.5
Global Const $deg = ACos(-1) / 180
Global Const $radius = $iWidth * 0.85, $cR = $radius * 0.50
Global Const $cR1 = $cR * 0.90, $cR2 = $cR * 0.20
Global Const $cR3 = $cR * 0.80, $cR4 = $cR * 0.15
Global Const $cR5 = $cR * 0.50, $cR6 = $cR * 0.10
Global $sek = @SEC * 6 - 90
Global $min = @MIN * 6 + (@SEC / 10) - 90
Global $std = @HOUR * 30 + (@MIN / 2) - 90
Global Const $fs = $iHeight / 30, $tms = $iHeight / 20, $tmh = $iHeight * 0.725
Global $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $x5, $x6, $y5, $y6, $tm
Global $T_Font, $T_Brush, $T_Format, $T_Family, $T_Layout, $T_String
Global $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint, $gdibitmap
Global $contextmenu, $button, $buttoncontext, $buttonitem
Global $newsubmenu, $textitem, $fileitem, $saveitem, $infoitem
Global  $SliderGUI,$Trans, $Trans_Handle, $Size, $Size_Handle, $TransValue, $SizeValue
Global Enum  $item1 = 1000, $item2, $item3

Global $title = "GDI+ Simple Clock by UEZ 2011 / "
Opt("GUIOnEventMode", 1)
; ====== Create Properties GUI but hide it =====================
$SliderGUI =GUICreate("Properties", 220, 150, 100, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "SliderGUIhide",$SliderGUI)
GUICtrlCreateLabel("Transparency",20,5)
$Trans = GUICtrlCreateSlider(10, 20, 200, 20)
$Trans_Handle = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 255, 0)  ; change min/max value
GUICtrlSetData($Trans, 125)  ; set cursor
GUICtrlCreateLabel("Size",20,50)
$Size = GUICtrlCreateSlider(10, 65, 200, 20)
$Size_Handle = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 100, 10)  ; change min/max value
GUICtrlSetData($Size, 100)   ; set cursor

GUISetState(@SW_HIDE, $SliderGUI)
GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider")
;==============================================================
; Initialize GDI+
_GDIPlus_Startup()
$hGUI = GUICreate($title, $iWidth, $iHeight, -1, -1, 0, $WS_EX_LAYERED + $WS_EX_TOPMOST)
;If @OSBuild < 7600 Then WinSetTrans($hGui,"", 0xFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") ;Adjust Trans

$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

; _WinAPI_UpdateLayeredWindow parameters
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $iWidth)
DllStructSetData($tSize, "Y", $iHeight)

$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)

Global $alpha =200
Global $alpha_steps = 5
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $alpha)
DllStructSetData($tBlend, "Format", 1)


$tPoint = DllStructCreate($tagPOINT) ; For Custom Line Caps
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)

GuiSetState()
Global $aPos = WinGetPos($hGUI)
;GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU")
GUIRegisterMsg($WM_NCHITTEST,   "WM_NCHITTEST") ;Drag Window
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") ;Adjust Trans
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
$ScreenDc = _WinAPI_GetDC($hGUI)
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
_WinAPI_SelectObject($dc, $gdibitmap)
; Using antialiasing
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hBackbuffer, "int", 3)
; Create a Pen object
$hPen1 = _GDIPlus_PenCreate(0xFF800010, 4)
$hPen2 = _GDIPlus_PenCreate(0xA01010F0,  $p2_hm)
$hPen3 = _GDIPlus_PenCreate(0xA01010F0,  $p3_hm)
$hPen4 = _GDIPlus_PenCreate(0x9010D040,  $p4_hm)
Global Const  $LineCapRound = 2,  $LineCapTriangle = 3, $DashCapFlat = 0
Global $hPath, $hCustomLineCap, $avCaps
Global $avPoints[3][2] = [[2], [0, 0], [0, 0]]
$hPath = _GDIPlus_PathCreate()
_GDIPlus_PathAddLines($hPath, $avPoints)
$hCustomLineCap = _GDIPlus_CustomLineCapCreate(0, $hPath)
_GDIPlus_CustomLineCapSetStrokeCaps($hCustomLineCap, $LineCapTriangle, $LineCapRound)
$avCaps = _GDIPlus_CustomLineCapGetStrokeCaps($hCustomLineCap)
_GDIPlus_PenSetLineCap($hPen2, $avCaps[0], $avCaps[1], $DashCapFlat)
_GDIPlus_PenSetLineCap($hPen3, $avCaps[0], $avCaps[1], $DashCapFlat)
_GDIPlus_PenSetLineCap($hPen4, $avCaps[0], $avCaps[1], $DashCapFlat)
Global $ws = WinGetPos($hGUI)
Global $ratio = $ws[3] / $ws[2]
Global $font = "Comic Sans MS"
If FileExists(@WindowsDir & "\fonts\showg.ttf") Then $font = "Showcard Gothic"

;Time init
  $T_Brush = _GDIPlus_BrushCreateSolid(0xFF008080)
  $T_Format = _GDIPlus_StringFormatCreate()
  $T_Family = _GDIPlus_FontFamilyCreate("Verdana")
  $T_Font   = _GDIPlus_FontCreate ($T_Family, 32, 3)
  $T_Layout = _GDIPlus_RectFCreate(0, 0, $iWidth, 80)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
AdlibRegister("Ticker", 50)

Global $timer = 100,  $speak = False, $speak_init = True, $SpeakingClock = True
Global $oVoice = ObjCreate("SAPI.SpVoice")
If @error Then
    $speak_init = False
Else
    $oVoice.Rate = -3
EndIf
GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $timer, "int", 0)
AdlibRegister( "SpeakingClock", 1000)
While Sleep(100000000)
WEnd
Func Draw()
    _GDIPlus_GraphicsClear($hBackbuffer, 0x00000000)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX - $cR, $cY, $cX - $cR + 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX + $cR, $cY, $cX + $cR - 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY - $cR, $cX, $cY - $cR + 35, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY + $cR, $cX, $cY + $cR - 35, $hPen1)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $cX - $cR, $cY - $cR, $radius, $radius, $hPen1)
    For $i = 0 To 11
        _GDIPlus_GraphicsDrawString($hBackbuffer, $i + 1, -$fs / 2 + $cX + Cos(-45 + $i * 29.7 * $deg) * $cR3, -$fs * 0.9 + $cY + Sin(-45 + $i * 29.7 * $deg) * $cR3, $font, $fs)
    Next
    If Int(StringLeft(_NowTime(4), 2) / 12) Then
        $tm = "PM"
    Else
        $tm = "AM"
    EndIf
    _GDIPlus_GraphicsDrawString($hBackbuffer, $tm,  -$tms * 1.1 + $cX, $tmh, $font, $tms)
    $x5 = $cX + Cos($std * $deg) * $cR5
    $y5 = $cY + Sin($std * $deg) * $cR5
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x5, $y5, $cX, $cY, $hPen2) ;hours
    $x3 = $cX + Cos($min * $deg) * $cR3
    $y3 = $cY + Sin($min * $deg) * $cR3
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x3, $y3, $cX, $cY, $hPen3) ;minutes
    $x1 = $cX + Cos($sek * $deg) * $cR1
    $y1 = $cY + Sin($sek * $deg) * $cR1
    $x2 = $cX + Cos(($sek + 180) * $deg) * $cR2
    $y2 = $cY + Sin(($sek + 180) * $deg) * $cR2
    _GDIPlus_GraphicsDrawLine($hBackbuffer, Floor($x1), Floor($y1), Floor($x2), Floor($y2), $hPen4) ;seconds
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $cX - 3, $cY - 3, 6, 6, $hPen1)
; _GDIPlus_GraphicsDrawString($hBackbuffer, @HOUR & ":" & @MIN & ":" & @SEC, 0, 0)
;   <<<< ================= Digital Time =======================
    DrawTime()
;=================================================================
;Update layered Window
    Local $hBmp = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int",  0x0026200A, "ptr", 0, "int*", 0)
    $hBmp = $hBmp[6]
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBmp)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hBitmap, 0, 0, $iW, $iH)

    $gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
    _WinAPI_SelectObject($dc, $gdibitmap)
    DllStructSetData($tSize, "X", $iW)
    DllStructSetData($tSize, "Y", $iH)
    _WinAPI_UpdateLayeredWindow($hGUI, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
    _WinAPI_DeleteObject($gdibitmap)

   _WinAPI_RedrawWindow($hGUI)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBmp)
EndFunc
;=================================================================

; ================== Draw the digital time =============================
Func DrawTime()
  Local $sString, $aSize
  ;   WinSetTitle($hGui, "", $title & @HOUR & ":" & @MIN & ":" & @SEC)
  $sString = StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
  $aSize   = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $T_Font, $T_Layout, $T_Format)
  DllStructSetData($T_Layout, "X", (DllStructGetData($aSize[0], "Width")* 0.77))       ; Middle of Window
  DllStructSetData($T_Layout, "Y", (DllStructGetData($aSize[0], "Height")- 64 ))      ; Clock at Top
  _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $T_Font, $T_Layout, $T_Format, $T_Brush)
EndFunc
; ============= Handle the WM_NCHITTEST message  ===============
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
Local $hMenu, $Win, $WinX, $WinY, $mX, $mY
if $hWnD = $hGUI and _IsPressed (01) then Return $HTCAPTION
if $hWnd = $hGUI and _IsPressed (02) then
; ConsoleWrite($GUI &" HIT!! "&@CRLF)
#cs
  $WinPos = WingetPos($GUI)
  $WinX = $WinPos[0]
  $WinY = $WinPos[0]

     $aPos = MouseGetPos()
  $mX = $aPos [0]
  $mY = $aPos [1]
  ConsoleWrite("MouseCoords = " &$WinX + $mX &" " &$WinY + $mY &@CRLF)
#ce
$hMenu = _GUICtrlMenu_CreatePopup ()
_GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Properties", $item1)
_GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Item 2", $item2)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "", 0)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Exit", $item3)
_GUICtrlMenu_TrackPopupMenu ($hMenu, $hGUI, -1,-1 ,1,0 )
_GUICtrlMenu_DestroyMenu ($hMenu)
Return True
endif
EndFunc
;==========================================================================================
; =========  Handle WM_COMMAND messages =======================
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
Switch $iwParam
  Case $item1
   Properties()
   ConsoleWrite("Item 1 = " &$item1 &@CRLF)
  Case $item2
   ConsoleWrite("Item 2 = " &$item2 &@CRLF)
  Case $item3
   _Exit()
   ConsoleWrite("Item 3 = " &$item3 &@CRLF)
EndSwitch
EndFunc   ;==>WM_COMMAND
;=============================================================
Func Properties()
   GUISetState(@SW_SHOW, $SliderGUI)
EndFunc
Func SliderGUIhide()
GUISetState(@SW_HIDE, $SliderGUI)
EndFunc
; ============ React to slider movement ========================
Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    If $lParam = $Trans_Handle Then
        $TransValue = GUICtrlRead($Trans)
        DllStructSetData($tBlend, "Alpha", $TransValue)         ; Set Alpha (Transparency) Level
        DllStructSetData($tBlend, "Format", 1)
        ToolTip($TransValue)
    EndIf

    If $lParam = $Size_Handle Then
        $SizeValue = GUICtrlRead($Size)
        $iW = $iWidth * $SizeValue * 0.01
        $iH = $iHeight * $SizeValue * 0.01
    EndIf
Return "GUI_RUNDEFMSG"
EndFunc
;===============================================================
; MouseWheel for Win Trans
Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
  Local $mouseData, $n1
      $mouseData = _WinAPI_HiWord($wParam) ;/ $WHEEL_DELTA
Select
;Case $wParam = $WM_MOUSEWHEEL And WinActive($GUI)
;WM_MOUSEWHEEL = 0x020A
Case WinActive($hGUI)
   If $mouseData > 0 Then ;wheel up
    If $alpha + $alpha_steps <= 512 Then $alpha += $alpha_steps
    Switch $alpha
     Case 0 To 255
      DllStructSetData($tBlend, "Alpha", $alpha)          ; Set Alpha (Transparency) Level
      DllStructSetData($tBlend, "Format", 1)
     Case 256 To 512
      DllStructSetData($tBlend, "Alpha", $alpha - 256)
      DllStructSetData($tBlend, "Format", 0)
    EndSwitch
   Else ;wheel down
    If $alpha - $alpha_steps > 0 Then $alpha -= $alpha_steps
    Switch $alpha
     Case 0 To 255
      DllStructSetData($tBlend, "Alpha", $alpha) ;wheel up
      DllStructSetData($tBlend, "Format", 1)
     Case 256 To 512
      DllStructSetData($tBlend, "Alpha", $alpha - 256) ;wheel up
      DllStructSetData($tBlend, "Format", 0)
    EndSwitch
   EndIf
   ConsoleWrite($alpha & @CRLF)
EndSelect
EndFunc ;==>WM_MOUSEWHEEL

Func SpeakingClock()
;   If  $min = -90.00 And $speak_init And $SpeakingClock Then $oVoice.Speak("It is " & Mod(@HOUR, 12) & " " & $tm, 1)
EndFunc

Func Ticker()
    $sek = @SEC * 6 - 90
    $min = @MIN * 6 + (@SEC * 0.10) - 90
    $std = @HOUR * 30 + (@MIN * 0.50) - 90
EndFunc
Func _Exit()
    AdlibUnRegister("Ticker")
    AdlibUnRegister("SpeakingClock")
    $oVoice = 0
    GUIRegisterMsg($WM_TIMER, "")
    GUIRegisterMsg($WM_GETMINMAXINFO, "")
    GUIRegisterMsg($WM_SIZE, "")
    GUIRegisterMsg($WM_ERASEBKGND, "")
    GUIRegisterMsg($WM_SIZING, "")
_WinAPI_DeleteDC($dc)
    _WinAPI_ReleaseDC($hGUI, $ScreenDc)
    ; Clean up GDI+ resources
    _GDIPlus_CustomLineCapDispose($hCustomLineCap)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_PenDispose($hPen3)
    _GDIPlus_PenDispose($hPen4)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
  _GDIPlus_FontDispose      ($T_Font  )
  _GDIPlus_FontFamilyDispose  ($T_Family)
  _GDIPlus_StringFormatDispose($T_Format)
  _GDIPlus_BrushDispose    ($T_Brush)
    ; Uninitialize GDI+
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc
Func _GDIPlus_PathCreate($iFillMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", $iFillMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[2]
EndFunc   ;==>_GDIPlus_PathCreate
Func _GDIPlus_PathAddLines($hPath, $aPoints)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult
    $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("float[" & $iCount * 2 & "]")
    $pPoints = DllStructGetPtr($tPoints)
    For $iI = 1 To $iCount
        DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1)
        DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2)
    Next
    $aResult = DllCall($ghGDIPDll, "uint", "GdipAddPathLine2", "hwnd", $hPath, "ptr", $pPoints, "int", $iCount)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PathAddLines
Func _GDIPlus_PathDispose($hPath)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PathDispose
Func _GDIPlus_CustomLineCapCreate($hPathFill, $hPathStroke, $iLineCap = 0, $nBaseInset = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateCustomLineCap", "hwnd", $hPathFill, "hwnd", $hPathStroke, "int", $iLineCap, "float", $nBaseInset, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[5]
EndFunc   ;==>_GDIPlus_CustomLineCapCreate
Func _GDIPlus_CustomLineCapSetStrokeCaps($hCustomLineCap, $iStartCap, $iEndCap)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetCustomLineCapStrokeCaps", "hwnd", $hCustomLineCap, "int", $iStartCap, "int", $iEndCap)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_CustomLineCapSetStrokeCaps
Func _GDIPlus_CustomLineCapGetStrokeCaps($hCustomLineCap)
    Local $aCaps[2], $aResult
    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetCustomLineCapStrokeCaps", "hwnd", $hCustomLineCap, "int*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, -1)
    If $aResult[0] Then Return -1
    $aCaps[0] = $aResult[2]
    $aCaps[1] = $aResult[3]
    Return $aCaps
EndFunc   ;==>_GDIPlus_CustomLineCapGetStrokeCap
Func _GDIPlus_PenSetLineCap($hPen, $iStartCap, $iEndCap, $iDashCap)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetPenLineCap197819", "hwnd", $hPen, "int", $iStartCap, "int", $iEndCap, "int", $iDashCap)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PenSetLineCap

You have to do some clever work how to repos clock that it will not move to left upper corner!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

It creates an empty bitmap with the new size. This bitmap will be used for the transparent GUI.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 7 years later...
#include <Date.au3>
#Include <Timers.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <String.au3>
#include <GuiMenu.au3>
#include <Misc.au3>
#include <WinAPISysWin.au3>
#include <GDIPlus.au3>

Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $hGUI, $hGraphics, $hBackbuffer, $hBitmap, $hPen1, $hPen2, $hPen3, $hPen4
Global $iWidth = 600, $iHeight = $iWidth, $iW = $iWidth, $iH = $iHeight
Global Const $p2_hm = $iWidth / 35
Global Const $p3_hm = $iWidth / 35
Global Const $p4_hm = $iWidth / 100
Global $newY = $iWidth, $newX = $iHeight
Global Const $minSize = $iWidth * 0.25
Global Const $maxSize = $iWidth * 1.5
Global Const $cX = $iWidth * 0.5, $cY = $iHeight * 0.5
Global Const $deg = ACos(-1) / 180
Global Const $radius = $iWidth * 0.85, $cR = $radius * 0.50
Global Const $cR1 = $cR * 0.90, $cR2 = $cR * 0.20
Global Const $cR3 = $cR * 0.80, $cR4 = $cR * 0.15
Global Const $cR5 = $cR * 0.50, $cR6 = $cR * 0.10
Global $sek = @SEC * 6 - 90
Global $min = @MIN * 6 + (@SEC / 10) - 90
Global $std = @HOUR * 30 + (@MIN / 2) - 90
Global Const $fs = $iHeight / 30, $tms = $iHeight / 20, $tmh = $iHeight * 0.725
Global $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $x5, $x6, $y5, $y6, $tm
Global $T_Font, $T_Brush, $T_Format, $T_Family, $T_Layout, $T_String
Global $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint, $gdibitmap
Global $contextmenu, $button, $buttoncontext, $buttonitem
Global $newsubmenu, $textitem, $fileitem, $saveitem, $infoitem
Global  $SliderGUI,$Trans, $Trans_Handle, $Size, $Size_Handle, $TransValue, $SizeValue
Global Enum  $item1 = 1000, $item2, $item3

Global $title = "GDI+ Simple Clock by UEZ 2011 / "
Opt("GUIOnEventMode", 1)
; ====== Create Properties GUI but hide it =====================
$SliderGUI =GUICreate("Properties", 220, 150, 100, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "SliderGUIhide",$SliderGUI)
GUICtrlCreateLabel("Transparency",20,5)
$Trans = GUICtrlCreateSlider(10, 20, 200, 20)
$Trans_Handle = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 255, 0)  ; change min/max value
GUICtrlSetData($Trans, 125)  ; set cursor
GUICtrlCreateLabel("Size",20,50)
$Size = GUICtrlCreateSlider(10, 65, 200, 20)
$Size_Handle = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 100, 10)  ; change min/max value
GUICtrlSetData($Size, 100)   ; set cursor

GUISetState(@SW_HIDE, $SliderGUI)
GUIRegisterMsg($WM_HSCROLL, "WM_H_Slider")
;==============================================================
; Initialize GDI+
_GDIPlus_Startup()
$hGUI = GUICreate($title, $iWidth, $iHeight, -1, -1, 0, $WS_EX_LAYERED + $WS_EX_TOPMOST)
;If @OSBuild < 7600 Then WinSetTrans($hGui,"", 0xFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") ;Adjust Trans

$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)

; _WinAPI_UpdateLayeredWindow parameters
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $iWidth)
DllStructSetData($tSize, "Y", $iHeight)

$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)

Global $alpha =200
Global $alpha_steps = 5
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $alpha)
DllStructSetData($tBlend, "Format", 1)


$tPoint = DllStructCreate($tagPOINT) ; For Custom Line Caps
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)

GuiSetState()
Global $aPos = WinGetPos($hGUI)
;GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU")
GUIRegisterMsg($WM_NCHITTEST,   "WM_NCHITTEST") ;Drag Window
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") ;Adjust Trans
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
$ScreenDc = _WinAPI_GetDC($hGUI)
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbitmap)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
_WinAPI_SelectObject($dc, $gdibitmap)
; Using antialiasing
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
;~ DllCall($__g_hGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hBackbuffer, "int", 3)
; Create a Pen object
$hPen1 = _GDIPlus_PenCreate(0xFF800010, 4)
$hPen2 = _GDIPlus_PenCreate(0xA01010F0,  $p2_hm)
$hPen3 = _GDIPlus_PenCreate(0xA01010F0,  $p3_hm)
$hPen4 = _GDIPlus_PenCreate(0x9010D040,  $p4_hm)
Global Const  $LineCapRound = 2,  $LineCapTriangle = 3, $DashCapFlat = 0
Global $hPath, $hCustomLineCap, $avCaps
Global $avPoints[3][2] = [[2], [0, 0], [0, 0]]
$hPath = _GDIPlus_PathCreate()
_GDIPlus_PathAddLines($hPath, $avPoints)
$hCustomLineCap = _GDIPlus_CustomLineCapCreate(0, $hPath)
_GDIPlus_CustomLineCapSetStrokeCaps($hCustomLineCap, $LineCapTriangle, $LineCapRound)
$avCaps = _GDIPlus_CustomLineCapGetStrokeCaps($hCustomLineCap)
_GDIPlus_PenSetLineCap($hPen2, $avCaps[0], $avCaps[1], $DashCapFlat)
_GDIPlus_PenSetLineCap($hPen3, $avCaps[0], $avCaps[1], $DashCapFlat)
_GDIPlus_PenSetLineCap($hPen4, $avCaps[0], $avCaps[1], $DashCapFlat)
Global $ws = WinGetPos($hGUI)
Global $ratio = $ws[3] / $ws[2]
Global $font = "Comic Sans MS"
If FileExists(@WindowsDir & "\fonts\showg.ttf") Then $font = "Showcard Gothic"

;Time init
  $T_Brush = _GDIPlus_BrushCreateSolid(0xFF008080)
  $T_Format = _GDIPlus_StringFormatCreate()
  $T_Family = _GDIPlus_FontFamilyCreate("Verdana")
  $T_Font   = _GDIPlus_FontCreate ($T_Family, 32, 3)
  $T_Layout = _GDIPlus_RectFCreate(0, 0, $iWidth, 80)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
AdlibRegister("Ticker", 50)

Global $timer = 100,  $speak = False, $speak_init = True, $SpeakingClock = True
Global $oVoice = ObjCreate("SAPI.SpVoice")
If @error Then
    $speak_init = False
Else
    $oVoice.Rate = -3
EndIf
GUIRegisterMsg($WM_TIMER, "Draw") ;$WM_TIMER = 0x0113
DllCall("User32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $timer, "int", 0)
AdlibRegister( "SpeakingClock", 1000)
While Sleep(100000000)
WEnd
Func Draw()
    _GDIPlus_GraphicsClear($hBackbuffer, 0x00000000)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX - $cR, $cY, $cX - $cR + 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX + $cR, $cY, $cX + $cR - 35, $cY, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY - $cR, $cX, $cY - $cR + 35, $hPen1)
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $cX, $cY + $cR, $cX, $cY + $cR - 35, $hPen1)
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $cX - $cR, $cY - $cR, $radius, $radius, $hPen1)
    For $i = 0 To 11
        _GDIPlus_GraphicsDrawString($hBackbuffer, $i + 1, -$fs / 2 + $cX + Cos(-45 + $i * 29.7 * $deg) * $cR3, -$fs * 0.9 + $cY + Sin(-45 + $i * 29.7 * $deg) * $cR3, $font, $fs)
    Next
    If Int(StringLeft(_NowTime(4), 2) / 12) Then
        $tm = "PM"
    Else
        $tm = "AM"
    EndIf
    _GDIPlus_GraphicsDrawString($hBackbuffer, $tm,  -$tms * 1.1 + $cX, $tmh, $font, $tms)
    $x5 = $cX + Cos($std * $deg) * $cR5
    $y5 = $cY + Sin($std * $deg) * $cR5
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x5, $y5, $cX, $cY, $hPen2) ;hours
    $x3 = $cX + Cos($min * $deg) * $cR3
    $y3 = $cY + Sin($min * $deg) * $cR3
    _GDIPlus_GraphicsDrawLine($hBackbuffer, $x3, $y3, $cX, $cY, $hPen3) ;minutes
    $x1 = $cX + Cos($sek * $deg) * $cR1
    $y1 = $cY + Sin($sek * $deg) * $cR1
    $x2 = $cX + Cos(($sek + 180) * $deg) * $cR2
    $y2 = $cY + Sin(($sek + 180) * $deg) * $cR2
    _GDIPlus_GraphicsDrawLine($hBackbuffer, Floor($x1), Floor($y1), Floor($x2), Floor($y2), $hPen4) ;seconds
    _GDIPlus_GraphicsDrawEllipse($hBackbuffer, $cX - 3, $cY - 3, 6, 6, $hPen1)
; _GDIPlus_GraphicsDrawString($hBackbuffer, @HOUR & ":" & @MIN & ":" & @SEC, 0, 0)
;   <<<< ================= Digital Time =======================
    DrawTime()
;=================================================================
;Update layered Window
    Local $hBmp = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int",  0x0026200A, "ptr", 0, "int*", 0)
    $hBmp = $hBmp[6]
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBmp)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hBitmap, 0, 0, $iW, $iH)

    $gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
    _WinAPI_SelectObject($dc, $gdibitmap)
    DllStructSetData($tSize, "X", $iW)
    DllStructSetData($tSize, "Y", $iH)
    _WinAPI_UpdateLayeredWindow($hGUI, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
    _WinAPI_DeleteObject($gdibitmap)

   _WinAPI_RedrawWindow($hGUI)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBmp)
EndFunc
;=================================================================

; ================== Draw the digital time =============================
Func DrawTime()
  Local $sString, $aSize
  ;   WinSetTitle($hGui, "", $title & @HOUR & ":" & @MIN & ":" & @SEC)
  $sString = StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC)
  $aSize   = _GDIPlus_GraphicsMeasureString($hBackbuffer, $sString, $T_Font, $T_Layout, $T_Format)
  DllStructSetData($T_Layout, "X", (DllStructGetData($aSize[0], "Width")* 0.77))       ; Middle of Window
  DllStructSetData($T_Layout, "Y", (DllStructGetData($aSize[0], "Height")- 64 ))      ; Clock at Top
  _GDIPlus_GraphicsDrawStringEx($hBackbuffer, $sString, $T_Font, $T_Layout, $T_Format, $T_Brush)
EndFunc
; ============= Handle the WM_NCHITTEST message  ===============
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
Local $hMenu, $Win, $WinX, $WinY, $mX, $mY
if $hWnD = $hGUI and _IsPressed (01) then Return $HTCAPTION
if $hWnd = $hGUI and _IsPressed (02) then
; ConsoleWrite($GUI &" HIT!! "&@CRLF)
#cs
  $WinPos = WingetPos($GUI)
  $WinX = $WinPos[0]
  $WinY = $WinPos[0]

     $aPos = MouseGetPos()
  $mX = $aPos [0]
  $mY = $aPos [1]
  ConsoleWrite("MouseCoords = " &$WinX + $mX &" " &$WinY + $mY &@CRLF)
#ce
$hMenu = _GUICtrlMenu_CreatePopup ()
_GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Properties", $item1)
_GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Item 2", $item2)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "", 0)
_GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Exit", $item3)
_GUICtrlMenu_TrackPopupMenu ($hMenu, $hGUI, -1,-1 ,1,0 )
_GUICtrlMenu_DestroyMenu ($hMenu)
Return True
endif
EndFunc
;==========================================================================================
; =========  Handle WM_COMMAND messages =======================
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
Switch $iwParam
  Case $item1
   Properties()
   ConsoleWrite("Item 1 = " &$item1 &@CRLF)
  Case $item2
   ConsoleWrite("Item 2 = " &$item2 &@CRLF)
  Case $item3
   _Exit()
   ConsoleWrite("Item 3 = " &$item3 &@CRLF)
EndSwitch
EndFunc   ;==>WM_COMMAND
;=============================================================
Func Properties()
   GUISetState(@SW_SHOW, $SliderGUI)
EndFunc
Func SliderGUIhide()
GUISetState(@SW_HIDE, $SliderGUI)
EndFunc
; ============ React to slider movement ========================
Func WM_H_Slider($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    If $lParam = $Trans_Handle Then
        $TransValue = GUICtrlRead($Trans)
        DllStructSetData($tBlend, "Alpha", $TransValue)         ; Set Alpha (Transparency) Level
        DllStructSetData($tBlend, "Format", 1)
        ToolTip($TransValue)
    EndIf

    If $lParam = $Size_Handle Then
        $SizeValue = GUICtrlRead($Size)
        $iW = $iWidth * $SizeValue * 0.01
        $iH = $iHeight * $SizeValue * 0.01
    EndIf
Return "GUI_RUNDEFMSG"
EndFunc
;===============================================================
; MouseWheel for Win Trans
Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
  Local $mouseData, $n1
      $mouseData = _WinAPI_HiWord($wParam) ;/ $WHEEL_DELTA
Select
;Case $wParam = $WM_MOUSEWHEEL And WinActive($GUI)
;WM_MOUSEWHEEL = 0x020A
Case WinActive($hGUI)
   If $mouseData > 0 Then ;wheel up
    If $alpha + $alpha_steps <= 512 Then $alpha += $alpha_steps
    Switch $alpha
     Case 0 To 255
      DllStructSetData($tBlend, "Alpha", $alpha)          ; Set Alpha (Transparency) Level
      DllStructSetData($tBlend, "Format", 1)
     Case 256 To 512
      DllStructSetData($tBlend, "Alpha", $alpha - 256)
      DllStructSetData($tBlend, "Format", 0)
    EndSwitch
   Else ;wheel down
    If $alpha - $alpha_steps > 0 Then $alpha -= $alpha_steps
    Switch $alpha
     Case 0 To 255
      DllStructSetData($tBlend, "Alpha", $alpha) ;wheel up
      DllStructSetData($tBlend, "Format", 1)
     Case 256 To 512
      DllStructSetData($tBlend, "Alpha", $alpha - 256) ;wheel up
      DllStructSetData($tBlend, "Format", 0)
    EndSwitch
   EndIf
   ConsoleWrite($alpha & @CRLF)
EndSelect
EndFunc ;==>WM_MOUSEWHEEL

Func SpeakingClock()
;   If  $min = -90.00 And $speak_init And $SpeakingClock Then $oVoice.Speak("It is " & Mod(@HOUR, 12) & " " & $tm, 1)
EndFunc

Func Ticker()
    $sek = @SEC * 6 - 90
    $min = @MIN * 6 + (@SEC * 0.10) - 90
    $std = @HOUR * 30 + (@MIN * 0.50) - 90
EndFunc
Func _Exit()
    AdlibUnRegister("Ticker")
    AdlibUnRegister("SpeakingClock")
    $oVoice = 0
    GUIRegisterMsg($WM_TIMER, "")
    GUIRegisterMsg($WM_GETMINMAXINFO, "")
    GUIRegisterMsg($WM_SIZE, "")
    GUIRegisterMsg($WM_ERASEBKGND, "")
    GUIRegisterMsg($WM_SIZING, "")
_WinAPI_DeleteDC($dc)
    _WinAPI_ReleaseDC($hGUI, $ScreenDc)
    ; Clean up GDI+ resources
    _GDIPlus_CustomLineCapDispose($hCustomLineCap)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_PenDispose($hPen3)
    _GDIPlus_PenDispose($hPen4)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hBackbuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
  _GDIPlus_FontDispose      ($T_Font  )
  _GDIPlus_FontFamilyDispose  ($T_Family)
  _GDIPlus_StringFormatDispose($T_Format)
  _GDIPlus_BrushDispose    ($T_Brush)
    ; Uninitialize GDI+
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc
;~ Func _GDIPlus_PathCreate($iFillMode = 0)
;~     Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipCreatePath", "int", $iFillMode, "int*", 0)
;~     If @error Then Return SetError(@error, @extended, 0)
;~     Return $aResult[2]
;~ EndFunc   ;==>_GDIPlus_PathCreate
Func _GDIPlus_PathAddLines($hPath, $aPoints)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult
    $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("float[" & $iCount * 2 & "]")
    $pPoints = DllStructGetPtr($tPoints)
    For $iI = 1 To $iCount
        DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1)
        DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2)
    Next
    $aResult = DllCall($__g_hGDIPDll, "uint", "GdipAddPathLine2", "hwnd", $hPath, "ptr", $pPoints, "int", $iCount)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_PathAddLines
;~ Func _GDIPlus_PathDispose($hPath)
;~     Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
;~     If @error Then Return SetError(@error, @extended, False)
;~     Return $aResult[0] = 0
;~ EndFunc   ;==>_GDIPlus_PathDispose
;~ Func _GDIPlus_CustomLineCapCreate($hPathFill, $hPathStroke, $iLineCap = 0, $nBaseInset = 0)
;~     Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipCreateCustomLineCap", "hwnd", $hPathFill, "hwnd", $hPathStroke, "int", $iLineCap, "float", $nBaseInset, "int*", 0)
;~     If @error Then Return SetError(@error, @extended, 0)
;~     Return $aResult[5]
;~ EndFunc   ;==>_GDIPlus_CustomLineCapCreate
;~ Func _GDIPlus_CustomLineCapSetStrokeCaps($hCustomLineCap, $iStartCap, $iEndCap)
;~     Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipSetCustomLineCapStrokeCaps", "hwnd", $hCustomLineCap, "int", $iStartCap, "int", $iEndCap)
;~     If @error Then Return SetError(@error, @extended, False)
;~     Return $aResult[0] = 0
;~ EndFunc   ;==>_GDIPlus_CustomLineCapSetStrokeCaps
;~ Func _GDIPlus_CustomLineCapGetStrokeCaps($hCustomLineCap)
;~     Local $aCaps[2], $aResult
;~     $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetCustomLineCapStrokeCaps", "hwnd", $hCustomLineCap, "int*", 0, "int*", 0)
;~     If @error Then Return SetError(@error, @extended, -1)
;~     If $aResult[0] Then Return -1
;~     $aCaps[0] = $aResult[2]
;~     $aCaps[1] = $aResult[3]
;~     Return $aCaps
;~ EndFunc   ;==>_GDIPlus_CustomLineCapGetStrokeCap
;~ Func _GDIPlus_PenSetLineCap($hPen, $iStartCap, $iEndCap, $iDashCap)
;~     Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipSetPenLineCap197819", "hwnd", $hPen, "int", $iStartCap, "int", $iEndCap, "int", $iDashCap)
;~     If @error Then Return SetError(@error, @extended, False)
;~     Return $aResult[0] = 0
;~ EndFunc   ;==>_GDIPlus_PenSetLineCap

as there have been improvements since 2011 in autoit follows the listing modified to 2019 ok
Thanks Ues for your skill.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...