①Button_Enable
Enables or disables a button
②Button_GetCheck
Gets the check state of a radio button or check box. You can use this macro or send the BM_GETCHECK message explicitly
③Button_GetIdealSize
Gets the size of the button that best fits the text and image, if an image list is present. You can use this macro or send the BCM_GETIDEALSIZE message explicitly
#define _CRT_SECURE_NO_WARNINGS #include <windows.h> #include <windowsx.h> #include <Commctrl.h> #include <tchar.h> int CDECL MessageBoxPrintf(TCHAR *szCaption, TCHAR *szFormat, ...) { TCHAR szBuffer[1024]; va_list pArgList; va_start(pArgList, szFormat); _vsntprintf(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), szFormat, pArgList); va_end(pArgList); return MessageBox(NULL, szBuffer, szCaption, 0); } LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND Button, Button1, Radio_Button, Check_Box; static PSIZE pSize; switch (message) { case WM_CREATE: Button = CreateWindow(TEXT("button"), TEXT("至死丶不渝"), WS_CHILD | WS_VISIBLE | BS_BOTTOM, 0, 0, 200, 30, hwnd, HMENU(1), ((LPCREATESTRUCT)lParam)->hInstance, NULL); Button_Enable(Button, TRUE); Radio_Button = CreateWindow(TEXT("button"), TEXT("至死丶不渝"), WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, 0, 30, 200, 30, hwnd, HMENU(2), ((LPCREATESTRUCT)lParam)->hInstance, NULL); Check_Box = CreateWindow(TEXT("button"), TEXT("至死丶不渝"), WS_CHILD | WS_VISIBLE | BS_CHECKBOX, 0, 60, 200, 30, hwnd, HMENU(3), ((LPCREATESTRUCT)lParam)->hInstance, NULL); Button1 = CreateWindow(TEXT("button"), TEXT("至死丶不渝"), WS_CHILD | WS_VISIBLE | BS_BOTTOM, 0, 90, 200, 30, hwnd, HMENU(4), ((LPCREATESTRUCT)lParam)->hInstance, NULL); return 0; case WM_COMMAND: if (wParam == 1) { if (Button_GetCheck(Check_Box) == BST_UNCHECKED) MessageBox(NULL, TEXT("Susake"), TEXT("至死丶不渝"), 0); } if (wParam == 4) { if (Button_GetIdealSize(Button1, pSize) == TRUE) MessageBoxPrintf(TEXT(""), TEXT("%d %d"), pSize->cx, pSize->cy); } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { static TCHAR *szClassName = TEXT("Susake"); HWND hwnd; MSG message; WNDCLASSEX wincl; wincl.cbSize = sizeof(WNDCLASSEX); wincl.style = NULL; wincl.lpfnWndProc = WindowProc; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; wincl.hInstance = hInstance; wincl.hIcon = NULL; wincl.hCursor = NULL; wincl.hbrBackground = NULL; wincl.lpszMenuName = NULL; wincl.lpszClassName = szClassName; wincl.hIconSm = NULL; if (RegisterClassEx(&wincl) == 0) MessageBoxPrintf(TEXT(""), TEXT("%d"), GetLastError()); hwnd = CreateWindowEx(0, szClassName, TEXT("Susake"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, HWND_DESKTOP, NULL, hInstance, NULL); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while (GetMessage(&message, NULL, 0, 0)) { TranslateMessage(&message); DispatchMessage(&message); } return message.wParam; }
④Button_GetImageList
Gets the BUTTON_IMAGELIST structure that describes the image list that is set for a button control. You can use this macro or send the BCM_GETIMAGELIST message explicitly
⑤Button_GetNote
Gets the text of the note associated with a command link button. You can use this macro or send the BCM_GETNOTE message explicitly
⑥Button_GetNoteLength
Gets the length of the note text that may be displayed in the description for a command link. Use this macro or send the BCM_GETNOTELENGTH message explicitly
⑦Button_GetSplitInfo
Gets information for a specified split button control. Use this macro or send the BCM_GETSPLITINFO message explicitly
⑧Button_GetState
Retrieves the state of a button or check box. You can use this macro or send the BM_GETSTATE message explicitly
⑨Button_GetText
Gets the text of a button
⑩Button_GetTextLength
Gets the number of characters in the text of a button
①②Button_GetTextMargin
Gets the margins used to draw text in a button control. You can use this macro or send the BCM_GETTEXTMARGIN message explicitly
①③Button_SetCheck
Sets the check state of a radio button or check box. You can use this macro or send the BM_SETCHECK message explicitly
①④Button_SetDropDownState
Sets the drop down state for a specified button with style of BS_SPLITBUTTON. Use this macro or send the BCM_SETDROPDOWNSTATE message explicitly
①⑤Button_SetElevationRequiredState
Sets the elevation required state for a specified button or command link to display an elevated icon. Use this macro or send the BCM_SETSHIELD message explicitly
①⑥Button_SetImageList
Assigns an image list to a button control. You can use this macro or send the BCM_SETIMAGELIST message explicitly
①⑦Button_SetNote
Sets the text of the note associated with a specified command link button. You can use this macro or send the BCM_SETNOTE message explicitly
①⑧Button_SetSplitInfo
Sets information for a specified split button control. Use this macro or send the BCM_SETSPLITINFO message explicitly
①⑨Button_SetState
Sets the highlight state of a button. The highlight state indicates whether the button is highlighted as if the user had pushed it. You can use this macro or send the BM_SETSTATE message explicitly
②0Button_SetStyle
Sets the style of a button. You can use this macro or send the BM_SETSTYLE message explicitly
②①Button_SetText
Sets the text of a button
②②Button_SetTextMargin
Sets the margins for drawing text in a button control. You can use this macro or send the BCM_SETTEXTMARGIN message explicitly.