PlanetSquires Forums

Please login or register.

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

Author Topic: CXpButton  (Read 2160 times)

Paul Squires

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

Okay, I see what you've done... seems to work for as well. Only thing is that you don't get that visual depressed look when the button is pressed and then released.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

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

As an aside: I was reading about theming and noticed that the control doesn't respond to WM_THEMECHANGED
Code: [Select]
        case WM_THEMECHANGED:
            if(pData->hTheme)
                CloseThemeData(pData->hTheme);
            pData->hTheme = OpenThemeData(hwnd, wszClass);
            InvalidateRect(hwnd, NULL, TRUE);
            return 0;
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #17 on: June 16, 2018, 06:19:31 PM »

As an aside: I was reading about theming and noticed that the control doesn't respond to WM_THEMECHANGED
Code: [Select]
        case WM_THEMECHANGED:
            if(pData->hTheme)
                CloseThemeData(pData->hTheme);
            pData->hTheme = OpenThemeData(hwnd, wszClass);
            InvalidateRect(hwnd, NULL, TRUE);
            return 0;


It is not needed. I call OpenThemeData and CloseThemeData in UxDrawPushButton each time that the button is redrawn.

Paul Squires

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

Ahhhhhh...... :)
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #19 on: June 16, 2018, 06:27:54 PM »

Unfortunately, my studying for tonight now has to end as I have to go out for the night. :(

Good series of articles you've no doubt have already read  :)
https://www.codeproject.com/Articles/620045/Custom-Controls-in-Win-API-Visual-Styles

The guy who wrote them also maintains the mCtl project:
http://www.mctrl.org/
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #20 on: June 16, 2018, 06:43:59 PM »

Unfortunately, my studying for tonight now has to end as I have to go out for the night. :(

Good series of articles you've no doubt have already read  :)
https://www.codeproject.com/Articles/620045/Custom-Controls-in-Win-API-Visual-Styles

The guy who wrote them also maintains the mCtl project:
http://www.mctrl.org/


But this guy still has not learned how to write DPI aware controls :) The mCtl controls are unusable with High DPI settings.

« Last Edit: June 16, 2018, 06:47:35 PM by Josť Roca »
Logged

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #21 on: June 16, 2018, 07:05:09 PM »

Okay, I see what you've done... seems to work for as well. Only thing is that you don't get that visual depressed look when the button is pressed and then released.

Well, I have modified the code again and we will only lose the depressed look when using custom colors.

Code: [Select]
   ' // Draws the button
   IF m_bIsThemed THEN
      ' // Increase 1 pixel to include the edge
      .InflateRect @rc, 1, 1
      ' // Draws the theme-specified border and fills for the "iPartId" and "iStateId".
      .DrawThemeBackground(hTheme, hDc, BP_PUSHBUTTON, iStateId, @rc, NULL)
      ' // Gets the size of the content for the theme-defined background
      .GetThemeBackgroundContentRect(hTheme, hDc, BP_PUSHBUTTON, iStateId, @rc, @rcContent)
   ELSE
      ' // Uses GDI to draw the button
      rcContent = rc
      IF bIsFocused THEN
         IF m_bIsToggle = FALSE OR bIsPressed = FALSE THEN
            .FrameRect hDc, @rcContent, GetSysColorBrush(COLOR_WINDOWTEXT)
         END IF
         .InflateRect @rcContent, -1, -1
      END IF
      IF m_bIsToggle THEN
         IF iStateId = PBS_PRESSED THEN
            .DrawEdge hDc, @rcContent, EDGE_SUNKEN, BF_RECT OR BF_MIDDLE OR BF_SOFT
         ELSE
            IF (lStyle AND BS_FLAT) = BS_FLAT THEN
               .DrawEdge hDc, @rcContent, EDGE_RAISED, BF_RECT OR BF_MIDDLE OR BF_SOFT OR BF_FLAT
            ELSE
               .DrawEdge hDc, @rcContent, EDGE_RAISED, BF_RECT OR BF_MIDDLE OR BF_SOFT
            END IF
         END IF
      ELSE
         IF m_hBkgBrush = NULL THEN .FillRect hDc, @rcContent, GetSysColorBrush(COLOR_BTNFACE)
         IF bIsPressed THEN
            .FrameRect hDc, @rcContent, GetSysColorBrush(COLOR_BTNSHADOW)
         ELSE
            uState = DFCS_BUTTONPUSH
            IF iStateId = PBS_HOT THEN uState = uState OR DFCS_HOT
            IF (lStyle AND BS_FLAT) = BS_FLAT THEN uState = uState OR DFCS_FLAT
            .DrawFrameControl hDc, @rcContent, DFC_BUTTON, uState
         END IF
      END IF
      IF m_hBkgBrush THEN.FillRect hDc, @rcContent, m_hBkgBrush
   END IF

I don't know what more I can do unless I get the source code of these API functions an rewrite them.

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #22 on: June 16, 2018, 07:48:53 PM »

I have added support for text foreground and background colors. Also some minor changes, e.g. SetBkgColor changed to SetButtonBkColor.

I also have added SetTextForeDownColor and SetTextBkDownColor to set the colors used when the button is down (pressed or toggled). This is a workaround to provide a clear indication that the button is pressed or toggled.

If you don't need more changes, we can simply rename it as CXpButton.inc, as the original. This way I don't need to change all the documentation of this control.
« Last Edit: June 16, 2018, 10:35:46 PM by Josť Roca »
Logged

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #23 on: June 17, 2018, 12:36:25 AM »

Thanks Jose, yes, rename this one as the original. I will use it in the designer and if I encounter any problems or suggestions for improvements then I will let you know. It seems like it has all of the properties I would need. Tomorrow, I will look at the button in Visual Studio 2017 to see how the fore/back color affects that button and themeing.

Thanks!
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #24 on: June 17, 2018, 09:46:36 AM »

It is SetTextForeDownColor an appropriate name? What I want to mean is foreground color when the button is down (pressed).

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #25 on: June 17, 2018, 09:52:59 AM »

Maybe, "SetTextForeColorDown" or "SetTextForeColorPressed" ?

or even, "SetForeColorTextDown" or "SetForeColorTextPressed" ?
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #26 on: June 17, 2018, 10:23:31 AM »

Changed names to SetTextForeColorDown and SetTextBkColorDown and renamed the include file as the original: CXpButton.inc.

Paul Squires

  • Administrator
  • Master Member
  • *****
  • Posts: 8635
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #27 on: June 18, 2018, 09:51:22 AM »

Hi Jose, I'm happy to report that I have been able to integrate the CXpButton into the visual designer as a replacement for the standard Windows button (so far, so good). I only really needed to add a call to subclass the control and an additional pointer in order to track the NEW/DELETE sequence for when I create and subsequently destroy the control. Working on integrating all of the CXpButton functionality into the PropertyList. Any issues/problems, I'll let you know. Thanks
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

Josť Roca

  • Moderator
  • Master Member
  • *****
  • Posts: 3109
    • Jos
Re: CXpButton
« Reply #28 on: June 18, 2018, 10:19:09 AM »

Excellent. I always have wondered why one of the first questions that every novice asks is how to change the color of a button. The result can be awful if you choose colors using a theme and then the user chooses another theme. The user needs a gui that doesn't strain their eyes. I have seen things like red text against a light green background or dark blue text against a black background.

Marc Pons

  • FireFly3 Registered User
  • Junior Member
  • *
  • Posts: 133
  • FF3 User
Re: CXpButton
« Reply #29 on: June 19, 2018, 07:15:09 AM »

Josť,
You probably have changed your Rar tool to new version, with my installed winrar 3.93 i was not able to uncompress your last attachments.


It would better stay on zip or previous version rar for more compatibiity when sharing

thanks for your tremendous job
Logged
Pages: 1 [2] 3 4