I tried to use the example with #BS_OWNERDRAW, but there is no hover event in it. There is a pressed button event - #ODS_SELECTED.
I tried the #
BCN_HOTITEMCHANGE event, but it doesn't work together with #BS_OWNERDRAW. I've tried disabling all button border styles, but that doesn't work. Using GetDC_() grabs the area of the button, but it doesn't include the button's borders, so I can't paint them and get rid of them.
When using Canvas, the size of the program increases by 40 kb, and the size of my program is 70 kb. I would not want to attach an airplane engine to a bicycle.
Code: Select all
EnableExplicit
Global hIcon
; START for button icon
#Library = 0
InitCommonControls_() ; инициализация классов элементов управления
If OpenLibrary(#Library,"comctl32.dll")
Prototype ImageList_AddIcon(List, Icon)
Global ImageList_AddIcon.ImageList_AddIcon
ImageList_AddIcon=GetFunction(#Library,"ImageList_AddIcon")
CloseLibrary(#Library)
EndIf
#BCM_FIRST = $1600
#BCM_SETIMAGELIST = #BCM_FIRST + 2
#BUTTON_IMAGELIST_ALIGN_LEFT = 0
Procedure AddIconToButton(ButtonID,IconID,s = 16)
Protected buttonImgList.BUTTON_IMAGELIST
Protected himlIcons
himlIcons = ImageList_Create_(s,s, #ILC_MASK | #ILC_COLOR32, 1, 0)
ImageList_AddIcon(himlIcons, IconID)
With buttonImgList
\uAlign = #BUTTON_IMAGELIST_ALIGN_LEFT
\margin\top = 3
\margin\bottom = 3
\margin\left = 3
\margin\right = 3
\himl = himlIcons
EndWith
SendMessage_(ButtonID, #BCM_SETIMAGELIST, 0, buttonImgList)
EndProcedure
; END for button icon
#BS_COMMANDLINK = 14
#BS_SPLITBUTTON = 12
If OpenWindow(0, 0, 0, 220, 100, "Example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget (0, 10, 10, 200, 40, "close", #BS_COMMANDLINK)
; ButtonGadget (1, 10, 50, 200, 30, "close", #BS_DEFPUSHBUTTON)
; HyperLinkGadget(0, 10, 10, 200, 30, "close", $FF0000, #BS_BITMAP | #BS_ICON)
; TextGadget(0, 10, 10, 200, 30, "close")
; CheckBoxGadget(0, 10, 10, 200, 30, "close")
; SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) ! #BS_AUTOCHECKBOX)
; SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) ! #BS_DEFPUSHBUTTON)
; SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) ! #BS_DEFPUSHBUTTON)
If ExtractIconEx_("shell32.dll", 4,0,@hIcon,1)
AddIconToButton(GadgetID(0), hIcon, 16)
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 1
CloseWindow(0)
End
EndSelect
Case #PB_Event_CloseWindow
CloseWindow(0)
End
EndSelect
ForEver
EndIf