I was looking for an example of a rebar, in the templats are a few examples.
The icons are very small on my screen, can I adjust that somewhere?
' ########################################################################################
' Microsoft Windows
' File: CW_COMMCTRL_Rebar.fbtpl
' Contents: CWindow with a rebar control
' Compiler: FreeBasic 32 & 64 bit
' Copyright (c) 2016 José Roca. Freeware. Use at your own risk.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#define UNICODE
#define _WIN32_WINNT &h0602
#INCLUDE ONCE "Afx/CWindow.inc"
USING Afx
DECLARE FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL szCmdLine AS ZSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
END WinMain(GetModuleHandleW(NULL), NULL, COMMAND(), SW_NORMAL)
CONST IDC_TOOLBAR = 1001
CONST IDC_CBBOX = 1002
CONST IDC_REBAR = 1003
enum
IDM_CUT = 28000
IDM_COPY, IDM_PASTE, IDM_UNDO, IDM_REDOW, IDM_DELETE, IDM_FILENEW, IDM_FILEOPEN
IDM_FILESAVE, IDM_PRINTPRE, IDM_PROPERTIES, IDM_HELP, IDM_FIND, IDM_REPLACE, IDM_PRINT
end enum
' // Forward declaration
DECLARE FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
' ========================================================================================
' Create the toolbar
' ========================================================================================
FUNCTION CreateToolbar (BYVAL pWindow AS CWindow PTR) AS HWND
' // Add a tooolbar
DIM hToolBar AS HWND = pWindow->AddControl("Toolbar", , IDC_TOOLBAR, "", , , , , _
WS_CHILD OR WS_VISIBLE OR TBSTYLE_TOOLTIPS OR TBSTYLE_FLAT OR CCS_NODIVIDER OR CCS_NORESIZE OR CCS_NOPARENTALIGN)
' // Allow drop down arrows
Toolbar_SetExtendedStyle(hToolBar, TBSTYLE_EX_DRAWDDARROWS)
' // Add a bitmap with the button images
DIM ttbab AS TBADDBITMAP
ttbab.hInst = HINST_COMMCTRL
IF AfxIsProcessDPIAware THEN
ttbab.nId = IDB_STD_LARGE_COLOR
ELSE
ttbab.nId = IDB_STD_SMALL_COLOR
END IF
Toolbar_AddBitmap(hToolBar, 0, @ttbab)
' // Add buttons to the toolbar
Toolbar_AddButton hToolBar, STD_CUT, IDM_CUT
Toolbar_AddButton hToolBar, STD_COPY, IDM_COPY
Toolbar_AddButton hToolBar, STD_PASTE, IDM_PASTE
Toolbar_AddButton hToolBar, STD_DELETE, IDM_DELETE
Toolbar_AddSeparator hToolBar
Toolbar_AddButton hToolBar, STD_UNDO, IDM_UNDO
Toolbar_AddButton hToolBar, STD_REDOW, IDM_REDOW
Toolbar_AddSeparator hToolBar
Toolbar_AddButton hToolBar, STD_FILENEW, IDM_FILENEW, 0, BTNS_DROPDOWN
Toolbar_AddButton hToolBar, STD_FILEOPEN, IDM_FILEOPEN
Toolbar_AddButton hToolBar, STD_FILESAVE, IDM_FILESAVE
Toolbar_AddButton hToolBar, STD_PRINTPRE, IDM_PRINTPRE
Toolbar_AddSeparator hToolBar
Toolbar_AddButton hToolBar, STD_FIND, IDM_FIND
Toolbar_AddButton hToolBar, STD_REPLACE, IDM_REPLACE
Toolbar_AddSeparator hToolBar
Toolbar_AddButton hToolBar, STD_PROPERTIES, IDM_PROPERTIES
Toolbar_AddButton hToolBar, STD_PRINT, IDM_PRINT
Toolbar_AddSeparator hToolBar
Toolbar_AddButton hToolBar, STD_HELP, IDM_HELP
' // Size the toolbar
Toolbar_AutoSize(hToolBar)
' // Return the toolbar handle
FUNCTION = hToolbar
END FUNCTION
' ========================================================================================
' ========================================================================================
' Main
' ========================================================================================
FUNCTION WinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL szCmdLine AS ZSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
' // Set process DPI aware
AfxSetProcessDPIAware
DIM pWindow AS CWindow
pWindow.Create(NULL, "CWindow with a rebar", @WndProc)
' // Disable background erasing
pWindow.ClassStyle = CS_DBLCLKS
' // Set the client size
pWindow.SetClientSize(600, 250)
' // Center the window
pWindow.Center
' // Add a button
DIM hButton AS HWND = pWindow.AddControl("Button", , IDCANCEL, "&Close")
' // Create a rebar control
DIM hRebar AS HWND = pWindow.AddControl("Rebar", , IDC_REBAR)
' // Create the toolbar
DIM hToolbar AS HWND = CreateToolbar(@pWindow)
' // Add the band containing the toolbar control to the rebar
' // The size of the REBARBANDINFOW is different in Vista/Windows 7
DIM rc AS RECT, wszText AS WSTRING * 260
DIM rbbi AS REBARBANDINFOW
IF AfxWindowsVersion >= 600 AND AfxComCtlVersion >= 600 THEN
rbbi.cbSize = REBARBANDINFO_V6_SIZE
ELSE
rbbi.cbSize = REBARBANDINFO_V3_SIZE
END IF
' // Insert the toolbar in the rebar control
rbbi.fMask = RBBIM_STYLE OR RBBIM_CHILD OR RBBIM_CHILDSIZE OR _
RBBIM_SIZE OR RBBIM_ID OR RBBIM_IDEALSIZE OR RBBIM_TEXT
rbbi.fStyle = RBBS_CHILDEDGE
rbbi.hwndChild = hToolbar
rbbi.cxMinChild = 270 * pWindow.rxRatio
rbbi.cyMinChild = Toolbar_GetButtonHeight(hToolbar)
rbbi.cx = 270 * pWindow.rxRatio
rbbi.cxIdeal = 270 * pWindow.rxRatio
wszText = "Toolbar"
rbbi.lpText = @wszText
'// Insert band into rebar
Rebar_InsertBand(hRebar, -1, @rbbi)
SendMessageW ( hRebar, TB_SETBUTTONSIZE, 0, MAKELONG(64, 64))
' ' // Insert a combobox in the rebar control
DIM hCbBox AS HWND = pWindow.AddControl("ComboBox", , IDC_CBBOX, "", 0, 0, 0, 50 * pWindow.rxRatio)
GetWindowRect hCbBox, @rc
rbbi.fMask = RBBIM_STYLE OR RBBIM_CHILD OR RBBIM_CHILDSIZE OR _
RBBIM_SIZE OR RBBIM_ID OR RBBIM_IDEALSIZE OR RBBIM_TEXT
rbbi.fStyle = RBBS_FIXEDSIZE OR RBBS_CHILDEDGE
rbbi.hwndChild = hCbBox
rbbi.cxMinChild = 200 * pWindow.rxRatio
rbbi.cyMinChild = rc.Bottom - rc.Top
rbbi.cx = 200 * pWindow.rxRatio
rbbi.cxIdeal = 200 * pWindow.rxRatio
wszText = "Combobox"
rbbi.lpText = @wszText
'// Insert band into rebar
Rebar_InsertBand(hRebar, -1, @rbbi)
' // Dispatch Windows messages
FUNCTION = pWindow.DoEvents(nCmdShow)
END FUNCTION
' ========================================================================================
' ========================================================================================
' Main window callback procedure
' ========================================================================================
FUNCTION WndProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
SELECT CASE uMsg
CASE WM_COMMAND
SELECT CASE GET_WM_COMMAND_ID(wParam, lParam)
CASE IDCANCEL
' // If ESC key pressed, close the application sending an WM_CLOSE message
IF GET_WM_COMMAND_CMD(wParam, lParam) = BN_CLICKED THEN
SendMessageW hwnd, WM_CLOSE, 0, 0
EXIT FUNCTION
END IF
' CASE IDM_CUT ' etc.
' MessageBoxW hwnd, "You have clicked the Cut button", "Toolbar", MB_OK
' EXIT FUNCTION
END SELECT
CASE WM_NOTIFY
' -------------------------------------------------------
' Notification messages are handled here.
' The TTN_GETDISPINFO message is sent by a ToolTip control
' to retrieve information needed to display a ToolTip window.
' ------------------------------------------------------
DIM ptnmhdr AS NMHDR PTR ' // Information about a notification message
DIM ptttdi AS NMTTDISPINFOW PTR ' // Tooltip notification message information
DIM wszTooltipText AS WSTRING * 260 ' // Tooltip text
ptnmhdr = CAST(NMHDR PTR, lParam)
SELECT CASE ptnmhdr->code
' // The height of the rebar has changed
CASE RBN_HEIGHTCHANGE
' // Get the coordinates of the client area
DIM rc AS RECT
GetClientRect hwnd, @rc
' // Send a WM_SIZE message to resize the controls
SendMessageW hwnd, WM_SIZE, SIZE_RESTORED, MAKELONG(rc.Right - rc.Left, rc.Bottom - rc.Top)
' // Toolbar tooltips
CASE TTN_GETDISPINFOW
ptttdi = CAST(NMTTDISPINFOW PTR, lParam)
ptttdi->hinst = NULL
wszTooltipText = ""
SELECT CASE ptttdi->hdr.hwndFrom
CASE Toolbar_GetTooltips(GetDlgItem(GetDlgItem(hwnd, IDC_REBAR), IDC_TOOLBAR))
SELECT CASE ptttdi->hdr.idFrom
CASE IDM_CUT : wszTooltipText = "Cut"
CASE IDM_COPY : wszTooltipText = "Copy"
CASE IDM_PASTE : wszTooltipText = "Paste"
CASE IDM_UNDO : wszTooltipText = "Undo"
CASE IDM_REDOW : wszTooltipText = "Redo"
CASE IDM_DELETE : wszTooltipText = "Delete"
CASE IDM_FILENEW : wszTooltipText = "File New"
CASE IDM_FILEOPEN : wszTooltipText = "File Open"
CASE IDM_FILESAVE : wszTooltipText = "File Save"
CASE IDM_PRINTPRE : wszTooltipText = "Print Preview"
CASE IDM_PROPERTIES : wszTooltipText = "Properties"
CASE IDM_HELP : wszTooltipText = "Help"
CASE IDM_FIND : wszTooltipText = "Find"
CASE IDM_REPLACE : wszTooltipText = "Replace"
CASE IDM_PRINT : wszTooltipText = "Print"
END SELECT
IF LEN(wszTooltipText) THEN ptttdi->lpszText = @wszTooltipText
END SELECT
CASE TBN_DROPDOWN
DIM ptbn AS TBNOTIFY PTR = CAST(TBNOTIFY PTR, lParam)
SELECT CASE ptbn->iItem
CASE IDM_FILENEW
DIM rc AS RECT
Toolbar_GetRect(ptbn->hdr.hwndFrom, ptbn->iItem, @rc)
MapWindowPoints(ptbn->hdr.hwndFrom, HWND_DESKTOP, CAsT(LPPOINT, @rc), 2)
DIM hPopupMenu AS HMENU = CreatePopUpMenu
AppendMenuW hPopupMenu, MF_ENABLED, 10001, "Option 1"
AppendMenuW hPopupMenu, MF_ENABLED, 10002, "Option 2"
AppendMenuW hPopupMenu, MF_ENABLED, 10003, "Option 3"
AppendMenuW hPopupMenu, MF_ENABLED, 10004, "Option 4"
AppendMenuW hPopupMenu, MF_ENABLED, 10005, "Option 5"
TrackPopupMenu(hPopupMenu, 0, rc.Left, rc.Bottom, 0, hwnd, NULL)
DestroyMenu hPopupMenu
END SELECT
END SELECT
CASE WM_SIZE
IF wParam <> SIZE_MINIMIZED THEN
' // Update the size and position of the Rebar control
SendMessageW GetDlgItem(hwnd, IDC_REBAR), WM_SIZE, wParam, lParam
' // Resize the button
DIM pWindow AS CWindow PTR = AfxCWindowPtr(hwnd)
IF pWindow THEN pWindow->MoveWindow GetDlgItem(hwnd, IDCANCEL), pWindow->ClientWidth - 95, pWindow->ClientHeight - 35, 75, 23, CTRUE
EXIT FUNCTION
END IF
CASE WM_DESTROY
' // End the application by sending an WM_QUIT message
PostQuitMessage(0)
EXIT FUNCTION
END SELECT
' // Default processing of Windows messages
FUNCTION = DefWindowProcW(hWnd, uMsg, wParam, lParam)
END FUNCTION
' ========================================================================================
Thanks in advance for your help
my description was not clear, given the number of responses.
Fortunately, I was able to solve it myself