雛形のソース
//------------------------------------------------------------------------------
//
//==============================================================================
// 新規作成日:
// 最終更新日:
//------------------------------------------------------------------------------
#include <tchar.h>
#include <Windows.h>
#include "resource.h"
//------------------------------------------------
// break付きのキーワード
//------------------------------------------------
#define CASE break;case
#define DEFAULT break;default
//------------------------------------------------
// ダイアログ・プロシージャの関数
//------------------------------------------------
extern BOOL CALLBACK mainDialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch ( uMsg ){
CASE WM_INITDIALOG:
CASE WM_CLOSE:
DestroyWindow( hDlg );
PostQuitMessage( 0 );
DEFAULT:return FALSE;
}
return TRUE;
}
//------------------------------------------------
// ウインドウ・プロシージャの関数
//------------------------------------------------
extern LRESULT CALLBACK mainWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch ( uMsg ){
CASE WM_CREATE:
CASE WM_DESTROY:
DEFAULT:return DefDlgProc( hWnd, uMsg, wParam, lParam );
}
return 0;
}
//------------------------------------------------
// ダイアログ・クラスの登録
//------------------------------------------------
static ATOM funcDialogClass( HINSTANCE hInstance, LPCTSTR lpClassName )
{
WNDCLASSEX wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = (CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS);
wcex.lpfnWndProc = mainWindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = DLGWINDOWEXTRA;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wcex.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
wcex.hbrBackground = GetSysColorBrush( COLOR_3DFACE );
wcex.lpszMenuName = NULL;
wcex.lpszClassName = lpClassName;
return RegisterClassEx( &wcex );
}
//------------------------------------------------
// メイン関数
//------------------------------------------------
extern int WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
{
LPCTSTR lpClassName = TEXT("XXXX_WndClass");
HWND hWnd;
MSG Msg;
if ( funcDialogClass(hInstance,lpClassName) == 0 ){
return -1;
}
if ( (hWnd = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG01),NULL,mainDialogProc)) == NULL ){
return -2;
}
while ( GetMessage(&Msg,NULL,0,0) > 0 ){
if ( !IsDialogMessage(hWnd,&Msg) ){
TranslateMessage( &Msg );
DispatchMessage( &Msg );
}
}
UNREFERENCED_PARAMETER( hPrevInstance );
UNREFERENCED_PARAMETER( lpCmdLine );
UNREFERENCED_PARAMETER( nCmdShow );
return Msg.wParam;
}
//------------------------------------------------------------------------------
// End of FileName.cpp
//------------------------------------------------------------------------------
関連記事