HWND CreateStatusWindow( LONG style , LPCTSTR lpszText , HWND hwndParent , UINT wID );style には、ウィンドウスタイルを指定します
定数 | 解説 |
---|---|
CCS_BOTTOM | クライアント領域の最下部に配置 |
CCS_TOP | クライアント領域の最上部に配置 |
SBARS_SIZEGRIP | 右端にサイズグリップを取り入れる 最上部に配置した場合は無効 |
#include <windows.h> #include <commctrl.h> #define TITLE TEXT("Kitty on your lap") LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { static HWND hStatus; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CREATE: InitCommonControls(); hStatus = CreateStatusWindow( WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP , TITLE , hWnd , 1 ); return 0; case WM_SIZE: SendMessage(hStatus , msg , wp , lp); return 0; } return DefWindowProc(hWnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hWnd; MSG msg; WNDCLASS winc; winc.style = CS_HREDRAW | CS_VREDRAW; winc.lpfnWndProc = WndProc; winc.cbClsExtra = winc.cbWndExtra = 0; winc.hInstance = hInstance; winc.hIcon = LoadIcon(NULL , IDI_APPLICATION); winc.hCursor = LoadCursor(NULL , IDC_ARROW); winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winc.lpszMenuName = NULL; winc.lpszClassName = TEXT("KITTY"); if (!RegisterClass(&winc)) return -1; hWnd = CreateWindow( TEXT("KITTY") , TITLE , WS_OVERLAPPEDWINDOW | WS_VISIBLE , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , NULL , NULL , hInstance , NULL ); if (hWnd == NULL) return -1; while(GetMessage(&msg , NULL , 0 , 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
#include <windows.h> #include <commctrl.h> #define TITLE TEXT("Kitty on your lap") LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { static HWND hStatus; static int iRight[] = { 100 , 200 , -1 }; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CREATE: InitCommonControls(); hStatus = CreateStatusWindow( WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP , TITLE , hWnd , 1 ); SendMessage(hStatus , SB_SETPARTS , 3 , (LPARAM)iRight); return 0; case WM_SIZE: SendMessage(hStatus , msg , wp , lp); return 0; } return DefWindowProc(hWnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hWnd; MSG msg; WNDCLASS winc; winc.style = CS_HREDRAW | CS_VREDRAW; winc.lpfnWndProc = WndProc; winc.cbClsExtra = winc.cbWndExtra = 0; winc.hInstance = hInstance; winc.hIcon = LoadIcon(NULL , IDI_APPLICATION); winc.hCursor = LoadCursor(NULL , IDC_ARROW); winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winc.lpszMenuName = NULL; winc.lpszClassName = TEXT("KITTY"); if (!RegisterClass(&winc)) return -1; hWnd = CreateWindow( TEXT("KITTY") , TITLE , WS_OVERLAPPEDWINDOW | WS_VISIBLE , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , NULL , NULL , hInstance , NULL ); if (hWnd == NULL) return -1; while(GetMessage(&msg , NULL , 0 , 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
定数 | 解説 |
---|---|
0 | くぼみのある境界線を持つデフォルトの描画 |
SBT_NOBORDERS | 境界線無し |
SBT_OWNERDRAW | 親ウィンドウによって描画される |
SBT_POPOUT | 盛り上がりのある境界線 |
SBT_RTLREADING | Window 95 : ヘブライ語、またはアラビア語に対応 右から左にテキストを表示 |
#include <windows.h> #include <commctrl.h> #define TITLE TEXT("Kitty on your lap") LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { static HWND hStatus; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CREATE: InitCommonControls(); hStatus = CreateStatusWindow( WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP , TITLE , hWnd , 1 ); return 0; case WM_LBUTTONDOWN: SendMessage(hStatus , SB_SETTEXT , 255 , (LPARAM)TEXT("Magical nyan nyan TARUTO")); return 0; case WM_RBUTTONDOWN: SendMessage(hStatus , SB_SETTEXT , 255 , (LPARAM)TEXT("Tokyo mew mew")); return 0; case WM_SIZE: SendMessage(hStatus , msg , wp , lp); return 0; } return DefWindowProc(hWnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hWnd; MSG msg; WNDCLASS winc; winc.style = CS_HREDRAW | CS_VREDRAW; winc.lpfnWndProc = WndProc; winc.cbClsExtra = winc.cbWndExtra = 0; winc.hInstance = hInstance; winc.hIcon = LoadIcon(NULL , IDI_APPLICATION); winc.hCursor = LoadCursor(NULL , IDC_ARROW); winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winc.lpszMenuName = NULL; winc.lpszClassName = TEXT("KITTY"); if (!RegisterClass(&winc)) return -1; hWnd = CreateWindow( TEXT("KITTY") , TITLE , WS_OVERLAPPEDWINDOW | WS_VISIBLE , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , NULL , NULL , hInstance , NULL ); if (hWnd == NULL) return -1; while(GetMessage(&msg , NULL , 0 , 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
void MenuHelp( UINT uMsg , WPARAM wParam , LPARAM lParam , HMENU hMainMenu , HINSTANCE hInst , HWND hwndStatus , LPUINT lpwIDs );uMsg には、メッセージ値を指定します
/*resource.h*/ #define IDM_RENA 10000 #define IDM_YUKI 10001 #define IDM_MIMI 10002
/*リソーススクリプト*/ #include "resource.h" KITTY MENU { POPUP "Kitty on your lap (&K)" { MENUITEM "RENA" , IDM_RENA MENUITEM "YUKI" , IDM_YUKI MENUITEM "MIMI" , IDM_MIMI } } STRINGTABLE { IDM_RENA "口が悪くて手が早い、勝手気ままでまさに「猫」。" IDM_YUKI "思慮深く、清楚でけなげ。" IDM_MIMI "「ごしゅじんさまだ〜いすきっ!」と飛びついてきそうな甘えん坊。" }
#include <windows.h> #include <commctrl.h> #include "resource.h" #define TITLE TEXT("Kitty on your lap") UINT ID[] = { NULL , IDM_RENA , NULL , IDM_YUKI , NULL , IDM_MIMI }; LRESULT CALLBACK WndProc(HWND hWnd , UINT msg , WPARAM wp , LPARAM lp) { static HWND hStatus; switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CREATE: InitCommonControls(); hStatus = CreateStatusWindow( WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP , TITLE , hWnd , 1 ); return 0; case WM_MENUSELECT: MenuHelp(msg , wp , lp , GetMenu(hWnd) , (HINSTANCE)GetWindowLong(hWnd , GWL_HINSTANCE) , hStatus , ID); return 0; case WM_SIZE: SendMessage(hStatus , msg , wp , lp); return 0; } return DefWindowProc(hWnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hWnd; MSG msg; WNDCLASS winc; winc.style = CS_HREDRAW | CS_VREDRAW; winc.lpfnWndProc = WndProc; winc.cbClsExtra = winc.cbWndExtra = 0; winc.hInstance = hInstance; winc.hIcon = LoadIcon(NULL , IDI_APPLICATION); winc.hCursor = LoadCursor(NULL , IDC_ARROW); winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winc.lpszMenuName = TEXT("KITTY"); winc.lpszClassName = TEXT("KITTY"); if (!RegisterClass(&winc)) return -1; hWnd = CreateWindow( TEXT("KITTY") , TITLE , WS_OVERLAPPEDWINDOW | WS_VISIBLE , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , NULL , NULL , hInstance , NULL ); if (hWnd == NULL) return -1; while(GetMessage(&msg , NULL , 0 , 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
HWND CreateStatusWindow( LONG style , LPCTSTR lpszText , HWND hwndParent , UINT wID );ステータスバーを作成します
定数 | 解説 |
---|---|
CCS_BOTTOM | クライアント領域の最下部に配置 |
CCS_TOP | クライアント領域の最上部に配置 |
SBARS_SIZEGRIP | 右端にサイズグリップを取り入れる 最上部に配置した場合は無効 |
void MenuHelp( UINT uMsg , WPARAM wParam , LPARAM lParam , HMENU hMainMenu , HINSTANCE hInst , HWND hwndStatus , LPUINT lpwIDs );メニューに関連した文字列をステータスバーに表示します