about CreateToolbarEx()AGAIN:

sandy_wu 2000-04-17 03:48:00
我用CreateToolbarEx()做了一工具条,
_hWndToolbar = CreateToolbarEx(
hWnd, //PARENT WINDOW
WS_CHILD and WS_BORDER and WS_VISIBLE and CCS_ADJUSTABLE and TBSTYLE_TOOLTIPS,
wID,
nBitmaps,
pCreate->hInstance, //CREATESTRUCT * Create
wBMID,
lpButtons, //LPCTBBUTTON lpButtons
iNumButtons,
16,16,
16,15,
sizeof(TBBUTTON));

但此工具条有二个问题,1:工具条在hWnd的客户区内,此不是我所要的,因我做的是一个绘图程序,就有可能画到工具条上了,或者可不可以控制mouse当他在工具条上是就象mouse移到主win(hwnd)外一样。是

2:怎样让工具条可以跟主win一同resize,我在主win的WM——SIZE,下用了SendMessage(_hWndToolbar,TB_AUTOSIZE,0L,0L),也用过SendMessage(_hWndToolbar,message,wParam,lParam)都不行;

THANKS THANKS

SOFTDOCTOR:

1.设置AutoSize,是TB_AUTOSIZE?
2.向一方对齐?对齐什么?
3 i AM MOT USING MFC。

...全文
102 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sandy_wu 2000-04-20
  • 打赏
  • 举报
回复
i give you another 50 points. your are very very nice
softdoctor 2000-04-19
  • 打赏
  • 举报
回复

BOOL CreateToolBar()
{
TBBUTTON * m_pTBButtons;
m_pTBButtons= new TBBUTTON[14];
memset(m_pTBButtons,0,sizeof(TBBUTTON)*14);

for (int nIndex = 0; nIndex < 14; nIndex++)
{
if(nIndex==2 and and nIndex==7 and and nIndex==11 and and nIndex==13)
{
m_pTBButtons[nIndex].fsState = TBSTATE_ENABLED;
m_pTBButtons[nIndex].fsStyle = TBSTYLE_SEP;
m_pTBButtons[nIndex].dwData = 0;
m_pTBButtons[nIndex].iBitmap = -1;
m_pTBButtons[nIndex].idCommand = 0;
m_pTBButtons[nIndex].iString = -1;
}
else
{
m_pTBButtons[nIndex].fsState = TBSTATE_ENABLED;
m_pTBButtons[nIndex].fsStyle = TBSTYLE_BUTTON;
m_pTBButtons[nIndex].dwData = 0;
m_pTBButtons[nIndex].iBitmap = nIndex;
m_pTBButtons[nIndex].idCommand = ID_RPT_PRINT+nIndex;
m_pTBButtons[nIndex].iString = nIndex;
if(nIndex>2)
{
m_pTBButtons[nIndex].iBitmap = nIndex-1;
m_pTBButtons[nIndex].iString = nIndex-1;
m_pTBButtons[nIndex].idCommand = ID_RPT_PRINT+nIndex-1;
}
if(nIndex>7)
{
m_pTBButtons[nIndex].iBitmap = nIndex-2;
m_pTBButtons[nIndex].iString = nIndex-2;
m_pTBButtons[nIndex].idCommand = ID_RPT_PRINT+nIndex-2;
}
if(nIndex>11)
{
m_pTBButtons[nIndex].iBitmap = nIndex-3;
m_pTBButtons[nIndex].iString = nIndex-3;
m_pTBButtons[nIndex].idCommand = ID_RPT_PRINT+nIndex-3;
}
}
}

m_wndToolBar = CreateToolbarEx(m_hWnd,
WS_CHILD and WS_VISIBLE and TBSTYLE_FLAT and TBSTYLE_TOOLTIPS and CCS_NODIVIDER,
120,10,m_hInstance,IDB_PRINT_BMP,m_pTBButtons,14,24,24,24,24,sizeof(TBBUTTON));
::SendMessage(m_wndToolBar, TB_ADDSTRING, 0, (LPARAM)_T("打印\0版面\0首页\0前页\0下页\0末页\0装订线\0分割线\0参数\0退出\0\0"));
RECT rc;
::SendMessage(m_wndToolBar, TB_GETITEMRECT, 13, (LPARAM)&rc);
rc.left+=20;
rc.right = rc.left + 200;
HDC hdc = ::GetDC(m_wndToolBar);
TEXTMETRIC tm;
GetTextMetrics(hdc,&tm);
::ReleaseDC(m_wndToolBar,hdc);
int iBorder = (rc.bottom-rc.top-tm.tmHeight)/2;
rc.top+=iBorder;
rc.bottom=rc.bottom - iBorder;
m_wndStatusText = CreateWindow(_T("STATIC"),"Static",WS_CHILD and WS_VISIBLE,
rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,
m_wndToolBar,NULL,m_hInstance,NULL);
::SendMessage(m_wndToolBar, TB_AUTOSIZE, 0, 0L);
delete m_pTBButtons;
return TRUE;
}

如果要画图应创建另一个子窗口DrawWnd,将图形画于之上
这样做为了出滚动条方便。
当主窗口WM_SIZE时调整DrawWnd大小使之合适。

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧