Re: Problem with IE style menu bar
- From: "banrenma23@xxxxxxxxxxxx" <banrenma23@xxxxxxxxxxxx>
- Date: 22 Sep 2005 23:37:27 -0700
Thanks.
Now, i changed the code to below.
The problem i met is:
(1) If i use
SetWindowLong(hMenuBarWnd,GWL_WNDPROC,(LONG)MenuBarWndProc));
to handle message in my own way, then all buttons including text on
them are invisable.
if i removed the
SetWindowLong(hMenuBarWnd,GWL_WNDPROC,(LONG)MenuBarWndProc));
then i can see the buttons and text on the toolbar
(2) though i have added BTNS_DROPDOWN style for each buttons, i can not
get TBN_DROPDOWN message at all in the producer function .
any help will be appreciated . Thanks in advance.
/*
create IE style menu bar
*/
LRESULT CALLBACK MenuBarWndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_FILE:
MessageBox(NULL,"File",NULL,0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
/*
i never get this message though i have added the BTNS_DROPDOWN style
for each buttons
I still don't know why this happen
*/
case TBN_DROPDOWN:
MessageBox(NULL,"TBN_DROPDOWN",NULL,0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
//CallWindowProc(WndProc,hBaseWnd, message, wParam, lParam);
}
return CallWindowProc(WndProc,hWnd, message, wParam, lParam);
}
HWND CreateMenuBar(HWND hWnd)
{
/*
1 initialize common control
*/
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
/*
2 create tool bar
*/
HWND hMenuBarWnd;
DWORD style =
WS_CHILDWINDOW|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|TBSTYLE_TRANSPARENT|TBSTYLE_REGISTERDROP|
TBSTYLE_LIST|TBSTYLE_FLAT|CCS_NODIVIDER|CCS_NOPARENTALIGN|CCS_NORESIZE|CCS_TOP|
WS_EX_LEFT|WS_EX_LTRREADING|WS_EX_RIGHTSCROLLBAR|WS_EX_TOOLWINDOW;
hMenuBarWnd = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL,style
,0, 0, 0, 0, hWnd, NULL, hInst, NULL);
SendMessage(hMenuBarWnd, TB_BUTTONSTRUCTSIZE, (WPARAM)
sizeof(TBBUTTON), 0);
/*
3 set buttons information
*/
TBBUTTON button[3];
char szBuf[16];
for(int i=0;i<3;i++)
{
LoadString(hInst, IDS_FILE + i, szBuf, sizeof(szBuf)-1);
button[i].iBitmap = I_IMAGENONE;
button[i].idCommand = ID_FILE + i;
button[i].fsState = TBSTATE_ENABLED;
button[i].fsStyle = TBSTYLE_BUTTON |BTNS_DROPDOWN;//|BTNS_SHOWTEXT;
button[i].dwData = 0;
button[i].iString = SendMessage(hMenuBarWnd, TB_ADDSTRING, 0,
(LPARAM)(LPSTR)szBuf);
}
/*
4 add buttons to toolbar
*/
SendMessage(hMenuBarWnd, TB_ADDBUTTONS, 3,(LPARAM) (LPTBBUTTON)
&button);
/*
5 change tool bar styles
*/
SendMessage(hMenuBarWnd, TB_SETSTYLE, 0, SendMessage(hMenuBarWnd,
TB_GETSTYLE, 0,0 )&~TBSTYLE_TRANSPARENT);
SendMessage(hMenuBarWnd, TB_SETBUTTONSIZE, 0,(LPARAM)MAKELONG(40,
60));
SendMessage(hMenuBarWnd,TB_SETIMAGELIST, 0, NULL);
SendMessage(hMenuBarWnd, TB_AUTOSIZE, 0, 0);
/*
I want to process message sent to this toolbar by myself. so i change
the producer to my own message hander.
However, if i don't use below 2 lines codes, i can see the buttons on
the toolbar.
if i use them, the buttons on toolbar can not be seen
and i never get TBN_DROPDOWN message though i have added the
BTNS_DROPDOWN style for each buttons in the toolbar.
Why ?????????
*/
//if(!SetWindowLong(hMenuBarWnd,GWL_WNDPROC,(LONG)MenuBarWndProc))//;
// MessageBox(NULL,"fail to process message",NULL,0);
return hMenuBarWnd;
}
.
- Follow-Ups:
- Re: Problem with IE style menu bar
- From: Jeff Partch [MVP]
- Re: Problem with IE style menu bar
- References:
- Problem with IE style menu bar
- From: banrenma23@xxxxxxxxxxxx
- Re: Problem with IE style menu bar
- From: banrenma23@xxxxxxxxxxxx
- Problem with IE style menu bar
- Prev by Date: Puzzling problem with CreateDialogParam
- Next by Date: WindowProc Vs DialogProc
- Previous by thread: Re: Problem with IE style menu bar
- Next by thread: Re: Problem with IE style menu bar
- Index(es):