Announcement

Collapse
No announcement yet.

DDT All Buttons Act Like %BS_PUSHLIKE ?

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

  • Michael Mattias
    replied
    FWIW, I ran your program, with all the original 'DDT' syntax (using PB/Win 9.0, your compiler version not shown).

    The behavior is exactly what I expected. As the keyboard focus changes (click or <TAB>) , the default button (the one with the heavy black border) changes to the focused button. That is, the visual cue to the user the "here's what gets 'clicked' if you press <ENTER>" is working exactly correctly.

    If you don't want heavy black border around the current DEFPUSHBUTTON, you can tinker around with the DM_SETDEFID and/or BM_SETSTYLE messages at the appropriate times.
    Using the DM_SETDEFID message can result in more than one button appearing to have the default push button state. When the system brings up a dialog, it draws the first push button in the dialog template with the default state border. Sending a DM_SETDEFID message to change the default button will not always remove the default state border from the first push button. In these cases, the application should send a BM_SETSTYLE message to change the first push button border style.
    Or, you can owner-draw your buttons. (with DDT syntax you may have to use the "CONTROL ADD "BUTTON"..." syntax rather than "CONTROL ADD BUTTON" syntax, but I'm not a DDT guy so you can tinker with that. )

    Or, you can leave the behavior alone, as it is what your users should be expecting.

    > Buttons 3 & 5 below ARE %BS_PUSHLIKE, the rest are not.
    Well, as per above, no they are not BS_PUSHLIKE, since BS_PUSHLIKE applies only to 'checkable' button styles.

    Meaning, you have an invalid combination of styles, resulting in unpredictable/undefined behavior.


    MCM
    Last edited by Michael Mattias; 23 Jan 2009, 08:33 AM.

    Leave a comment:


  • Michael Mattias
    replied
    >> Never mix CreateWindowEx windows with CONTROL ADD windows on a DDT dialog.

    >But for the purpose of demonstrating an event or action, it works,
    >just something you don't do in a "production" program.

    Not even for the purposes of demonstrating a "trick" or a "hack."

    It's not supported, so it demonstrates exactly nothing.

    Well, maybe it demonstrates "Hey, look what works by dumb luck with this version of Windows and this version of the compiler - today," but that is the limit of its validity.


    MCM

    Leave a comment:


  • colin glenn
    replied
    Originally posted by SDK, emphasis mine
    BS_PUSHLIKE
    Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked.
    This is the behavior I am referring to and what I want to eliminate.

    Originally posted by Charles Dietz View Post
    Colin, I'm not sure if this is what you are wanting, but I use this technique when I don't want the button I push to remember...
    Works like a charm. Something to undepress the depressed button.

    Originally posted by Michael Mattias View Post
    Don't do that. Never mix CreateWindowEx windows with CONTROL ADD windows on a DDT dialog.
    :iagree:
    But for the purpose of demonstrating an event or action, it works, just something you don't do in a "production" program.

    Leave a comment:


  • Fred Buffington
    replied
    Great Charles, works like a charm even on IMGBUTTON/IMGBUTTONX

    thanks (had never really noticed that behavior before).

    Leave a comment:


  • Michael Mattias
    replied
    >Even adding a button via CreateWindow

    Don't do that. Never mix CreateWindowEx windows with CONTROL ADD windows on a DDT dialog.

    That's why the "CONTROL ADD "classname"" statement exists!

    Leave a comment:


  • Charles Dietz
    replied
    Colin, I'm not sure if this is what you are wanting, but I use this technique when I don't want the button I push to remember...

    Code:
            CASE %WM_COMMAND
                ' Process control notifications
                CONTROL SET FOCUS CB.HNDL, %IDSP_IMAGE1
                
                SELECT CASE CB.CTL
                CASE %IDB_BUTTON1 TO %IDB_BUTTON5 
                   CONTROL SEND CB.HNDL, CB.CTL, %BM_SETSTYLE, %BS_PUSHBUTTON, %TRUE
                END SELECT

    Leave a comment:


  • Michael Mattias
    replied
    Pushlike button demo buried in amongst other stuff, with totally unrelated 'subject' Probably no way to find via 'search.'

    http://www.powerbasic.com/support/pb...ad.php?t=22173

    (Post #11 of this thread is the demo)

    MCM

    Leave a comment:


  • Kev Peel
    replied
    Well I guess I don't know exactly what you want to do? BS_PUSHLIKE is for checkboxes or option buttons only. It cannot be used with standard push buttons as they don't have a "checked" attribute. The BS_PUSHLIKE style will draw checkboxes and radio buttons as a normal button but with a pressed state when the control is checked.

    If the button border displays poorly with your interface may I suggest using an ownerdrawn button and draw the button display yourself? (or change the background color). Here is some code for BS_OWNERDRAW:

    http://www.powerbasic.com/support/pb...ad.php?t=23834

    If PBFORMS is changing custom class controls back to CONTROL ADD BUTTON I would report this to [email protected] (unless this is by design? I don't use PBFORMS myself).
    Last edited by Kev Peel; 22 Jan 2009, 08:44 AM.

    Leave a comment:


  • colin glenn
    replied
    Please understand, this whole thing is purely cosmetic, I'm using a dark background for the dialog so when a use presses a button on the dialog to tell the program to do something, the button appears to get smaller due to the black outline being drawn around the button until they press it again. I just find it distracting to see such behavior.
    Originally posted by Kev Peel View Post
    A DDT "Control Add Button" is always a "push" button.
    Yes, I know.
    Code:
    %BS_PushLike
    All the buttons created by the dialog appear to have this style. In essence, there's no difference between the three buttons created below:
    Code:
        CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON1, "Button1", 6, 6, 57, 17
        CONTROL ADD "Button", hDlg, %IDB_BUTTON2, "Button2", 6, 32, 57, 17, _
            %WS_CHILD OR %WS_VISIBLE
        CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON3, "Button3", 6, 58, 57, 17, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
            %BS_PUSHLIKE OR %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER
    Even adding a button via CreateWindow:
    Code:
    bHandle = CreateWindow("button", "Button 6", %WS_CHILD OR %WS_VISIBLE, _
    6, 84, 57, 17, CB.HNDL, %IDB_BUTTON6, BYVAL 0, BYVAL 0)
    Except that it's using a different font, one that's a bit bigger, and when I click the button, the whole surface gets smaller, resulting in the caption being clipped.

    Note that loading the buttons.bas (included in the zip below) into PBForms reverts the manual CONTROL ADD "Button" into a CONTROL ADD BUTTON. Also included in the zip is a hacked skeleton.bas from the samples, drawing one button so you can see that a button created under that operational mode is not drawing a black line around a clicked button.
    Attached Files

    Leave a comment:


  • Kev Peel
    replied
    A DDT "Control Add Button" is always a "push" button. If you want something that does not have the default button styles, use CONTROL ADD "BUTTON" (ie. custom class) and set the styles how you want. Don't forget to include WS_CHILD, WS_VISIBLE and WS_TABSTOP.

    DDT buttons are defined:-

    Push buttons as BUTTON
    Check boxes as CHECKBOX
    Radio buttons as OPTION

    What you need:

    Code:
     Control Add "BUTTON", hDlg, 306, "&no", _
                 220,20,40,40, _
                 %WS_Child Or %WS_Visible Or %WS_TabStop Or _
                 %BS_AutoCheckbox Or %BS_PushLike Or %WS_Border
    Last edited by Kev Peel; 22 Jan 2009, 06:14 AM.

    Leave a comment:


  • colin glenn
    replied
    I think it's something with the DDT buttons, if you create a button with CreateWindow:
    Code:
            hWndNew& =CreateWindowEx(0,"BUTTON", "&Button", _
                                     %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS _
                                     OR %BS_PUSHBUTTON, _
                                     100, _
                                     100, _
                                     100, _
                                     30, _
                                     hWnd, BYVAL %NULL, ghInst, BYVAL %NULL)
    Then the button pops back out after being clicked.

    Leave a comment:


  • Michael Mattias
    replied
    As best I know, the black line is simply an indication of focus, just like the dotted line around the text.
    The "thick black border" is what's shown for the current DEFPUSHBUTTON
    BS_DEFPUSHBUTTON
    Creates a push button that behaves like a BS_PUSHBUTTON style button, but also has a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely (default) option.
    If you don't specify a DEFPUSHBUTTON, Windows (and by extension the compiler) will select one for you. (I think. This has always been a confusing thing to me).

    Keyboard focus is shown via the dotted focus rectangle.

    MCM

    Leave a comment:


  • Gary Beene
    replied
    As best I know, the black line is simply an indication of focus, just like the dotted line around the text.

    Simply pushing the button again does not get rid of the black line on my tests. Only pushing another button does it.

    All of these work that as I've described.

    Code:
        Control Add Button , hdlg, 301, "o&k", 20,20,40,40, %bs_default
        Control Add Button , hdlg, 302, "&yes", 20,80,40,40, %bs_center
    
        Control Add Button , hdlg, 303, "&no", 70,20,40,40, %bs_left
        Control Add Button , hdlg, 311, "ok", 70,80,40,40, %bs_right
    
        Control Add Button , hdlg, 312, "&yes", 120,20,40,40, %bs_top
        Control Add Button , hdlg, 313, "&no", 120,80,40,40, %bs_vcenter
    
        Control Add Button , hdlg, 304, "ok", 170,20,40,40, %bs_flat
        Control Add Button , hdlg, 305, "&yes press me", 170,80,40,40, %bs_multiline
    
        Control Add Button , hdlg, 306, "&no", 220,20,40,40, %bs_pushlike Or %ws_border

    Leave a comment:


  • colin glenn
    started a topic DDT All Buttons Act Like %BS_PUSHLIKE ?

    DDT All Buttons Act Like %BS_PUSHLIKE ?

    Either I'm missing something or that's been the behavior all along and I never noticed. No matter how I create a button, that is, a "normal" button which one expects to be pushable and will return to the "popped out" state, when I push one, it develops a black rectangle around the button which does not go away until you push it again. Or push another button. Buttons 3 & 5 below ARE %BS_PUSHLIKE, the rest are not.
    Code:
    #PBFORMS CREATED V1.51
    
    #COMPILE EXE
    #DIM ALL
    
    '------------------------------------------------------------------------------
    '   ** Includes **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN INCLUDES
    #RESOURCE "buttons.pbr"
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #PBFORMS END INCLUDES
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Constants **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS
    %IDB_BUTTON1   = 1001
    %IDB_BUTTON2   = 1002
    %IDB_BUTTON3   = 1003
    %IDB_BUTTON4   = 1004
    %IDB_BUTTON5   = 1006
    %IDD_DIALOG1   =  101
    %IDLB_LISTBOX1 = 1007
    %IDR_IMGFILE2  =  102
    %IDSP_IMAGE1   = 1005
    #PBFORMS END CONSTANTS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Declarations **
    '------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
                DIALOG SET TEXT CB.HNDL, HEX$(%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
                    %BS_PUSHBUTTON OR %BS_FLAT OR %BS_CENTER OR %BS_VCENTER)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%WS_CHILD=" & HEX$(%WS_CHILD)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%WS_VISIBLE=" & HEX$(%WS_VISIBLE)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%WS_TABSTOP=" & HEX$(%WS_TABSTOP)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%BS_TEXT=" & HEX$(%BS_TEXT)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%BS_PUSHBUTTON=" & HEX$(%BS_PUSHBUTTON)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%BS_FLAT=" & HEX$(%BS_FLAT)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%BS_CENTER=" & HEX$(%BS_CENTER)
                LISTBOX ADD CB.HNDL, %idlb_listbox1, "%BS_VCENTER =" & HEX$(%BS_VCENTER )
    
    
            CASE %WM_NCACTIVATE
                STATIC hWndSaveFocus AS DWORD
                IF ISFALSE CBWPARAM THEN
                    ' Save control focus
                    hWndSaveFocus = GetFocus()
                ELSEIF hWndSaveFocus THEN
                    ' Restore control focus
                    SetFocus(hWndSaveFocus)
                    hWndSaveFocus = 0
                END IF
    
            CASE %WM_COMMAND
                ' Process control notifications
                CONTROL SET FOCUS CB.HNDL, %IDSP_IMAGE1
        END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW hParent, "Dialog1", 201, 366, 201, 132, %WS_POPUP OR _
            %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
            %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON1, "Button1", 8, 4, 56, 16
        CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON2, "Button2", 8, 24, 56, 12
        CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON3, "Button3", 8, 40, 60, 12, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR %BS_PUSHLIKE _
            OR %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, %WS_EX_LEFT OR _
            %WS_EX_LTRREADING
        CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON4, "Button4", 8, 56, 60, 12, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
            %BS_PUSHBUTTON OR %BS_FLAT OR %BS_CENTER OR %BS_VCENTER, %WS_EX_LEFT _
            OR %WS_EX_LTRREADING
        CONTROL ADD BUTTON,  hDlg, %IDB_BUTTON5, "Button5", 8, 72, 64, 12, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR %BS_PUSHLIKE _
            OR %BS_PUSHBUTTON OR %BS_FLAT OR %BS_CENTER OR %BS_VCENTER, _
            %WS_EX_LEFT OR %WS_EX_LTRREADING
        CONTROL ADD LISTBOX, hDlg, %IDLB_LISTBOX1, , 88, 8, 100, 112
        CONTROL ADD IMAGE,   hDlg, %IDSP_IMAGE1, "#" + FORMAT$(%IDR_IMGFILE2), 8, _
            88, 43, 39
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
Working...
X