Jump to content

GDI+ Text each line with own colour?


Go to solution Solved by AutoBert,

Recommended Posts

Posted

I want to make a Calendar App, therefor i played with some GDI+ scripts i found for creating a Gui for each day in month. Following script (Original was coded by @UEZ build 2015-05-13) seems to be the best to modify for my needs:

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global Const $hImage_Icon = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\merlin.gif")
Global Const $ahGUI = _GDIPlus_CreateW10TrayWin("Done with AutoIt", "This little example was created with" & @CRLF & "AutoIT, using GDI+." &@CRLF & "Original coded by UEZ" & @CRLF & "                      Have fun. ;-)", _
                                                $hImage_Icon, 10, 10, 144, 108)
;                                                $hImage_Icon, @DesktopWidth - 370, @DesktopHeight - 150)
WinSetTrans($ahGUI[0], "", 0xF4)
GUISetState(@SW_SHOW, $ahGUI[0])

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $ahGUI[1]
            _GDIPlus_ImageDispose($hImage_Icon)
            GUIDelete($ahGUI[0])
            Exit
    EndSwitch
Until False

;coded by UEZ build 2015-05-13
Func _GDIPlus_CreateW10TrayWin($sTitle, $sText, $hBmp_Icon = 0, $iGUIPosX = -1, $iGUIPosY = -1, $iW = 360, $iH = 100, $sFontName = "Palatino Linotype", $fFontSize = 8, $iBgColor = 0xFF1F1F1F, $iTitleColor = 0xFFF8F8F8, $iTextColor = 0xFFA0A0A0)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $hGUI_W10TW = GUICreate($sTitle, $iW, $iH, $iGUIPosX, $iGUIPosY, $WS_POPUP)
    Local Const $iLable_Drag = GUICtrlCreateLabel("", 0, 0, $iW, 11, -1, $GUI_WS_EX_PARENTDRAG)
    Local Const $iPicBg_W10TW = GUICtrlCreatePic("", 0, 0, $iW, $iH)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local Const $iPicIcon_W10TW = GUICtrlCreatePic("", 2, 12, 32, 32)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local Const $iBtn_W10TW = GUICtrlCreateLabel("X", $iW + 25, 14, 10, 10, BitOR($SS_CENTER, $SS_SIMPLE)) ;absichtlich ausserhalb wird nicht benötigt
    GUICtrlSetFont(-1, 8, 200, 0, "Arial")
    GUICtrlSetBkColor(-1, BitAND($iBgColor, 0x00FFFFFF))
    GUICtrlSetColor(-1, 0xF0F0F0)
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 5)
    _GDIPlus_GraphicsClear($hGfx, $iBgColor)
    Local $hBmp_GDI
    Local $hPen_Border = _GDIPlus_PenCreate(0xFF484848)
    Local Const $hBrush_TextTitle = _GDIPlus_BrushCreateSolid($iTitleColor), $hBrush_Text = _GDIPlus_BrushCreateSolid($iTextColor)
    _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iW - 1, $iH - 1, $hPen_Border)
;$sTitle = 'So 6. Aug. 2023'
    Local $tLayout_Title = _GDIPlus_RectFCreate(36, 13, $iW - 20, 16)
    Local Const $hFormat_Title = _GDIPlus_StringFormatCreate()
    Local Const $hFamily_Title = _GDIPlus_FontFamilyCreate($sFontName)
    Local Const $hFont_Title = _GDIPlus_FontCreate($hFamily_Title, $fFontSize+2, 1)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $sTitle, $hFont_Title, $tLayout_Title, $hFormat_Title, $hBrush_TextTitle)

    Local $tLayout_Text = _GDIPlus_RectFCreate(3, 33, $iW - 10, $iH - 15)
    Local Const $hFormat_Text = _GDIPlus_StringFormatCreate()
    Local Const $hFamily_Text = _GDIPlus_FontFamilyCreate($sFontName)
    Local Const $hFont_Text = _GDIPlus_FontCreate($hFamily_Title, $fFontSize)
    _GDIPlus_GraphicsDrawStringEx($hGfx, '           ' & $sText, $hFont_Text, $tLayout_Text, $hFormat_Text, $hBrush_Text) ;the spaces are needed for protecting merlin from overlapping

    $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBg_W10TW, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_GDI))
    _WinAPI_DeleteObject($hBmp_GDI)
    _GDIPlus_FontDispose($hFont_Title)
    _GDIPlus_FontFamilyDispose($hFamily_Title)
    _GDIPlus_StringFormatDispose($hFormat_Title)
    _GDIPlus_FontDispose($hFont_Text)
    _GDIPlus_FontFamilyDispose($hFamily_Text)
    _GDIPlus_StringFormatDispose($hFormat_Text)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_BrushDispose($hBrush_Text)
    _GDIPlus_BrushDispose($hBrush_TextTitle)
    _GDIPlus_PenDispose($hPen_Border)
    If $hBmp_Icon Then
        Local $aDim = _GDIPlus_ImageGetDimension($hBmp_Icon), $fScaleX, $fScaleY
        If $aDim[0] >= $aDim[1] Then
            $fScaleX = 32 / $aDim[0]
            $fScaleY = $fScaleX
        ElseIf $aDim[0] < $aDim[1] Then
            $fScaleY = 32 / $aDim[1]
            $fScaleX = $fScaleY
        EndIf
        Local Const $hBmp_tmp = _GDIPlus_ImageScale($hBmp_Icon, $fScaleX, $fScaleY)
        $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp_tmp)
        _WinAPI_DeleteObject(GUICtrlSendMsg($iPicIcon_W10TW, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_GDI))
        _GDIPlus_BitmapDispose($hBmp_tmp)
        _WinAPI_DeleteObject($hBmp_GDI)
    EndIf
    Local $aGUI_W10TW[2] = [$hGUI_W10TW, $iBtn_W10TW]
    Return $aGUI_W10TW
EndFunc   ;==>_GDIPlus_CreateW10TrayWin

it is a little bit modified (posioning, fontsizing, text) to see the posibilities. It's nearly perfect but enabling coloring each textline in different colour seems to be needed, as i will use this lines for extrainformation like BirthDay, holidays etc. 

But GDI is a nightmare of me, so i hope to get here a simple solution 

mfg (auto)Bert

  • Solution
Posted

I got one solution myself:

 

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
_GDIPlus_Startup()
Global Const $hImage_Icon = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\merlin.gif")
Global Const $ahGUI = _GDIPlus_CreateW10TrayWin("Done with AutoIt", "This little example" & @CRLF & "was created with" & @CRLF & "AutoIT, using GDI+." &@CRLF & "Original coded by UEZ" & @CRLF & "                      Have fun. ;-)", _
                                                $hImage_Icon, 10, 10, 144, 108)
;                                                $hImage_Icon, @DesktopWidth - 370, @DesktopHeight - 150)
WinSetTrans($ahGUI[0], "", 0xF4)
GUISetState(@SW_SHOW, $ahGUI[0])
ConsoleWrite(WinGetTitle($ahGUI) & @crlf)
Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $ahGUI[1]
            _GDIPlus_ImageDispose($hImage_Icon)
            GUIDelete($ahGUI[0])
            Exit
    EndSwitch
Until False

;Original coded by UEZ build 2015-05-13
;modified autoBert 2022-10-07
Func _GDIPlus_CreateW10TrayWin($sTitle, $sText, $hBmp_Icon = 0, $iGUIPosX = -1, $iGUIPosY = -1, $iW = 360, $iH = 100, $sFontName = "Palatino Linotype", $fFontSize = 8, $iBgColor = 0xFF1F1F1F, $iTitleColor = 0xFFF8F8F8, $iTextColor = 0xFFA0A0A0)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $hGUI_W10TW = GUICreate($sTitle, $iW, $iH, $iGUIPosX, $iGUIPosY, $WS_POPUP)
    Local Const $iLable_Drag = GUICtrlCreateLabel("", 0, 0, $iW, 11, -1, $GUI_WS_EX_PARENTDRAG)
    Local Const $iPicBg_W10TW = GUICtrlCreatePic("", 0, 0, $iW, $iH)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local Const $iPicIcon_W10TW = GUICtrlCreatePic("", 2, 12, 32, 32)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local Const $iBtn_W10TW = GUICtrlCreateLabel("X", $iW + 25, 14, 10, 10, BitOR($SS_CENTER, $SS_SIMPLE)) ;absichtlich ausserhalb wird nicht benötigt
    GUICtrlSetFont(-1, 8, 200, 0, "Arial")
    GUICtrlSetBkColor(-1, BitAND($iBgColor, 0x00FFFFFF))
    GUICtrlSetColor(-1, 0xF0F0F0)
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 5)
    _GDIPlus_GraphicsClear($hGfx, $iBgColor)
    Local $hBmp_GDI
    Local $hPen_Border = _GDIPlus_PenCreate(0xFF484848)
    Local Const $hBrush_TextTitle = _GDIPlus_BrushCreateSolid($iTitleColor), $hBrush_Text = _GDIPlus_BrushCreateSolid($iTextColor)
    _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iW - 1, $iH - 1, $hPen_Border)
;$sTitle = 'So 6. Aug. 2023'
    Local $tLayout_Title = _GDIPlus_RectFCreate(36, 13, $iW - 20, 16)
    Local Const $hFormat_Title = _GDIPlus_StringFormatCreate()
    Local Const $hFamily_Title = _GDIPlus_FontFamilyCreate($sFontName)
    Local Const $hFont_Title = _GDIPlus_FontCreate($hFamily_Title, $fFontSize+2, 1)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $sTitle, $hFont_Title, $tLayout_Title, $hFormat_Title, $hBrush_TextTitle)
    Local $aSplit = StringSplit($sText, @CRLF, 3)
    _ArrayDisplay($aSplit)
    Local $tLayout_Text1 = _GDIPlus_RectFCreate(3, 32, $iW - 10, $iH - 15)
    Local Const $hFormat_Text = _GDIPlus_StringFormatCreate()
    Local Const $hFamily_Text = _GDIPlus_FontFamilyCreate($sFontName)
    Local Const $hFont_Text = _GDIPlus_FontCreate($hFamily_Title, $fFontSize)
    _GDIPlus_GraphicsDrawStringEx($hGfx, '           ' & $aSplit[0], $hFont_Text, $tLayout_Text1, $hFormat_Text, $hBrush_Text)
    Local $tLayout_Text2 = _GDIPlus_RectFCreate(3, 51, $iW - 10, $iH - 35)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFFFF0000)
   _GDIPlus_GraphicsDrawStringEx($hGfx,  $aSplit[1], $hFont_Text, $tLayout_Text2, $hFormat_Text, $hBrush_Text)
    Local $tLayout_Text3 = _GDIPlus_RectFCreate(3, 70, $iW - 10, $iH - 55)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFF00FF00)
   _GDIPlus_GraphicsDrawStringEx($hGfx,  $aSplit[2], $hFont_Text, $tLayout_Text3, $hFormat_Text, $hBrush_Text)
    Local $tLayout_Text4 = _GDIPlus_RectFCreate(3, 89, $iW - 10, $iH - 75)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFF0000FF)
   _GDIPlus_GraphicsDrawStringEx($hGfx,  $aSplit[4], $hFont_Text, $tLayout_Text4, $hFormat_Text, $hBrush_Text)

    $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBg_W10TW, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_GDI))
    _WinAPI_DeleteObject($hBmp_GDI)
    _GDIPlus_FontDispose($hFont_Title)
    _GDIPlus_FontFamilyDispose($hFamily_Title)
    _GDIPlus_StringFormatDispose($hFormat_Title)
    _GDIPlus_FontDispose($hFont_Text)
    _GDIPlus_FontFamilyDispose($hFamily_Text)
    _GDIPlus_StringFormatDispose($hFormat_Text)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_BrushDispose($hBrush_Text)
    _GDIPlus_BrushDispose($hBrush_TextTitle)
    _GDIPlus_PenDispose($hPen_Border)
    If $hBmp_Icon Then
        Local $aDim = _GDIPlus_ImageGetDimension($hBmp_Icon), $fScaleX, $fScaleY
        If $aDim[0] >= $aDim[1] Then
            $fScaleX = 32 / $aDim[0]
            $fScaleY = $fScaleX
        ElseIf $aDim[0] < $aDim[1] Then
            $fScaleY = 32 / $aDim[1]
            $fScaleX = $fScaleY
        EndIf
        Local Const $hBmp_tmp = _GDIPlus_ImageScale($hBmp_Icon, $fScaleX, $fScaleY)
        $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp_tmp)
        _WinAPI_DeleteObject(GUICtrlSendMsg($iPicIcon_W10TW, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_GDI))
        _GDIPlus_BitmapDispose($hBmp_tmp)
        _WinAPI_DeleteObject($hBmp_GDI)
    EndIf
    Local $aGUI_W10TW[2] = [$hGUI_W10TW, $iBtn_W10TW]
    Return $aGUI_W10TW
EndFunc   ;==>_GDIPlus_CreateW10TrayWin

 

Posted (edited)

I could offer you this:

Edit:

Here is an example script to display colorful lines 

#include "GDIP_AsciiGamework_include.au3"
;;Startup and en ding
Initialize(320, 200)   ;Initialize GDI and Fonts

GameDemoTemplate()         ;Game Loop

CleanUp()        ;Stop Gdi and free the ressources


Func GameDemoTemplate()
    $guiQuit = 0        ;Always reset the $guiQuit to 0


    While Delay(140) = 0
        CLS("000000")
        $co = ""
        $co1 = "ff000000ff000000ffaabbccddee00006060303030206080806020554433"

        Font("Arial", 15)
         $z=0

        For $x = 0 To 9
            For $y = 0 To 3

                $co = StringMid($co1, ($z*6)+1 , 6)
                $z=$z+1
                if $z>9 then $z=0
                color($co)
                Print("Color", $y * 58, $x * 16)
            Next
        Next
        ;   If Delay(500) = 1 Then ExitLoop 2      ;Alternative: Frame limiter - Exit the "for" and "while" loops when the close button (x) has been pressed.
    WEnd
EndFunc   ;==>GameDemoTemplate

 

Edited by Dan_555

Some of my script sourcecode

Posted

Now i have changed to make a control instead of a GUI:

#include-once
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <Date.au3>
;#include <_GetSunRiseAndSunSet.au3>

_GDIPlus_Startup()
Global Const $__g_hCalLeaf_Image = _GDIPlus_ImageLoadFromFile("c:\Program Files (x86)\AutoIt3\Examples\GUI\merlin.gif")

;#cs
test()

Func test()
    Local $hMain, $sDate
    Opt('GUIOnEventMode', 1)

    $hMain = GUICreate('Kalender: ' & _DateToMonth(@MON, $DMW_LOCALE_LONGNAME) & ' ' & @YEAR)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_CalLeaf_BitmapDispose')
    GUISetBkColor(0xFF1F1F1F)

    $sDate = StringFormat('%04i/%02i/%02i', @YEAR, @MON, @MDAY)
    ;;ConsoleWrite('rID: ' & $iID & @TAB & $sDate & @CRLF)
    _CreateCalLeaf($sDate, 'Zeile1|Zeile2|3|Zeile 4', 180, 155)
    ;GUICtrlSetOnEvent(-1, '_DateClick')
    GUISetState()
    While 1
        Sleep(5000)
    WEnd
EndFunc   ;==>test
;#ce

OnAutoItExitRegister('_CalLeaf_BitmapDispose')

;Original coded by UEZ build 2015-05-13
;modified autoBert 2022-10-07
Func _CreateCalLeaf($sTitle, $aText, $iGUIPosX = -1, $iGUIPosY = -1,  $iW = 168, $iH = 108, $sFontName = "Palatino Linotype", $fFontSize = 8, $iBgColor = 0xFF1F1F1F, $iTitleColor = 0xFFF8F8F8, $iTextColor = 0xFFA0A0A0, $hParent = 0)
    If Not IsArray($aText) Then $aText = StringSplit($aText & '|||', '|', 3)
    ;ConsoleWrite($iGUIPosX & '|' & $iGUIPosY & @TAB & $iW & '|' & $iH & @CRLF)
    Local $aDate, $aTime, $bIsDate = False
    _DateTimeSplit($sTitle, $aDate, $aTime)
    If Not @error Then
        $bIsDate = True
        ;Local $aSun = StringSplit(StringReplace(_GetSunriseAndSunset($iLat, $iLon, $iTimezone, $aDate[1], $aDate[2], $aDate[3]), 'Uhr', ''),' - ', 3)
        Local $aSun = StringSplit('07:31 - 18:45',' - ', 3)
        Local $iWeekday = _DateToDayOfWeek($aDate[1], $aDate[2], $aDate[3])
        Local $sMonth = _DateToMonth($aDate[2], $DMW_LOCALE_SHORTNAME)
        Local $sDay = StringFormat('%s %2i. %s. %04i', _DateDayOfWeek($iWeekday, $DMW_LOCALE_ShortNAME), $aDate[3], $sMonth, $aDate[1])
    EndIf
    ;ConsoleWrite($sDay & @CRLF)
    Local Const $STM_SETIMAGE = 0x0172
    Local $idCalLeaf = GUICtrlCreatePic("", $iGUIPosX, $iGUIPosY, $iW, $iH, $SS_NOTIFY) ;, $WS_POPUP, -1, $hParent)
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 2)
    _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 5)
    _GDIPlus_GraphicsClear($hGfx, $iBgColor)
    Local $hBmp_GDI
    Local $hPen_Border = _GDIPlus_PenCreate(0xFF484848)
    Local Const $hBrush_TextTitle = _GDIPlus_BrushCreateSolid($iTitleColor), $hBrush_Text = _GDIPlus_BrushCreateSolid($iTextColor)
    _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iW - 1, $iH - 1, $hPen_Border)
    Local $tLayout_Title = _GDIPlus_RectFCreate(36, 5, $iW - 36, 16)
    Local Const $hFormat_Title = _GDIPlus_StringFormatCreate()
    Local Const $hFamily_Title = _GDIPlus_FontFamilyCreate($sFontName)
    Local Const $hFont_Title = _GDIPlus_FontCreate($hFamily_Title, $fFontSize + 2, 1)
    If $bIsDate Then $sTitle = $sDay
    _GDIPlus_GraphicsDrawStringEx($hGfx, $sTitle, $hFont_Title, $tLayout_Title, $hFormat_Title, $hBrush_TextTitle)
    Local $tLayout_Text1 = _GDIPlus_RectFCreate(3, 32, $iW - 10, 20)
    Local Const $hFormat_Text = _GDIPlus_StringFormatCreate()
    Local Const $hFamily_Text = _GDIPlus_FontFamilyCreate($sFontName)
    Local $hFont_Text = _GDIPlus_FontCreate($hFamily_Title, $fFontSize)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $aText[0], $hFont_Text, $tLayout_Text1, $hFormat_Text, $hBrush_Text)
    Local $tLayout_Text2 = _GDIPlus_RectFCreate(3, 51, $iW - 10, 20)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFFFF0000)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $aText[1], $hFont_Text, $tLayout_Text2, $hFormat_Text, $hBrush_Text)
    Local $tLayout_Text3 = _GDIPlus_RectFCreate(3, 70, $iW - 10, 20)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFF00FF00)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $aText[2], $hFont_Text, $tLayout_Text3, $hFormat_Text, $hBrush_Text)
    Local $tLayout_Text4 = _GDIPlus_RectFCreate(3, 89, $iW - 10, 20)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFF0000FF)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $aText[3], $hFont_Text, $tLayout_Text4, $hFormat_Text, $hBrush_Text)
    Local $tLayout_SR = _GDIPlus_RectFCreate(1, 1, 32, 32)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFFDAA520)
    $hFont_Text = _GDIPlus_FontCreate($hFamily_Title, $fFontSize - 1)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $aSun[0], $hFont_Text, $tLayout_SR, $hFormat_Text, $hBrush_Text)
    Local $tLayout_SS = _GDIPlus_RectFCreate($iW -32, 1, 32, 32)
    _GDIPlus_BrushSetSolidColor($hBrush_Text, 0xFFFFD700)
    $hFont_Text = _GDIPlus_FontCreate($hFamily_Title, $fFontSize - 1)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $aSun[1], $hFont_Text, $tLayout_SS, $hFormat_Text, $hBrush_Text)

    $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idCalLeaf, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_GDI))
    _WinAPI_DeleteObject($hBmp_GDI)
    _GDIPlus_FontDispose($hFont_Title)
    _GDIPlus_FontFamilyDispose($hFamily_Title)
    _GDIPlus_StringFormatDispose($hFormat_Title)
    _GDIPlus_FontDispose($hFont_Text)
    _GDIPlus_FontFamilyDispose($hFamily_Text)
    _GDIPlus_StringFormatDispose($hFormat_Text)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_BrushDispose($hBrush_Text)
    _GDIPlus_BrushDispose($hBrush_TextTitle)
    _GDIPlus_PenDispose($hPen_Border)
    #cs
    If $hBmp_Icon Then
        Local $aDim = _GDIPlus_ImageGetDimension($hBmp_Icon), $fScaleX, $fScaleY
        If $aDim[0] >= $aDim[1] Then
            $fScaleX = 32 / $aDim[0]
            $fScaleY = $fScaleX
        ElseIf $aDim[0] < $aDim[1] Then
            $fScaleY = 32 / $aDim[1]
            $fScaleX = $fScaleY
        EndIf
        Local Const $hBmp_tmp = _GDIPlus_ImageScale($hBmp_Icon, $fScaleX, $fScaleY)
        $hBmp_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp_tmp)
        ;_WinAPI_DeleteObject(GUICtrlSendMsg($idCalLeaf, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp_GDI))
        _GDIPlus_BitmapDispose($hBmp_tmp)
        _WinAPI_DeleteObject($hBmp_GDI)
    EndIf
    #ce
    Return $idCalLeaf
EndFunc   ;==>_CreateCalLeaf

Func _CalLeaf_BitmapDispose()
    _GDIPlus_BitmapDispose($__g_hCalLeaf_Image)
    _GDIPlus_Shutdown()
    ConsoleWrite('Disposed!' & @CRLF)
    Exit
EndFunc   ;==>_CalLeaf_BitmapDispose

This version makes problems with the merlin, so there is no Image drawing possible.  But i'm still searching for drawing Icons and Text with GDI+ on a "GUICtrlCreatePic" created control.

mfg (auto)Bert

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
  • Recently Browsing   0 members

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