TBBUTTON 具有以下結構:
typedef struct _TBBUTTON {
int iBitmap;
int idCommand;
BYTE fsState;
BYTE fsStyle;
#ifdef _WIN64
BYTE bReserved[6]; // padding for alignment
#elif defined(_WIN32)
BYTE bReserved[2]; // padding for alignment
#endif
DWORD_PTR dwData;
INT_PTR iString;
} TBBUTTON, NEAR* PTBBUTTON, *LPTBBUTTON;
typedef const TBBUTTON *LPCTBBUTTON;
現在,如果您看到,fsStyle是一個BYTE(范圍 0-255);但是,您可以傳遞的值是:
#define TBSTYLE_TOOLTIPS 0x0100
#define TBSTYLE_WRAPABLE 0x0200
#define TBSTYLE_ALTDRAG 0x0400
#define TBSTYLE_FLAT 0x0800
#define TBSTYLE_LIST 0x1000
#define TBSTYLE_CUSTOMERASE 0x2000
#define TBSTYLE_REGISTERDROP 0x4000
#define TBSTYLE_TRANSPARENT 0x8000
這些都不適合BYTE; 并且,非常正確,編譯器在使用時會發出警告(warning C4305: '=': truncation from 'int' to 'BYTE'),例如:
TBBUTTON button;
button.fsStyle = TBSTYLE_TOOLTIPS;
MSDN沒有提及這方面的任何內容,所以我在這里缺少什么?
uj5u.com熱心網友回復:
您列出的“樣式標志”常量(TBSTYLE_TOOLTIPS通過)是工具列本身TBSTYLE_TRANSPARENT的視窗樣式,而不是它包含的任何按鈕。
在您鏈接的 MSDN 檔案中,“工具列按鈕可以具有以下樣式的組合”這句話。, 出現在這些樣式的串列之后,并指代具有BTNS_AUTOSIZEthruTBSTYLE_SEP樣式的串列/框,這些樣式的值在0x0000thru范圍內0x0080——這些確實適合結構的fsStyle( BYTE) 欄位TBBUTTON。
這是定義這些的“CommCtrl.h”標題部分:
#define BTNS_BUTTON TBSTYLE_BUTTON // 0x0000
#define BTNS_SEP TBSTYLE_SEP // 0x0001
#define BTNS_CHECK TBSTYLE_CHECK // 0x0002
#define BTNS_GROUP TBSTYLE_GROUP // 0x0004
#define BTNS_CHECKGROUP TBSTYLE_CHECKGROUP // (TBSTYLE_GROUP | TBSTYLE_CHECK)
#define BTNS_DROPDOWN TBSTYLE_DROPDOWN // 0x0008
#define BTNS_AUTOSIZE TBSTYLE_AUTOSIZE // 0x0010; automatically calculate the cx of the button
#define BTNS_NOPREFIX TBSTYLE_NOPREFIX // 0x0020; this button should not have accel prefix
#define BTNS_SHOWTEXT 0x0040 // ignored unless TBSTYLE_EX_MIXEDBUTTONS is set
#define BTNS_WHOLEDROPDOWN 0x0080 // draw drop-down arrow, but without split arrow section
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/517455.html
標籤:C温纳皮
