PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Capture (shift or control) when button clicked.  (Read 220 times)

James Conforti

  • Little Newbie
  • *
  • Posts: 12
  • FF3 User
Capture (shift or control) when button clicked.
« on: April 30, 2019, 05:56:08 AM »

FF3 on PB10

Here's what I'm trying to do (and I've tried searching and experimenting)...

Click a button "function 1"

Hold some "secret" key down (control or shift) and click button "function 2"

Button is located on a form that's assigned to a tab of a tab control on the main form if that matters.

Please, I can write all the technical PB there is, in just NOT a UI guy.
Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8793
  • Windows 10
    • PlanetSquires Software
Re: Capture (shift or control) when button clicked.
« Reply #1 on: April 30, 2019, 08:21:06 AM »

It's been a while since I used Firefly but here are two different ways to handle this. The first is in BN_CLICKED and the second is via WM_LBUTTONUP. Choose one or the other depending on your needs. Hope this works for you.

Code: [Select]
'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     as Long, _      ' index in Control Array
                                   hWndForm         as HWnd, _      ' handle of Form
                                   hWndControl      as HWnd, _      ' handle of Control
                                   idButtonControl  as Long   _     ' identifier of button
                                   ) as Long

   If GetAsyncKeyState( VK_LCONTROL) And &H8000 Then
      MessageBox( 0, "BN_CLICKED: Control pressed", "Message", 0 )
   End If

   Function = 0   ' change according to your needs
End Function


'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_WM_LBUTTONUP ( _
                                     ControlIndex  as Long,  _     ' index in Control Array
                                     hWndForm      as HWnd, _      ' handle of Form
                                     hWndControl   as HWnd, _      ' handle of Control
                                     MouseFlags    as Long,  _     ' virtual keys that are pressed
                                     xPos          as Long,  _     ' x-coordinate of cursor
                                     yPos          as Long   _     ' y-coordinate of cursor
                                     ) as Long

   If (MouseFlags And MK_CONTROL) = MK_CONTROL Then
      MessageBox( 0, "WM_LBUTTONUP: Control pressed", "Message", 0 )
   End If
   
   Function = 0   ' change according to your needs
End Function
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

James Conforti

  • Little Newbie
  • *
  • Posts: 12
  • FF3 User
Re: Capture (shift or control) when button clicked.
« Reply #2 on: May 01, 2019, 09:50:24 PM »

Thanks much, Paul!  Works like a charm.  Sorry if my questions seem newb-ish, as I'm an experienced programmer (crypto, comms, automotive reprogramming, etc) but the graphic environment of windows escapes me.  Things like changing tool tips programmatically, adding buttons programmatically, etc.  (think dynamic interface).  Is there somewhere I can bug people about these issues - I still use FF3 (I actually just started using it) and PB10 as it works for me and I have literally a grundle of libraries that I choose to NEVER write again ;-) )
Logged

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 428
Re: Capture (shift or control) when button clicked.
« Reply #3 on: May 02, 2019, 08:19:59 AM »

Hi James

Best is to post it here.
The PB Forums everywhere had died.

There are still a few of us on FF3 and PB10, however at some point soon I will also move to WINFBE and FreeBasic.
Ask your hearts desire. Sometimes if we know, someone will still have code and Paul is always willing to help.

I still ask a lot of questions, and i still get a lot of help.

-regards Peter
Logged