Announcement

Collapse
No announcement yet.

Button in StatusBar

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

  • Button in StatusBar

    I have the need to add a button to one of my sections of a statusbar. But after searching all morning for "Button" "StatusBar" "Jose Roca" "Owner Draw" and various other words I still can not locate an example that in the back of my foggy mind, I know I have seen before.

    My closest thought was an api wrapper from Jose Roca that would draw text, or a combobox or a button on a statusbar. But I can not find example code, and the api wrappers have changed.

    Does anyone know where the example I am racking my brain to find is???

    I have searched here and POFFS and still find nothing
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    Why draw?
    use Setparent()
    You'll have to hook the SB to obtain the WM_COMMAND > click though.
    hellobasic

    Comment


    • #3
      Why draw?
      use Setparent()
      You'll have to hook the SB to obtain the WM_COMMAND > click though.
      Why hook?
      Code:
        hButton = CreateWindowEx  class "button",  parent hStatusBar...
        SetParent hbutton, hWnd
      Now your WM_COMMAND/BN_CLICKED come right in your window procedure with all your other WM_COMMANDs....
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        If SetParent works then I would use that, but at the moment my 1st attempt to do so on my own, I am missing a flag or something????
        Code:
        #PBFORMS CREATED V1.51
        '------------------------------------------------------------------------------
        ' The first line in this file is a PB/Forms metastatement.
        ' It should ALWAYS be the first line of the file. Other
        ' PB/Forms metastatements are placed at the beginning and
        ' end of "Named Blocks" of code that should be edited
        ' with PBForms only. Do not manually edit or delete these
        ' metastatements or PB/Forms will not be able to reread
        ' the file correctly.  See the PB/Forms documentation for
        ' more information.
        ' Named blocks begin like this:    #PBFORMS BEGIN ...
        ' Named blocks end like this:      #PBFORMS END ...
        ' Other PB/Forms metastatements such as:
        '     #PBFORMS DECLARATIONS
        ' are used by PB/Forms to insert additional code.
        ' Feel free to make changes anywhere else in the file.
        '------------------------------------------------------------------------------
        
        #COMPILE EXE
        #DIM ALL
        
        '------------------------------------------------------------------------------
        '   ** Includes **
        '------------------------------------------------------------------------------
        #PBFORMS BEGIN INCLUDES
        %USEMACROS = 1
        #IF NOT %DEF(%WINAPI)
            #INCLUDE "WIN32API.INC"
        #ENDIF
        #IF NOT %DEF(%COMMCTRL_INC)
            #INCLUDE "COMMCTRL.INC"
        #ENDIF
        #INCLUDE "PBForms.INC"
        #PBFORMS END INCLUDES
        '------------------------------------------------------------------------------
        
        '------------------------------------------------------------------------------
        '   ** Constants **
        '------------------------------------------------------------------------------
        #PBFORMS BEGIN CONSTANTS
        %IDD_DIALOG1              =  101
        %IDC_MSCTLS_STATUSBAR32_1 = 1001
        %IDC_BUTTON1              = 1002
        #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()
            PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
                %ICC_INTERNET_CLASSES)
        
            ShowDIALOG1 %HWND_DESKTOP
        END FUNCTION
        '------------------------------------------------------------------------------
        
        '------------------------------------------------------------------------------
        '   ** CallBacks **
        '------------------------------------------------------------------------------
        CALLBACK FUNCTION ShowDIALOG1Proc()
        
            SELECT CASE AS LONG CBMSG
                CASE %WM_INITDIALOG
                    ' Initialization handler
        
                CASE %WM_SIZE
                    ' Dialog has been resized
                    CONTROL SEND CBHNDL, %IDC_MSCTLS_STATUSBAR32_1, CBMSG, CBWPARAM, _
                        CBLPARAM
        
                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
                    SELECT CASE AS LONG CBCTL
                        CASE %IDC_MSCTLS_STATUSBAR32_1
        
                        CASE %IDC_BUTTON1
                            IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                MSGBOX "%IDC_BUTTON1=" + FORMAT$(%IDC_BUTTON1), _
                                    %MB_TASKMODAL
                            END IF
        
                    END SELECT
            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", 70, 70, 201, 121, TO hDlg
            CONTROL ADD "msctls_statusbar32", hDlg, %IDC_MSCTLS_STATUSBAR32_1, _
                "msctls_statusbar32_1", 0, 108, 201, 13, %WS_CHILD OR %WS_VISIBLE, _
                %WS_EX_TRANSPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
                %WS_EX_RIGHTSCROLLBAR
            CONTROL ADD BUTTON, GetDlgItem(hDlg, %IDC_MSCTLS_STATUSBAR32_1), %IDC_BUTTON1, "Button1", 115, 110, 70, 20, %WS_CHILD OR %WS_VISIBLE OR %WS_VSCROLL OR _         ' window styles
                                         %WS_BORDER OR %WS_TABSTOP, %WS_EX_TRANSPARENT
        
            SetParent GetDlgItem(hDlg, %IDC_BUTTON1), GetDlgItem(hDlg, %IDC_MSCTLS_STATUSBAR32_1)
        #PBFORMS END DIALOG
        
            DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
        
        #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
        #PBFORMS END CLEANUP
        
            FUNCTION = lRslt
        END FUNCTION
        '------------------------------------------------------------------------------
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          Your button is too big and it's coordinates are outside the statusbar.
          Code:
          #PBFORMS CREATED V1.51
          '------------------------------------------------------------------------------
          ' The first line in this file is a PB/Forms metastatement.
          ' It should ALWAYS be the first line of the file. Other
          ' PB/Forms metastatements are placed at the beginning and
          ' end of "Named Blocks" of code that should be edited
          ' with PBForms only. Do not manually edit or delete these
          ' metastatements or PB/Forms will not be able to reread
          ' the file correctly.  See the PB/Forms documentation for
          ' more information.
          ' Named blocks begin like this:    #PBFORMS BEGIN ...
          ' Named blocks end like this:      #PBFORMS END ...
          ' Other PB/Forms metastatements such as:
          '     #PBFORMS DECLARATIONS
          ' are used by PB/Forms to insert additional code.
          ' Feel free to make changes anywhere else in the file.
          '------------------------------------------------------------------------------
          
          #COMPILE EXE
          #DIM ALL
          
          '------------------------------------------------------------------------------
          '   ** Includes **
          '------------------------------------------------------------------------------
          #PBFORMS BEGIN INCLUDES
          %USEMACROS = 1
          #IF NOT %DEF(%WINAPI)
              #INCLUDE "WIN32API.INC"
          #ENDIF
          #IF NOT %DEF(%COMMCTRL_INC)
              #INCLUDE "COMMCTRL.INC"
          #ENDIF
          #INCLUDE "PBForms.INC"
          #PBFORMS END INCLUDES
          '------------------------------------------------------------------------------
          
          '------------------------------------------------------------------------------
          '   ** Constants **
          '------------------------------------------------------------------------------
          #PBFORMS BEGIN CONSTANTS
          %IDD_DIALOG1              =  101
          %IDC_MSCTLS_STATUSBAR32_1 = 1001
          %IDC_BUTTON1              = 1002
          #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()
              PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
                  %ICC_INTERNET_CLASSES)
          
              ShowDIALOG1 %HWND_DESKTOP
          END FUNCTION
          '------------------------------------------------------------------------------
          
          '------------------------------------------------------------------------------
          '   ** CallBacks **
          '------------------------------------------------------------------------------
          CALLBACK FUNCTION ShowDIALOG1Proc()
          
              SELECT CASE AS LONG CBMSG
                  CASE %WM_INITDIALOG
                      ' Initialization handler
          
                  CASE %WM_SIZE
                      ' Dialog has been resized
                      CONTROL SEND CBHNDL, %IDC_MSCTLS_STATUSBAR32_1, CBMSG, CBWPARAM, _
                          CBLPARAM
          
                  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
                      SELECT CASE AS LONG CBCTL
                          CASE %IDC_MSCTLS_STATUSBAR32_1
          
                          CASE %IDC_BUTTON1
                              IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                  MSGBOX "%IDC_BUTTON1=" + FORMAT$(%IDC_BUTTON1), _
                                      %MB_TASKMODAL
                              END IF
          
                      END SELECT
              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
              DIM SbParts(1) AS DWORD
          
              DIALOG NEW hParent, "Dialog1", 70, 70, 201, 121, %WS_SYSMENU, TO hDlg
              CONTROL ADD "msctls_statusbar32", hDlg, %IDC_MSCTLS_STATUSBAR32_1, _
                  "msctls_statusbar32_1", 0, 108, 201, 20, %WS_CHILD OR %WS_VISIBLE, _
                  %WS_EX_TRANSPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
                  %WS_EX_RIGHTSCROLLBAR
                  
              CONTROL ADD BUTTON, GetDlgItem(hDlg, %IDC_MSCTLS_STATUSBAR32_1), %IDC_BUTTON1, "Button1", 1, 2, 120, 18, %WS_CHILD OR %WS_VISIBLE OR  _         ' window styles
                                           %WS_BORDER OR %WS_TABSTOP, %WS_EX_TRANSPARENT
          
              SetParent GetDlgItem(hDlg, %IDC_BUTTON1), GetDlgItem(hDlg, %IDC_MSCTLS_STATUSBAR32_1)
          #PBFORMS END DIALOG
          
              DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
          
          #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
          #PBFORMS END CLEANUP
          
              FUNCTION = lRslt
          END FUNCTION
          '------------------------------------------------------------------------------
          Regards,
          Peter

          Comment


          • #6
            CNS

            I should have seen that one.

            The other minor thing that seems to not work, is increasing the height of the statusbar does not work? (Some catch-22 that I vaguely remember about windows resizing the height to what it wants and not the height I gave it???)
            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment


            • #7
              SetParent is not good to use with DDT controls. The reason is the notification messages (ie. WM_COMMAND) will be sent to the new parent and not a DDT form so you in essence deactive the DDT event engine (ie. no BN_CLICKED will be sent to form).

              The better approach is to simply put the control on top of the statusbar, so it still works as normal. This is tricky though because DDT ZOrder and repainting is confsuing using the default window styles.

              You need to define the actual window styles for the controls (make sure button created first before statusbar) and make sure you add the following style:

              WS_CLIPSIBLINGS

              This is critical for this to work.

              Here is an example of doing this:

              Code:
              #PBFORMS CREATED V1.51
              '------------------------------------------------------------------------------
              ' The first line in this file is a PB/Forms metastatement.
              ' It should ALWAYS be the first line of the file. Other
              ' PB/Forms metastatements are placed at the beginning and
              ' end of "Named Blocks" of code that should be edited
              ' with PBForms only. Do not manually edit or delete these
              ' metastatements or PB/Forms will not be able to reread
              ' the file correctly.  See the PB/Forms documentation for
              ' more information.
              ' Named blocks begin like this:    #PBFORMS BEGIN ...
              ' Named blocks end like this:      #PBFORMS END ...
              ' Other PB/Forms metastatements such as:
              '     #PBFORMS DECLARATIONS
              ' are used by PB/Forms to insert additional code.
              ' Feel free to make changes anywhere else in the file.
              '------------------------------------------------------------------------------
              #COMPILE EXE
              #DIM ALL
              '------------------------------------------------------------------------------
              '   ** Includes **
              '------------------------------------------------------------------------------
              #PBFORMS BEGIN INCLUDES
              %USEMACROS = 1
              #IF NOT %DEF(%WINAPI)
                  #INCLUDE "WIN32API.INC"
              #ENDIF
              #IF NOT %DEF(%COMMCTRL_INC)
                  #INCLUDE "COMMCTRL.INC"
              #ENDIF
              #INCLUDE "PBForms.INC"
              #PBFORMS END INCLUDES
              '------------------------------------------------------------------------------
              '------------------------------------------------------------------------------
              '   ** Constants **
              '------------------------------------------------------------------------------
              #PBFORMS BEGIN CONSTANTS
              %IDD_DIALOG1              =  101
              %IDC_MSCTLS_STATUSBAR32_1 = 1001
              %IDC_BUTTON1              = 1002
              #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()
                  PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
                      %ICC_INTERNET_CLASSES)
                  ShowDIALOG1 %HWND_DESKTOP
              END FUNCTION
              '------------------------------------------------------------------------------
              '------------------------------------------------------------------------------
              '   ** CallBacks **
              '------------------------------------------------------------------------------
              CALLBACK FUNCTION ShowDIALOG1Proc()
                  SELECT CASE AS LONG CBMSG
                      CASE %WM_INITDIALOG
                          ' Initialization handler
                      CASE %WM_SIZE
                          ' Dialog has been resized
                          CONTROL SEND CBHNDL, %IDC_MSCTLS_STATUSBAR32_1, CBMSG, CBWPARAM, _
                              CBLPARAM
                          LOCAL R AS RECT, IPart&, hStat&, hBtn&, X&,Y&,W&,H&, XOffset&
                          IPart&=0
                          CONTROL SEND CBHNDL, %IDC_MSCTLS_STATUSBAR32_1, %SB_GETRECT, IPart&, VARPTR(R)
                          CONTROL HANDLE CBHNDL, %IDC_MSCTLS_STATUSBAR32_1 TO hStat&
                          MapWindowPoints hStat&, CBHNDL, BYVAL VARPTR(R), 2
                          CONTROL HANDLE CBHNDL, %IDC_BUTTON1 TO hBtn&
                          XOffset&=72
                          X&=R.nLeft+GetSystemMetrics(%SM_CXEDGE)
                          Y&=R.nTop+GetSystemMetrics(%SM_CYEDGE)
                          W&=120
                          H&=(R.nBottom-R.nTop)-(2*GetSystemMetrics(%SM_CYEDGE))+1
                          MoveWindow hBtn&, X&+XOffset&,Y&,W&,H&,1
                      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 ELSE
                  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
                  DIM SbParts(1) AS DWORD
                  DIALOG NEW hParent, "Dialog1", 70, 70, 201, 121, %WS_SYSMENU, TO hDlg
                  CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "Button1", 1, 2, 120, 18, %WS_CHILD OR %WS_VISIBLE OR %BS_PUSHBUTTON OR %WS_CLIPSIBLINGS,0 CALL Button_Proc
                  CONTROL ADD STATUSBAR, hDlg, %IDC_MSCTLS_STATUSBAR32_1, "", 0, 108, 201, 20,%WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS
                  CONTROL SEND hDlg,%IDC_MSCTLS_STATUSBAR32_1, %SB_SETMINHEIGHT, 24,0
               
              #PBFORMS END DIALOG
                  DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
              #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
              #PBFORMS END CLEANUP
                  FUNCTION = lRslt
              END FUNCTION
              '------------------------------------------------------------------------------
              CALLBACK FUNCTION Button_Proc
                   IF CBCTLMSG=%BN_CLICKED THEN
                        MSGBOX "Hello, you clicked me"
                   END IF
              END FUNCTION
              Attached Files
              Chris Boss
              Computer Workshop
              Developer of "EZGUI"
              http://cwsof.com
              http://twitter.com/EZGUIProGuy

              Comment


              • #8
                Height of bar is based on font:
                Code:
                #PBFORMS CREATED V1.51
                '------------------------------------------------------------------------------
                ' The first line in this file is a PB/Forms metastatement.
                ' It should ALWAYS be the first line of the file. Other
                ' PB/Forms metastatements are placed at the beginning and
                ' end of "Named Blocks" of code that should be edited
                ' with PBForms only. Do not manually edit or delete these
                ' metastatements or PB/Forms will not be able to reread
                ' the file correctly.  See the PB/Forms documentation for
                ' more information.
                ' Named blocks begin like this:    #PBFORMS BEGIN ...
                ' Named blocks end like this:      #PBFORMS END ...
                ' Other PB/Forms metastatements such as:
                '     #PBFORMS DECLARATIONS
                ' are used by PB/Forms to insert additional code.
                ' Feel free to make changes anywhere else in the file.
                '------------------------------------------------------------------------------
                
                #COMPILE EXE
                #DIM ALL
                
                '------------------------------------------------------------------------------
                '   ** Includes **
                '------------------------------------------------------------------------------
                #PBFORMS BEGIN INCLUDES
                %USEMACROS = 1
                #IF NOT %DEF(%WINAPI)
                    #INCLUDE "WIN32API.INC"
                #ENDIF
                #IF NOT %DEF(%COMMCTRL_INC)
                    #INCLUDE "COMMCTRL.INC"
                #ENDIF
                #INCLUDE "PBForms.INC"
                #PBFORMS END INCLUDES
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** Constants **
                '------------------------------------------------------------------------------
                #PBFORMS BEGIN CONSTANTS
                %IDD_DIALOG1              =  101
                %IDC_MSCTLS_STATUSBAR32_1 = 1001
                %IDC_BUTTON1              = 1002
                #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()
                    PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
                        %ICC_INTERNET_CLASSES)
                
                    ShowDIALOG1 %HWND_DESKTOP
                END FUNCTION
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** CallBacks **
                '------------------------------------------------------------------------------
                CALLBACK FUNCTION ShowDIALOG1Proc()
                
                    SELECT CASE AS LONG CBMSG
                        CASE %WM_INITDIALOG
                            ' Initialization handler
                
                        CASE %WM_SIZE
                            ' Dialog has been resized
                            CONTROL SEND CBHNDL, %IDC_MSCTLS_STATUSBAR32_1, CBMSG, CBWPARAM, _
                                CBLPARAM
                
                        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
                            SELECT CASE AS LONG CBCTL
                                CASE %IDC_MSCTLS_STATUSBAR32_1
                
                                CASE %IDC_BUTTON1
                                    IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                                        MSGBOX "%IDC_BUTTON1=" + FORMAT$(%IDC_BUTTON1), _
                                            %MB_TASKMODAL
                                    END IF
                
                            END SELECT
                    END SELECT
                END FUNCTION
                '------------------------------------------------------------------------------
                
                '------------------------------------------------------------------------------
                '   ** Dialogs **
                '------------------------------------------------------------------------------
                FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                    LOCAL lRslt AS LONG, lFont AS LONG
                
                #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                    LOCAL hDlg  AS DWORD
                    DIM SbParts(1) AS DWORD
                    DIALOG NEW hParent, "Dialog1", 70, 70, 201, 121, %WS_SYSMENU, TO hDlg
                    CONTROL ADD "msctls_statusbar32", hDlg, %IDC_MSCTLS_STATUSBAR32_1, _
                        "", 0, 108, 201, 20, %WS_CHILD OR %WS_VISIBLE, _
                        %WS_EX_TRANSPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
                        %WS_EX_RIGHTSCROLLBAR
                        
                    FONT NEW "Arial", 20 TO lFont
                    CONTROL SET FONT hDlg, %IDC_MSCTLS_STATUSBAR32_1, lFont
                
                    CONTROL ADD BUTTON, GetDlgItem(hDlg, %IDC_MSCTLS_STATUSBAR32_1), %IDC_BUTTON1, "Button1", 1, 2, 120, 40, %WS_CHILD OR %WS_VISIBLE OR  _         ' window styles
                                                 %WS_BORDER OR %WS_TABSTOP, %WS_EX_TRANSPARENT
                
                    SetParent GetDlgItem(hDlg, %IDC_BUTTON1), GetDlgItem(hDlg, %IDC_MSCTLS_STATUSBAR32_1)
                #PBFORMS END DIALOG
                
                    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                
                #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                #PBFORMS END CLEANUP
                
                    FUNCTION = lRslt
                END FUNCTION
                '------------------------------------------------------------------------------
                Regards,
                Peter

                Comment


                • #9
                  Align - none gives me any size and position i like.

                  The caption is vertical centered so i assume it is a feature.
                  hellobasic

                  Comment


                  • #10
                    Take a closer look at my code above.

                    Code:
                            CASE %WM_SIZE
                                ' Dialog has been resized
                                CONTROL SEND CBHNDL, %IDC_MSCTLS_STATUSBAR32_1, CBMSG, CBWPARAM, _
                                    CBLPARAM
                                LOCAL R AS RECT, IPart&, hStat&, hBtn&, X&,Y&,W&,H&, XOffset&
                                IPart&=0
                                CONTROL SEND CBHNDL, %IDC_MSCTLS_STATUSBAR32_1, %SB_GETRECT, IPart&, VARPTR(R)
                                CONTROL HANDLE CBHNDL, %IDC_MSCTLS_STATUSBAR32_1 TO hStat&
                                MapWindowPoints hStat&, CBHNDL, BYVAL VARPTR(R), 2
                                CONTROL HANDLE CBHNDL, %IDC_BUTTON1 TO hBtn&
                                XOffset&=72
                                X&=R.nLeft+GetSystemMetrics(%SM_CXEDGE)
                                Y&=R.nTop+GetSystemMetrics(%SM_CYEDGE)
                                W&=120
                                H&=(R.nBottom-R.nTop)-(2*GetSystemMetrics(%SM_CYEDGE))+1
                                MoveWindow hBtn&, X&+XOffset&,Y&,W&,H&,1
                    The line:

                    IPart&=0

                    Defines which part (or section) of the statusbar to place the button (and size it)

                    The line:

                    XOffset&=72

                    Defines an offset from the far left of the part (section) in pixels to place the button.

                    The line:

                    W&=120

                    Sets the width of the button in pixels. If you want it to fill the entire width of the part (section) of the statusbar you define in IPart& then use:

                    W& = (R.nLeft-R.nRight)-(2*GetSystemMetrics(%SM_CXEDGE))+1

                    This makes the button the entire area (aside from sunken border) of the part (section) of the statusbar defined.
                    Chris Boss
                    Computer Workshop
                    Developer of "EZGUI"
                    http://cwsof.com
                    http://twitter.com/EZGUIProGuy

                    Comment

                    Working...
                    X