Announcement

Collapse
No announcement yet.

how to make an active button invisible in a dialog?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to make an active button invisible in a dialog?

    Is there some style to add to a control ( eg. a button) to make it invisible but still active and clickable?

    what can I add to bStyle below to make the button invisible ?

    Code:
    LOCAL bStyle AS DWORD
    bStyle = %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_OWNERDRAW
    CONTROL ADD BUTTON, hDlg, %ID_Btn2, "Confirm", 10, 195, 50, 16, bStyle

  • #2
    Try a LABEL with no text and style %SS_NOTIFY.
    Dale

    Comment


    • #3
      I use the below code to make it invisible -- not sure that it works o not , but to me it does work as nothing shown on screen

      Code:
      ' Hidden button 
       ' to make it invisible but clickable -- set its text to
       ' blank and its size to 1 , 1 and no style %WS_VISIBLE
        CONTROL ADD BUTTON, hDlg, %ID_HidBtn, "", 10, 265, 1, 1, _
        %WS_CHILD  OR %WS_TABSTOP OR %BS_OWNERDRAW
      any suggestion to improve?

      Comment


      • #4
        Tim,

        I think the BS_OWNERDRAW style does it for you. Create a button with that style and place it where you know where it is on the client area, then with a normal WM_COMMAND message processing, see if it works by clicking within that location.
        hutch at movsd dot com
        The MASM Forum - SLL Modules and PB Libraries

        http://www.masm32.com/board/index.php?board=69.0

        Comment


        • #5
          Thank you Steve that works out

          Comment


          • #6
            If this is to do with your other thread where you want to cause an action by triggering a button click from another application, you may like to re-think your solution.

            What happens when a user unknowingly clicks on this anonymous part of your application window?
            Do you want the user to activiate the on_click code accidentally by some random click when trying to re-activate/regain focus on the application?

            If not, there are alternative solutions which don't have this risk.
            The simplest is probably to just set the button's location outside of the bounds of the application window (negative x andy's are good for that.)

            Comment


            • #7
              Thank you Stuart, I have set the button coordinates to - 10 , 265 that is outside the program's window

              Comment


              • #8
                is there some style to add to a control ( eg. a button) to make it invisible but still active and clickable?
                "clickable" but you cannot see it?

                Call me simple minded but I cannot see how that makes sense.

                But FWIW ...my very first Windows/32 posted code here...

                PB DLL 5 or 6: A game for you September 22, 1999

                It's a related concept.

                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Originally posted by Tim Lakinir View Post
                  Thank you Stuart, I have set the button coordinates to - 10 , 265 that is outside the program's window
                  This is seemingly about a control that has no physical manifestation.
                  How will this control be accessed, if not by direct uses interactions?
                  If it is entirely programatic, then you do not need an actual control.
                  All you need is an ID.
                  You can post a message that will activate the control, as though it had a windows object attached.
                  Your callback doesn't care if the control is real or visible, of course. It just processes the control number.
                  The world is strange and wonderful.*
                  I reserve the right to be horrifically wrong.
                  Please maintain a safe following distance.
                  *wonderful sold separately.

                  Comment


                  • #10
                    Hi Kurt, this hidden button is being implemented in my source code at https://forum.powerbasic.com/forum/u...ode#post817848

                    The hidden button is located in ProgDlg1.bas in that post. It is clickable programatically by the other program ProgDlg2.bas's button , it is use to show how 2 programs can communicate via Process Memory technique.

                    The hidden button is not clickable by human but can be clickable by another program ( proof of concept) , it is invisible and out of view of the hosting program's window. thus explains why I adopted the hidden button coordinates of - 10 , 265 in the ProgDlg1.bas

                    Also check out the button named "Test Hidden ProgDlg1 btn" on ProgDlg2.bas which is used to semi programatically click the hidden button of ProgDlg1

                    Comment


                    • #11
                      If this is to do with your other thread where you want to cause an action by triggering a button click from another application, you may like to re-think your solution.
                      . . . I cannot see how that makes sense.
                      If it is entirely programmatic, then you do not need an actual control. All you need is an ID.
                      You do not need a hidden button! The button in program2 can
                      DIALOG POST hDialog1, %WM_User + 501, 0, 0
                      In callback for dialog1
                      SELECT CASE CB.MSG
                      CASE %WM_User + 501
                      'code you want

                      If you need to do multiple things you've still got wParam and lParam and %WM_User + 502, etc.
                      Dale

                      Comment


                      • #12
                        If it is entirely programmatic, then you do not need an actual control. All you need is an ID.

                        You don't even need that.

                        Methinks young Mr. Lakinir is looking for the hard way to accomplish something.

                        Search here (or elsewhere) for "interprocess communication" and you'll probably find double digits worth of ways to do it.
                        Michael Mattias
                        Tal Systems (retired)
                        Port Washington WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          Remember that buttons moved to be "hidden" also may be reachable via the keyboard. Tab-tab-tab...
                          And that some users actually prefer to work via keyboard only. Fast keyboard shortcuts should always exist.
                          Sometimes using an accelerator key + info about it can be a good solution. See PB help, ACCEL ATTACH.

                          Comment


                          • #14
                            Thank you Everyone, the use of the Hidden button ( or invisible) is a proof of concept and it will be hidden from users so that it is NOT accessible to them but it can only be
                            access by a button in another program ( this is to prove Process communication ).

                            Thank you Borje, yes the Hidden button is still be accessible by the tab tab tab keystrokes, and that this must be prevented.
                            In this issue, how can I disable the tab keys for this hidden button ? is there a button style that can prevent the usage of a tab key ?

                            Comment


                            • #15
                              is there a button style that can prevent the usage of a tab key ?
                              See: WS_TABSTOP window style. Use of WS_GROUP style can also affect but only for certain styles of button.

                              (Yes I am making you look it up!)
                              Michael Mattias
                              Tal Systems (retired)
                              Port Washington WI USA
                              [email protected]ems.com
                              http://www.talsystems.com

                              Comment


                              • #16
                                WS_TABSTOP window style.
                                Specifies a control that can receive the keyboard focus when the user presses Tab. Pressing Tab changes the keyboard focus to the next control with the WS_TABSTOP style

                                this WS_TABSTOP window style is not suitable for my hidden button as it allow for user to push theTab key to navigate around all the controls one by one

                                I want to stop User from using the Tab key !

                                anything to disable the Tab key ? how to trap the Tab key ? what message is used to trap the tab key






                                Comment


                                • #17
                                  I have not digested all of the nuances of this topic but making an invisible button seems to be redundant in that you can send or post a message to you WM_COMMAND processing and save yourself the extra work and complexity.
                                  hutch at movsd dot com
                                  The MASM Forum - SLL Modules and PB Libraries

                                  http://www.masm32.com/board/index.php?board=69.0

                                  Comment


                                  • #18
                                    Originally posted by Tim Lakinir View Post
                                    WS_TABSTOP window style.
                                    Specifies a control that can receive the keyboard focus when the user presses Tab. Pressing Tab changes the keyboard focus to the next control with the WS_TABSTOP style

                                    this WS_TABSTOP window style is not suitable for my hidden button as it allow for user to push theTab key to navigate around all the controls one by one

                                    I want to stop User from using the Tab key !

                                    anything to disable the Tab key ? how to trap the Tab key ? what message is used to trap the tab key

                                    Look at the style& description under CONTROL ADD BUTTON!!

                                    Comment


                                    • #19
                                      Tim, if your goal is to send a message to another program, you don't need a control to receive it.
                                      Just send the message to %WM_APP (or %WM_APP + 1, +2, +3, etc)
                                      In bonus, you can pass two parameters.

                                      There is many ways, one other is RegisterWindowMessage() to define a "private" unique message

                                      Code:
                                      PostMessage(hOtherProgram, %WM_APP, 123, 456)
                                      In OtherProgram:
                                      Code:
                                       CALLBACK FUNCTION DlgProc() AS LONG
                                         SELECT CASE CBMSG
                                           CASE %WM_APP
                                             MessageBox(hDlg, "Message from space" & STR$(CBWPARAM) & STR$(CBLPARAM), "OtherProgram", %MB_OK OR %MB_TOPMOST)

                                      Comment


                                      • #20
                                        I want to stop User from using the Tab key !
                                        Again from multiple sources, DO NOT USE A BUTTON or any kind of control.

                                        1. Send/post a WM_COMMAND message with an ID, but do not use CONTROL ADD with that ID in dialog 1. A control does not need to exist to catch ID in callback. WParam and LParam are used.

                                        2. Send/post a WM_User + 500 message, WParam and LParam are available.

                                        3. Send/post a WM_App message, WParam and LParam are available.

                                        see Help or MSDN for difference between SEND and POST.

                                        2. or 3. make more sense.
                                        Dale

                                        Comment

                                        Working...
                                        X