Created
May 12, 2016 09:07
-
-
Save bg1bgst333/fcdec77ab31808b9be7053154467e7af to your computer and use it in GitHub Desktop.
helloworld#helloworld#mfc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HelloWorld.cpp : アプリケーションのクラス動作を定義します。 | |
// | |
#include "stdafx.h" | |
#include "HelloWorld.h" | |
#include "HelloWorldDlg.h" | |
#ifdef _DEBUG | |
#define new DEBUG_NEW | |
#endif | |
// CHelloWorldApp | |
BEGIN_MESSAGE_MAP(CHelloWorldApp, CWinApp) | |
ON_COMMAND(ID_HELP, &CWinApp::OnHelp) | |
END_MESSAGE_MAP() | |
// CHelloWorldApp コンストラクション | |
CHelloWorldApp::CHelloWorldApp() | |
{ | |
// TODO: この位置に構築用コードを追加してください。 | |
// ここに InitInstance 中の重要な初期化処理をすべて記述してください。 | |
} | |
// 唯一の CHelloWorldApp オブジェクトです。 | |
CHelloWorldApp theApp; | |
// CHelloWorldApp 初期化 | |
BOOL CHelloWorldApp::InitInstance() | |
{ | |
CWinApp::InitInstance(); | |
// ダイアログにシェル ツリー ビューまたはシェル リスト ビュー コントロールが | |
// 含まれている場合にシェル マネージャーを作成します。 | |
CShellManager *pShellManager = new CShellManager; | |
// MFC コントロールでテーマを有効にするために、"Windows ネイティブ" のビジュアル マネージャーをアクティブ化 | |
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); | |
// 標準初期化 | |
// これらの機能を使わずに最終的な実行可能ファイルの | |
// サイズを縮小したい場合は、以下から不要な初期化 | |
// ルーチンを削除してください。 | |
// 設定が格納されているレジストリ キーを変更します。 | |
// TODO: 会社名または組織名などの適切な文字列に | |
// この文字列を変更してください。 | |
SetRegistryKey(_T("アプリケーション ウィザードで生成されたローカル アプリケーション")); | |
CHelloWorldDlg dlg; | |
m_pMainWnd = &dlg; | |
INT_PTR nResponse = dlg.DoModal(); | |
if (nResponse == IDOK) | |
{ | |
// TODO: ダイアログが <OK> で消された時のコードを | |
// 記述してください。 | |
} | |
else if (nResponse == IDCANCEL) | |
{ | |
// TODO: ダイアログが <キャンセル> で消された時のコードを | |
// 記述してください。 | |
} | |
else if (nResponse == -1) | |
{ | |
TRACE(traceAppMsg, 0, "警告: ダイアログの作成に失敗しました。アプリケーションは予期せずに終了します。\n"); | |
TRACE(traceAppMsg, 0, "警告: ダイアログで MFC コントロールを使用している場合、#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS を指定できません。\n"); | |
} | |
// 上で作成されたシェル マネージャーを削除します。 | |
if (pShellManager != NULL) | |
{ | |
delete pShellManager; | |
} | |
// ダイアログは閉じられました。アプリケーションのメッセージ ポンプを開始しないで | |
// アプリケーションを終了するために FALSE を返してください。 | |
return FALSE; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HelloWorld.h : PROJECT_NAME アプリケーションのメイン ヘッダー ファイルです。 | |
// | |
#pragma once | |
#ifndef __AFXWIN_H__ | |
#error "PCH に対してこのファイルをインクルードする前に 'stdafx.h' をインクルードしてください" | |
#endif | |
#include "resource.h" // メイン シンボル | |
// CHelloWorldApp: | |
// このクラスの実装については、HelloWorld.cpp を参照してください。 | |
// | |
class CHelloWorldApp : public CWinApp | |
{ | |
public: | |
CHelloWorldApp(); | |
// オーバーライド | |
public: | |
virtual BOOL InitInstance(); | |
// 実装 | |
DECLARE_MESSAGE_MAP() | |
}; | |
extern CHelloWorldApp theApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Microsoft Visual C++ generated resource script. | |
// | |
#include "resource.h" | |
#define APSTUDIO_READONLY_SYMBOLS | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// Generated from the TEXTINCLUDE 2 resource. | |
// | |
#ifndef APSTUDIO_INVOKED | |
#include "targetver.h" | |
#endif | |
#include "afxres.h" | |
#include "verrsrc.h" | |
///////////////////////////////////////////////////////////////////////////// | |
#undef APSTUDIO_READONLY_SYMBOLS | |
///////////////////////////////////////////////////////////////////////////// | |
// 日本語 (日本) resources | |
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) | |
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT | |
#ifdef APSTUDIO_INVOKED | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// TEXTINCLUDE | |
// | |
1 TEXTINCLUDE | |
BEGIN | |
"resource.h\0" | |
END | |
2 TEXTINCLUDE | |
BEGIN | |
"#ifndef APSTUDIO_INVOKED\r\n" | |
"#include ""targetver.h""\r\n" | |
"#endif\r\n" | |
"#include ""afxres.h""\r\n" | |
"#include ""verrsrc.h""\r\n" | |
"\0" | |
END | |
3 TEXTINCLUDE | |
BEGIN | |
"#define _AFX_NO_SPLITTER_RESOURCES\r\n" | |
"#define _AFX_NO_OLE_RESOURCES\r\n" | |
"#define _AFX_NO_TRACKER_RESOURCES\r\n" | |
"#define _AFX_NO_PROPERTY_RESOURCES\r\n" | |
"\r\n" | |
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)\r\n" | |
"LANGUAGE 17, 1\r\n" | |
"#include ""res\\HelloWorld.rc2"" // Microsoft Visual C++ 以外で編集されたリソース\r\n" | |
"#include ""l.JPN\\afxres.rc"" // 標準コンポーネント\r\n" | |
"#if !defined(_AFXDLL)\r\n" | |
"#include ""l.JPN\\afxribbon.rc"" // MFC リボンおよびコントロール バー リソース\r\n" | |
"#endif\r\n" | |
"#endif\r\n" | |
"\0" | |
END | |
#endif // APSTUDIO_INVOKED | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// Icon | |
// | |
// Icon with lowest ID value placed first to ensure application icon | |
// remains consistent on all systems. | |
IDR_MAINFRAME ICON "res\\HelloWorld.ico" | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// Dialog | |
// | |
IDD_HELLOWORLD_DIALOG DIALOGEX 0, 0, 320, 200 | |
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | |
EXSTYLE WS_EX_APPWINDOW | |
CAPTION "HelloWorld" | |
FONT 9, "MS UI Gothic", 0, 0, 0x1 | |
BEGIN | |
DEFPUSHBUTTON "OK",IDOK,209,179,50,14 | |
PUSHBUTTON "キャンセル",IDCANCEL,263,179,50,14 | |
CTEXT "Hello, world!",IDC_STATIC,10,96,300,8 | |
END | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// Version | |
// | |
VS_VERSION_INFO VERSIONINFO | |
FILEVERSION 1,0,0,1 | |
PRODUCTVERSION 1,0,0,1 | |
FILEFLAGSMASK 0x3fL | |
#ifdef _DEBUG | |
FILEFLAGS 0x1L | |
#else | |
FILEFLAGS 0x0L | |
#endif | |
FILEOS 0x40004L | |
FILETYPE 0x1L | |
FILESUBTYPE 0x0L | |
BEGIN | |
BLOCK "StringFileInfo" | |
BEGIN | |
BLOCK "041104B0" | |
BEGIN | |
VALUE "CompanyName", "TODO: <会社名>" | |
VALUE "FileDescription", "HelloWorld" | |
VALUE "FileVersion", "1.0.0.1" | |
VALUE "InternalName", "HelloWorld.exe" | |
VALUE "LegalCopyright", "TODO: (C) <会社名>. All rights reserved." | |
VALUE "OriginalFilename", "HelloWorld.exe" | |
VALUE "ProductName", "TODO: <製品名>" | |
VALUE "ProductVersion", "1.0.0.1" | |
END | |
END | |
BLOCK "VarFileInfo" | |
BEGIN | |
VALUE "Translation", 0x411, 1200 | |
END | |
END | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// DESIGNINFO | |
// | |
#ifdef APSTUDIO_INVOKED | |
GUIDELINES DESIGNINFO | |
BEGIN | |
IDD_HELLOWORLD_DIALOG, DIALOG | |
BEGIN | |
LEFTMARGIN, 7 | |
RIGHTMARGIN, 313 | |
TOPMARGIN, 7 | |
BOTTOMMARGIN, 193 | |
END | |
END | |
#endif // APSTUDIO_INVOKED | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// AFX_DIALOG_LAYOUT | |
// | |
IDD_HELLOWORLD_DIALOG AFX_DIALOG_LAYOUT | |
BEGIN | |
0 | |
END | |
#endif // 日本語 (日本) resources | |
///////////////////////////////////////////////////////////////////////////// | |
#ifndef APSTUDIO_INVOKED | |
///////////////////////////////////////////////////////////////////////////// | |
// | |
// Generated from the TEXTINCLUDE 3 resource. | |
// | |
#define _AFX_NO_SPLITTER_RESOURCES | |
#define _AFX_NO_OLE_RESOURCES | |
#define _AFX_NO_TRACKER_RESOURCES | |
#define _AFX_NO_PROPERTY_RESOURCES | |
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) | |
LANGUAGE 17, 1 | |
#include "res\HelloWorld.rc2" // Microsoft Visual C++ 以外で編集されたリソース | |
#include "l.JPN\afxres.rc" // 標準コンポーネント | |
#if !defined(_AFXDLL) | |
#include "l.JPN\afxribbon.rc" // MFC リボンおよびコントロール バー リソース | |
#endif | |
#endif | |
///////////////////////////////////////////////////////////////////////////// | |
#endif // not APSTUDIO_INVOKED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HelloWorldDlg.cpp : 実装ファイル | |
// | |
#include "stdafx.h" | |
#include "HelloWorld.h" | |
#include "HelloWorldDlg.h" | |
#include "afxdialogex.h" | |
#ifdef _DEBUG | |
#define new DEBUG_NEW | |
#endif | |
// CHelloWorldDlg ダイアログ | |
CHelloWorldDlg::CHelloWorldDlg(CWnd* pParent /*=NULL*/) | |
: CDialog(IDD_HELLOWORLD_DIALOG, pParent) | |
{ | |
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); | |
} | |
void CHelloWorldDlg::DoDataExchange(CDataExchange* pDX) | |
{ | |
CDialog::DoDataExchange(pDX); | |
} | |
BEGIN_MESSAGE_MAP(CHelloWorldDlg, CDialog) | |
ON_WM_PAINT() | |
ON_WM_QUERYDRAGICON() | |
END_MESSAGE_MAP() | |
// CHelloWorldDlg メッセージ ハンドラー | |
BOOL CHelloWorldDlg::OnInitDialog() | |
{ | |
CDialog::OnInitDialog(); | |
// このダイアログのアイコンを設定します。アプリケーションのメイン ウィンドウがダイアログでない場合、 | |
// Framework は、この設定を自動的に行います。 | |
SetIcon(m_hIcon, TRUE); // 大きいアイコンの設定 | |
SetIcon(m_hIcon, FALSE); // 小さいアイコンの設定 | |
// TODO: 初期化をここに追加します。 | |
return TRUE; // フォーカスをコントロールに設定した場合を除き、TRUE を返します。 | |
} | |
// ダイアログに最小化ボタンを追加する場合、アイコンを描画するための | |
// 下のコードが必要です。ドキュメント/ビュー モデルを使う MFC アプリケーションの場合、 | |
// これは、Framework によって自動的に設定されます。 | |
void CHelloWorldDlg::OnPaint() | |
{ | |
if (IsIconic()) | |
{ | |
CPaintDC dc(this); // 描画のデバイス コンテキスト | |
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); | |
// クライアントの四角形領域内の中央 | |
int cxIcon = GetSystemMetrics(SM_CXICON); | |
int cyIcon = GetSystemMetrics(SM_CYICON); | |
CRect rect; | |
GetClientRect(&rect); | |
int x = (rect.Width() - cxIcon + 1) / 2; | |
int y = (rect.Height() - cyIcon + 1) / 2; | |
// アイコンの描画 | |
dc.DrawIcon(x, y, m_hIcon); | |
} | |
else | |
{ | |
CDialog::OnPaint(); | |
} | |
} | |
// ユーザーが最小化したウィンドウをドラッグしているときに表示するカーソルを取得するために、 | |
// システムがこの関数を呼び出します。 | |
HCURSOR CHelloWorldDlg::OnQueryDragIcon() | |
{ | |
return static_cast<HCURSOR>(m_hIcon); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HelloWorld.h : PROJECT_NAME アプリケーションのメイン ヘッダー ファイルです。 | |
// | |
#pragma once | |
#ifndef __AFXWIN_H__ | |
#error "PCH に対してこのファイルをインクルードする前に 'stdafx.h' をインクルードしてください" | |
#endif | |
#include "resource.h" // メイン シンボル | |
// CHelloWorldApp: | |
// このクラスの実装については、HelloWorld.cpp を参照してください。 | |
// | |
class CHelloWorldApp : public CWinApp | |
{ | |
public: | |
CHelloWorldApp(); | |
// オーバーライド | |
public: | |
virtual BOOL InitInstance(); | |
// 実装 | |
DECLARE_MESSAGE_MAP() | |
}; | |
extern CHelloWorldApp theApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//{{NO_DEPENDENCIES}} | |
// Microsoft Visual C++ で生成されたインクルード ファイル。 | |
// HelloWorld.rc で使用 | |
// | |
#define IDR_MAINFRAME 128 | |
#define IDD_HELLOWORLD_DIALOG 102 | |
// 新しいオブジェクトの次の既定値 | |
// | |
#ifdef APSTUDIO_INVOKED | |
#ifndef APSTUDIO_READONLY_SYMBOLS | |
#define _APS_NEXT_RESOURCE_VALUE 129 | |
#define _APS_NEXT_CONTROL_VALUE 1000 | |
#define _APS_NEXT_SYMED_VALUE 101 | |
#define _APS_NEXT_COMMAND_VALUE 32771 | |
#endif | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stdafx.cpp : 標準インクルード HelloWorld.pch のみを | |
// 含むソース ファイルは、プリコンパイル済みヘッダーになります。 | |
// stdafx.obj にはプリコンパイル済み型情報が含まれます。 | |
#include "stdafx.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または | |
// 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル | |
// を記述します。 | |
#pragma once | |
#ifndef VC_EXTRALEAN | |
#define VC_EXTRALEAN // Windows ヘッダーから使用されていない部分を除外します。 | |
#endif | |
#include "targetver.h" | |
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 一部の CString コンストラクターは明示的です。 | |
// 一般的で無視しても安全な MFC の警告メッセージの一部の非表示を解除します。 | |
#define _AFX_ALL_WARNINGS | |
#include <afxwin.h> // MFC のコアおよび標準コンポーネント | |
#include <afxext.h> // MFC の拡張部分 | |
#ifndef _AFX_NO_OLE_SUPPORT | |
#include <afxdtctl.h> // MFC の Internet Explorer 4 コモン コントロール サポート | |
#endif | |
#ifndef _AFX_NO_AFXCMN_SUPPORT | |
#include <afxcmn.h> // MFC の Windows コモン コントロール サポート | |
#endif // _AFX_NO_AFXCMN_SUPPORT | |
#include <afxcontrolbars.h> // MFC におけるリボンとコントロール バーのサポート |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
// SDKDDKVer.h をインクルードすると、利用できる最も上位の Windows プラットフォームが定義されます。 | |
// 以前の Windows プラットフォーム用にアプリケーションをビルドする場合は、WinSDKVer.h をインクルードし、 | |
// SDKDDKVer.h をインクルードする前に、サポート対象とするプラットフォームを示すように _WIN32_WINNT マクロを設定します。 | |
#include <SDKDDKVer.h> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment