Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Toolbar sample?

138 views
Skip to first unread message

John Kidson

unread,
Oct 25, 2000, 6:06:12 PM10/25/00
to
Does anyone have a simple program showing the use of a toolbar in which
buttons have been inserted using Developer Studio? So far I managed to
create one, but when it is loaded none of the buttons appear.

Many thanks

John Kidson

j.ki...@niwa.cri.nz


ArvidQ

unread,
Oct 31, 2000, 3:21:02 PM10/31/00
to
In article <972511541.873416@clam-ext>,

"John Kidson" <j.ki...@nospam.niwa.cri.nz> wrote:
> Does anyone have a simple program showing the use of a toolbar in
which
> buttons have been inserted using Developer Studio? So far I managed to
> create one, but when it is loaded none of the buttons appear.
>

I can't give you the program (proprietary), but this code works for me
(excuse any formatting Deja does on the text):


//*********************************************************************
// Create the Toolbar window
//*********************************************************************

void CreateToolBar (HWND hParent)
{
TOOLINFO ti;
TBADDBITMAP tb;
int index, stdidx = 0;
int itbsz = (sizeof(tbButtons) / sizeof(TBBUTTON));

// Create the toolbar window
//..........................................
hWndTool = CreateToolbarEx(hParent,
WS_CHILD | WS_BORDER | WS_VISIBLE,
IDR_TOOLBAR, itbsz,
(HINSTANCE)HINST_COMMCTRL,
IDR_TOOLBAR,
tbButtons, 0,
0, 0, 100, 30, sizeof(TBBUTTON));

if (hWndTool)
{
GetClientRect (hWndTool, &toolrect); // keep size stats

// Set the size of the TBBUTTON structure.
//........................................
SendMessage(hWndTool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);

// Load bitmap to add to the toolbar.
//...................................
tb.hInst = NULL;

for (index = 0; index < itbsz+1; index++)
{
tb.nID = (UINT) CreateMappedBitmap(hInst, IDR_TOOLBAR, 0, NULL,
0);
}

stdidx = SendMessage(hWndTool, TB_ADDBITMAP, itbsz, (LPARAM)&tb);

// Add the buttons to the toolbar.
//................................
SendMessage(hWndTool, TB_ADDBUTTONS, itbsz, (LONG) &tbButtons[0]);

// Create tool tip control.
//.........................
hToolTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
TTS_ALWAYSTIP,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hParent, NULL,
hInst, NULL);

// Add the tools to the tool tip control.
//.......................................
ti.cbSize = sizeof(TOOLINFO);
ti.hwnd = hWndTool;
ti.hinst = hInst;
ti.uFlags = TTF_SUBCLASS;

for (index=0; index < itbsz; index++)
{
if ((index == 3) ||
(index == 11) ||
(index == 14))
continue; // skip seperators

SendMessage(hWndTool, TB_GETITEMRECT, index, (LPARAM)&ti.rect);

ti.uId = tbButtons[index].idCommand;
ti.lpszText = (LPTSTR)tbButtons[index].idCommand;

SendMessage(hToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
}

// Set the tool tip control as
// part of the toolbar.
//............................
SendMessage(hWndTool, TB_SETTOOLTIPS, (WPARAM)hToolTip, 0);

// Disable toolbar buttons not in current use

SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_CLOSE, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_LISTSPRITES, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_SECTORMATCH, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_ELEVATOR, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_ACTIVATORS, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_SECRET, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_CRACKS, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_CARDS, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_NUKEIT, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_ZOOMOUT, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_ZOOMIN, FALSE);
SendMessage(hWndTool, TB_ENABLEBUTTON, IDM_PRINT, FALSE);
}

return;
}
//////////////////////////////////////////////////////

case WM_COMMAND:

switch(LOWORD(wParam))
{
case IDM_ACTIVATE:
// Activate/Deactivate the tool tip control.
//..........................................
MenuItemCheck(hwnd, IDM_ACTIVATE);
bActivate = !bActivate;
SendMessage(hToolTip, TTM_ACTIVATE, bActivate, 0);
return 0;


case IDM_TOOLBAR:
if (hWndTool)
{
DestroyWindow(hWndTool);
hWndTool = NULL;
SendMessage (hwnd, WM_SIZE, 0, lClient);
}
else
{
CreateToolBar(hwnd);
}

MenuItemCheck (hwnd, IDM_TOOLBAR);
SendMessage (hwnd, WM_SIZE, 0, lClient);
return 0;


--
Arvid Qvigstad

"Only someone who understands something absolutely can explain it
so no one else can understand it."`-- Rudnicki's Nobel Prize Principle

--
Arvid Qvigstad

"Only someone who understands something absolutely can explain it
so no one else can understand it."`-- Rudnicki's Nobel Prize Principle


Sent via Deja.com http://www.deja.com/
Before you buy.

0 new messages