PlanetSquires Forums

Please login or register.

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

Author Topic: CXpButton  (Read 5563 times)

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3215
Re: CXpButton
« Reply #45 on: July 09, 2018, 11:48:29 PM »

I have added:

Code: [Select]
      CASE BM_CLICK
         .SendMessageW hwnd, WM_LBUTTONDOWN, 0, 0
         .SendMessageW hwnd, WM_LBUTTONUP, 0, 0
         EXIT FUNCTION

Not tested yet, but it should work.
« Last Edit: July 10, 2018, 02:28:26 PM by Josť Roca »
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8905
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #46 on: July 10, 2018, 01:41:22 PM »

I doubt that will work because LBUTTONDOWN and LBUTTONUP do hit testing based on the cursor position to determine if the user has clicked the button. When I get home this evening I will work up some code and post it here for you to include in the button class.

Thanks, Paul
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3215
Re: CXpButton
« Reply #47 on: July 10, 2018, 02:29:51 PM »

You're right. I had no time for testing it. Let's see if this works:

Code: [Select]
      CASE BM_CLICK
         IF .IsWindowEnabled(hwnd) = FALSE THEN EXIT FUNCTION
         ' // Redraws the button in pushed state
         pButton = CAST(CXpButton PTR, .GetWindowLongPtrW(hwnd, 0))
         IF pButton = NULL THEN EXIT FUNCTION
         IF pButton->m_bIsToggle THEN
            IF pButton->m_bToggled = FALSE THEN
               pButton->m_bToggled = TRUE
            ELSE
               pButton->m_bToggled = FALSE
            END IF
         END IF
         pButton->m_fState = BST_PUSHED
         pButton->Redraw
         ' // Redraws the button in unpushed state
         pButton->m_fState = 0
         pButton->Redraw
         ' // Set the focus in the button
         .SetFocus hwnd
         ' // Forwards the message to the parent window
         .SendMessageW .GetParent(hwnd), WM_COMMAND, MAKELONG(GetDlgCtrlId(hwnd), BN_CLICKED), CAST(.LPARAM, hwnd)
         EXIT FUNCTION

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8905
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #48 on: July 10, 2018, 05:20:04 PM »

Thanks Jose! I tested it and it seems to be working okay so far  :-)

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3215
Re: CXpButton
« Reply #49 on: July 29, 2018, 01:22:37 PM »

Hi Paul,

I have added the ButtonBkColorDown properties to change the background color of the button when it is pressed or toggled.

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8905
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #50 on: July 29, 2018, 07:25:20 PM »

Hi Josť,

Thanks for the new code. I added a new Button property called "BackColorDown". Seems to be working okay.
« Last Edit: July 29, 2018, 07:26:51 PM by Paul Squires »
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8905
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #51 on: January 04, 2019, 01:27:58 PM »

Hi Josť,

The CXpButton could use two functions similar to the ones that you have for the CImageCtx control. Currently, I have to use the GetWindowLongPtr calls directly during my WM_DESTROY to get the CXpButton pointers. For convenience and consistency it would be nice to have AfxCXpButtonPtr like the AfxCImageCtxPtr functions below.

Code: [Select]
' ========================================================================================
' Returns a pointer to the class given the handle of its associated window handle.
' hCtl = Handle of the image control.
' ========================================================================================
PRIVATE FUNCTION AfxCImageCtxPtr OVERLOAD (BYVAL hCtl AS HWND) AS CImageCtx PTR
   FUNCTION = CAST(CImageCtx PTR, .GetWindowLongPtrW(hCtl, 0))
END FUNCTION
' ========================================================================================
' ========================================================================================
' hParent = Handle of the parent window of the image control.
' cID = Identifier of the image control.
' ========================================================================================
PRIVATE FUNCTION AfxCImageCtxPtr OVERLOAD (BYVAL hParent AS HWND, BYVAL cID AS LONG) AS CImageCtx PTR
   FUNCTION = CAST(CImageCtx PTR, .GetWindowLongPtrW(GetDlgItem(hParent, cID), 0))
END FUNCTION
' ========================================================================================
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3215
Re: CXpButton
« Reply #52 on: January 04, 2019, 02:26:32 PM »

Done.

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3215
Re: CXpButton
« Reply #53 on: January 04, 2019, 02:37:28 PM »

I smile when I remember that I thought of deprecate it, and only adapted it to practice how to implement a custom control using a class :)

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8905
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #54 on: January 04, 2019, 02:48:58 PM »

Excellent - thanks :-) 

That button is one of the main controls in the WinFBE visual designer code output. It is very versatile.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8905
  • Windows 10
    • PlanetSquires Software
Re: CXpButton
« Reply #55 on: January 21, 2019, 03:15:14 PM »

Hi Josť,

I had to make a very change to the CTmageCtx.DrawImage function. I had to move the test for the pImage pointer being null down to the block where the image is actually outputted. It now looks like this:

   IF ( pGraphics ) andalso ( pImage )THEN

This enables me to draw the background normal or HOT regardless of whether an image is actually specified.

I have attached the new CImageCtx control code.

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer
Pages: 1 2 3 [4]