求SDK ToolBar的示例代码,带注释,要求从窗体创建到显示一个简单的ToolBar,用sdk,不用MFC(50全给),要待资源脚本,用上tooltip,添加图片等,50分全给最好的示例
解决方案 »
- 请教一下:基于mfc的对话框程序里,用了一个树形控件CTreeCtrl,能否对每个结点设置属性:比如有的结点只允许修改名称,有的结点修改后弹出对话框来修改参数
- 我们如何为动态创建的工具栏按钮添加响应的消息呢?
- 在VC6.0 中 的 MFC ClassWizard Automation 对应到 vc.net 2003 是什么????
- 如何获得IE浏览器工具栏的图标
- 谁有抓屏的VC源代码,急。。。
- 如果设置程序菜单的字体?在线等,解决马上结贴。
- **********关于数字与字符串相互转换的问题(高分,在线等待!)***********
- 关于属性页,是不是见鬼了??呵呵,求教
- 如何在运行时改变SDI程序当前使用的View类为另一个CxxxView?
- 请教,经常提到的脚本语言是什么意思呀?我很困惑!!
- 怎么取得新创建的视图的指针
- 请问各位高手,如何得到桌面上任意被激活的窗口的标题呢?
it's convenient
another control?
I have no time,I need tutorial,example!not just a word "wtl",its do no business!
//Add tooltips to the toolbar
#pragma comment(lib,"comctl32.lib")
#include<windows.h>
#include<commctrl.h>
#include"graph.h"#define NUMBUTTONS 6void InitToolbar(); //initialize the toolbar LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
char szWinName[]="MyWin";TBBUTTON tbButton[NUMBUTTONS];
HWND tbwnd; //toolbar handle
int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPreInst,LPSTR lpszArgs,int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
HACCEL hAccel;
INITCOMMONCONTROLSEX cc;//Define a window class
wcl.cbSize =sizeof(WNDCLASSEX);
wcl.hInstance =hThisInst;
wcl.lpszClassName =szWinName;
wcl.lpfnWndProc =WindowFunc;
wcl.style =0;
wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wcl.hIconSm =LoadIcon(NULL,IDI_WINLOGO);
wcl.hCursor =LoadCursor(NULL,IDC_ARROW); wcl.lpszMenuName ="MyMenu";
wcl.cbClsExtra =0;
wcl.cbWndExtra =0; wcl.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);//Register the window class
if(!RegisterClassEx(&wcl)) return 0; hwnd=CreateWindow(
szWinName,
"Changing Mapping Modes",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
HWND_DESKTOP,
NULL,
hThisInst,
NULL,
); hAccel=LoadAccelerators(hThisInst,"MyMenu"); //Initialize the common controls
cc.dwSize=sizeof(INITCOMMONCONTROLSEX);
cc.dwICC=ICC_BAR_CLASSES;
InitCommonControlsEx(&cc); InitToolbar(); //initialize the toobar structures tbwnd=CreateToolbarEx(hwnd,
WS_VISIBLE|WS_CHILD|WS_BORDER|TBSTYLE_TOOLTIPS,
IDM_TOOLBAR,
NUMBUTTONS,
hThisInst,
IDTB_BMP,
tbButton,
NUMBUTTONS,
16,16,16,16,
sizeof(TBBUTTON));
ShowWindow(hwnd,nWinMode);
UpdateWindow(hwnd); //Create the message loop
while(GetMessage(&msg,NULL,0,0))
{
if(!TranslateAccelerator(hwnd,hAccel,&msg)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message){
case WM_CREATE:
break; case WM_COMMAND:
break;
case WM_PAINT:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
//Initialize the toolbar structures
void InitToolbar()
{
tbButton[0].idCommand=IDM_LINES;
tbButton[0].fsState=TBSTATE_ENABLED;
tbButton[0].fsStyle=TBSTYLE_BUTTON;
tbButton[0].dwData=0l;
tbButton[0].iBitmap=0;
tbButton[0].iString=0; tbButton[1].idCommand=IDM_RECTANGLES;
tbButton[1].fsState=TBSTATE_ENABLED;
tbButton[1].fsStyle=TBSTYLE_BUTTON;
tbButton[1].dwData=0l;
tbButton[1].iBitmap=1;
tbButton[1].iString=0; tbButton[2].idCommand=IDM_ELLIPSES;
tbButton[2].fsState=TBSTATE_ENABLED;
tbButton[2].fsStyle=TBSTYLE_BUTTON;
tbButton[2].dwData=0l;
tbButton[2].iBitmap=2;
tbButton[2].iString=0; tbButton[3].idCommand=IDM_RESET;
tbButton[3].fsState=TBSTATE_ENABLED;
tbButton[3].fsStyle=TBSTYLE_BUTTON;
tbButton[3].dwData=0l;
tbButton[3].iBitmap=3;
tbButton[3].iString=0; //button separator
tbButton[4].idCommand=0;
tbButton[4].fsState=TBSTATE_ENABLED;
tbButton[4].fsStyle=TBSTYLE_SEP;
tbButton[4].dwData=0l;
tbButton[4].iBitmap=0;
tbButton[4].iString=0; tbButton[5].idCommand=IDM_HELP;
tbButton[5].fsState=TBSTATE_ENABLED;
tbButton[5].fsStyle=TBSTYLE_BUTTON;
tbButton[5].dwData=0l;
tbButton[5].iBitmap=5;
tbButton[5].iString=0;}
#include"graph.h"IDTB_BMP BITMAP "toolbar.bmp"MyMenu MENU
{
POPUP "&Draw"{
MENUITEM "&Lines\tF2",IDM_LINES
MENUITEM "&Rectangles\tF3",IDM_RECTANGLES
MENUITEM "&Ellipses\tF4",IDM_ELLIPSES
MENUITEM "E&xit\tCtrl+X",IDM_EXIT
}
POPUP "&Options"
{
MENUITEM "&Reset\tF5",IDM_RESET
MENUITEM "&Show Toolbar\tF6",IDM_SHOW
MENUITEM "&Hide Toolbar\tF7",IDM_HIDE
} MENUITEM "&Help",IDM_HELP
}MyMenu ACCELERATORS
{
VK_F2,IDM_LINES,VIRTKEY
VK_F3,IDM_RECTANGLES,VIRTKEY
VK_F4,IDM_ELLIPSES,VIRTKEY
VK_F5,IDM_RESET,VIRTKEY
VK_F6,IDM_SHOW,VIRTKEY
VK_F7,IDM_HIDE,VIRTKEY
"^X",IDM_EXIT
VK_F1,IDM_HELP,VIRTKEY
}
#define IDM_RECTANGLES 101
#define IDM_ELLIPSES 102
#define IDM_SHOW 103
#define IDM_HIDE 104
#define IDM_RESET 105
#define IDM_EXIT 106
#define IDM_HELP 107#define IDM_TOOLBAR 200#define IDTB_BMP 300