- 浏览: 150070 次
- 性别:
- 来自: 武汉
最新评论
-
robingdo:
不错,解决了我的问题,谢谢
grails配合mysql的中文乱码问题 -
nihongye:
遇到相同的问题,谢谢你的分享
jsp文件下载,中文文件名 -
iq527:
可惜没图看。。。
wine模拟完美世界 -
igogo007:
看了一下,这个现在还不会。
有了一点初步的了解。
Annotation学习笔记 -
stworthy:
<div class='quote_title'> ...
Annotation学习笔记
处理命令带消息 翻译:tellmenow
同起命令条相比,命令带控件需要更多一些维护。差别在于,命令带控件可以改变高度,这样就要求包含命令带控件的窗口必须监视控件,并且在控件尺寸变化时重新绘制窗口,很可能还要格式化其客户区。
当用户重新排列控件的时候,命令带控件会发送许多不同的WM_NOTIFY消息。为了监控控件高度,应用程序需要检查RBN_HEIGHCHANGE通知消息并做相应回应。下面的代码演示这个过程:
// This code is inside a WM_NOTIFY message handler.
LPNMHDR pnmh;
pnmh = (LPNMHDR)lParam;
if (pnmh->code == RBN_HEIGHTCHANGE) {
InvalidateRect (hWnd, NULL, TRUE);
}
如果检测到RBN_HEIGHTCHANGE消息通知,例程就简单的使窗口客户区无效,产生一个WM_PAINT消息。接下来在处理绘制消息的代码中调用UINT CommandBands_Height (HWND hwndCmdBands)来查询命令带控件的高度,并从客户区矩形中减去该高度。和命令条一样,使用BOOL CommandBands_Show (HWND HwndCmdBands, BOOL fShow)可以隐藏或者显示命令带控件。通过调用函数BOOL CommandBands_IsVisible (HWND hwndCmdBands)可以查询控件的可视状态。
CmdBand示例
CmdBand程序演示了一个相当完整的命令带控件。示例中创建了三个带区,一个是固定菜单带区,一个是包含许多按钮的带区,一个是包含编辑控件的带区。每个带区中的透明命令条和背景位图被用在创建带背景图的命令带控件中。
通过选择View菜单中的Command Bar菜单项,可以使用一个简单的命令条来替换命令带控件。通过选择View菜单中的Command Bands,可以将命令带控件重新创建并恢复到上次的配置状态。CmdBand程序代码显示在清单5-2中。
清单5-2:CmdBand 程序
CmdBand.rc
//======================================================================
// Resource file
//
// Written for the book Programming Windows CE
// Copyright (C) 2003 Douglas Boling
//======================================================================
#include "windows.h"
#include "CmdBand.h" // Program-specific stuff
//----------------------------------------------------------------------
// Icons and bitmaps
//
ID_ICON ICON "cmdband.ico" // Program icon
CmdBarBmps BITMAP "cbarbmps.bmp" // Bmp used in cmdband image list
CmdBarEditBmp BITMAP "cbarbmp2.bmp" // Bmp used in cmdband image list
CmdBarBack BITMAP "backg2.bmp" // Bmp used for cmdband background
//----------------------------------------------------------------------
// Menu
//
ID_MENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", IDM_EXIT
END
POPUP "&View"
BEGIN
MENUITEM "Command Bar", IDM_VIEWCMDBAR
MENUITEM "Command Band", IDM_VIEWCMDBAND
END
POPUP "&Help"
BEGIN
MENUITEM "&About...", IDM_ABOUT
END
END
//----------------------------------------------------------------------
// About box dialog template
//
aboutbox DIALOG discardable 10, 10, 160, 40
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER |
DS_MODALFRAME
CAPTION "About"
BEGIN
ICON ID_ICON, -1, 5, 5, 10, 10
LTEXT "CmdBand - Written for the book Programming Windows \
CE Copyright 2003 Douglas Boling"
-1, 40, 5, 110, 30
END
CmdBand.h
//======================================================================
// Header file
//
// Written for the book Programming Windows CE
// Copyright (C) 2003 Douglas Boling
//======================================================================
// Returns number of elements
#define dim(x) (sizeof(x) / sizeof(x[0]))
//----------------------------------------------------------------------
// Generic defines and data types
//
struct decodeUINT { // Structure associates
UINT Code; // messages
// with a function.
LRESULT (*Fxn)(HWND, UINT, WPARAM, LPARAM);
};
struct decodeCMD { // Structure associates
UINT Code; // menu IDs with a
LRESULT (*Fxn)(HWND, WORD, HWND, WORD); // function.
};
//----------------------------------------------------------------------
// Defines used by application
//
#define IDC_CMDBAND 1 // Command band ID
#define IDC_CMDBAR 2 // Command bar ID
#define ID_ICON 10 // Icon ID
#define ID_MENU 11 // Main menu resource ID
#define IDC_EDITCTL 12
#define IDB_CMDBAND 50 // Base ID for bands
#define IDB_CMDBANDMENU 50 // Menu band ID
#define IDB_CMDBANDBTN 51 // Button band ID
#define IDB_CMDBANDEDIT 52 // Edit control band ID
// Menu item IDs
#define IDM_EXIT 100
#define IDM_VIEWCMDBAR 110
#define IDM_VIEWCMDBAND 111
#define IDM_ABOUT 120
#define NUMBANDS 3
//----------------------------------------------------------------------
// Function prototypes
//
int CreateCommandBand (HWND hWnd, BOOL fFirst);
int DestroyCommandBand (HWND hWnd);
HWND InitInstance (HINSTANCE, LPWSTR, int);
int TermInstance (HINSTANCE, int);
// Window procedures
LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM);
// Message handlers
LRESULT DoCreateMain (HWND, UINT, WPARAM, LPARAM);
LRESULT DoPaintMain (HWND, UINT, WPARAM, LPARAM);
LRESULT DoNotifyMain (HWND, UINT, WPARAM, LPARAM);
LRESULT DoCommandMain (HWND, UINT, WPARAM, LPARAM);
LRESULT DoDestroyMain (HWND, UINT, WPARAM, LPARAM);
// Command functions
LPARAM DoMainCommandViewCmdBar (HWND, WORD, HWND, WORD);
LPARAM DoMainCommandVCmdBand (HWND, WORD, HWND, WORD);
LPARAM DoMainCommandExit (HWND, WORD, HWND, WORD);
LPARAM DoMainCommandAbout (HWND, WORD, HWND, WORD);
// Dialog procedures
BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM);
CmdBand.cpp
//======================================================================
// CmdBand - Dialog box demonstration
//
// Written for the book Programming Windows CE
// Copyright (C) 2003 Douglas Boling
//======================================================================
#include <windows.h> // For all that Windows stuff
#include <commctrl.h> // Command bar includes
#include "CmdBand.h" // Program-specific stuff
//----------------------------------------------------------------------
// Global data
//
const TCHAR szAppName[] = TEXT ("CmdBand");
HINSTANCE hInst; // Program instance handle
// Message dispatch table for MainWindowProc
const struct decodeUINT MainMessages[] = {
WM_CREATE, DoCreateMain,
WM_PAINT, DoPaintMain,
WM_NOTIFY, DoNotifyMain,
WM_COMMAND, DoCommandMain,
WM_DESTROY, DoDestroyMain,
};
// Command message dispatch for MainWindowProc
const struct decodeCMD MainCommandItems[] = {
IDM_VIEWCMDBAR, DoMainCommandViewCmdBar,
IDM_VIEWCMDBAND, DoMainCommandVCmdBand,
IDM_EXIT, DoMainCommandExit,
IDM_ABOUT, DoMainCommandAbout,
};
// Command band button initialization structure
const TBBUTTON tbCBStdBtns[] = {
// BitmapIndex Command State Style UserData String
{STD_FILENEW, 210, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_FILEOPEN, 211, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_FILESAVE, 212, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
{STD_CUT, 213, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_COPY, 214, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{STD_PASTE, 215, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
{0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
{STD_PROPERTIES, 216, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
};
// Command bar initialization structure
const TBBUTTON tbCBViewBtns[] = {
// BitmapIndex Command State Style UserData String
{0, 0, 0,
TBSTYLE_SEP, 0, 0},
{VIEW_LARGEICONS, 210, TBSTATE_ENABLED | TBSTATE_CHECKED,
TBSTYLE_CHECKGROUP, 0, 0},
{VIEW_SMALLICONS, 211, TBSTATE_ENABLED,
TBSTYLE_CHECKGROUP, 0, 0},
{VIEW_LIST, 212, TBSTATE_ENABLED,
TBSTYLE_CHECKGROUP, 0, 0},
{VIEW_DETAILS, 213, TBSTATE_ENABLED,
TBSTYLE_CHECKGROUP, 0, 0},
{0, 0, 0, TBSTYLE_SEP, 0, 0},
{VIEW_SORTNAME, 214, TBSTATE_ENABLED | TBSTATE_CHECKED,
TBSTYLE_CHECKGROUP, 0, 0},
{VIEW_SORTTYPE, 215, TBSTATE_ENABLED,
TBSTYLE_CHECKGROUP, 0, 0},
{VIEW_SORTSIZE, 216, TBSTATE_ENABLED,
TBSTYLE_CHECKGROUP, 0, 0},
{VIEW_SORTDATE, 217, TBSTATE_ENABLED,
TBSTYLE_CHECKGROUP, 0, 0}
};
// Array that stores the band configuration
COMMANDBANDSRESTOREINFO cbr[NUMBANDS];
INT nBandOrder[NUMBANDS];
//======================================================================
// Program entry point
//
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPWSTR lpCmdLine, int nCmdShow) {
HWND hwndMain;
MSG msg;
// Initialize application.
hwndMain = InitInstance (hInstance, lpCmdLine, nCmdShow);
if (hwndMain == 0)
return 0x10;
// Application message loop
while (GetMessage (&msg, NULL, 0, 0)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
// Instance cleanup
return TermInstance (hInstance, msg.wParam);
}
//----------------------------------------------------------------------
// InitInstance - Instance initialization
//
HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow){
HWND hWnd;
WNDCLASS wc;
INITCOMMONCONTROLSEX icex;
// Save program instance handle in global variable.
hInst = hInstance;
#if defined(WIN32_PLATFORM_PSPC)
// If Pocket PC, allow only one instance of the application.
hWnd = FindWindow (szAppName, NULL);
if (hWnd) {
SetForegroundWindow ((HWND)(((DWORD)hWnd) | 0x01));
return 0;
}
#endif
// Register application main window class.
wc.style = 0; // Window style
wc.lpfnWndProc = MainWndProc; // Callback function
wc.cbClsExtra = 0; // Extra class data
wc.cbWndExtra = 0; // Extra window data
wc.hInstance = hInstance; // Owner handle
wc.hIcon = NULL, // Application icon
wc.hCursor = LoadCursor (NULL, IDC_ARROW);// Default cursor
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wc.lpszMenuName = NULL; // Menu name
wc.lpszClassName = szAppName; // Window class name
if (RegisterClass (&wc) == 0) return 0;
// Load the command bar common control class.
icex.dwSize = sizeof (INITCOMMONCONTROLSEX);
icex.dwICC = ICC_COOL_CLASSES;
InitCommonControlsEx (&icex);
// Create main window.
hWnd = CreateWindow (szAppName, TEXT ("CmdBand Demo"), WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
// Return fail code if window not created.
if (!IsWindow (hWnd)) return 0;
// Standard show and update calls
ShowWindow (hWnd, nCmdShow);
UpdateWindow (hWnd);
return hWnd;
}
//----------------------------------------------------------------------
// TermInstance - Program cleanup
//
int TermInstance (HINSTANCE hInstance, int nDefRC) {
return nDefRC;
}
//======================================================================
// Message handling procedures for MainWindow
//----------------------------------------------------------------------
// MainWndProc - Callback function for application window
//
LRESULT CALLBACK MainWndProc (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
INT i;
//
// Search message list to see if we need to handle this
// message. If in list, call procedure.
//
for (i = 0; i < dim(MainMessages); i++) {
if (wMsg == MainMessages[i].Code)
return (*MainMessages[i].Fxn)(hWnd, wMsg, wParam, lParam);
}
return DefWindowProc (hWnd, wMsg, wParam, lParam);
}
//----------------------------------------------------------------------
// DoCreateMain - Process WM_CREATE message for window.
//
LRESULT DoCreateMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
CreateCommandBand (hWnd, TRUE);
return 0;
}
//----------------------------------------------------------------------
// DoPaintMain - Process WM_PAINT message for window.
//
LRESULT DoPaintMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
PAINTSTRUCT ps;
HWND hwndCB;
RECT rect;
HDC hdc;
POINT ptArray[2];
// Adjust the size of the client rect to take into account
// the command bar or command bands height.
GetClientRect (hWnd, &rect);
if (hwndCB = GetDlgItem (hWnd, IDC_CMDBAND))
rect.top += CommandBands_Height (hwndCB);
else
rect.top += CommandBar_Height (GetDlgItem (hWnd, IDC_CMDBAR));
hdc = BeginPaint (hWnd, &ps);
ptArray[0].x = rect.left;
ptArray[0].y = rect.top;
ptArray[1].x = rect.right;
ptArray[1].y = rect.bottom;
Polyline (hdc, ptArray, 2);
ptArray[0].x = rect.right;
ptArray[1].x = rect.left;
Polyline (hdc, ptArray, 2);
EndPaint (hWnd, &ps);
return 0;
}
//----------------------------------------------------------------------
// DoCommandMain - Process WM_COMMAND message for window.
//
LRESULT DoCommandMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
WORD idItem, wNotifyCode;
HWND hwndCtl;
INT i;
// Parse the parameters.
idItem = (WORD) LOWORD (wParam);
wNotifyCode = (WORD) HIWORD (wParam);
hwndCtl = (HWND) lParam;
// Call routine to handle control message.
for (i = 0; i < dim(MainCommandItems); i++) {
if (idItem == MainCommandItems[i].Code)
return (*MainCommandItems[i].Fxn)(hWnd, idItem, hwndCtl,
wNotifyCode);
}
return 0;
}
//----------------------------------------------------------------------
// DoNotifyMain - Process WM_NOTIFY message for window.
//
LRESULT DoNotifyMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
LPNMHDR pnmh;
// Parse the parameters.
pnmh = (LPNMHDR)lParam;
if (pnmh->code == RBN_HEIGHTCHANGE) {
InvalidateRect (hWnd, NULL, TRUE);
}
return 0;
}
//----------------------------------------------------------------------
// DoDestroyMain - Process WM_DESTROY message for window.
//
LRESULT DoDestroyMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
PostQuitMessage (0);
return 0;
}
//======================================================================
// Command handler routines
//----------------------------------------------------------------------
// DoMainCommandExit - Process Program Exit command.
//
LPARAM DoMainCommandExit (HWND hWnd, WORD idItem, HWND hwndCtl,
WORD wNotifyCode) {
SendMessage (hWnd, WM_CLOSE, 0, 0);
return 0;
}
//----------------------------------------------------------------------
// DoMainCommandVCmdBarStd - Process View | Std Command bar command.
//
LPARAM DoMainCommandViewCmdBar (HWND hWnd, WORD idItem, HWND hwndCtl,
WORD wNotifyCode) {
HWND hwndCB;
hwndCB = GetDlgItem (hWnd, IDC_CMDBAND);
if (hwndCB)
DestroyCommandBand (hWnd);
else
return 0;
// Create a minimal command bar that has only a menu and
// an exit button.
hwndCB = CommandBar_Create (hInst, hWnd, IDC_CMDBAR);
// Insert the menu.
CommandBar_InsertMenubar (hwndCB, hInst, ID_MENU, 0);
// Add exit button to command bar.
CommandBar_AddAdornments (hwndCB, 0, 0);
InvalidateRect (hWnd, NULL, TRUE);
return 0;
}
//----------------------------------------------------------------------
// DoMainCommandVCmdBand - Process View | Command band command.
//
LPARAM DoMainCommandVCmdBand (HWND hWnd, WORD idItem, HWND hwndCtl,
WORD wNotifyCode) {
HWND hwndCB;
hwndCB = GetDlgItem (hWnd, IDC_CMDBAR);
if (hwndCB)
CommandBar_Destroy (hwndCB);
else
return 0;
CreateCommandBand (hWnd, FALSE);
InvalidateRect (hWnd, NULL, TRUE);
return 0;
}
//----------------------------------------------------------------------
// DoMainCommandAbout - Process the Help | About menu command.
//
LPARAM DoMainCommandAbout(HWND hWnd, WORD idItem, HWND hwndCtl,
WORD wNotifyCode) {
// Use DialogBox to create modal dialog box.
DialogBox (hInst, TEXT ("aboutbox"), hWnd, AboutDlgProc);
return 0;
}
//======================================================================
// About Dialog procedure
//
BOOL CALLBACK AboutDlgProc (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
switch (wMsg) {
case WM_COMMAND:
switch (LOWORD (wParam)) {
case IDOK:
case IDCANCEL:
EndDialog (hWnd, 0);
return TRUE;
}
break;
}
return FALSE;
}
//----------------------------------------------------------------------
// DestroyCommandBand - Destroy command band control after saving
// the current configuration.
//
int DestroyCommandBand (HWND hWnd) {
HWND hwndCB;
INT i, nBand, nMaxBand = 0;
hwndCB = GetDlgItem (hWnd, IDC_CMDBAND);
for (i = 0; i < NUMBANDS; i++) {
// Get band index from ID value.
nBand = SendMessage (hwndCB, RB_IDTOINDEX, IDB_CMDBAND+i, 0);
// Save the band number to save order of bands.
nBandOrder[i] = nBand;
// Get the restore information.
cbr[i].cbSize = sizeof (COMMANDBANDSRESTOREINFO);
CommandBands_GetRestoreInformation (hwndCB, nBand, &cbr[i]);
}
DestroyWindow (hwndCB);
return 0;
}
//----------------------------------------------------------------------
// CreateCommandBand - Create a formatted command band control.
//
int CreateCommandBand (HWND hWnd, BOOL fFirst) {
HWND hwndCB, hwndBand, hwndChild;
INT i, nBand, nBtnIndex, nEditIndex;
LONG lStyle;
HBITMAP hBmp;
HIMAGELIST himl;
REBARBANDINFO rbi[NUMBANDS];
// Create image list control for bitmaps for minimized bands.
himl = ImageList_Create (16, 16, ILC_COLOR, 3, 0);
// Load first two images from one bitmap.
hBmp = LoadBitmap (hInst, TEXT ("CmdBarBmps"));
ImageList_Add (himl, hBmp, NULL);
DeleteObject (hBmp);
// Load third image as a single bitmap.
hBmp = LoadBitmap (hInst, TEXT ("CmdBarEditBmp"));
ImageList_Add (himl, hBmp, NULL);
DeleteObject (hBmp);
// Create a command band.
hwndCB = CommandBands_Create (hInst, hWnd, IDC_CMDBAND,
RBS_SMARTLABELS |
RBS_AUTOSIZE | RBS_VARHEIGHT, himl);
// Load bitmap used as background for command bar.
hBmp = LoadBitmap (hInst, TEXT ("CmdBarBack"));
// Initialize common REBARBANDINFO structure fields.
for (i = 0; i < dim(rbi); i++) {
rbi[i].cbSize = sizeof (REBARBANDINFO);
rbi[i].fMask = RBBIM_ID | RBBIM_IMAGE | RBBIM_SIZE |
RBBIM_BACKGROUND | RBBIM_STYLE;
rbi[i].wID = IDB_CMDBAND+i;
rbi[i].hbmBack = hBmp;
}
// If first time, initialize the restore structure since it is
// used to initialize the band size and style fields.
if (fFirst) {
nBtnIndex = 1;
nEditIndex = 2;
cbr[0].cxRestored = 130;
cbr[1].cxRestored = 210;
cbr[1].fStyle = RBBS_FIXEDBMP;
cbr[2].cxRestored = 130;
cbr[2].fStyle = RBBS_FIXEDBMP | RBBS_CHILDEDGE;
} else {
// If not first time, set order of bands depending on
// the last order.
if (nBandOrder[1] < nBandOrder[2]) {
nBtnIndex = 1;
nEditIndex = 2;
} else {
nBtnIndex = 2;
nEditIndex = 1;
}
}
// Initialize REBARBANDINFO structure for each band.
// 1. Menu band
rbi[0].fStyle = RBBS_FIXEDBMP | RBBS_NOGRIPPER;
rbi[0].cx = cbr[0].cxRestored;
rbi[0].iImage = 0;
// 2. Standard button band
rbi[nBtnIndex].fMask |= RBBIM_TEXT;
rbi[nBtnIndex].iImage = 1;
rbi[nBtnIndex].lpText = TEXT ("Std Btns");
// The next two parameters are initialized from saved data.
rbi[nBtnIndex].cx = cbr[1].cxRestored;
rbi[nBtnIndex].fStyle = cbr[1].fStyle;
// 3. Edit control band
hwndChild = CreateWindow (TEXT ("edit"), TEXT ("edit ctl"),
WS_VISIBLE | WS_CHILD | ES_MULTILINE | WS_BORDER,
0, 0, 10, 5, hWnd, (HMENU)IDC_EDITCTL, hInst, NULL);
rbi[nEditIndex].fMask |= RBBIM_TEXT | RBBIM_STYLE |
RBBIM_CHILDSIZE | RBBIM_CHILD;
rbi[nEditIndex].hwndChild = hwndChild;
rbi[nEditIndex].cxMinChild = 0;
rbi[nEditIndex].cyMinChild = 23;
rbi[nEditIndex].cyChild = 55;
rbi[nEditIndex].iImage = 2;
rbi[nEditIndex].lpText = TEXT ("Edit field");
// The next two parameters are initialized from saved data.
rbi[nEditIndex].cx = cbr[2].cxRestored;
rbi[nEditIndex].fStyle = cbr[2].fStyle;
// Add bands.
CommandBands_AddBands (hwndCB, hInst, 3, rbi);
// Add menu to first band.
hwndBand = CommandBands_GetCommandBar (hwndCB, 0);
CommandBar_InsertMenubar (hwndBand, hInst, ID_MENU, 0);
// Add standard buttons to second band.
hwndBand = CommandBands_GetCommandBar (hwndCB, nBtnIndex);
// Insert buttons
CommandBar_AddBitmap (hwndBand, HINST_COMMCTRL, IDB_STD_SMALL_COLOR,
16, 0, 0);
CommandBar_AddButtons (hwndBand, dim(tbCBStdBtns), tbCBStdBtns);
// Modify the style flags of each command bar to make transparent.
for (i = 0; i < NUMBANDS; i++) {
hwndBand = CommandBands_GetCommandBar (hwndCB, i);
lStyle = SendMessage (hwndBand, TB_GETSTYLE, 0, 0);
lStyle |= TBSTYLE_TRANSPARENT;
SendMessage (hwndBand, TB_SETSTYLE, 0, lStyle);
}
// If not the first time the command band has been created, restore
// the user's last configuration.
if (!fFirst) {
for (i = 0; i < NUMBANDS; i++) {
if (cbr[i].fMaximized) {
nBand = SendMessage (hwndCB, RB_IDTOINDEX,
cbr[i].wID, 0);
SendMessage (hwndCB, RB_MAXIMIZEBAND, nBand, TRUE);
}
}
}
// Add exit button to command band.
CommandBands_AddAdornments (hwndCB, hInst, 0, NULL);
return 0;
}
CmdBand示例中,在CreateCommandBand例程里创建了命令带。该例程最初在DoCreateMain中被调用,随后又在菜单处理函数DoMain-CommandVCmdBand中被调用。程序使用RBS_SMARTLABELS风格创建了命令带控件,在最小化和被还原或最大化时使用图像列表和文本标签来标记每个带区。图像列表被创建,并使用位图初始化,当带区被最小化时需要使用这些位图。
REBARBANDINFO结构数组被初始化,用来定义三个带区。如果控件之前被销毁,那么来自COMMANDBANDSRESTOREINFO结构的数据被用来初始化风格域以及cx域。CreateCommandBand例程中,通过查看控件最后一次被销毁时保存的带区索引,对按钮和编辑带区的顺序做了一个假设。虽然用这个方法来判断带区之前的顺序不完全可靠,但它为您提供了一个很好的参考评估。
当命令带控件创建以后,会修改每个带区中的命令条来设置TBS_TRANSPARENT风格。这个过程中,通过使用每个带区的背景位图,演示了如何使用背景位图来使命令带控件有合适的外观。
当程序CmdBand使用命令条来替换命令带区控件时,应用程序首先调用DestroyCommandBand函数来保存当前配置信息,并销毁命令带控件。该函数使用CommandBands_GetRestoreInformation来查询每个带区的尺寸和风格。该函数还保存了每个带区的索引,作为将来推测按钮和编辑带区当前顺序的数据。第一个带区--菜单带区--使用的是RBBS_NOGRIPPER风格,所以不存在位置问题。
相关推荐
最新版windows graalvm-ce-java17-windows-amd64-22.2.0.zip最新版windows graalvm-ce-java17-windows-amd64-22.2.0.zip
最新版windows graalvm-ce-java11-windows-amd64-22.2.0.zip最新版windows graalvm-ce-java11-windows-amd64-22.2.0.zip
《Windows CE程序设计(中文版)》是一本深入探讨Windows CE平台应用程序开发的专业书籍,它为读者揭示了在Windows CE操作系统上构建高效、稳定且功能丰富的应用程序的技术与策略。这本书籍以其独特的外国人写作风格...
最新版windows graalvm-ce-java8-windows-amd64-20.3.0.zip最新版windows graalvm-ce-java8-windows-amd64-20.3.0.zip
《Microsoft Windows CE 程序设计》是一本深入探讨Windows CE平台应用程序开发的专业教程。Windows CE,全称为“Compact Edition”,是微软推出的一种嵌入式操作系统,主要用于掌上设备、工业自动化、汽车导航系统等...
《Windows CE程序设计》这本书是针对初学者和开发者的一份宝贵资源,主要涵盖了Windows CE操作系统的基础知识以及在该平台上进行程序开发的技术细节。Windows CE是一个嵌入式操作系统,广泛应用于移动设备、工业控制...
PDF到Windows CE程序设计是一个涉及移动设备开发的重要主题。Windows CE是一种嵌入式操作系统,广泛应用于掌上电脑、工业设备和车载系统等。本资源提供了一本关于如何在Windows CE平台上进行程序设计的PDF电子书,这...
标题和描述中提到的"UT-890 485-USB能用驱动"是一款专为基于Windows CE操作系统,特别是版本4.2至5.2,并且在ARM架构的XScale处理器上运行的设备设计的驱动程序。这款驱动允许UT-890 485-USB模块在这些设备上正常...
graalvm-ce-java8-windows-amd64-21.0.0.2.zip
《Windows CE程序设计实务:使用eMbedded Visual Basic》这本书是李永隆编著的一本专业指南,由中国电力出版社出版,ISBN号为9787508309408。这本书主要聚焦于如何利用eMbedded Visual Basic(EVB)在Windows CE平台...
1.3 第一个WindowsCE应用程序 1.3.1 创建第一个WindowsCE应用程序 1.3.2 运行程序 1.3.3 出了什么问题 1.4 Hello2程序 1.5 剖析窗口应用程序 1.5.1 窗口 1.5.2 窗口类 1.5.3 窗口过程 1.5.4 消息的生命期 1.5.5 注册...
GraalVM(graalvm-ce-java17-windows-amd64-21.3.0.zip适用于Windows (amd64)), GraalVM 是一个高性能 JDK 发行版,旨在加速用 Java 和其他 JVM 语言编写的应用程序的执行,并支持 JavaScript、Ruby、Python 和...
6. **兼容性**:尽管Windows CE是为嵌入式设备设计的,但它与传统的Windows桌面系统有一定的兼容性,比如文件系统、应用程序接口(API)等,这有助于降低开发成本并提升用户体验。 7. **网络和通信**:Windows CE...
最新版windows graalvm-ce-java11-windows-amd64-21.2.0.zip最新版windows graalvm-ce-java11-windows-amd64-21.2.0.zip
《Programming Windows CE 程序设计(第三版)》是一本深入探讨在Windows CE平台上进行程序开发的专业书籍。Windows CE是微软开发的一个嵌入式操作系统,广泛应用于掌上设备、工业控制、汽车电子等领域。本书作为第三...
《深入理解GraalVM:基于graalvm-ce-java11-windows-amd64-21.0.0.2.zip的探索》 GraalVM,全称为“GraalVM”,是一款高性能的运行时环境,它集成了Java虚拟机(JVM)、JavaScript引擎、Truffle框架以及自优化的...
同时,由于Windows CE 5.0与桌面版Windows的相似性,使得开发者更容易上手,提高开发效率。 总结,Windows CE 5.0是嵌入式领域的重要操作系统之一,其灵活性、可裁剪性和广泛的硬件支持使得它在多个行业得到了广泛...
在"最新版windows graalvm-ce-java11-windows-amd64-21.3.0.zip"这个压缩包中,我们讨论的是针对Windows平台、基于AMD64架构的GraalVM社区版(Community Edition)的21.3.0版本,与Java 11兼容。 1. GraalVM概述:...
《Microsoft Windows CE 程序设计》是一本深入探讨Windows CE平台应用程序开发的专业书籍。Windows CE,全称为“Microsoft Windows Embedded Compact”,是微软推出的一种面向嵌入式系统的实时操作系统,广泛应用于...
《Windows CE程序设计》是一本深入探讨在Windows CE操作系统上进行程序开发的指南。Windows CE是一种嵌入式操作系统,常用于掌上设备、工业设备和汽车电子系统等。本教材旨在帮助开发者理解和掌握如何利用Windows CE...