请问有谁用SDK做过toolbar,能给个code吗?多谢!(无内容,但分是有的)

Ani 2001-12-03 11:49:49
...全文
122 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ani 2001-12-05
  • 打赏
  • 举报
回复
ss
Ani 2001-12-05
  • 打赏
  • 举报
回复
多谢各位。

不过我还有问题请教。

请一定光顾我的下个贴子。
prog_st 2001-12-04
  • 打赏
  • 举报
回复
anigold@163.com
发出!
Ani 2001-12-04
  • 打赏
  • 举报
回复
anigold@163.com

多谢!
masterz 2001-12-03
  • 打赏
  • 举报
回复
#define IDM_NEW 1001
#define IDM_OPEN 1002
#define IDM_SAVE 1003
#define IDM_LARGEICON 1011
#define IDM_SMALLICON 1012
#define IDM_LISTVIEW 1013
#define IDM_REPORTVIEW 1014
#define BTNS_BUTTON TBSTYLE_FLAT
#define ID_TOOLBAR 1111
TBBUTTON tbButtonsCreate[] =
{
{STD_FILENEW, IDM_NEW, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
{STD_FILEOPEN, IDM_OPEN, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
{STD_FILESAVE, IDM_SAVE, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0L, 0},
};

TBBUTTON tbButtonsAdd[] =
{
{VIEW_LARGEICONS, IDM_LARGEICON, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
{VIEW_SMALLICONS, IDM_SMALLICON, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
{VIEW_LIST, IDM_LISTVIEW, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
{VIEW_DETAILS, IDM_REPORTVIEW, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
};

#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))

// The function uses HINST_COMMCTRL as the HINSTANCE and
// IDB_STD_SMALL_COLOR as the bitmap identifier.
HWND CreateAToolBar2(HWND hWndParent)
{
HWND hWndToolbar;
TBADDBITMAP tb;
int index, stdidx;
// Create a toolbar with three standard file bitmaps and one
// separator.
// In the CreateToolbarEx call the number 15 is used because there
// are 15 items in IDB_STD_SMALL_COLOR.
hWndToolbar = CreateToolbarEx (hWndParent,
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS,
ID_TOOLBAR, 15, HINST_COMMCTRL, IDB_STD_SMALL_COLOR,
tbButtonsCreate, ARRAYSIZE(tbButtonsCreate), 0, 0, 100, 30, sizeof (TBBUTTON));
// Add four view bitmaps. The view bitmaps are not in the same
// file as the standard bitmaps; therefore, you must change the
// resource identifier from IDB_STD_SMALL_COLOR to
// IDB_VIEW_SMALL_COLOR.
tb.hInst = HINST_COMMCTRL;
tb.nID = IDB_VIEW_SMALL_COLOR;
// In the SendMessage call the number 12 is used because there
// are 12 items in IDB_VIEW_SMALL_COLOR.
stdidx = SendMessage (hWndToolbar, TB_ADDBITMAP, 12, (LPARAM)&tb);
// Update the indexes to the view bitmaps.
for (index = 0; index < 4; index++)
tbButtonsAdd[index].iBitmap += stdidx;
// Add the view buttons.
SendMessage (hWndToolbar, TB_ADDBUTTONS, ARRAYSIZE(tbButtonsAdd), (LPARAM) &tbButtonsAdd[0]);
return hWndToolbar;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
HBRUSH hbrButton;
HWND hwndToolbar;
hbrButton=CreateSolidBrush(RGB(244,0,0));
LPDRAWITEMSTRUCT lpdrawitem=NULL;
int i=4;
int j=4;
switch (message)
{
case WM_CREATE:
hwndToolbar = CreateAToolBar2(hWnd);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
case IDM_NEW:
::MessageBox(hWnd,"New button of toolbar message","Toolbar",MB_OK);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
DeleteObject(hbrButton);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
cullon 2001-12-03
  • 打赏
  • 举报
回复
cullon@sohu.com
能CC给我一份吗?
cullon 2001-12-03
  • 打赏
  • 举报
回复
也给我一个吧!cullon@sohu.com
prog_st 2001-12-03
  • 打赏
  • 举报
回复
Email,给例子!
Ani 2001-12-03
  • 打赏
  • 举报
回复
没人知吗?

16,550

社区成员

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

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

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