Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Rebar Demo

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

  • Rebar Demo

    -----------------------------------------REBAR.BAS-------------------------
    Code:
    '/********************************************************************************************
    '* PROGRAM: REBAR.C Released Oct/96, Updated June/1997
    '* The Rebar Control: Using a Coolbar in Your Application.
    '*
    '* By: Nancy Winnick Cluts, Developer Technology Engineer Microsoft Corp.
    '* Read Application Note:  http://msdn.microsoft.com/library/te...msdn_rebar.htm 
    '*
    '* Translation to PBDLL By: Jules Marchildon, FEB. 2nd, 2000  mailto:[email protected][email protected]</A> 
    '* Also, demo's usage of an image list with the Extended ComboBoxEx control.
    '*********************************************************************************************/
     
    $COMPILE EXE  '**Compiled with PBDLL50 OR PBDLL60
     
    '---
    $INCLUDE  "WIN32API.INC"
    $INCLUDE  "COMMCTRL.INC"
    $RESOURCE "REBAR.PBR"
     
    '---
    DECLARE SUB InitLinks()
    DECLARE FUNCTION CreateTheRebar(BYVAL hWndParent AS LONG) AS LONG
    DECLARE FUNCTION CreateComboBox(BYVAL hWndParent AS LONG, BYVAL hWndMain AS LONG) AS LONG
    DECLARE FUNCTION CreateTheToolBar(BYVAL hWndParent AS LONG) AS LONG
     
    '---
    '// menu commands
    %IDM_NEW             =            100
    %IDM_OPEN            =            102
    %IDM_SAVE            =            104
    %IDM_CUT             =            106
    %IDM_COPY            =            108
    %IDM_PASTE           =            110
    %IDM_PRINT           =            112
    %IDM_ABOUT           =            114
    %IDM_EXIT            =            116
    %IDM_BARINFO         =            118
     
    '// identifiers
    %IDB_TOOLBAR         =            125
    %IDB_IE              =            126
    %IDB_SB              =            127
    %IDB_WIN32           =            128
    %IDB_IM              =            129
    %IDB_MSDN            =            130
    %IDB_MSFT            =            131
    %IDB_SMEAR           =            132
    %IDB_BACKGND         =            133
     
    %IDS_NEW             =            200
    %IDS_OPEN            =            201
    %IDS_SAVE            =            202
    %IDS_CUT             =            203
    %IDS_COPY            =            204
    %IDS_PASTE           =            205
    %IDS_PRINT           =            206
    %IDS_ABOUT           =            207
    %IDS_TBBUTTON2       =            208
     
    %ID_TOOLBAR          =            1000
    %ID_REBAR            =            1001
    %ID_COMBO            =            1002
     
    %IDC_NUMBANDS        =            1003
    %IDC_NUMROWS         =            1004
    %IDC_ROWHEIGHT       =            1005
     
    '// other constants
    %NUM_BUTTONS    =    3
    %NUM_BITMAPS    =    10
    %BMP_CX         =    32
    %BMP_CY         =    32
    %MAX_LENGTH     =    64
    %MAX_URLPATH    =    255
    %NUM_LINKS      =    6
    %NUM_TBBUTTONS  =    8
    %NUM_TBBITMAPS  =    8
    %MIN_TBCX       =    200
    %MIN_COMBOCX    =    113
    %MIN_COMBOCY    =    42
    %MIN_CY         =    50
    
     
    '**Skip this if using PBDLL60\COMMCTRL.INC
    $INCLUDE "ComboEx.inc" 'Missing equates in PBDLL50\COMMCTRL.INC
     
     
    '// Structure used for cool links
    TYPE COOLLINKS
       szName AS ASCIIZ*%MAX_LENGTH
       szURL  AS ASCIIZ*%MAX_URLPATH
       iBmp   AS INTEGER
       idx    AS INTEGER
    END TYPE
    
     
    '---
    '// Handles to windows
    GLOBAL hInst        AS LONG
    GLOBAL hWndCombo    AS LONG
    GLOBAL hWndToolBar  AS LONG
    GLOBAL hWndRebar    AS LONG
    GLOBAL lpfnDefCombo AS LONG
    GLOBAL rgLinks()    AS COOLLINKS
     
    '// Image list for combo box
    GLOBAL hIml          AS LONG
    GLOBAL idxFirstImage AS INTEGER
    
     
    '/****************************************************************************
    '*
    '*    FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
    '*
    '*    PURPOSE: calls initialization function, processes message loop
    '*
    '****************************************************************************/
    FUNCTION WINMAIN (BYVAL hInstance     AS LONG, _
                      BYVAL hPrevInstance AS LONG, _
                      lpCmdLine           AS ASCIIZ PTR, _
                      BYVAL nCmdShow      AS LONG) AS LONG
     
      LOCAL Msg         AS tagMsg
      LOCAL wndclass    AS WndClassEx
      LOCAL szClassName AS ASCIIZ * 80
      LOCAL szMenuName  AS ASCIIZ * 80
      LOCAL szChildName AS ASCIIZ * 80
      LOCAL hMenu       AS LONG
      LOCAL hWnd        AS LONG
     
      hInst                  = hInstance
     
      szClassName            = "REBARWClass"
      szMenuName             = "REBARMENU"
      wndclass.cbSize        = SIZEOF(WndClass)
      wndclass.style         = 0
      wndclass.lpfnWndProc   = CODEPTR( WndProc )
      wndclass.cbClsExtra    = 0
      wndclass.cbWndExtra    = 0
      wndclass.hInstance     = hInstance
      wndclass.hIcon         = LoadIcon( hInstance, "REBAR_ICON" )
      wndclass.hCursor       = LoadCursor( %NULL, BYVAL %IDC_ARROW )
      wndclass.hbrBackground = GetStockObject (%WHITE_BRUSH)
      wndclass.lpszMenuName  = VARPTR(szMenuName)
      wndclass.lpszClassName = VARPTR( szClassName )
      wndclass.hIconSm       = LoadIcon( hInstance, BYVAL %IDI_APPLICATION )
      RegisterClassEx wndclass
     
    
      CALL InitLinks()    '<-- initialize the IE Links into the Array of UDT's
    
     
    '---
        hWnd = CreateWindow( _
                "REBARWClass", _
                "REBAR Sample", _
                %WS_OVERLAPPEDWINDOW, _
                %CW_USEDEFAULT, %CW_USEDEFAULT, _
                %CW_USEDEFAULT, %CW_USEDEFAULT, _
                %NULL, _
                %NULL, _
                hInstance, _
                BYVAL %NULL)
     
    
        '/* Make the window visible  update its client area  and return "success" */
        CALL ShowWindow(hWnd, nCmdShow)
        CALL UpdateWindow(hWnd)
    
     
      '/* Acquire and dispatch messages until a WM_QUIT message is received. */
      WHILE GetMessage(Msg, %NULL, 0, 0)
        TranslateMessage Msg
        DispatchMessage Msg
      WEND
     
      FUNCTION = msg.wParam
     
    END FUNCTION
     
    
    ''/****************************************************************************
    '*
    '*    FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
    '*
    '*    PURPOSE:  Processes messages for main window
    '*
    '****************************************************************************/
    FUNCTION WndProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                      BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
     
    LOCAL lpToolTip   AS TOOLTIPTEXT PTR
    STATIC zText      AS ASCIIZ*255
    
     
      SELECT CASE wMsg
     
        CASE %WM_CREATE
     
                CALL CreateTheRebar(hWnd)
                CALL ShowWindow(hWnd, %SW_SHOW)
     
    '---
        CASE %WM_COMMAND
     
          SELECT CASE LOWRD(wParam)
     
            CASE %IDM_NEW
            CASE %IDM_OPEN
            CASE %IDM_SAVE
            CASE %IDM_CUT
            CASE %IDM_COPY
            CASE %IDM_PASTE
            CASE %IDM_PRINT
     
            CASE %IDM_ABOUT
                 CALL DialogBox(hInst, "AboutBox", hWnd, CODEPTR(AboutProc))
     
            CASE %IDM_BARINFO
                 CALL DialogBox(hInst, "BarInfo", hWnd, CODEPTR(BarInfo))
     
            CASE %IDM_EXIT
                 CALL SendMessage (hWnd,%WM_CLOSE, 0, 0)
     
    
          END SELECT
     
    '---
        CASE  %WM_SIZE
              CALL MoveWindow(hWndRebar, 0, 0, LOWRD(lParam), HIWRD(lParam), %TRUE)
     
    
        CASE %WM_NOTIFY
          lpToolTip = lParam
          IF @lpToolTip.hdr.code = %TTN_NEEDTEXT THEN
            LoadString hInst, @lpToolTip.hdr.idFrom, zText, SIZEOF(zText)
            @lpToolTip.lpszText = VARPTR(zText)
          END IF
    
     
    '---
            CASE %WM_DESTROY                   '/* message  window being destroyed */
     
                IF (hWndRebar) THEN
                    CALL DestroyWindow(hWndRebar)
                END IF
     
                IF (hWndToolBar) THEN
                    CALL DestroyWindow(hWndToolBar)
                END IF
     
                IF (hWndCombo) THEN
                    CALL ImageList_Destroy(hIml)
                    CALL DestroyWindow(hWndCombo)
                END IF
     
                CALL PostQuitMessage(0)
     
          FUNCTION = 0
          EXIT FUNCTION
     
      END SELECT
     
      FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
     
    END FUNCTION
    
     
    ''/****************************************************************************
    '*
    '*    FUNCTION  CreateRebar(HWND)
    '*
    '*    PURPOSE   Creates the rebar
    '*
    '****************************************************************************/
    FUNCTION CreateTheRebar(BYVAL hWndParent AS LONG) AS LONG
     
      LOCAL hRebar   AS LONG
      LOCAL rbi      AS REBARINFO
      LOCAL rb       AS REBARBANDINFO
      LOCAL hBmp     AS LONG
      LOCAL hImlBmp  AS LONG
      LOCAL icex     AS INIT_COMMON_CONTROLSEX
     
    
        '// This is where we create the rebar control
        '// First, we initialize the common controls
        icex.dwSize = sizeof(icex)
        icex.dwICC  = %ICC_COOL_CLASSES OR %ICC_USEREX_CLASSES
     
        '// load the rebar and combo
        CALL InitCommonControlsEx(icex)
    
     
        '// create the image list
        hIml = ImageList_Create( _
                      %MIN_COMBOCX, _         '// width
                      %MIN_COMBOCY, _         '// height
                      0,  _                   '// creation flags
                      %NUM_LINKS +1, _        '// number of images
                      0)                      '// amount this list can grow
     
        '// Load the bitmap and add it to the image list.
        hBmp = LoadBitmap(hInst, BYVAL %IDB_SMEAR) ' MAKLNG(%IDB_SMEAR,0))
     
        idxFirstImage = ImageList_Add (hIml, _  '// handle to image list
                                       hBmp, _  '// handle of bitmap to add
                                       %NULL)   '// handle of bitmap mask
     
        '// Create the REBAR control
        hWndRebar = CreateWindowEx( _
                    0, _
                    "ReBarWindow32", _
                    BYVAL %NULL, _
                    %WS_VISIBLE OR %WS_BORDER OR %WS_CHILD OR %WS_CLIPCHILDREN OR _
                    %WS_CLIPSIBLINGS OR %CCS_NODIVIDER OR %CCS_NOPARENTALIGN OR _
                    %RBS_VARHEIGHT OR %RBS_BANDBORDERS, _
                    0, 0, 400, 275, _
                    hWndParent, _
                    %ID_REBAR, _
                    hInst, _
                    BYVAL %NULL )
    
     
        '// Set the image list for the rebar
        rbi.cbSize = sizeof(rbi)
        rbi.fMask  = %RBIM_IMAGELIST
        rbi.himl   = hIml
     
        CALL SendMessage(hWndRebar, %RB_SETBARINFO, 0, BYVAL VARPTR(rbi))
     
        '// Create the combo box
        hWndCombo = CreateComboBox(hWndRebar, hWndParent)
     
        '// Create the toolbar to be added
        hWndToolBar = CreateTheToolBar(hWndRebar)
     
        FUNCTION = 1
     
    END FUNCTION
    
     
    '/****************************************************************************
    '*
    '*    FUNCTION  CreateComboBox(HWND)
    '*
    '*    PURPOSE   Creates the combo box
    '*
    '****************************************************************************/
    FUNCTION CreateComboBox(BYVAL hWndParent AS LONG, BYVAL hWndMain AS LONG) AS LONG
     
        LOCAL idx        AS INTEGER
        LOCAL idxImage   AS INTEGER
        LOCAL rbBand     AS REBARBANDINFO
        LOCAL cbI        AS COMBOBOXEXITEM
        LOCAL hBmp       AS LONG
     
        '// create combo box
        hWndCombo = CreateWindowEx( _
            0, _                                '// extended styles
            "ComboBoxEx32", _                   '// extended combo box
            "", _                               '// default text
            %WS_VISIBLE OR %WS_CHILD OR %WS_TABSTOP OR _
            %WS_VSCROLL OR %WS_CLIPCHILDREN OR %WS_CLIPSIBLINGS OR %CCS_NORESIZE OR _
            %CBS_AUTOHSCROLL OR %CBS_DROPDOWNLIST, _
            0,0, _                              '// x, y
            %MIN_COMBOCX, _                     '// width
            %MIN_COMBOCY * %NUM_LINKS, _        '// height
            hWndParent, _                       '// parent window
            %ID_COMBO, _                        '// ID
            hInst, _                            '// current instance
            BYVAL %NULL )                       '// no class data
    
    
     
        '// Set the image list for the combo box
        CALL SendMessage(hWndCombo, %CBEM_SETIMAGELIST, 0, hIml)
     
        '// Add strings to the combo box
        FOR idx = 0  TO %NUM_LINKS -1
    
     
            '// Load the bitmap and add it to the image list.
            hBmp = LoadBitmap (hInst, BYVAL rgLinks(idx).iBmp) 'MAKLNG(rgLinks(idx).iBmp,0))
     
            idxImage = ImageList_Add(hIml, _  '// handle to image list
                                     hBmp, _  '// handle of bitmap to add
                                     %NULL)   '// handle of bitmap mask
    
     
            rgLinks(idx).idx   = idxImage
     
            DIM szLinkName AS ASCIIZ*%MAX_LENGTH
            DIM szPathName AS ASCIIZ*%MAX_URLPATH
            szLinkName = rgLinks(idx).szName
            szPathName = rgLinks(idx).szURL
     
            cbI.mask           = %CBEIF_TEXT OR %CBEIF_LPARAM OR %CBEIF_IMAGE OR %CBEIF_SELECTEDIMAGE
            cbI.pszText        = VARPTR(szLinkName) 'rgLinks(idx).szName
            cbI.cchTextMax     = sizeof(szLinkName) 'sizeof(rgLinks(idx).szName)
            cbI.lParam         = VARPTR(szPathName) 'rgLinks(idx).szURL
            cbI.iItem          = -1
            cbI.iImage         = idxImage           '// Image to display
            cbI.iSelectedImage = idxImage           '// Image to display
     
            '// Add the item to the combo box drop-down list
            CALL SendMessage(hWndCombo, %CBEM_INSERTITEM, 0,BYVAL VARPTR(cbI))
     
        NEXT
     
    '---
     
        '// Initialize REBARBANDINFO
        Dim szTopic As Asciiz*80
        szTopic = "Cool sites:"
    
        rbBand.cbSize     = sizeof(rbBand)
        rbBand.fMask      = %RBBIM_COLORS OR _       '// clrFore and clrBack are valid
                            %RBBIM_CHILD OR _        '// hwndChild is valid
                            %RBBIM_CHILDSIZE OR _    '// cxMinChild and cyMinChild are valid
                            %RBBIM_STYLE OR _        '// fStyle is valid
                            %RBBIM_ID OR _           '// wID is valid
                            %RBBIM_TEXT OR _         '// lpText is valid
                            %RBBIM_IMAGE OR _        '// iImage is valid
                            %RBBIM_BACKGROUND        '// hbmBack is valid
        rbBand.clrFore    = GetSysColor(%COLOR_BTNTEXT)
        rbBand.clrBack    = GetSysColor(%COLOR_BTNFACE)
        rbBand.fStyle     = %RBBS_NOVERT OR _        '// do not display in vertical orientation
                            %RBBS_CHILDEDGE OR _
                            %RBBS_FIXEDBMP
        rbBand.hbmBack    = LoadBitmap(hInst, BYVAL %IDB_BACKGND) 'MAKLNG(%IDB_BACKGND,0))
        rbBand.lpText     = VARPTR(szTopic)
        rbBand.hwndChild  = hWndCombo
        rbBand.cxMinChild = %MIN_COMBOCX
        rbBand.cyMinChild = %MIN_CY
        rbBand.iImage     = idxFirstImage
     
        '// Add the combo box band to the end
        CALL SendMessage(hWndRebar, %RB_INSERTBAND, -1, VARPTR(rbBand))
     
        '// Select a default item in the combo box
        CALL SendMessage(hWndCombo, %CB_SETCURSEL, 0, 0)
     
        '// Set the window procedure for the combo box.
        lpfnDefCombo = GetWindowLong(hWndCombo, %GWL_WNDPROC)
        CALL SetWindowLong(hWndCombo, %GWL_WNDPROC, BYVAL CODEPTR(ComboWndProc))
     
        FUNCTION = hWndCombo
     
    END FUNCTION
    
     
    
    '/****************************************************************************
    '*
    '*    FUNCTION  ComboWndProc(HWND, UINT, WPARAM, LPARAM)
    '*
    '*    PURPOSE   Get the selected link and send it to IE to display.
    '*
    '****************************************************************************/
    FUNCTION ComboWndProc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                          BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
     
        LOCAL iSelect AS INTEGER
     
        SELECT CASE wMsg
            CASE %WM_COMMAND
                SELECT CASE HIWRD(wParam)
     
                    CASE %CBN_SELCHANGE
                         
                      '  CALL ShellExecute( %NULL, _
                      '     "open", rgLinks(iSelect).szURL, _
                      '     ByVal %NULL, ByVal %NULL, %SW_SHOWNORMAL)
     
                    FUNCTION = 1
     
                END SELECT
        END SELECT
     
        FUNCTION = CallWindowProc(lpfnDefCombo, hWnd, wMsg, wParam, lParam)
     
    END FUNCTION
    
     
    '/****************************************************************************
    '*
    '*    FUNCTION  CreateTheToolBar(REBARBANDINFO)
    '*
    '*    PURPOSE   Creates the toolbar
    '*
    '****************************************************************************/
    FUNCTION CreateTheToolBar(BYVAL hWndParent AS LONG) AS LONG
     
      LOCAL rbBand   AS REBARBANDINFO
     
      DIM tbb(0 to 7) AS TBBUTTON
     
      ' Fill the TBBUTTON array with button information
      tbb(0).iBitmap   = 0
      tbb(0).idCommand = %IDM_NEW
      tbb(0).fsState   = %TBSTATE_ENABLED
      tbb(0).fsStyle   = %TBSTYLE_BUTTON
      tbb(0).dwData    = 0
      tbb(0).iString   = %IDS_NEW
     
      tbb(1).iBitmap   = 1
      tbb(1).idCommand = %IDM_OPEN
      tbb(1).fsState   = %TBSTATE_ENABLED
      tbb(1).fsStyle   = %TBSTYLE_BUTTON
      tbb(1).dwData    = 0
      tbb(1).iString   = %IDS_OPEN
     
      tbb(2).iBitmap   = 2
      tbb(2).idCommand = %IDM_SAVE
      tbb(2).fsState   = %TBSTATE_ENABLED
      tbb(2).fsStyle   = %TBSTYLE_BUTTON
      tbb(2).dwData    = 0
      tbb(2).iString   = %IDS_SAVE
     
      tbb(3).iBitmap   = 3
      tbb(3).idCommand = %IDM_CUT
      tbb(3).fsState   = %TBSTATE_ENABLED
      tbb(3).fsStyle   = %TBSTYLE_BUTTON
      tbb(3).dwData    = 0
      tbb(3).iString   = %IDS_CUT
     
      tbb(4).iBitmap   = 4
      tbb(4).idCommand = %IDM_COPY
      tbb(4).fsState   = %TBSTATE_ENABLED
      tbb(4).fsStyle   = %TBSTYLE_BUTTON
      tbb(4).dwData    = 0
      tbb(4).iString   = %IDS_COPY
     
      tbb(5).iBitmap   = 5
      tbb(5).idCommand = %IDM_PASTE
      tbb(5).fsState   = %TBSTATE_ENABLED
      tbb(5).fsStyle   = %TBSTYLE_BUTTON
      tbb(5).dwData    = 0
      tbb(5).iString   = %IDS_PASTE
     
      tbb(6).iBitmap   = 6
      tbb(6).idCommand = %IDM_PRINT
      tbb(6).fsState   = %TBSTATE_ENABLED
      tbb(6).fsStyle   = %TBSTYLE_BUTTON
      tbb(6).dwData    = 0
      tbb(6).iString   = %IDS_PRINT
     
      tbb(7).iBitmap   = 7
      tbb(7).idCommand = %IDM_ABOUT
      tbb(7).fsState   = %TBSTATE_ENABLED
      tbb(7).fsStyle   = %TBSTYLE_BUTTON
      tbb(7).dwData    = 0
      tbb(7).iString   = %IDS_ABOUT
    
     
    
        hWndToolBar = CreateToolbarEx(hWndParent, _
            %WS_CHILD OR %TBSTYLE_LIST OR %TBSTYLE_FLAT OR %TBSTYLE_TOOLTIPS OR %WS_CLIPCHILDREN OR _
            %WS_CLIPSIBLINGS OR %CCS_NODIVIDER OR %CCS_NORESIZE OR %WS_VISIBLE, _
            %ID_TOOLBAR, _
            %NUM_TBBITMAPS, _
            hInst, _
            %IDB_TOOLBAR, _
            tbb(0), _
            %NUM_TBBUTTONS, _
            %BMP_CX,%BMP_CY, _                 '// width & height of buttons
            %BMP_CX,%BMP_CY, _                 '// width & height of bitmaps
            LEN(TBBUTTON))
    
    
     
        '// Initialize REBARBANDINFO for all rebar bands
        rbBand.cbSize    = sizeof(rbBand)
        rbBand.fMask     = %RBBIM_COLORS    OR _    '// clrFore and clrBack are valid
                           %RBBIM_CHILD     OR _    '// hwndChild is valid
                           %RBBIM_CHILDSIZE OR _    '// cxMinChild and cyMinChild are valid
                           %RBBIM_STYLE     OR _    '// fStyle is valid
                           %RBBIM_ID        OR _    '// wID is valid
                           %RBBIM_BACKGROUND        '// hbmBack is valid
        rbBand.clrFore    = GetSysColor(%COLOR_BTNTEXT)
        rbBand.clrBack    = GetSysColor(%COLOR_BTNFACE)
        rbBand.fStyle     = %RBBS_NOVERT    OR _    '// do not display in vertical orientation
                            %RBBS_CHILDEDGE OR _
                            %RBBS_FIXEDBMP
        rbBand.hbmBack    = LoadBitmap(hInst, BYVAL %IDB_BACKGND) 'MAKLNG(%IDB_BACKGND,0))
        rbBand.hwndChild  = hWndToolBar
        rbBand.wID        = %ID_TOOLBAR
        rbBand.cxMinChild = %MIN_TBCX
        rbBand.cyMinChild = %MIN_CY
     
        '// Insert band into rebar
        CALL SendMessage(hWndRebar, %RB_INSERTBAND, -1, BYVAL VARPTR(rbBand))
     
        FUNCTION = hWndToolBar
     
    END FUNCTION
    
     
    '/****************************************************************************
    '*
    '*    FUNCTION  BarInfo(HWND, UINT, UINT, LONG)
    '*
    '*    PURPOSE   Processes messages for "BarInfo" dialog box
    '*              It calls RB_GETBARINFO, RB_GETBANDCOUNT,
    '*              RB_GETROWHEIGHT, and RB_GETROWCOUNT
    '*              to get information about the rebar
    '*              then displays the information in the dialog box fields.
    '*
    '****************************************************************************/
    FUNCTION BarInfo(BYVAL hDlg AS LONG, BYVAL wMsg AS LONG, _
                     BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
     
    
    STATIC uHeight    AS INTEGER
    STATIC uRowCount  AS INTEGER
    STATIC uBandCount AS INTEGER
    STATIC rbi        AS REBARINFO
     
        SELECT CASE wMsg
      
            CASE %WM_INITDIALOG
                '// get the number of bands
                uBandCount = SendMessage(hWndRebar, %RB_GETBANDCOUNT, 0, 0)
                CALL SetDlgItemInt(hDlg, %IDC_NUMBANDS, uBandCount, %FALSE)
                '// get the number of rows
                uRowCount = SendMessage(hWndRebar, %RB_GETROWCOUNT, 0, 0)
                CALL SetDlgItemInt(hDlg, %IDC_NUMROWS, uRowCount, %FALSE)
                '// get the row height for the first row
                uHeight = SendMessage(hWndRebar, %RB_GETROWHEIGHT, 0, 0)
                CALL SetDlgItemInt(hDlg, %IDC_ROWHEIGHT, uHeight, %FALSE)
                FUNCTION =1
     
            CASE %WM_COMMAND
                SELECT CASE LOWRD(wParam)
     
                    CASE %IDOK
                    EndDialog hDlg, 1
                    FUNCTION = 1
     
                END SELECT
        END SELECT
    END FUNCTION
     
    '/****************************************************************************
    '*
    '*    FUNCTION  About(HWND, UINT, UINT, LONG)
    '*
    '*    PURPOSE   Processes messages for "About" dialog box
    '*
    '****************************************************************************/
    FUNCTION AboutProc(BYVAL hDlg AS LONG, BYVAL wMsg AS LONG, _
                       BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
    
     
        SELECT CASE wMsg
     
            CASE %WM_INITDIALOG
                FUNCTION = %TRUE
     
            CASE %WM_COMMAND
                SELECT CASE LOWRD(wParam)
     
                    CASE %IDOK
                    EndDialog hDlg, 1
                    FUNCTION = 1
     
                END SELECT
     
      END SELECT
     
    END FUNCTION
    
     
    '---
    SUB InitLinks()     '// global array of cool links
     
        DIM rgLinks(0:5) AS COOLLINKS
     
        rgLinks(0).szName = "Microsoft"
        rgLinks(0).szURL  = "http://www.microsoft.com/default.htm"
        rgLinks(0).iBmp   = %IDB_MSFT
        rgLinks(0).idx    = 0
     
        rgLinks(1).szName = "Site Builder"
        rgLinks(1).szURL  = "http://www.microsoft.com/workshop/default.htm"
        rgLinks(1).iBmp   = %IDB_SB
        rgLinks(1).idx    = 0
     
        rgLinks(2).szName = "Win32 Development"
        rgLinks(2).szURL  = "http://www.microsoft.com/win32dev/default.htm"
        rgLinks(2).iBmp   = %IDB_WIN32
        rgLinks(2).idx    = 0
     
        rgLinks(3).szName = "Interactive Media"
        rgLinks(3).szURL  = "http://www.microsoft.com/imedia/default.htm"
        rgLinks(3).iBmp   = %IDB_IM
        rgLinks(3).idx    = 0
     
        rgLinks(4).szName = "Microsoft Developer Network"
        rgLinks(4).szURL  = "http://www.microsoft.com/msdn/default.htm"
        rgLinks(4).iBmp   = %IDB_MSDN
        rgLinks(4).idx    = 0
     
        rgLinks(5).szName = "Internet Explorer"
        rgLinks(5).szURL  = "http://www.microsoft.com/ie30/default.htm"
        rgLinks(5).iBmp   = %IDB_IE
        rgLinks(5).idx    = 0
     
    END SUB

    -----------------------------------------COMBOEX.INC-----------------------

    Code:
    '-------------------------------------------------------------
    ' File: ComboEx.inc
    ' Missing equates, flags, structures for PBDLL50\COMMCTRL.INC
    ' Used for Extended Combo Box   "ComboBoxEx32" Class
    '-------------------------------------------------------------
    %CBEIF_TEXT             = &H00000001
    %CBEIF_IMAGE            = &H00000002
    %CBEIF_SELECTEDIMAGE    = &H00000004
    %CBEIF_OVERLAY          = &H00000008
    %CBEIF_INDENT           = &H00000010
    %CBEIF_LPARAM           = &H00000020
     
    %CBEIF_DI_SETITEM       = &H10000000
     
    TYPE COMBOBOXEXITEM
      mask           AS DWORD
      iItem          AS LONG
      pszText        AS ASCIIZ PTR
      cchTextMax     AS LONG
      iImage         AS LONG
      iSelectedImage AS LONG
      iOverlay       AS LONG
      iIndent        AS LONG
      lParam         AS LONG
    END TYPE
     
    %CBEM_INSERTITEM        = %WM_USER + 1
    %CBEM_SETIMAGELIST      = %WM_USER + 2
    %CBEM_GETIMAGELIST      = %WM_USER + 3
    %CBEM_GETITEM           = %WM_USER + 4
    %CBEM_SETITEM           = %WM_USER + 5
    %CBEM_DELETEITEM        = %CB_DELETESTRING
    %CBEM_GETCOMBOCONTROL   = %WM_USER + 6
    %CBEM_GETEDITCONTROL    = %WM_USER + 7
    %CBEM_SETEXSTYLE        = %WM_USER + 8     ' use  SETEXTENDEDSTYLE instead
    %CBEM_SETEXTENDEDSTYLE  = %WM_USER + 14    ' lparam == new style, wParam (optional) == mask
    %CBEM_GETEXSTYLE        = %WM_USER + 9     ' use GETEXTENDEDSTYLE instead
    %CBEM_GETEXTENDEDSTYLE  = %WM_USER + 9
    %CBEM_SETUNICODEFORMAT  = %CCM_SETUNICODEFORMAT
    %CBEM_GETUNICODEFORMAT  = %CCM_GETUNICODEFORMAT
    %CBEM_HASEDITCHANGED    = %WM_USER + 10
     
    %CBES_EX_NOEDITIMAGE         = &H00000001
    %CBES_EX_NOEDITIMAGEINDENT   = &H00000002
    %CBES_EX_PATHWORDBREAKPROC   = &H00000004
    %CBES_EX_NOSIZELIMIT         = &H00000008
    %CBES_EX_CASESENSITIVE       = &H00000010
     
    TYPE NMCOMBOBOXEX
      hdr AS NMHDR
      ceItem AS COMBOBOXEXITEM
    END TYPE
     
    %CBEN_GETDISPINFO        = %CBEN_FIRST - 0
    %CBEN_INSERTITEM         = %CBEN_FIRST - 1
    %CBEN_DELETEITEM         = %CBEN_FIRST - 2
    %CBEN_BEGINEDIT          = %CBEN_FIRST - 4
    %CBEN_ENDEDIT            = %CBEN_FIRST - 5
    %CBEN_DRAGBEGIN          = %CBEN_FIRST - 8
     
    %CBENF_KILLFOCUS         = 1
    %CBENF_RETURN            = 2
    %CBENF_ESCAPE            = 3
    %CBENF_DROPDOWN          = 4
     
    %CBEMAXSTRLEN            = 260
     
    ' CBEN_DRAGBEGIN sends this information ...
     
    TYPE NMCBEDRAGBEGIN
      hdr AS NMHDR
      iItemid AS LONG
      szText AS ASCIIZ * %CBEMAXSTRLEN
    END TYPE
     
    ' CBEN_ENDEDIT sends this information...
    ' fChanged if the user actually did anything
    ' iNewSelection gives what would be the new selection unless the notify is failed
    '                      iNewSelection may be CB_ERR if there's no match
    TYPE NMCBEENDEDIT
      hdr AS NMHDR
      fChanged AS LONG
      iNewSelection AS LONG
      szText AS ASCIIZ * %CBEMAXSTRLEN
      iWhy AS LONG
    END TYPE


    ------------------------------------------REBAR.RC-------------------------
    Code:
    #include "resource.h"
     
    #define IDM_NEW                         100
    #define IDM_OPEN                        102
    #define IDM_SAVE                        104
    #define IDM_CUT                         106
    #define IDM_COPY                        108
    #define IDM_PASTE                       110
    #define IDM_PRINT                       112
    #define IDM_ABOUT                       114
    #define IDM_EXIT                        116
    #define IDM_BARINFO                     118
     
    #define IDB_TOOLBAR                     125
    #define IDB_IE                          126
    #define IDB_SB                          127
    #define IDB_WIN32                       128
    #define IDB_IM                          129
    #define IDB_MSDN                        130
    #define IDB_MSFT                        131
    #define IDB_SMEAR                       132
    #define IDB_BACKGND                     133
     
    #define IDS_NEW                         200
    #define IDS_OPEN                        201
    #define IDS_SAVE                        202
    #define IDS_CUT                         203
    #define IDS_COPY                        204
    #define IDS_PASTE                       205
    #define IDS_PRINT                       206
    #define IDS_ABOUT                       207
    #define IDS_TBBUTTON2                   208
     
    #define ID_TOOLBAR                      1000
    #define ID_REBAR                        1001
    #define ID_COMBO                        1002
    #define IDC_NUMBANDS                    1003
    #define IDC_NUMROWS                     1004
    #define IDC_ROWHEIGHT                   1005
     
     
    REBAR_ICON              ICON    DISCARDABLE     "REBAR.ICO"
     
    IDB_TOOLBAR             BITMAP  DISCARDABLE     "TOOLBAR.BMP"
    IDB_BACKGND             BITMAP  DISCARDABLE     "BACKGND.BMP"
    IDB_IE                  BITMAP  DISCARDABLE     "IE.BMP"
    IDB_SB                  BITMAP  DISCARDABLE     "SB.BMP"
    IDB_WIN32               BITMAP  DISCARDABLE     "WIN32.BMP"
    IDB_IM                  BITMAP  DISCARDABLE     "IM.BMP"
    IDB_MSFT                BITMAP  DISCARDABLE     "MSFT.BMP"
    IDB_SMEAR               BITMAP  DISCARDABLE     "SMEAR.BMP"
    IDB_MSDN                BITMAP  DISCARDABLE     "MSDN.BMP"
     
     
    REBARMENU MENU DISCARDABLE
    BEGIN
        POPUP "Options"
        BEGIN
            MENUITEM "&Rebar Information",          IDM_BARINFO
            MENUITEM "&About",                      IDM_ABOUT
            MENUITEM SEPARATOR
            MENUITEM "E&xit",                       IDM_EXIT
        END
    END
     
     
    STRINGTABLE DISCARDABLE
    BEGIN
        IDM_NEW,                 "New file"
        IDM_OPEN,                "Open the file"
        IDM_SAVE,                "Save the file"
        IDM_CUT,                 "Cut  selected text to clipboard"
        IDM_COPY,                "Copy selected text to clipboard"
        IDM_PASTE,               "Paste clipboard text"
        IDM_PRINT,               "Print"
        IDM_ABOUT,               "About this sample"
        IDS_TBBUTTON2,           "Band Info"
    END
      
     
    ABOUTBOX DIALOG DISCARDABLE  160, 78, 144, 77
    STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
    CAPTION "About the Rebar Sample"
    FONT 8, "MS Sans Serif"
    BEGIN
        PUSHBUTTON      "OK",IDOK,54,51,40,14
        LTEXT           "Rebar Sample version 1.0",-1,25,17,92,8
        LTEXT           "written by Nancy Winnick Cluts",-1,19,27,106,8,NOT WS_GROUP
        LTEXT           "Microsoft Developer Network",-1,22,37,99,8,NOT WS_GROUP
    END
     
     
    BARINFO DIALOG DISCARDABLE  0, 0, 165, 114
    STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "Rebar Information"
    FONT 8, "MS Sans Serif"
    BEGIN
        DEFPUSHBUTTON   "OK",IDOK,7,93,50,14
        LTEXT           "Number of Rows:",IDC_STATIC,7,36,56,12
        LTEXT           "Height (in pixels) of First Row:",IDC_STATIC,7,56,97,10
        LTEXT           "Number of Bands:",IDC_STATIC,7,18,57,10
        EDITTEXT        IDC_NUMBANDS,69,16,77,13,ES_AUTOHSCROLL
        EDITTEXT        IDC_NUMROWS,70,36,76,12,ES_AUTOHSCROLL
        EDITTEXT        IDC_ROWHEIGHT,103,55,43,12,ES_AUTOHSCROLL
    END




    [This message has been edited by Jules Marchildon (edited February 02, 2000).]
    Best regards
    Jules
    www.rpmarchildon.com

  • #2
    Does anyone have the original resource file for this demo, "REBAR.PBR", or the separate files listed below that allow the correct compilation of the "REBAR.RC" file. and so make it possible to use this nice demo program?
    Code:
    REBAR_ICON              ICON    DISCARDABLE     "REBAR.ICO"
    
    IDB_TOOLBAR             BITMAP  DISCARDABLE     "TOOLBAR.BMP"
    IDB_BACKGND             BITMAP  DISCARDABLE     "BACKGND.BMP"
    IDB_IE                  BITMAP  DISCARDABLE     "IE.BMP"
    IDB_SB                  BITMAP  DISCARDABLE     "SB.BMP"
    IDB_WIN32               BITMAP  DISCARDABLE     "WIN32.BMP"
    IDB_IM                  BITMAP  DISCARDABLE     "IM.BMP"
    IDB_MSFT                BITMAP  DISCARDABLE     "MSFT.BMP"
    IDB_SMEAR               BITMAP  DISCARDABLE     "SMEAR.BMP"
    IDB_MSDN                BITMAP  DISCARDABLE     "MSDN.BMP"
    "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

    Comment


    • #3
      I do believe this is it. or very close
      REBAR.zip the original source from MS.
      Attached Files
      Last edited by Michael Mayerhoffer; 4 Feb 2017, 08:52 AM.
      A dozen what.

      Comment


      • #4
        Wow!

        Very thanks, Michael!
        "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

        Comment


        • #5
          Arthur, can you please post the completed code that can be compiled to the latest PB Win 10?

          I compiled it but it exit immediately upon execution, there must be something wrong in my amended code.

          Comment


          • #6
            I got this, I only added a valid manifest...

            RebarDemoJules.zip

            Pierre

            Comment


            • #7
              Thanks so much Pierre

              Comment


              • #8
                Well, I was struggling with this old version. I was unaware of the existence of the latest version ... good solution, Pierre!

                Very thanks,

                Arthur.
                "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

                Comment

                Working...
                X