sdk toolbar建立
来源:互联网 发布:重庆java招聘 编辑:程序博客网 时间:2024/05/16 18:45
/**///////////////////////////////////////////////////////////////////////////
HWND CreateAToolbar(HINSTANCE hinst,HWND hwndParent,TBBUTTON tbButtons[],int NUM_BUTTONS)
...{
HWND hwndToolbar;
TBADDBITMAP tb;
TBBUTTON *ptbButton = NULL; //sizeof (TBBUTTON) 没有他就会发生访问违例
ptbButton = tbButtons;
InitCommonControls();
hwndToolbar = CreateToolbarEx (
hwndParent, // parent
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS |
CCS_ADJUSTABLE, // window style
ID_TOOLBAR, // toolbar ID
11, // number of bitmaps
(HINSTANCE)HINST_COMMCTRL, // mod instance
IDB_STD_SMALL_COLOR, // resource ID for bitmap(从标准的bitmap中取图片)
(LPCTBBUTTON)ptbButton, // address of buttons
NUM_BUTTONS - 4, // number of buttons 先创建前NUM_BUTTONS - 4个button
16, 16, // width & height of buttons
16, 16, // width & height of bitmaps
sizeof (TBBUTTON)); // structure size
//修改后4个的图片
// Add the system-defined view bitmaps.
// The hInst == HINST_COMMCTRL
// The nID == IDB_VIEW_SMALL_COLOR
tb.hInst = HINST_COMMCTRL;
tb.nID = IDB_VIEW_SMALL_COLOR;//指定图片来的地方前面有11个标准的图片,
//所以从12开始,返回非标准的图片的index
int stdidx = SendMessage (hwndToolbar, TB_ADDBITMAP,0, (LPARAM)&tb);//重要的 stdix = 15
//将非标准的图片放入后4个button中的iBitmap变量中
// Update the indexes to the bitmaps.
for (int index = NUM_BUTTONS-4 ; index < NUM_BUTTONS; index++)
tbButtons[index].iBitmap += stdidx; //开始是iBitmap = 0 现在后4的iBitmap = 15
//建立后4个button,从tbButtons[NUM_BUTTONS-4]开始
// Add the view buttons.
SendMessage (hwndToolbar, TB_ADDBUTTONS, 4/**//*后4个*/, (LONG) &tbButtons[NUM_BUTTONS-4]/**//*开始的button*/);
if (hwndToolbar == NULL)
...{
MessageBox (NULL, "Toolbar not created!", NULL, MB_OK);
return 0;
}
return hwndToolbar;
}
HWND CreateAToolbar(HINSTANCE hinst,HWND hwndParent,TBBUTTON tbButtons[],int NUM_BUTTONS)
...{
HWND hwndToolbar;
TBADDBITMAP tb;
TBBUTTON *ptbButton = NULL; //sizeof (TBBUTTON) 没有他就会发生访问违例
ptbButton = tbButtons;
InitCommonControls();
hwndToolbar = CreateToolbarEx (
hwndParent, // parent
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS |
CCS_ADJUSTABLE, // window style
ID_TOOLBAR, // toolbar ID
11, // number of bitmaps
(HINSTANCE)HINST_COMMCTRL, // mod instance
IDB_STD_SMALL_COLOR, // resource ID for bitmap(从标准的bitmap中取图片)
(LPCTBBUTTON)ptbButton, // address of buttons
NUM_BUTTONS - 4, // number of buttons 先创建前NUM_BUTTONS - 4个button
16, 16, // width & height of buttons
16, 16, // width & height of bitmaps
sizeof (TBBUTTON)); // structure size
//修改后4个的图片
// Add the system-defined view bitmaps.
// The hInst == HINST_COMMCTRL
// The nID == IDB_VIEW_SMALL_COLOR
tb.hInst = HINST_COMMCTRL;
tb.nID = IDB_VIEW_SMALL_COLOR;//指定图片来的地方前面有11个标准的图片,
//所以从12开始,返回非标准的图片的index
int stdidx = SendMessage (hwndToolbar, TB_ADDBITMAP,0, (LPARAM)&tb);//重要的 stdix = 15
//将非标准的图片放入后4个button中的iBitmap变量中
// Update the indexes to the bitmaps.
for (int index = NUM_BUTTONS-4 ; index < NUM_BUTTONS; index++)
tbButtons[index].iBitmap += stdidx; //开始是iBitmap = 0 现在后4的iBitmap = 15
//建立后4个button,从tbButtons[NUM_BUTTONS-4]开始
// Add the view buttons.
SendMessage (hwndToolbar, TB_ADDBUTTONS, 4/**//*后4个*/, (LONG) &tbButtons[NUM_BUTTONS-4]/**//*开始的button*/);
if (hwndToolbar == NULL)
...{
MessageBox (NULL, "Toolbar not created!", NULL, MB_OK);
return 0;
}
return hwndToolbar;
}
/**///////////////////////////////////////////////////////////////////////////
void InitToolbar(HINSTANCE hinst,HWND hwndToolbar)
...{
HWND hwndCombo,hwndTT;
TOOLINFO lpToolInfo;
char *szStrings[] = ...{"Nancy", "Dale", "Dennis", "Herman", "Ken", "Kyle",
"Nigel", "Renan", "Ruediger"};
// Create the combo box and add it to the toolbar.
hwndCombo = CreateWindowEx (0L, // no extended styles
"COMBOBOX", // class name
"", // default text
WS_CHILD | WS_BORDER | WS_VISIBLE |
CBS_HASSTRINGS | CBS_DROPDOWN, // styles and defaults
0, 0, 100, 250, // size and position
hwndToolbar, // parent window
(HMENU)IDM_COMBO, // ID
hinst, // current instance
NULL); // no class data
if (hwndCombo)
...{
// Add strings to the combo box.
for (int idx = 0; idx < sizeof szStrings / sizeof szStrings[0]; idx++)
SendMessage (hwndCombo, CB_INSERTSTRING, (WPARAM)(-1),
(LPARAM)szStrings[idx]);
}
// This code is in the main window procedure after the combo box
// has been created.
// Set the window procedure for the combo box.
lpfnDefCombo = (WNDPROC) GetWindowLong (hwndCombo, GWL_WNDPROC);
SetWindowLong (hwndCombo, GWL_WNDPROC, (LONG)ComboWndProc);
// Get the handle to the ToolTip window.
hwndTT = (HWND) SendMessage (hwndToolbar, TB_GETTOOLTIPS, 0, 0);
if (hwndTT)
...{
// Fill out the TOOLINFO structure.
lpToolInfo.cbSize = sizeof (lpToolInfo);
// The uID is the handle of the tool (the combo box).
lpToolInfo.uFlags = TTF_IDISHWND | TTF_CENTERTIP;
// The string ID in the resource
lpToolInfo.lpszText = (LPTSTR)IDM_COMBO;
// The window that gets the ToolTip messages
lpToolInfo.hwnd = hwndToolbar;
// The tool
lpToolInfo.uId = (UINT)hwndCombo;
// The instance that owns the string resource
lpToolInfo.hinst = hinst;
// Set up the ToolTip for the combo box.
SendMessage (hwndTT, TTM_ADDTOOL, 0,
(LPARAM)(LPTOOLINFO)&lpToolInfo);
}
}
void InitToolbar(HINSTANCE hinst,HWND hwndToolbar)
...{
HWND hwndCombo,hwndTT;
TOOLINFO lpToolInfo;
char *szStrings[] = ...{"Nancy", "Dale", "Dennis", "Herman", "Ken", "Kyle",
"Nigel", "Renan", "Ruediger"};
// Create the combo box and add it to the toolbar.
hwndCombo = CreateWindowEx (0L, // no extended styles
"COMBOBOX", // class name
"", // default text
WS_CHILD | WS_BORDER | WS_VISIBLE |
CBS_HASSTRINGS | CBS_DROPDOWN, // styles and defaults
0, 0, 100, 250, // size and position
hwndToolbar, // parent window
(HMENU)IDM_COMBO, // ID
hinst, // current instance
NULL); // no class data
if (hwndCombo)
...{
// Add strings to the combo box.
for (int idx = 0; idx < sizeof szStrings / sizeof szStrings[0]; idx++)
SendMessage (hwndCombo, CB_INSERTSTRING, (WPARAM)(-1),
(LPARAM)szStrings[idx]);
}
// This code is in the main window procedure after the combo box
// has been created.
// Set the window procedure for the combo box.
lpfnDefCombo = (WNDPROC) GetWindowLong (hwndCombo, GWL_WNDPROC);
SetWindowLong (hwndCombo, GWL_WNDPROC, (LONG)ComboWndProc);
// Get the handle to the ToolTip window.
hwndTT = (HWND) SendMessage (hwndToolbar, TB_GETTOOLTIPS, 0, 0);
if (hwndTT)
...{
// Fill out the TOOLINFO structure.
lpToolInfo.cbSize = sizeof (lpToolInfo);
// The uID is the handle of the tool (the combo box).
lpToolInfo.uFlags = TTF_IDISHWND | TTF_CENTERTIP;
// The string ID in the resource
lpToolInfo.lpszText = (LPTSTR)IDM_COMBO;
// The window that gets the ToolTip messages
lpToolInfo.hwnd = hwndToolbar;
// The tool
lpToolInfo.uId = (UINT)hwndCombo;
// The instance that owns the string resource
lpToolInfo.hinst = hinst;
// Set up the ToolTip for the combo box.
SendMessage (hwndTT, TTM_ADDTOOL, 0,
(LPARAM)(LPTOOLINFO)&lpToolInfo);
}
}
使用函数
- sdk toolbar建立
- ToolBar,出错“建立文档失败”
- Win32 SDK的Toolbar使用标准位图
- Toolbar在Win SDK下用法
- 建立Android SDK开发环境
- ToolBar的Button上使用ToolTip的方法(SDK)
- ToolBar的Button上使用ToolTip的方法(SDK)
- ToolBar
- ToolBar
- TOOLBAR
- ToolBar
- ToolBar
- toolbar
- ToolBar
- Toolbar
- Toolbar
- ToolBar
- ToolBar
- javascript面向对象简单示例
- 抽象数据类型的表示和实现方法
- 第一次真正接触SAP模块
- 镜子里的自己
- L的儿子
- sdk toolbar建立
- 苏菲的世界
- 北京绿卡
- 使用 Visual Studio 2005 设计设备应用程序的用户界面和数据
- 高质量C++/C编程指南 -- 第8章 C++函数的高级特性
- 如何防止重载toString方法时产生递归调用
- 高质量C++/C编程指南 -- 第9章 类的构造函数、析构函数与赋值函数
- Who am I...
- 项目总结