Jump to content

Recommended Posts

I want to create a Pause/Continue button styled by the class from the visual style, I don't know how to use the second four images for the state. The visual style uses a ribbon of eight images — four to display pause status and four to display resume status. In the following example, the button displays only the first four images - the paused state. How to use the second four images?

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <WinAPITheme.au3>
#include <GuiImageList.au3>

Local $GUI = GUICreate('', 200, 100)

Local $but = GUICtrlCreateButton('', 50, 50, 17, 16) ;_GUICtrlButton_Create($GUI, '', 50, 50, 17, 16)

_Winapi_SetWindowTheme(GUICtrlGetHandle($but), '', 'Pause')
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

 

Безымянный.png

Link to post
Share on other sites

I only managed to do it the hard way, to draw with _WinAPI_DrawThemeBackground

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPITheme.au3>
#include <WinAPIGdi.au3>
#include <WinAPISysWin.au3>


Local $GUI = GUICreate('', 200, 100)

Local $but = GUICtrlCreatePic('', 50, 50, 17, 16)
_GUICtrlSetTheme(-1, 'Pause', 1, 1, 17, 16)
GUISetState()

For $i = 1 To 8
   _GUICtrlSetTheme($but, 'Pause', 1, $i, 17, 16)
   Sleep(1000)
Next

;Do
;Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _GUICtrlSetTheme($CTRL, $Class, $Part, $Stat, $width, $height)
    Local $hCTRL = GUICtrlGetHandle($CTRL)
    Local $hDev = _WinAPI_GetDC($hCTRL)
    Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
    Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, $width, $height, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
    Local $hSv = _WinAPI_SelectObject($hDC, $hSource)
    Local $tRECT = _WinAPI_CreateRectEx(0, 0, $width, $height)
    Local $hTheme = _WinAPI_OpenThemeData(0, $Class)
    _WinAPI_DrawThemeBackground($hTheme, $Part, $Stat, $hDC, $tRECT)
    _WinAPI_CloseThemeData($hTheme)
    Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, $width, $height)
    _WinAPI_SelectObject($hDC, $hBitmap)
    _WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
    _WinAPI_ReleaseDC($hCTRL, $hDev)
    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteDC($hDC)
    _WinAPI_DeleteObject(_SendMessage($hCTRL, $STM_SETIMAGE, 0, $hBitmap))
    Local $hWnd = _WinAPI_GetAncestor($hCTRL, $GA_ROOT)
    Local $Pos = ControlGetPos($hWnd, '', $hCTRL)
    If @error Then Return
    _WinAPI_InvalidateRect($hWnd, _WinAPI_CreateRectEx($pos[0], $pos[1], $width, $height), True)
EndFunc

 

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

    No registered users viewing this page.

×
×
  • Create New...