/*リソーススクリプト*/ KITTY DIALOG 10 , 10 , 100 , 50 FONT 12 , "MS Shell Dlg" CAPTION "Magical nyan nyan TARUTO" { LTEXT "Kitty on your lap" , -1, 2 , 0 , 70 , 10 CTEXT "Kitty on your lap" , -1 , 2 , 10 , 70 , 10 RTEXT "Kitty on your lap" , -1 , 2 , 20 , 70 , 10 }
#include <windows.h> BOOL CALLBACK DialogProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_CLOSE: EndDialog(hwnd , IDOK); return TRUE; } return FALSE; } LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_LBUTTONUP: DialogBox( (HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE) , TEXT("KITTY") , hwnd , DialogProc ); return 0; } return DefWindowProc(hwnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hwnd; HACCEL haccel; 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") , TEXT("Kitty on your lap") , 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; }
/*リソーススクリプト*/ KITTY DIALOG 10 , 10 , 100 , 50 FONT 12 , "MS ゴシック" CAPTION "Magical nyan nyan TARUTO" { LTEXT "終了します\nよろしいですか?" , -1 , 5 , 5 , 90 , 20 PUSHBUTTON "OK" , IDOK , 40 , 35 , 20 , 10 PUSHBUTTON "Cancel" , IDCANCEL , 65 , 35 , 30 , 10 }
#include <windows.h> BOOL CALLBACK DialogProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_CLOSE: EndDialog(hwnd , IDCANCEL); return TRUE; case WM_COMMAND: if (LOWORD(wp) == IDOK) EndDialog(hwnd , IDOK); else EndDialog(hwnd , IDCANCEL); return TRUE; } return FALSE; } LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_CLOSE: if (DialogBox( (HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE) , TEXT("KITTY") , hwnd , DialogProc ) == IDOK) DestroyWindow(hwnd); return 0; } return DefWindowProc(hwnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hwnd; HACCEL haccel; 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") , TEXT("Kitty on your lap") , 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; }
LONG SendDlgItemMessage( HWND hDlg , int nIDDlgItem , UINT Msg, WPARAM wParam , LPARAM lParam );hDlg には、ダイアログのハンドルを、nIDDDlgItem には対象のコントロール ID
/*リソーススクリプト*/ KITTY DIALOG 10 , 10 , 100 , 50 FONT 12 , "MS ゴシック" CAPTION "Magical nyan nyan TARUTO" { RADIOBUTTON "RENA" , 1 , 5 , 5 , 40 , 10 RADIOBUTTON "YUKI" , 2 , 5 , 15 , 40 , 10 RADIOBUTTON "MIMI" , 3 , 5 , 25 , 40 , 10 }
#include <windows.h> BOOL CALLBACK DialogProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { int iCount; switch (msg) { case WM_CLOSE: EndDialog(hwnd , IDOK); return TRUE; case WM_COMMAND: for (iCount = 1 ; iCount < 4 ; iCount++) SendDlgItemMessage( hwnd , iCount , BM_SETCHECK , iCount == LOWORD(wp) , 0 ); return TRUE; } return FALSE; } LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_LBUTTONUP: DialogBox( (HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE) , TEXT("KITTY") , hwnd , DialogProc ); return 0; } return DefWindowProc(hwnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hwnd; HACCEL haccel; 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") , TEXT("Kitty on your lap") , 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; }
BOOL CheckRadioButton( HWND hDlg , int nIDFirstButton , int nIDLastButton , int nIDCheckButton );hDlg は、ラジオボタンを持つダイアログボックスのハンドルを
定数 | 解説 |
---|---|
BST_CHECKED | ボタンをチェックされた状態にします |
BST_INDETERMINATE | ボタンをグレイ表示 (不確定) の状態にします ボタンが、BS_3STATEまたは BS_AUTO3STATE スタイルを 持つときにだけ使用してください |
BST_UNCHECKED | ボタンをチェックされていない状態にします |
定数 | 解説 |
---|---|
BST_CHECKED | ボタンをチェックされた状態である |
BST_INDETERMINATE | ボタンをグレイ表示 (不確定) の状態である |
BST_UNCHECKED | ボタンをチェックされていない状態である |
/*リソーススクリプト*/ KITTY DIALOG 10 , 10 , 100 , 50 FONT 12 , "MS ゴシック" CAPTION "Magical nyan nyan TARUTO" { RADIOBUTTON "RENA" , 1 , 5 , 5 , 40 , 10 RADIOBUTTON "YUKI" , 2 , 5 , 15 , 40 , 10 RADIOBUTTON "MIMI" , 3 , 5 , 25 , 40 , 10 CHECKBOX "KAIMU" , 4 , 50 , 5 , 40 , 10 }
#include <windows.h> BOOL CALLBACK DialogProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { int iCount; switch (msg) { case WM_CLOSE: EndDialog(hwnd , IDOK); return TRUE; case WM_COMMAND: if (LOWORD(wp) < 4) CheckRadioButton(hwnd , 1 , 3 , LOWORD(wp)); else CheckDlgButton(hwnd , 4 , !(IsDlgButtonChecked(hwnd , 4) == BST_CHECKED) ); return TRUE; } return FALSE; } LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_LBUTTONUP: DialogBox( (HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE) , TEXT("KITTY") , hwnd , DialogProc ); return 0; } return DefWindowProc(hwnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hwnd; HACCEL haccel; 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") , TEXT("Kitty on your lap") , 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; }
/*リソーススクリプト*/ KITTY ICON "test.ico" KITTY DIALOG 10 , 10 , 100 , 50 FONT 12 , "MS ゴシック" CAPTION "Magical nyan nyan TARUTO" { ICON "KITTY" , 0 , 10 , 10 , 0 , 0 }
#include <windows.h> BOOL CALLBACK DialogProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_CLOSE: EndDialog(hwnd , IDOK); return TRUE; } return FALSE; } LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_LBUTTONUP: DialogBox( (HINSTANCE)GetWindowLong(hwnd , GWL_HINSTANCE) , TEXT("KITTY") , hwnd , DialogProc ); return 0; } return DefWindowProc(hwnd , msg , wp , lp); } int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { HWND hwnd; HACCEL haccel; 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") , TEXT("Kitty on your lap") , 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; }
LONG SendDlgItemMessage( HWND hDlg , int nIDDlgItem , UINT Msg, WPARAM wParam , LPARAM lParam );ダイアログの指定コントロールにメッセージを送ります
BOOL CheckRadioButton( HWND hDlg , int nIDFirstButton , int nIDLastButton , int nIDCheckButton );列挙されているオプションボタンのグループから
定数 | 解説 |
---|---|
BST_CHECKED | ボタンをチェックされた状態にします |
BST_INDETERMINATE | ボタンをグレイ表示 (不確定) の状態にします ボタンが、BS_3STATEまたは BS_AUTO3STATE スタイルを 持つときにだけ使用してください |
BST_UNCHECKED | ボタンをチェックされていない状態にします |
定数 | 解説 |
---|---|
BST_CHECKED | ボタンをチェックされた状態である |
BST_INDETERMINATE | ボタンをグレイ表示 (不確定) の状態である |
BST_UNCHECKED | ボタンをチェックされていない状態である |