PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4

Author Topic: CXpButton  (Read 2159 times)

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #30 on: June 19, 2018, 08:13:59 AM »

Same file in .zip format.

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #31 on: June 19, 2018, 11:37:17 AM »

Also, don't forget that you can always get Jose's latest files from: https://github.com/JoseRoca/WinFBX
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #32 on: June 26, 2018, 09:04:11 PM »

Should the CXpButton's TextMargin and ImageMargin be adjusted based on DPI setting? It says that the incoming value should be specified as a pixel number (the default is 4 pixels). Should that value be upscaled when the control is drawn?   pWindow->ScaleX(m_TextMargin)
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #33 on: June 26, 2018, 09:35:09 PM »

Well, when I wrote it, DPI did not still existed... and I had not realized this detail when I did the translation. Maybe we can modify the control to scale this value and also m_ImageWidth, m_ImageHeight and m_ImageMargin.

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #34 on: June 26, 2018, 09:47:00 PM »

Thanks Jose, yes, I think the control should do the transformation of the ImageMargin and TextMargin values during the drawing routine. (not sure about the image scaling.. maybe let the user do that one in case they manually specify images based on dpi settings. Wouldn't want a 64px image to be scaled even bigger automatically).
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #35 on: June 26, 2018, 10:22:08 PM »

Then we will scale only the margins.

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #36 on: June 26, 2018, 10:57:05 PM »

Changed it to scale the margins.

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #37 on: June 26, 2018, 11:11:37 PM »

Thanks Jose, I will integrate this new version into the visual designer.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #38 on: June 30, 2018, 11:23:04 PM »

Hi Jose, I am working on the various properties of the CXpButton. It would seem to me that it would be easier to work with the control if the various items were implemented as Properties rather than functions. There are various functions to set colors for the background and various text states but no functions to retrieve those values. If implemented as properties then the it would eliminate the need to have a corresponding Get function.

eg.

Using Function approach:
SetButtonBkColor
GetButtonBkColor (this function does not exist)

Using Property approach:
ButtonBkColor( byval nValue as COLORREF )
ButtonBkColor () as COLORREF

Is it too late in this control's life to make such a large change? If it is too late, then maybe you could simply add the missing Get functions for the sake of completeness?

Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #39 on: July 01, 2018, 02:00:42 AM »

Now you have both functions and properties:

Code: [Select]
      ' // Properties
      DECLARE PROPERTY Font () AS HFONT
      DECLARE PROPERTY Font (BYVAL hFont AS HFONT)
      DECLARE PROPERTY TextFormat () AS DWORD
      DECLARE PROPERTY TextFormat (BYVAL dwTextFlags AS DWORD)
      DECLARE PROPERTY Cursor () AS HCURSOR
      DECLARE PROPERTY Cursor (BYVAL hCursor AS HCURSOR)
      DECLARE PROPERTY Toggle (BYVAL fToggle AS LONG)
      DECLARE PROPERTY Toggle () AS LONG
      DECLARE PROPERTY ToggleState () AS LONG
      DECLARE PROPERTY ToggleState (BYVAL fState AS LONG)
      DECLARE PROPERTY ImageWidth () AS LONG
      DECLARE PROPERTY ImageWidth (BYVAL nWidth AS LONG)
      DECLARE PROPERTY ImageHeight () AS LONG
      DECLARE PROPERTY ImageHeight (BYVAL nHeight AS LONG)
      DECLARE PROPERTY ImagePos () AS LONG
      DECLARE PROPERTY ImagePos (BYVAL nPos AS LONG)
      DECLARE PROPERTY ImageMargin () AS LONG
      DECLARE PROPERTY ImageMargin (BYVAL nMargin AS LONG)
      DECLARE PROPERTY ButtonState () AS LONG
      DECLARE PROPERTY ImageType () AS LONG
      DECLARE PROPERTY ButtonBkColor () AS COLORREF
      DECLARE PROPERTY ButtonBkColor (BYVAL bkColor AS COLORREF)
      DECLARE PROPERTY TextForeColor () AS COLORREF
      DECLARE PROPERTY TextForeColor (BYVAL textColor AS COLORREF)
      DECLARE PROPERTY TextBkColor () AS COLORREF
      DECLARE PROPERTY TextBkColor (BYVAL textColor AS COLORREF)
      DECLARE PROPERTY TextForeColorDown () AS COLORREF
      DECLARE PROPERTY TextForeColorDown (BYVAL textColor AS COLORREF)
      DECLARE PROPERTY TextBkColorDown () AS COLORREF
      DECLARE PROPERTY TextBkColorDown (BYVAL textColor AS COLORREF)
      DECLARE PROPERTY NormalImageHandle () AS HANDLE
      DECLARE PROPERTY HotImageHandle () AS HANDLE
      DECLARE PROPERTY DisabledImageHandle () AS HANDLE
      DECLARE PROPERTY BkBrush () AS HBRUSH

Functions have the advantage of the additional fRedraw parameter. Using properties on the fly, you may need to call the Redraw method separately.
« Last Edit: July 01, 2018, 02:03:02 AM by Josť Roca »
Logged

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #40 on: July 01, 2018, 08:02:00 AM »

Thanks Jose! Great job as always :)
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #41 on: July 01, 2018, 09:35:07 AM »

Here's another one.... 

Would be nice if CXpButton handled the WM_SETFONT message. I know that I can set it via the Font property but being able to WM_SETFONT to the control is easier based on the code I am using. WM_SETCURSOR is handled, but not WM_SETFONT.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #42 on: July 01, 2018, 11:49:46 AM »

This should work:

Code: [Select]
      CASE WM_SETFONT
         ' // Sets the font that a control is to use when drawing text.
         pButton = CAST(CXpButton PTR, .GetWindowLongPtrW(hwnd, 0))
         IF pButton THEN
            pButton->SetFont(CAST(.HFONT, wParam), lParam)
            EXIT FUNCTION
         END IF

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #43 on: July 01, 2018, 07:00:20 PM »

Thanks Jose, yes it seems to be working perfectly so far.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #44 on: July 09, 2018, 11:29:21 PM »

Hi Jose,

Maybe add code for the button to handle an incoming BM_CLICK message? I am sending the BM_CLICK message to the button designated as the default button when the ENTER key or ESC keys are pressed. This works perfectly for regular push buttons of course, but fails with the CXPButton button because it doesn't handle the BM_CLICK message.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor
Pages: 1 2 [3] 4