Thanks for the explanation, mk-soft, and for refining Rashad’s code.
Breaking the code into 2 separate elements makes it self explanatory and clears up its workings as well as the purpose of the parameters.
Excellent improvement.
ButtonGadget modify color by CallBack [Resolved]
Re: ButtonGadget modify color by CallBack [Resolved]
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Re: ButtonGadget modify color by CallBack [Resolved]
Hi AZJIO
Out of curiosity, I tried your code.
It needs to be reworked to make it DPi aware.
take a look :

On a high resolutions display, that is illegible.
(Of course, deselecting PB's DPi option makes the whole thing normal.)
Out of curiosity, I tried your code.
It needs to be reworked to make it DPi aware.
take a look :

On a high resolutions display, that is illegible.
(Of course, deselecting PB's DPi option makes the whole thing normal.)
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Re: ButtonGadget modify color by CallBack [Resolved]
When starting the program, calculate the DPI and add the coefficient where it is needed.
DesktopResolutionX()
GetDeviceCaps
DesktopResolutionX()
GetDeviceCaps
Re: ButtonGadget modify color by CallBack [Resolved]
Hmmm… seems that we may need a debate as to who should do such workAZJIO wrote: Sun Jun 25, 2023 7:56 pm When starting the program, calculate the DPI and add the coefficient where it is needed.[…]

i know how to make MY code DPi aware, so that my programs (or parts thereof) don’t appear as postage stamps on my display. I’m not so sure others do.
However, in the case that concerns us here, I was merely pointing out that your code is lacking in this respect.
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Re: ButtonGadget modify color by CallBack [Resolved]
I gave a link to the launcher in which this is done and works. I don't want to complicate the code where I showed examples of using other functions to draw a square border in different styles, since oval borders look messy. That is, I would not like to add DPI check, processor architecture, type of operating system to the code. For each DPI use case, the calculations will be different and depend on what you want to draw on the button. If you don't need a font and an icon, then you don't need DPI at all. You may need to calculate the size of the icon, for example 32x32, if it fits on the button. I cannot predict all the options that you may need, I just showed how to do it. There are function names, and you yourself will figure out mathematical calculations, I hope everyone studied at school.
Re: ButtonGadget modify color by CallBack [Resolved]
--------------------------------------------------------------------------------------------------
*** Never mind - I found the (very simple) solution ***
It was staring me in the face...
--------------------------------------------------------------------------------------------------
Question to mk-soft in particular, but anyone is welcome to answer.
I would like to display disabled buttons with a specific colour to mark them clearly as disabled.
I was thinking that the "natural" place for that would be in the DrawButtonCB() procedure (see mock-up below), but, so far, I haven't figured out how to identify disabled buttons... Any suggestion or solution ?
*** Never mind - I found the (very simple) solution ***
It was staring me in the face...
--------------------------------------------------------------------------------------------------
Question to mk-soft in particular, but anyone is welcome to answer.

I would like to display disabled buttons with a specific colour to mark them clearly as disabled.
I was thinking that the "natural" place for that would be in the DrawButtonCB() procedure (see mock-up below), but, so far, I haven't figured out how to identify disabled buttons... Any suggestion or solution ?
mk-soft wrote: Sun Jun 25, 2023 9:32 am [...]
But I would check the PB ID and the gadget type.
Code: Select all
[...] Procedure DrawButtonCB(wParam, *lParam.DRAWITEMSTRUCT) SetBkMode_(*lParam\hDC, #TRANSPARENT) If *lParam\itemState & #ODS_DISABLED ; <<< Solution : so simple... SelectObject_(*lParam\hDC, A_Brush_for_Disabled_Gadgets) SetTextColor_(*lParam\hDC, #A_Pale_Colour) ElseIf *lParam\itemState & #ODS_SELECTED SelectObject_(*lParam\hDC, BBrush) SetTextColor_(*lParam\hDC, $D9FEFE) Else SelectObject_(*lParam\hDC, TBrush) SetTextColor_(*lParam\hDC, $FF3028) EndIf [etc...] EndProcedure Procedure WCB(hWnd,uMsg,wParam,lParam) [etc...] EndProcedure [... rest of the code ...]
Last edited by Blue on Mon Jun 26, 2023 2:48 am, edited 1 time in total.
PB Forums : Proof positive that 2 heads (or more...) are better than one 

Re: ButtonGadget modify color by CallBack [Resolved]
You could have stopped right there, AZJIO.AZJIO wrote: Sun Jun 25, 2023 8:44 pm I gave a link to the launcher in which this is done and works.
A simple answer is sometimes all that's required.
I was * NOT * questioning your programming abilities.
PB Forums : Proof positive that 2 heads (or more...) are better than one 
