Announcement

Collapse
No announcement yet.

Rebar as splitter

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

  • Rebar as splitter

    I was playing around with a splitting up a window area using some code posted by
    Dominic, I stripped it down and want three main child windows...

    The rebar disappears on me while dragging the bands, I think they are trying to attach
    outside the visible area, but not sure.

    Testing,
    grab the Horz rebar,(mousedown and hold) slide to the left and off the window and let go...
    grab the Vert rebar, slide the mouse to the bottom, off the window and let go...

    I'm unable to come up with a solution to prevent this effect.

    Code:
    ' Skeleton code provided by Dominic Mitchell posting...
    
    #COMPILE EXE
    
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"
    
    ' Form1
    %IDD_FORM1           = 100
    %IDC_FORM1_REBAR1    = 101
    %IDC_FORM1_REBAR2    = 102
    %IDC_FORM1_GENERIC1  = 103
    %IDC_FORM1_GENERIC2  = 104
    %IDC_FORM1_GENERIC3  = 105
    ' Rebar1
    %IDS_STRING0         = 32770
    %IDS_STRING19        = 32771
    ' Rebar2
    %IDS_STRING1         = 32784
    %IDS_STRING6         = 32785
    
    GLOBAL  gdwADM_RESIZEBANDS    AS DWORD    ' identifier of registered message
    
    DECLARE FUNCTION RebarSplit_RegisterClasses() AS LONG
    
    '--output debug string to Main window caption
    GLOBAL ghCtl AS DWORD
    SUB dout(BYVAL stext AS STRING)
       sendmessage ghCtl,%WM_SETTEXT,0,BYVAL STRPTR(stext)
    END SUB
    
    
    '----------------------------------------------------------------------
    ' FUNCTION: phnxGetFormHandle
    ' PURPOSE:  Finds the handle of the top-level window or MDI child
    '           window that is the ancestor of the specified window.  The
    '           reference handle is the handle of any control on the form.
    ' RETURNS:  The handle of the form.
    '----------------------------------------------------------------------
    FUNCTION phnxGetFormHandle( BYVAL hWnd  AS DWORD) AS DWORD
    
        WHILE ISTRUE (GetWindowLong(hWnd, %GWL_STYLE) AND %WS_CHILD)
            IF ISTRUE (GetWindowLong(hWnd, %GWL_EXSTYLE) AND %WS_EX_MDICHILD) THEN EXIT LOOP
            hWnd = GetParent(hWnd)
        WEND
    
        FUNCTION = hWnd
    
    END FUNCTION
    
    '-------------------------------------------------------------------------------
    ' PROCEDURE: phnxResizeRebarBands
    ' PURPOSE:   Resizes the bands of a rebar control with the CCS_NORESIZE style
    '            perpendicularly to the orientation of the control.
    ' RETURN:    No return value.
    '-------------------------------------------------------------------------------
    FUNCTION phnxResizeRebarBands(BYVAL hWndRebar AS DWORD,BYVAL fVertical AS LONG ) AS LONG
    
        '-if TRUE, rebar conrol has the CCS_VERT style
    
        LOCAL trc       AS RECT, rc AS RECT
        LOCAL trbbi     AS REBARBANDINFO
        LOCAL lCount    AS LONG
        LOCAL lBandIdx  AS LONG
        LOCAL cyChild   AS LONG
    
        GetClientRect hWndRebar, trc
    
        IF ISFALSE fVertical THEN
            cyChild = trc.nBottom - trc.nTop - 4*GetSystemMetrics(%SM_CXBORDER)
        ELSE
            cyChild = trc.nRight - trc.nLeft - 4*GetSystemMetrics(%SM_CXBORDER)
        END IF
    
        trbbi.cbSize = SIZEOF(trbbi)
        trbbi.fMask  = %RBBIM_CHILDSIZE
    
        lCount   = SendMessage(hWndRebar, %RB_GETBANDCOUNT, 0, 0)
        lBandIdx = 0
    
        DO WHILE lBandIdx < lCount
            SendMessage hWndRebar, %RB_GETBANDINFO, lBandIdx, BYVAL VARPTR(trbbi)
            trbbi.cyMinChild = cyChild
            trbbi.cyChild    = cyChild
            trbbi.cyMaxChild = cyChild
            SendMessage hWndRebar, %RB_SETBANDINFO, lBandIdx, BYVAL VARPTR(trbbi)
            INCR lBandIdx
        LOOP
    
    END FUNCTION
    
    
    '-------------------------------------------------------------------------------
    ' WINMAIN:
    '
    '-------------------------------------------------------------------------------
    
    FUNCTION WINMAIN(BYVAL hInstance AS DWORD,BYVAL hPrevInstance AS DWORD, _
                     BYVAL pszCmdLine AS ASCIIZ PTR,BYVAL nCmdShow AS LONG ) AS LONG
    
        LOCAL tmsg            AS tagMsg
        LOCAL ticc            AS INIT_COMMON_CONTROLSEX
        LOCAL hWnd            AS DWORD
        LOCAL hWndModeless    AS DWORD
    
        LOCAL hInst           AS DWORD
        hInst = GetModuleHandle(BYVAL %NULL)  'handle of the application instance
    
        ' Load the common controls library and specify the classes to register.
        ticc.dwSize = SIZEOF(ticc)
        ticc.dwICC  = %ICC_LISTVIEW_CLASSES OR %ICC_COOL_CLASSES
        InitCommonControlsEx ticc
    
        ' Register custom messages
        gdwADM_RESIZEBANDS = RegisterWindowMessage("ADM_RESIZEBANDS")
    
        ' Register window classes
        IF ISTRUE RebarSplit_RegisterClasses() THEN
            FUNCTION = %FALSE
            EXIT FUNCTION
        END IF
    
        ' Create the Main Form1 window...
        hWnd = CreateWindowEx(%WS_EX_WINDOWEDGE,"Form1_Class","Rebars as splitterbars", _
                            %WS_OVERLAPPEDWINDOW OR %WS_VISIBLE OR _
                            %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN, _
                            70, 130,439, 374, _
                            %NULL, %NULL,hInst, BYVAL %NULL)
    
        ghCtl = hWnd 'save for trouble shooting messages.
    
        ' If window could not be created, return "failure"
        IF ISFALSE hWnd THEN
            FUNCTION = %FALSE :EXIT FUNCTION
        END IF
    
        ' Make the window visible; update its client area
        ShowWindow hWnd, nCmdShow
        UpdateWindow hWnd
    
        ' Main message loop of program.
        ' Acquire and dispatch messages until a WM_QUIT message is received.
        WHILE ISTRUE GetMessage(tmsg, BYVAL %NULL, 0, 0)
            hWndModeless = phnxGetFormHandle(GetFocus())
            IF (ISFALSE hWndModeless) OR (ISFALSE IsDialogMessage(hWndModeless, tmsg)) THEN
                TranslateMessage tmsg
                DispatchMessage tmsg
            END IF
        WEND
    
        FUNCTION = tmsg.wParam
    
    END FUNCTION
    
    '-------------------------------------------------------------------------------
    ' PROCEDURE: RebarSplit_RegisterClasses
    ' PURPOSE:   Registers the window classes that are used in the program.
    ' RETURNS:   FALSE if successful, TRUE if registration failed.
    '-------------------------------------------------------------------------------
    FUNCTION RebarSplit_RegisterClasses() AS LONG
    
        LOCAL szClassName   AS ASCIIZ * %MAX_PATH   ' class name
        LOCAL twcx          AS WNDCLASSEX           ' class information
    
        LOCAL hInst           AS DWORD
        hInst = GetModuleHandle(BYVAL %NULL)  'handle of the application instance
    
        '-Register the window classes that belong to the Form1 window
    
        ' Register the MAIN Form1 window...
        szClassName        = "Form1_Class"
        twcx.cbSize        = SIZEOF(twcx)
        twcx.style         = %CS_DBLCLKS
        twcx.lpfnWndProc   = CODEPTR(Form1_WndProc)
        twcx.cbClsExtra    = 0
        twcx.cbWndExtra    = 0
        twcx.hInstance     = hInst
        twcx.hIcon         = LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
        twcx.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
        twcx.hbrBackground = %COLOR_BTNFACE + 1
        twcx.lpszMenuName  = %NULL
        twcx.lpszClassName = VARPTR(szClassName)
        twcx.hIconSm       = %NULL
    
        IF ISFALSE RegisterClassEx(twcx) THEN
            FUNCTION = %TRUE :EXIT FUNCTION
        END IF
    
        ' Register the Generic1 window
        szClassName        = "Form1_Generic1_Class"
        twcx.cbSize        = SIZEOF(twcx)
        twcx.style         = %CS_DBLCLKS
        twcx.lpfnWndProc   = CODEPTR(Form1_Generic1_WndProc)
        twcx.cbClsExtra    = 0
        twcx.cbWndExtra    = 0
        twcx.hInstance     = hInst
        twcx.hIcon         = %NULL
        twcx.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
        twcx.hbrBackground = %COLOR_BTNFACE + 1
        twcx.lpszMenuName  = %NULL
        twcx.lpszClassName = VARPTR(szClassName)
        twcx.hIconSm       = %NULL
    
        IF ISFALSE RegisterClassEx(twcx) THEN
            FUNCTION = %TRUE :EXIT FUNCTION
        END IF
    
        ' Register the Generic2 window
        szClassName        = "Form1_Generic2_Class"
        twcx.cbSize        = SIZEOF(twcx)
        twcx.style         = %CS_DBLCLKS
        twcx.lpfnWndProc   = CODEPTR(Form1_Generic1_WndProc)
        twcx.cbClsExtra    = 0
        twcx.cbWndExtra    = 0
        twcx.hInstance     = hInst
        twcx.hIcon         = %NULL
        twcx.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
        twcx.hbrBackground = %COLOR_BTNFACE + 1
        twcx.lpszMenuName  = %NULL
        twcx.lpszClassName = VARPTR(szClassName)
        twcx.hIconSm       = %NULL
    
        IF ISFALSE RegisterClassEx(twcx) THEN
            FUNCTION = %TRUE :EXIT FUNCTION
        END IF
    
        ' Register the Generic3 window
        szClassName        = "Form1_Generic3_Class"
        twcx.cbSize        = SIZEOF(twcx)
        twcx.style         = %CS_DBLCLKS
        twcx.lpfnWndProc   = CODEPTR(Form1_Generic3_WndProc)
        twcx.cbClsExtra    = 0
        twcx.cbWndExtra    = 0
        twcx.hInstance     = hInst
        twcx.hIcon         = %NULL
        twcx.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
        twcx.hbrBackground = %COLOR_BTNFACE + 1
        twcx.lpszMenuName  = %NULL
        twcx.lpszClassName = VARPTR(szClassName)
        twcx.hIconSm       = %NULL
    
        IF ISFALSE RegisterClassEx(twcx) THEN
            FUNCTION = %TRUE :EXIT FUNCTION
        END IF
    
      ' All registration successful
      FUNCTION = %FALSE
    
    END FUNCTION
    
    '-------------------------------------------------------------------------------
    ' PROCEDURE: Form1_WndProc
    ' PURPOSE:   Processes messages for the Form1 window.
    '-------------------------------------------------------------------------------
    FUNCTION Form1_WndProc(BYVAL hWnd AS DWORD,BYVAL uMsg AS DWORD, _
                           BYVAL wParam  AS DWORD,BYVAL lParam  AS LONG) AS LONG
    
        LOCAL szItem      AS ASCIIZ * %MAX_PATH   ' working variable
        LOCAL trbi        AS REBARINFO            ' specifies attributes(imagelist) of the rebar control
        LOCAL trbbi       AS REBARBANDINFO        ' specifies or receives the attributes of a rebar band
        LOCAL ptnmhdr     AS NMHDR PTR            ' information about a notification message
        LOCAL ptrbcs      AS NMREBARCHILDSIZE PTR ' information about the change in size of a window embedded in a rebar band
        LOCAL hWndChild   AS DWORD                ' handle of child window
        LOCAL hWndRebar   AS DWORD                ' handle of rebar control
        LOCAL hFont       AS DWORD                ' handle of font used by form
    
    
        '---
        SELECT CASE uMsg
    
            '---
            CASE %WM_NOTIFY
                ptnmhdr = lParam
                '---
                SELECT CASE @ptnmhdr.idFrom
                    '---
                    CASE %IDC_FORM1_REBAR1
                        '---
                        SELECT CASE @ptnmhdr.code
                            '---
                            'CASE %RBN_BEGINDRAG
                            'CASE %RBN_LAYOUTCHANGED
                            '---
                            CASE %RBN_CHILDSIZE
                                ptrbcs = lParam
                                ' Resize the child controls of the embedded window
                                IF @ptrbcs.wID = %IDS_STRING19 THEN
                                    hWndRebar = GetDlgItem(@ptnmhdr.hwndFrom, %IDC_FORM1_REBAR2)
                                    PostMessage hWnd, gdwADM_RESIZEBANDS, 0, hWndRebar
                                END IF
                        END SELECT
                END SELECT
    
    
            '---
            CASE %WM_DESTROY
            PostQuitMessage 0
            FUNCTION = %FALSE :EXIT FUNCTION
    
            '---
            CASE %WM_SIZE
                IF wParam <> %SIZE_MINIMIZED THEN
                    hWndRebar = GetDlgItem(hWnd, %IDC_FORM1_REBAR1)
                    SetWindowPos hWndRebar, %NULL, 0, 0, LOWRD(lParam), HIWRD(lParam), %SWP_NOZORDER OR %SWP_NOMOVE
                    ' Resize rebar panels perpendicular to orientation of rebar
                    PostMessage hWnd, gdwADM_RESIZEBANDS, 0, hWndRebar
                    hWndRebar = GetDlgItem(hWndRebar, %IDC_FORM1_REBAR2)
                    PostMessage hWnd, gdwADM_RESIZEBANDS, 0, hWndRebar
                END IF
                FUNCTION = %FALSE :EXIT FUNCTION
    
            '---
            CASE gdwADM_RESIZEBANDS
                '-Resize rebar panels perpendicular to orientation of rebar
                phnxResizeRebarBands lParam, ( GetWindowLong(lParam, %GWL_STYLE) AND %CCS_VERT )
                phnxResizeRebarBands lParam, ( GetWindowLong(lParam, %GWL_STYLE) AND %CCS_VERT )
                FUNCTION = %FALSE :EXIT FUNCTION
    
            '---
            CASE %WM_CREATE
    
                LOCAL hInst  AS DWORD
                hInst = GetModuleHandle(BYVAL %NULL)  'handle of the application instance
    
                '-Create the Rebar1 rebar control...
                hWndChild = CreateWindowEx(%NULL,"ReBarWindow32","", _
                                     %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR _
                                     %WS_CLIPCHILDREN OR %WS_CLIPSIBLINGS OR _
                                     %CCS_NORESIZE OR %CCS_NODIVIDER OR _
                                     %RBS_VARHEIGHT OR %RBS_FIXEDORDER, _
                                     0, 0,176, 211, _
                                     hWnd, %IDC_FORM1_REBAR1,hInst, BYVAL %NULL)
    
                '-Save the handle of the rebar.  It is used when embedding controls
                hWndRebar = hWndChild
    
                '-Subclass the Rebar control
                SetProp hWndChild, "OLDWNDPROC", SetWindowLong(hWndChild, %GWL_WNDPROC, CODEPTR(Form1_Rebar1_SubclassProc))
                SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
    
                '-Create Generic1 window...
                 hWndChild = CreateWindowEx(%WS_EX_CONTROLPARENT OR %WS_EX_CLIENTEDGE,"Form1_Generic1_Class", "", _
                                     %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR _
                                     %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN, _
                                     9, 2,133, 200, _
                                     hWnd, %IDC_FORM1_GENERIC1,hInst, BYVAL %NULL)
    
    
                '-Add the band containing the Generic1 Window to the rebar...
                trbbi.cbSize     = SIZEOF(trbbi)
                trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                                   %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
                trbbi.fStyle     = %RBBS_CHILDEDGE OR %RBBS_VARIABLEHEIGHT OR %RBBS_NOGRIPPER
                trbbi.hwndChild  = hWndChild
                trbbi.cxMinChild = 1    '-minimum size > 0 so that gripper does not become stuck
                trbbi.cyMinChild = 0
                trbbi.cyChild    = 200
                trbbi.cyMaxChild = 32767
                trbbi.cyIntegral = 0
                trbbi.cx         = 146
                trbbi.wID        = %IDS_STRING0
                trbbi.cxIdeal    = 146
                SendMessage hWndRebar, %RB_INSERTBAND, 0, BYVAL VARPTR(trbbi)
    
                '-Create the Rebar2 rebar control...
                hWndChild = CreateWindowEx(%NULL,"ReBarWindow32", "", _
                                     %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR _
                                     %WS_CLIPCHILDREN OR %WS_CLIPSIBLINGS OR _
                                     %CCS_NORESIZE OR %CCS_NODIVIDER OR %CCS_VERT OR _
                                     %RBS_VARHEIGHT OR %RBS_FIXEDORDER, _
                                     190, 1, 211, 246, _
                                     hWnd, %IDC_FORM1_REBAR2,hInst, BYVAL %NULL)
    
                '-Save the handle of the rebar.  It is used when embedding controls
                hWndRebar = hWndChild
                SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
    
                '-Create the Generic2 window control...
                hWndChild = CreateWindowEx(%WS_EX_CONTROLPARENT OR %WS_EX_CLIENTEDGE,"Form1_Generic2_Class", "", _
                                     %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR _
                                     %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN, _
                                     2, 9,200, 114, _
                                     hWnd, %IDC_FORM1_GENERIC2,hInst, BYVAL %NULL)
    
                '-Add the band containing the Generic2 window to the rebar
                trbbi.cbSize     = SIZEOF(trbbi)
                trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                                   %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
                trbbi.fStyle     = %RBBS_CHILDEDGE OR %RBBS_VARIABLEHEIGHT OR %RBBS_NOGRIPPER
                trbbi.hwndChild  = hWndChild
                trbbi.cxMinChild = 1 ' minimum size > 0 so that gripper does not become stuck
                trbbi.cyMinChild = 0
                trbbi.cyChild    = 200
                trbbi.cyMaxChild = 32767
                trbbi.cyIntegral = 0
                trbbi.cx         = 146
                trbbi.wID        = %IDS_STRING1
                trbbi.cxIdeal    = 146
                SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)
    
                '-Create the Generic3 window...
                hWndChild = CreateWindowEx(%WS_EX_CONTROLPARENT OR %WS_EX_CLIENTEDGE,"Form1_Generic3_Class", "", _
                                     %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR _
                                     %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN, _
                                     2, 138,200, 104, _
                                     hWnd, %IDC_FORM1_GENERIC3,hInst, BYVAL %NULL)
    
                '-Add the band containing the Generic1 window to the rebar
                trbbi.cbSize     = SIZEOF(trbbi)
                trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                                   %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
                trbbi.fStyle     = %RBBS_CHILDEDGE OR %RBBS_VARIABLEHEIGHT OR %RBBS_GRIPPERALWAYS
                trbbi.hwndChild  = hWndChild 'GetDlgItem(hWnd, %IDC_FORM1_GENERIC3)
                trbbi.cxMinChild = 100
                trbbi.cyMinChild = 0
                trbbi.cyChild    = 200
                trbbi.cyMaxChild = 32767
                trbbi.cyIntegral = 0
                trbbi.cx         = 191
                trbbi.wID        = %IDS_STRING6
                trbbi.cxIdeal    = 191
                SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)
    
                '-Add the band containing the second rebar to first rebar
                hWndRebar = GetDlgItem(hWnd, %IDC_FORM1_REBAR1)
                trbbi.cbSize     = SIZEOF(trbbi)
                trbbi.fMask      = %RBBIM_STYLE OR %RBBIM_CHILD OR %RBBIM_CHILDSIZE OR _
                                   %RBBIM_SIZE OR %RBBIM_ID OR %RBBIM_IDEALSIZE
                trbbi.fStyle     = %RBBS_CHILDEDGE OR %RBBS_VARIABLEHEIGHT OR %RBBS_GRIPPERALWAYS
                trbbi.hwndChild  = GetDlgItem(hWnd, %IDC_FORM1_REBAR2)
                trbbi.cxMinChild = 100
                trbbi.cyMinChild = 0
                trbbi.cyChild    = 200
                trbbi.cyMaxChild = 32767
                trbbi.cyIntegral = 0
                trbbi.cx         = 146
                trbbi.wID        = %IDS_STRING19
                trbbi.cxIdeal    = 146
                SendMessage hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(trbbi)
    
                FUNCTION = %FALSE :EXIT FUNCTION
    
        END SELECT
    
        FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
    
    END FUNCTION
    
    '-------------------------------------------------------------------------------
    ' PROCEDURE: Form1_Rebar1_SubclassProc
    ' PURPOSE:   Processes messages for the subclassed Rebar window.
    '-------------------------------------------------------------------------------
    FUNCTION Form1_Rebar1_SubclassProc(BYVAL hWnd AS DWORD,BYVAL uMsg AS DWORD, _
                                       BYVAL wParam AS DWORD,BYVAL lParam AS LONG ) AS LONG
    
        LOCAL lpOldWndProc    AS DWORD    ' address of original window procedure
    
        lpOldWndProc = GetProp(hWnd, "OLDWNDPROC")
    
        '---
        SELECT CASE uMsg
            '---
            CASE %WM_DESTROY
                ' Remove control subclassing
                SetWindowLong hWnd, %GWL_WNDPROC, RemoveProp(hWnd, "OLDWNDPROC")
            '---
            CASE %WM_SETCURSOR
                ' If the window under the cursor is the embedded rebar
                IF wParam = GetDlgItem(hWnd, %IDC_FORM1_REBAR2) THEN
                    ' Forward the message to the embedded rebar
                    SendMessage wParam, uMsg, wParam, lParam
                    ' Return true to stop further processing of this message
                    FUNCTION = %TRUE :EXIT FUNCTION
                END IF
        END SELECT
    
      FUNCTION = CallWindowProc(lpOldWndProc, hWnd, uMsg, wParam, lParam)
    
    END FUNCTION
    
    '-------------------------------------------------------------------------------
    ' PROCEDURE: Form1_Generic1_WndProc
    ' PURPOSE:   Processes messages for the Generic1 window.
    '-------------------------------------------------------------------------------
    FUNCTION Form1_Generic1_WndProc(BYVAL hWnd AS DWORD,BYVAL uMsg AS DWORD, _
                                    BYVAL wParam AS DWORD,BYVAL lParam AS LONG ) AS LONG
    
        LOCAL hWndChild   AS DWORD
        LOCAL hFont       AS DWORD
    
        '---
        SELECT CASE uMsg
            '---
            CASE %WM_COMMAND
                '---
                SELECT CASE LOWRD(wParam)
                END SELECT
            '---
            CASE %WM_DESTROY
                FUNCTION = %FALSE :EXIT FUNCTION
            '---
            CASE %WM_SIZE
            '---
            CASE %WM_CREATE
                LOCAL hInst AS DWORD
                hInst = GetModuleHandle(BYVAL %NULL)
                FUNCTION = %FALSE :EXIT FUNCTION
    
        END SELECT
    
        FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
    
    END FUNCTION
    
    
    '-------------------------------------------------------------------------------
    ' PROCEDURE: Form1_Generic2_WndProc
    ' PURPOSE:   Processes messages for the Generic1 window.
    '-------------------------------------------------------------------------------
    FUNCTION Form1_Generic2_WndProc(BYVAL hWnd AS DWORD,BYVAL uMsg AS DWORD, _
                                    BYVAL wParam AS DWORD,BYVAL lParam AS LONG ) AS LONG
    
        LOCAL hWndChild   AS DWORD
        LOCAL hFont       AS DWORD
    
        '---
        SELECT CASE uMsg
            '---
            CASE %WM_COMMAND
                '---
                SELECT CASE LOWRD(wParam)
                END SELECT
            '---
            CASE %WM_DESTROY
                FUNCTION = %FALSE :EXIT FUNCTION
            '---
            CASE %WM_SIZE
            '---
            CASE %WM_CREATE
                LOCAL hInst AS DWORD
                hInst = GetModuleHandle(BYVAL %NULL)
                FUNCTION = %FALSE :EXIT FUNCTION
    
        END SELECT
    
        FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
    
    END FUNCTION
    
    
    '-------------------------------------------------------------------------------
    ' PROCEDURE: Form1_Generic3_WndProc
    ' PURPOSE:   Processes messages for the Generic1 window.
    '-------------------------------------------------------------------------------
    FUNCTION Form1_Generic3_WndProc(BYVAL hWnd AS DWORD,BYVAL uMsg AS DWORD, _
                                    BYVAL wParam AS DWORD,BYVAL lParam AS LONG ) AS LONG
    
        LOCAL hWndChild   AS DWORD
        LOCAL hFont       AS DWORD
    
        '---
        SELECT CASE uMsg
            '---
            CASE %WM_COMMAND
                '---
                SELECT CASE LOWRD(wParam)
                END SELECT
            '---
            CASE %WM_DESTROY
                FUNCTION = %FALSE :EXIT FUNCTION
            '---
            CASE %WM_SIZE
            '---
            CASE %WM_CREATE
                LOCAL hInst AS DWORD
                hInst = GetModuleHandle(BYVAL %NULL)
                FUNCTION = %FALSE :EXIT FUNCTION
        END SELECT
    
        FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
    
    END FUNCTION
    Best regards
    Jules
    www.rpmarchildon.com

  • #2
    The explanation is simple.
    The horizontal rebar has two bands, therefore, when you drag the gripper in the
    manner you described, the rebar goes from having one row of bands to two rows.
    The second row is out of sight because of what phnxResizeRebarBands does.
    The same holds true for the vertical rebar.
    Dominic Mitchell
    Phoenix Visual Designer
    http://www.phnxthunder.com

    Comment


    • #3
      The code below is a general solution for rebars that should only have one row of bands.
      The rebars should be subclassed.
      Code:
      '-------------------------------------------------------------------------------
      '
      ' PROCEDURE: Form1_Rebar1_SubclassProc
      ' PURPOSE:   Processes messages for the subclassed Rebar window.
      '
      '-------------------------------------------------------------------------------
      
      FUNCTION Form1_Rebar1_SubclassProc _
        ( _
        BYVAL hWnd    AS DWORD, _ ' control handle
        BYVAL uMsg    AS DWORD, _ ' type of message
        BYVAL wParam  AS DWORD, _ ' first message parameter
        BYVAL lParam  AS LONG _   ' second message parameter
        ) EXPORT AS LONG
      
        LOCAL trc             AS RECT
        LOCAL x               AS LONG
        LOCAL y               AS LONG  
        LOCAL cxBorder        AS LONG
        LOCAL lpOldWndProc    AS DWORD    ' address of original window procedure
      
        lpOldWndProc = GetProp(hWnd, "OLDWNDPROC")
      
        SELECT CASE uMsg
          CASE %WM_DESTROY
            ' Remove control subclassing
            SetWindowLong hWnd, %GWL_WNDPROC, RemoveProp(hWnd, "OLDWNDPROC")
      
          CASE %WM_MOUSEMOVE, %WM_LBUTTONUP
            IF GetCapture() = hWnd THEN
              x = LOINT(lParam)
              y = HIINT(lParam)
              GetClientRect hWnd, trc
              cxBorder = 4 * GetSystemMetrics(%SM_CXBORDER)
              IF (GetWindowLong(hWnd, %GWL_STYLE) AND %CCS_VERT) = %CCS_VERT THEN
                IF (x <= cxBorder) OR (x >= (trc.nRight - cxBorder)) THEN
                  ReleaseCapture
                  EXIT FUNCTION
                END IF           
              ELSE  
                IF (y <= cxBorder) OR (y >= (trc.nBottom - cxBorder)) THEN
                  ReleaseCapture
                  EXIT FUNCTION
                END IF
              END IF  
            END IF
        END SELECT
      
        FUNCTION = CallWindowProc(lpOldWndProc, hWnd, uMsg, wParam, lParam)
      
      END FUNCTION
      Dominic Mitchell
      Phoenix Visual Designer
      http://www.phnxthunder.com

      Comment


      • #4
        Personally, I've never used rebar controls. Whenever I've wanted that functionality I just add code to my window's WM_MOUSEMOVE message to see if the mouse is over the spot I want to allow resizing and change the mouse pointer to the appropriate one. I then add code to the WM_LBUTTONDOWN and WM_LBUTTON UP messages to capture and release the mouse if we are resizing.
        Jeff Blakeney

        Comment


        • #5
          Thanks Dominic,
          ...starts me in the right direction, some more tinkering around with it to make it perfect.

          Jeff,
          ...I have done my own splitters in the past too. Exploring different options.

          Thx.
          Regards,
          Jules.
          Best regards
          Jules
          www.rpmarchildon.com

          Comment

          Working...
          X