utility.cpp

来自「文件加密解密源代码」· C++ 代码 · 共 64 行

CPP
64
字号
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///	This is the starting execution point, _tWinMain calls PreMessageLoop and from then on the execution goes to
///	MainDialog class constructor & WM_INITDIALOG message processing (OnInitDialog method).
///	The Application is Using ATL (Active Template Library) only for easy Dialog/UI implementation.
///	The linkage with ATL library is disabled - The ONLY usage of ATL is the macro version of 
///	the WinProc (check MainDialog.h)
///	I hope that the usage of ATL does the code clearer and not the other way arround :)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainDialog.h"

class CUtilityModule : public CAtlExeModuleT<CUtilityModule>
{
public :
	CUtilityModule() : _mainDialog(0)
	{
	}

	~CUtilityModule()
	{
		delete _mainDialog;
	}

	/* WinMain Actual starting Point. */
	HRESULT PreMessageLoop(int nShowCmd) throw()
	{
		::InitCommonControls();

		_mainDialog = new MainDialog();

		// Checking for memory allocation error.
		if (_mainDialog == NULL)
		{
			__super::PostMessageLoop();
			return E_OUTOFMEMORY;
		}

		_mainDialog->Create(NULL);
		_mainDialog->ShowWindow(nShowCmd);

		// Message Processing.
		MSG msg;
		while (GetMessage(&msg, NULL, 0, 0)) 
		{
			// *_mainDialog = MainDialog Dialog Handle (hWnd).
			if (!IsDialogMessage(*_mainDialog, &msg))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}

		return __super::PreMessageLoop(nShowCmd);
	}
private:
	MainDialog *_mainDialog;
};

CUtilityModule _AtlModule;

extern "C" int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int nShowCmd)
{
	return _AtlModule.WinMain(nShowCmd);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?