Hi Luke,
I tried all this but don't find my error. From reading several newsgroups
it seems to be an error in the message loop. But that's just a guess.
Thus I post the source here:
Thanks
Martin
---------------------------------------------------------------------------
Compile(under Debian):
i586-mingw32msvc-g++ main.cc -D_WIN32_IE=0x400 -lcomctl32 -mwindows
#include <windows.h>
#include <commctrl.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LPCSTR lpszAppName = "AppName";
LPCSTR lpszTitle = "Meine erste Applikation";
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
InitCommonControls();
HWND hWnd;
MSG msg;
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszClassName = lpszAppName;
wc.lpszMenuName = lpszAppName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if( RegisterClassEx(&wc) == 0)
return 0;
hWnd = CreateWindowEx(NULL,
lpszAppName,
lpszTitle,
WS_OVERLAPPEDWINDOW,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if( hWnd == NULL) return 0;
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
//Create three buttons
TBBUTTON tbb[3];
ZeroMemory(tbb, sizeof(tbb));
for(int i=0; i<3; ++i)
{
tbb[i].idCommand = i;
tbb[i].fsState = TBSTATE_ENABLED;
tbb[i].fsStyle = TBSTYLE_BUTTON;
}
tbb[0].iBitmap = STD_FILENEW;
tbb[1].iBitmap = STD_FILEOPEN;
tbb[2].iBitmap = STD_FILESAVE;
//Create Toolbar with TBSTYLE_TOOLTIPS
HWND hToolbar = CreateToolbarEx(
hWnd,
TBSTYLE_TOOLTIPS|WS_CHILD|WS_VISIBLE,
500,
3,
HINST_COMMCTRL,
IDB_STD_SMALL_COLOR,
tbb,
3,16,16,16,16,
sizeof(TBBUTTON));
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
switch (umsg)
{
//The TTN_GETDISPINFO should be sent via WM_NOTIFY
case WM_NOTIFY:
{
LPNMHDR lpn = (LPNMHDR)lParam;
LPNMTOOLBAR lpnTB = (LPNMTOOLBAR)lParam;
switch(lpn->code)
{
case TTN_GETDISPINFO:
{
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam;
switch(lpttt->hdr.idFrom)
{
case 0:
{lpttt->lpszText = "First Button";}
break;
case 1:
{lpttt->lpszText = "second Button";}
break;
}
}
break;
}
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hWnd, umsg, wParam, lParam);
}
[5~
|