本文整理汇总了C++中InitCommonControlsEx函数的典型用法代码示例。如果您正苦于以下问题:C++ InitCommonControlsEx函数的具体用法?C++ InitCommonControlsEx怎么用?C++ InitCommonControlsEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitCommonControlsEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
BOOL CVODServerApp::InitInstance()
{
//COM库的初始化也可以写OLE库的初始化
//CoInitialize(NULL);//下面有OLE库的初始化了
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
//Socket库的初始化是通过设置生成的。
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// 使用 RichEdit 控件需要 AfxInitRichEdit2()
// AfxInitRichEdit2();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
// 注册应用程序的文档模板。 文档模板
// 将用作文档、框架窗口和视图之间的连接
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CVODServerDoc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CVODServerView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。 如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
//加载皮肤
//1 初始化界面库
VERIFY(1 == InitSkinMagicLib(AfxGetInstanceHandle(), NULL, NULL, NULL));
//2 加载皮肤文件
//VERIFY(1 == LoadSkinFile(_T("./skin/xpsteel.smf")));
/*VERIFY(1 == LoadSkinFile(_T("./skin/corona.smf")));*/
VERIFY(1 == LoadSkinFile(_T("corona.smf")));
//3 设置窗口皮肤
VERIFY(1 == SetWindowSkin(m_pMainWnd->m_hWnd, _T("MainFrame")));
//4 设置对话框窗口皮肤
VERIFY(1 == SetDialogSkin(_T("Dialog")));
g_pWnd = (CMainFrame*)AfxGetMainWnd();
return TRUE;
}
示例2: sizeof
BOOL CCGRealtime_2010_00App::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// 使用 RichEdit 控件需要 AfxInitRichEdit2()
// AfxInitRichEdit2();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
InitContextMenuManager();
InitKeyboardManager();
InitTooltipManager();
CMFCToolTipInfo ttParams;
ttParams.m_bVislManagerTheme = TRUE;
theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
// 注册应用程序的文档模板。文档模板
// 将用作文档、框架窗口和视图之间的连接
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CCGRealtime_2010_00Doc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CCGRealtime_2010_00View));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// 仅当具有后缀时才调用 DragAcceptFiles
// 在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
AllocConsole(); // 开辟控制台
SetConsoleTitle(_T("Debug Output")); // 设置控制台窗口标题
freopen("CONOUT$","w",stdout); // 重定向输出
return TRUE;
}
示例3: sizeof
bool CMainWindow::CreateToolbar()
{
// Ensure that the common control DLL is loaded.
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
InitCommonControlsEx(&icex);
hwndTB = CreateWindowEx(0,
TOOLBARCLASSNAME,
(LPCTSTR)NULL,
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,
0, 0, 0, 0,
*this,
(HMENU)IDC_TORTOISEIDIFF,
hResource,
NULL);
if (hwndTB == INVALID_HANDLE_VALUE)
return false;
SendMessage(hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
TBBUTTON tbb[13];
// create an imagelist containing the icons for the toolbar
hToolbarImgList = ImageList_Create(24, 24, ILC_COLOR32 | ILC_MASK, 12, 4);
if (hToolbarImgList == NULL)
return false;
int index = 0;
HICON hIcon = NULL;
if (selectionPaths.empty())
{
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_OVERLAP));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_OVERLAPIMAGES;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_BLEND));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_BLENDALPHA;
tbb[index].fsState = 0;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_LINK));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_LINKIMAGESTOGETHER;
tbb[index].fsState = TBSTATE_ENABLED | TBSTATE_CHECKED;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_FITWIDTHS));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_FITIMAGEWIDTHS;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_FITHEIGHTS));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_FITIMAGEHEIGHTS;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
tbb[index].iBitmap = 0;
tbb[index].idCommand = 0;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_SEP;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
}
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_VERTICAL));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_ARRANGEVERTICAL;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_FITINWINDOW));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_FITIMAGESINWINDOW;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_ORIGSIZE));
tbb[index].iBitmap = ImageList_AddIcon(hToolbarImgList, hIcon);
tbb[index].idCommand = ID_VIEW_ORININALSIZE;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
//.........这里部分代码省略.........
示例4: _tWinMain
//
// Main entry point
//
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
INITCOMMONCONTROLSEX ice;
HACCEL hAccelTable;
hInstance = hInst;
// Load application title
LoadString(hInst, IDS_SOL_NAME, szAppName, sizeof(szAppName) / sizeof(szAppName[0]));
// Load MsgBox() texts here to avoid loading them many times later
LoadString(hInst, IDS_SOL_ABOUT, MsgAbout, sizeof(MsgAbout) / sizeof(MsgAbout[0]));
LoadString(hInst, IDS_SOL_QUIT, MsgQuit, sizeof(MsgQuit) / sizeof(MsgQuit[0]));
LoadString(hInst, IDS_SOL_WIN, MsgWin, sizeof(MsgWin) / sizeof(MsgWin[0]));
LoadString(hInst, IDS_SOL_DEAL, MsgDeal, sizeof(MsgDeal) / sizeof(MsgDeal[0]));
//Window class for the main application parent window
wndclass.style = 0;//CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInst;
wndclass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IDI_SOLITAIRE));
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)NULL;
wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
ice.dwSize = sizeof(ice);
ice.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&ice);
srand((unsigned)GetTickCount());//timeGetTime());
// InitCardLib();
LoadSettings();
//Construct the path to our help file
MakePath(szHelpPath, MAX_PATH, _T(".hlp"));
hwnd = CreateWindow(szAppName, // window class name
szAppName, // window caption
WS_OVERLAPPEDWINDOW
,//|WS_CLIPCHILDREN, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
0, // The real size will be computed in WndProc through WM_GETMINMAXINFO
0, // The real size will be computed in WndProc through WM_GETMINMAXINFO
NULL, // parent window handle
NULL, // use window class menu
hInst, // program instance handle
NULL); // creation parameters
hwndMain = hwnd;
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
while(GetMessage(&msg, NULL,0,0))
{
if(!TranslateAccelerator(hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
SaveSettings();
return msg.wParam;
}
示例5: CefEnableHighDPISupport
BOOL CKTVStartApp::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
// Enable High-DPI support on Windows 7 or newer.
CefEnableHighDPISupport();
//wchar_t path[MAX_PATH];
//GetModuleFileName(NULL, path, sizeof(path));
////判断环境是否为WOW64
//BOOL isWOW64;
//REGSAM p;
//IsWow64Process(GetCurrentProcess(), &isWOW64);
//if (isWOW64) {
// p = KEY_WRITE | KEY_WOW64_64KEY;
//}
//else {
// p = KEY_WRITE;
//}
//HKEY hKey;
//if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, NULL, 0, p, NULL, &hKey, NULL) != ERROR_SUCCESS) {
// //失败
// return 0;
//}
//if (RegSetValueEx(hKey, TEXT("KTVStart"), 0, REG_SZ, (BYTE*)path, sizeof(path) * sizeof(TCHAR)) != ERROR_SUCCESS) {
// //失败
// return 0;
//}
//RegCloseKey(hKey);
CefMainArgs main_args(theApp.m_hInstance);
CefRefPtr<SimpleApp> app(new SimpleApp);
int exit_code = CefExecuteProcess(main_args, app.get(), NULL);
if (exit_code >= 0) {
exit(exit_code);
}
CefSettings settings;
//settings.log_severity = LOGSEVERITY_DISABLE;
settings.ignore_certificate_errors = true;
//settings.command_line_args_disabled = 0;
//settings.Add("enable-media-stream", "enable-media-stream");
CefSettingsTraits::init(&settings);
settings.multi_threaded_message_loop = true;
CefInitialize(main_args, settings, app.get(), NULL);
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// 创建 shell 管理器,以防对话框包含
// 任何 shell 树视图控件或 shell 列表视图控件。
CShellManager *pShellManager = new CShellManager;
// 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
// 安装钩子
//g_HookHwnd = SetWindowsHookEx(WH_KEYBOARD_LL, MyHookFun, m_hInstance, 0);
CKTVStartDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
else if (nResponse == -1)
//.........这里部分代码省略.........
示例6: sizeof
BOOL CImgAppApp::InitInstance()
{
// 假如應用程式資訊清單指定使用 ComCtl32.dll 6 (含) 以後版本,
// 來啟動視覺化樣式,在 Windows XP 上,則需要 InitCommonControls()。
// 否則任何視窗的建立都將失敗。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 設定要包含所有您想要用於應用程式中的
// 通用控制項類別。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// 初始化 OLE 程式庫
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 標準初始設定
// 如果您不使用這些功能並且想減少
// 最後完成的可執行檔大小,您可以
// 從下列程式碼移除不需要的初始化常式,
// 變更儲存設定值的登錄機碼
// TODO: 您應該適度修改此字串
// (例如,公司名稱或組織名稱)
SetRegistryKey(_T("本機 AppWizard 所產生的應用程式"));
LoadStdProfileSettings(4); // 載入標準 INI 檔選項 (包含 MRU)
// 登錄應用程式的文件範本。文件範本負責在文件、
// 框架視窗與檢視間進行連接
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_ImgAppTYPE,
RUNTIME_CLASS(CImgAppDoc),
RUNTIME_CLASS(CChildFrame), // 自訂 MDI 子框架
RUNTIME_CLASS(CImgAppView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 建立主 MDI 框架視窗
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// 只有在 MDI 應用程式中有後置字元時,才呼叫 DragAcceptFiles
// 這會立即發生在設定 m_pMainWnd 之後
// 剖析標準 Shell 命令、DDE、檔案開啟舊檔的命令列
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 在命令列中指定的分派命令。如果已使用
// /RegServer、/Register、/Unregserver 或 /Unregister 啟動應用程式,將傳回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 已經初始設定主視窗,所以顯示並更新該視窗
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
示例7: WinMain
//.........这里部分代码省略.........
g_Config.bSoftwareRendering = false;
}
else if (restOfOption == L"gles") {
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
g_Config.bSoftwareRendering = false;
}
else if (restOfOption == L"software") {
g_Config.iGPUBackend = GPU_BACKEND_OPENGL;
g_Config.bSoftwareRendering = true;
}
}
}
}
#ifdef _DEBUG
g_Config.bEnableLogging = true;
#endif
LogManager::Init();
// Consider at least the following cases before changing this code:
// - By default in Release, the console should be hidden by default even if logging is enabled.
// - By default in Debug, the console should be shown by default.
// - The -l switch is expected to show the log console, REGARDLESS of config settings.
// - It should be possible to log to a file without showing the console.
LogManager::GetInstance()->GetConsoleListener()->Init(showLog, 150, 120, "PPSSPP Debug Console");
if (debugLogLevel)
LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG);
//Windows, API init stuff
INITCOMMONCONTROLSEX comm;
comm.dwSize = sizeof(comm);
comm.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES;
InitCommonControlsEx(&comm);
timeBeginPeriod(1);
MainWindow::Init(_hInstance);
g_hPopupMenus = LoadMenu(_hInstance, (LPCWSTR)IDR_POPUPMENUS);
MainWindow::Show(_hInstance);
HWND hwndMain = MainWindow::GetHWND();
HWND hwndDisplay = MainWindow::GetDisplayHWND();
//initialize custom controls
CtrlDisAsmView::init();
CtrlMemView::init();
CtrlRegisterList::init();
CGEDebugger::Init();
DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));
host = new WindowsHost(hwndMain, hwndDisplay);
host->SetWindowTitle(0);
MainWindow::CreateDebugWindows();
// Emu thread is always running!
EmuThread_Start();
InputDevice::BeginPolling();
HACCEL hAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_ACCELS);
HACCEL hDebugAccelTable = LoadAccelerators(_hInstance, (LPCTSTR)IDR_DEBUGACCELS);
//so.. we're at the message pump of the GUI thread
for (MSG msg; GetMessage(&msg, NULL, 0, 0); ) // for no quit
示例8: DbgLog
bool CApp::InitInstance(int nCmdShow)
{
DbgLog((LOG_TRACE, 5, TEXT("CApp::InitInstance()"))) ;
// Win32 will always set hPrevInstance to NULL, so check
// things a little closer. This is because we only want a single
// version of this app to run at a time.
m_hWnd = FindWindow(m_szAppName, m_szAppTitle) ;
if(m_hWnd) {
// We found another instance of ourself. Lets use that one:
if(IsIconic(m_hWnd)) {
ShowWindow(m_hWnd, SW_RESTORE);
}
SetForegroundWindow(m_hWnd);
// If this app actually had any methodality, we would
// also want to communicate any action that our 'twin'
// should now perform based on how the user tried to
// execute us.
return false;
}
// Register the app main window class
WNDCLASSEX wc ;
wc.cbSize = sizeof(wc) ;
wc.style = CS_HREDRAW | CS_VREDRAW ;
wc.lpfnWndProc = (WNDPROC) WndProc ;
wc.cbClsExtra = 0 ;
wc.cbWndExtra = 0 ;
wc.hInstance = m_hInstance ;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW) ;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) ;
wc.lpszMenuName = TEXT("DvdSample_Menu");
wc.lpszClassName = m_szAppName ;
wc.hIconSm = NULL ;
if(0 == RegisterClassEx(&wc)) {
DbgLog((LOG_ERROR, 0,
TEXT("ERROR: RegisterClassEx() for app class failed (Error %ld)"),
GetLastError())) ;
return false ;
}
// Determine where to put the Application Window
RECT rDesktop;
SystemParametersInfo(SPI_GETWORKAREA, NULL, &rDesktop, NULL);
// Create an instance of the window we just registered
// locate it at the bottom of the screen (bottom of screen - height of player)
m_hWnd = CreateWindowEx(0, m_szAppName, m_szAppTitle, WS_OVERLAPPEDWINDOW, //& ~WS_THICKFRAME,
160, rDesktop.bottom - 150, 300, 150,
NULL, NULL, m_hInstance, NULL);
if(!m_hWnd) {
DbgLog((LOG_ERROR, 0,
TEXT("ERROR: CreateWindowEx() failed (Error %ld)"),
GetLastError())) ;
return false ;
}
// We now create the toolbar
INITCOMMONCONTROLSEX cc;
cc.dwSize = sizeof(INITCOMMONCONTROLSEX);
cc.dwICC = ICC_BAR_CLASSES; // register only the toolbar control
InitCommonControlsEx(&cc);
#ifdef _WIN64
// BYTE bReserved[6] // padding for alignment
#define PAD 0,0,0,0,0,0, 0,0,
#elif defined(_WIN32)
// BYTE bReserved[2] // padding for alignment
#define PAD 0,0, 0,0,
#endif
// Configure toolbar buttons
TBBUTTON tbb[] =
{
0, ID_PLAYBACK_PREVIOUSCHAPTER, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
1, ID_PLAYBACK_REWIND, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
2, ID_PLAYBACK_PAUSE, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
3, ID_PLAYBACK_PLAY, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
4, ID_PLAYBACK_STOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
5, ID_PLAYBACK_FASTFORWARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
6, ID_PLAYBACK_NEXTCHAPTER, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
9, 0, TBSTATE_ENABLED, TBSTYLE_SEP, PAD
7, ID_PLAYBACK_MENUROOT, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
8, ID_OPTIONS_FULLSCREEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
9, ID_PLAYBACK_STEPFORWARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, PAD
};
m_hwndToolBar = CreateToolbarEx(m_hWnd, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CCS_TOP
| TBSTYLE_TOOLTIPS, 1, 10, m_hInstance, IDR_TOOLBAR1, tbb, 11, 0, 0, 0, 0,
sizeof(TBBUTTON));
if(!m_hwndToolBar) {
DbgLog((LOG_ERROR, 0,
TEXT("ERROR: CreateToolbarEx() failed (Error %ld)"),
GetLastError())) ;
return false ;
}
//.........这里部分代码省略.........
示例9: AfxOleInit
BOOL CThresholding1App::InitInstance()
{
AfxOleInit();
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
#if !defined(_WIN32_WCE) || defined(_CE_DCOM)
// 通过 CoRegisterClassObject() 注册类工厂。
if (FAILED(_AtlModule.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE)))
return FALSE;
#endif // !defined(_WIN32_WCE) || defined(_CE_DCOM)
// 应用程序是用 /Embedding 或 /Automation 开关启动的。
// 将应用程序作为自动化服务器运行。
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
{
// 不显示主窗口
return TRUE;
}
// 应用程序是用 /Unregserver 或 /Unregister 开关启动的。
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
{
_AtlModule.UpdateRegistryAppId(FALSE);
_AtlModule.UnregisterServer(TRUE);
return FALSE;
}
// 应用程序是用 /Register 或 /Regserver 开关启动的。
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister)
{
_AtlModule.UpdateRegistryAppId(TRUE);
_AtlModule.RegisterServer(TRUE);
return FALSE;
}
// 创建 shell 管理器,以防对话框包含
// 任何 shell 树视图控件或 shell 列表视图控件。
CShellManager *pShellManager = new CShellManager;
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
CThresholding1Dlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
// 删除上面创建的 shell 管理器。
if (pShellManager != NULL)
{
delete pShellManager;
}
// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
// 而不是启动应用程序的消息泵。
return FALSE;
}
示例10: InitInstance
//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
hInst = hInstance; // Store instance handle in our global variable
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_MAXIMIZEBOX| WS_MINIMIZEBOX| WS_SYSMENU,
0, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
if (!hWnd)
{
return FALSE;
}
INITCOMMONCONTROLSEX InitCtrlEx;
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCtrlEx.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&InitCtrlEx);
TBBUTTON tbrButtons[10];
tbrButtons[0].iBitmap = 0;
tbrButtons[0].idCommand = ID_FILE_OPEN;
tbrButtons[0].fsState = TBSTATE_ENABLED;
tbrButtons[0].fsStyle = TBSTYLE_BUTTON;
tbrButtons[0].dwData = 0L;
tbrButtons[0].iBitmap = 0;
tbrButtons[0].iString = 0;
tbrButtons[1].iBitmap = 1;
tbrButtons[1].idCommand = ID_FILE_SAVE;
tbrButtons[1].fsState = TBSTATE_ENABLED;
tbrButtons[1].fsStyle = TBSTYLE_BUTTON;
tbrButtons[1].dwData = 0L;
tbrButtons[1].iString = 0;
tbrButtons[2].iBitmap = 0;
tbrButtons[2].idCommand =0;
tbrButtons[2].fsState = TBSTATE_ENABLED;
tbrButtons[2].fsStyle = TBSTYLE_SEP;
tbrButtons[2].dwData = 0L;
tbrButtons[2].iString = 0;
tbrButtons[3].iBitmap = 2;
tbrButtons[3].idCommand = ID_FORMAT_COLOR;
tbrButtons[3].fsState = TBSTATE_ENABLED;
tbrButtons[3].fsStyle = TBSTYLE_BUTTON;
tbrButtons[3].dwData = 0L;
tbrButtons[3].iString = 0;
tbrButtons[4].iBitmap = 3;
tbrButtons[4].idCommand = ID_SHAPE_SQUARE;
tbrButtons[4].fsState = TBSTATE_ENABLED;
tbrButtons[4].fsStyle = TBSTYLE_BUTTON;
tbrButtons[4].dwData = 0L;
tbrButtons[4].iString = 0;
tbrButtons[5].iBitmap = 4;
tbrButtons[5].idCommand = ID_SHAPE_ROUND;
tbrButtons[5].fsState = TBSTATE_ENABLED;
tbrButtons[5].fsStyle = TBSTYLE_BUTTON;
tbrButtons[5].dwData = 0L;
tbrButtons[5].iString = 0;
tbrButtons[6].iBitmap = 5;
tbrButtons[6].idCommand = ID_LINE_STRAIGHTLINE;
tbrButtons[6].fsState = TBSTATE_ENABLED;
tbrButtons[6].fsStyle = TBSTYLE_BUTTON;
tbrButtons[6].dwData = 0L;
tbrButtons[6].iString = 0;
tbrButtons[7].iBitmap = 6;
tbrButtons[7].idCommand = ID_SHAPE_ELLIPSE;
tbrButtons[7].fsState = TBSTATE_ENABLED;
tbrButtons[7].fsStyle = TBSTYLE_BUTTON;
tbrButtons[7].dwData = 0L;
tbrButtons[7].iString = 0;
tbrButtons[8].iBitmap = 7;
tbrButtons[8].idCommand = ID_SHAPE_RECTANGLE;
tbrButtons[8].fsState = TBSTATE_ENABLED;
tbrButtons[8].fsStyle = TBSTYLE_BUTTON;
tbrButtons[8].dwData = 0L;
tbrButtons[8].iString = 0;
tbrButtons[9].iBitmap = 8;
tbrButtons[9].idCommand = ID_LINE_FREESTYLE;
tbrButtons[9].fsState = TBSTATE_ENABLED;
tbrButtons[9].fsStyle = TBSTYLE_BUTTON;
tbrButtons[9].dwData = 0L;
tbrButtons[9].iString = 0;
//.........这里部分代码省略.........
示例11: sizeof
void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTraditional, bool isMultiLine)
{
Window::init(hInst, parent);
int vertical = isVertical?(TCS_VERTICAL | TCS_MULTILINE | TCS_RIGHTJUSTIFY):0;
_isTraditional = isTraditional;
_isVertical = isVertical;
_isMultiLine = isMultiLine;
INITCOMMONCONTROLSEX icce;
icce.dwSize = sizeof(icce);
icce.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icce);
int multiLine = isMultiLine?(_isTraditional?TCS_MULTILINE:0):0;
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |\
TCS_TOOLTIPS | TCS_FOCUSNEVER | TCS_TABS | vertical | multiLine;
style |= TCS_OWNERDRAWFIXED;
_hSelf = ::CreateWindowEx(
0,
WC_TABCONTROL,
TEXT("Tab"),
style,
0, 0, 0, 0,
_hParent,
NULL,
_hInst,
0);
if (!_hSelf)
{
throw std::runtime_error("TabBarPlus::init : CreateWindowEx() function return null");
}
if (!_isTraditional)
{
if (!_hwndArray[_nbCtrl])
{
_hwndArray[_nbCtrl] = _hSelf;
_ctrlID = _nbCtrl;
}
else
{
int i = 0;
bool found = false;
for ( ; i < nbCtrlMax && !found ; i++)
if (!_hwndArray[i])
found = true;
if (!found)
{
_ctrlID = -1;
destroy();
throw std::runtime_error("TabBarPlus::init : Tab Control error - Tab Control # is over its limit");
}
_hwndArray[i] = _hSelf;
_ctrlID = i;
}
_nbCtrl++;
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
_tabBarDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)TabBarPlus_Proc));
}
LOGFONT LogFont;
_hFont = (HFONT)::SendMessage(_hSelf, WM_GETFONT, 0, 0);
if (_hFont == NULL)
_hFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
if (_hLargeFont == NULL)
_hLargeFont = (HFONT)::GetStockObject(SYSTEM_FONT);
if (::GetObject(_hFont, sizeof(LOGFONT), &LogFont) != 0)
{
LogFont.lfEscapement = 900;
LogFont.lfOrientation = 900;
_hVerticalFont = CreateFontIndirect(&LogFont);
LogFont.lfWeight = 900;
_hVerticalLargeFont = CreateFontIndirect(&LogFont);
}
}
示例12: sizeof
BOOL CMidtermProjectApp::InitInstance()
{
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
// 이 항목을 설정하십시오.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
// OLE 라이브러리를 초기화합니다.
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화
// 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
LoadStdProfileSettings(4); // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다.
// 응용 프로그램의 문서 템플릿을 등록합니다. 문서 템플릿은
// 문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다.
//CMultiDocTemplate* pDocTemplate;
m_pImageDocTemplate = new CMultiDocTemplate(IDR_MidtermProjectTYPE,
RUNTIME_CLASS(CMidtermProjectDoc),
RUNTIME_CLASS(CChildFrame), // 사용자 지정 MDI 자식 프레임입니다.
RUNTIME_CLASS(CMidtermProjectView));
if (!m_pImageDocTemplate)
return FALSE;
AddDocTemplate(m_pImageDocTemplate);
// 주 MDI 프레임 창을 만듭니다.
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
{
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
// 접미사가 있을 경우에만 DragAcceptFiles를 호출합니다.
// MDI 응용 프로그램에서는 m_pMainWnd를 설정한 후 바로 이러한 호출이 발생해야 합니다.
// 끌어서 놓기에 대한 열기를 활성화합니다.
m_pMainWnd->DragAcceptFiles();
// DDE Execute 열기를 활성화합니다.
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 프로그램 시작 시 빈 창을 띄우지 않는다.
if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew )
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
// 명령줄에 지정된 명령을 디스패치합니다.
// 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 주 창이 초기화되었으므로 이를 표시하고 업데이트합니다.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
示例13: InitializeCoolSB
//
// Initialize the cool scrollbars for a window by subclassing it
// and using the coolsb window procedure instead
//
BOOL WINAPI InitializeCoolSB(HWND hwnd)
{
SCROLLWND *sw;
SCROLLINFO *si;
INITCOMMONCONTROLSEX ice;
TOOLINFO ti;
RECT rect;
DWORD dwCurStyle;
//BOOL fDisabled;
if(pEnableScrollBar == 0)
pEnableScrollBar = EnableScrollBar;
GetClientRect(hwnd, &rect);
//if we have already initialized Cool Scrollbars for this window,
//then stop the user from doing it again
if(GetScrollWndFromHwnd(hwnd) != 0)
{
return FALSE;
}
//allocate a private scrollbar structure which we
//will use to keep track of the scrollbar data
sw = (SCROLLWND *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SCROLLWND));
si = &sw->sbarHorz.scrollInfo;
si->cbSize = sizeof(SCROLLINFO);
si->fMask = SIF_ALL;
GetScrollInfo(hwnd, SB_HORZ, si);
si = &sw->sbarVert.scrollInfo;
si->cbSize = sizeof(SCROLLINFO);
si->fMask = SIF_ALL;
GetScrollInfo(hwnd, SB_VERT, si);
//check to see if the window has left-aligned scrollbars
if(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LEFTSCROLLBAR)
sw->fLeftScrollbar = TRUE;
else
sw->fLeftScrollbar = FALSE;
dwCurStyle = GetWindowLong(hwnd, GWL_STYLE);
SetProp(hwnd, szPropStr, (HANDLE)sw);
//try to enable the scrollbar arrows - if the return value is
//non-zero, then the scrollbars were previously disabled
//fDisabled = pEnableScrollBar(hwnd, SB_HORZ, ESB_ENABLE_BOTH);
//scrollbars will automatically get enabled, even if
//they aren't to start with....sorry, but there isn't an
//easy alternative.
if(dwCurStyle & WS_HSCROLL)
sw->sbarHorz.fScrollFlags = CSBS_VISIBLE;
if(dwCurStyle & WS_VSCROLL)
sw->sbarVert.fScrollFlags = CSBS_VISIBLE;
//need to be able to distinguish between horizontal and vertical
//scrollbars in some instances
sw->sbarHorz.nBarType = SB_HORZ;
sw->sbarVert.nBarType = SB_VERT;
sw->sbarHorz.fFlatScrollbar = CSBS_NORMAL;
sw->sbarVert.fFlatScrollbar = CSBS_NORMAL;
//set the default arrow sizes for the scrollbars
sw->sbarHorz.nArrowLength = SYSTEM_METRIC;
sw->sbarHorz.nArrowWidth = SYSTEM_METRIC;
sw->sbarVert.nArrowLength = SYSTEM_METRIC;
sw->sbarVert.nArrowWidth = SYSTEM_METRIC;
sw->bPreventStyleChange = FALSE;
sw->oldproc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)CoolSBWndProc);
CoolSB_SetMinThumbSize(hwnd, SB_BOTH, CoolSB_GetDefaultMinThumbSize());
#ifdef COOLSB_TOOLTIPS
ice.dwSize = sizeof(ice);
ice.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&ice);
sw->hwndToolTip = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TOOLWINDOW, TOOLTIPS_CLASS, _T(""),
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
hwnd, NULL, GetModuleHandle(0),
NULL);
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_IDISHWND;
ti.hwnd = hwnd;
ti.uId = (UINT)hwnd;
ti.lpszText = LPSTR_TEXTCALLBACK;
//.........这里部分代码省略.........
示例14: sizeof
BOOL CFoosballApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;
// Activate "Windows Native" visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CFoosballDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
else if (nResponse == -1)
{
TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");
TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n");
}
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
示例15: sizeof
BOOL CServeApp::InitInstance()
{
// 如果一个运行在 Windows XP 上的应用程序清单指定要
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 将它设置为包括所有要在应用程序中使用的
// 公共控件类。
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
// 初始化 OLE 库
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// 使用 RichEdit 控件需要 AfxInitRichEdit2()
// AfxInitRichEdit2();
// 标准初始化
// 如果未使用这些功能并希望减小
// 最终可执行文件的大小,则应移除下列
// 不需要的特定初始化例程
// 更改用于存储设置的注册表项
// TODO: 应适当修改该字符串,
// 例如修改为公司或组织名
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU)
// 注册应用程序的文档模板。 文档模板
// 将用作文档、框架窗口和视图之间的连接
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CServeDoc),
RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口
RUNTIME_CLASS(CServeView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 分析标准 shell 命令、DDE、打开文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 调度在命令行中指定的命令。 如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 唯一的一个窗口已初始化,因此显示它并对其进行更新
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}