当前位置: 首页>>代码示例>>C++>>正文


C++ CWinApp类代码示例

本文整理汇总了C++中CWinApp的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp类的具体用法?C++ CWinApp怎么用?C++ CWinApp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CWinApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dlgSaveAs

void CMainWizard::OnScExportSettings(void)
{
	CString strFilter;
	CString strTitle;
	CProcessPrivileges processPrivileges;

	enum { fdwFlags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY };
	strFilter.LoadString(IDS_SETTINGS_FILTER);
#if (_MFC_VER < 0x0700)
	CFileDialogEx dlgSaveAs(FALSE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter);
#else
	CFileDialog dlgSaveAs(FALSE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter);
#endif   // _MFC_VER
	strTitle.LoadString(IDS_TITLE_EXPORT);
	dlgSaveAs.m_ofn.lpstrTitle = strTitle;
	if (dlgSaveAs.DoModal() == IDOK)
	{
		BeginWaitCursor();
		CWinApp* pApp = AfxGetApp();
		ASSERT_VALID(pApp);
		processPrivileges[SE_BACKUP_NAME] = SE_PRIVILEGE_ENABLED;
		HKEY hAppKey = pApp->GetAppRegistryKey();
		::RegSaveKey(hAppKey, dlgSaveAs.GetPathName(), NULL);
		::RegCloseKey(hAppKey);
		processPrivileges[SE_BACKUP_NAME] = 0;
		EndWaitCursor();
	}
}
开发者ID:zephyrer,项目名称:update-it,代码行数:28,代码来源:MainWizard.cpp

示例2: pLeashGetTimeServerName

BOOL CLeashProperties::OnInitDialog()
{
	CDialog::OnInitDialog();

    pLeashGetTimeServerName(timeServer, TIMEHOST);
    SetDlgItemText(IDC_EDIT_TIME_SERVER, timeServer);

   	if (getenv(TIMEHOST))
        GetDlgItem(IDC_EDIT_TIME_SERVER)->EnableWindow(FALSE);
    else
        GetDlgItem(IDC_STATIC_TIMEHOST)->ShowWindow(FALSE);

    CWinApp * pApp = AfxGetApp();
    if (pApp)
        m_initMissingFiles = m_newMissingFiles =
            pApp->GetProfileInt("Settings", "CreateMissingConfig", FALSE_FLAG);
    CheckDlgButton(IDC_CHECK_CREATE_MISSING_CFG, m_initMissingFiles);

    dw_initMslsaImport = dw_newMslsaImport = pLeash_get_default_mslsa_import();
    switch ( dw_initMslsaImport ) {
    case 0:
        CheckDlgButton(IDC_RADIO_MSLSA_IMPORT_OFF,TRUE);
        break;
    case 1:
        CheckDlgButton(IDC_RADIO_MSLSA_IMPORT_ON,TRUE);
        break;
    case 2:
        CheckDlgButton(IDC_RADIO_MSLSA_IMPORT_MATCH,TRUE);
        break;
    }

    return TRUE;
}
开发者ID:secure-endpoints,项目名称:pismere,代码行数:33,代码来源:LeashProperties.cpp

示例3: ui_app_add_doc_template

// @pymethod |PyCWinApp|AddDocTemplate|Adds a template to the application list.
static PyObject *
ui_app_add_doc_template(PyObject *self, PyObject *args)
{
	PyObject *obTemplate;
	if (!PyArg_ParseTuple(args,"O:AddDocTemplate",
	                      &obTemplate))     // @pyparm <o PyCDocTemplate>|template||The template to be added.
		return NULL;

	if (!ui_base_class::is_uiobject(obTemplate, &PyCDocTemplate::type))
		RETURN_TYPE_ERR("The parameter must be a template object");

	CDocTemplate *pTempl = PyCDocTemplate::GetTemplate(obTemplate);
	if (pTempl==NULL)
		return NULL;
	CWinApp *pApp = GetApp();
	if (!pApp) return NULL;
	// walk all templates in the application looking for it.
	CDocTemplate* pTemplate;
	POSITION pos = pApp->m_pDocManager ? pApp->m_pDocManager->GetFirstDocTemplatePosition() : NULL;
	while (pos != NULL) {
		pTemplate = pApp->m_pDocManager->GetNextDocTemplate(pos);
		if (pTemplate==pTempl)
			RETURN_ERR("The template is already in the application list");
	}
	GUI_BGN_SAVE;
	pApp->AddDocTemplate(pTempl);
	GUI_END_SAVE;
	RETURN_NONE;
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:30,代码来源:win32app.cpp

示例4: SetActiveWindow

void CMainFrame::OnDropFiles( HDROP hDropInfo )
{
	SetActiveWindow();      // activate us first !

	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp != NULL);

	CString strFile;
	UINT nFilesCount=DragQueryFile(hDropInfo,INFINITE,NULL,0);
	for(UINT i=0; i<nFilesCount; i++)
	{
		int pathLen = DragQueryFile(hDropInfo, i, strFile.GetBuffer(MAX_PATH), MAX_PATH);
		strFile.ReleaseBuffer(pathLen);
		DWORD dwFileAttr = ::GetFileAttributes(strFile);
		if ((dwFileAttr & FILE_ATTRIBUTE_DIRECTORY)==FILE_ATTRIBUTE_DIRECTORY)
		{
			//目录,需要递归里面包含的文件
		}
		else
		{
			CString strExt=strFile.Mid(strFile.GetLength()-4,4);
			if (strExt.CompareNoCase(_T(".xml"))==0)
			{
				pApp->OpenDocumentFile(strFile);
			}
		}
	}
	DragFinish(hDropInfo);
}
开发者ID:ddcatgg,项目名称:duilib,代码行数:29,代码来源:MainFrm.cpp

示例5: AfxGetApp

void CMainFrame::OnViewDeletedrecords() 
{
	m_bShowDeletedRecords = !m_bShowDeletedRecords;
	
	CWinApp* pApp = AfxGetApp();
	ASSERT_VALID(pApp);

	// Iterate through the application's document templates list
	POSITION posTemplate = pApp->GetFirstDocTemplatePosition();
	while(posTemplate)
	{
		// For each document template object...
		CDocTemplate* pTemplate = pApp->GetNextDocTemplate(posTemplate);
		ASSERT_VALID(pTemplate);
		ASSERT_KINDOF(CDocTemplate, pTemplate);

		// Iterate through the template's document list
		POSITION posDocument = pTemplate->GetFirstDocPosition();
		while(posDocument)
		{
			// For each document object...
			CDocument* pDoc = pTemplate->GetNextDoc(posDocument);
			ASSERT_VALID(pDoc);
			ASSERT_KINDOF(CDocument, pDoc);

			// reload records
			POSITION pos = pDoc->GetFirstViewPosition();
			while (pos)
				((CDBFExplorerView *)pDoc->GetNextView(pos))->ShowRecords(m_bShowDeletedRecords);
		}
	}
}
开发者ID:tchv71,项目名称:StartPP,代码行数:32,代码来源:MainFrm.cpp

示例6: AfxGetApp

BOOL CLogin::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	CWinApp* pApp = AfxGetApp();

	//determine range of accounts in history.
	//range begins at 1 and ends at and includes latest.  Bing: "latest" is actually the count for previous logins.
	//
	//in this case, if 0 is the latest, then there is no history
	//and thus, don't do anything.

	UINT latest = pApp->GetProfileInt("History", "Latest", 0);

	m_ListBox.SetExtendedStyle( m_ListBox.GetExtendedStyle() | LVS_EX_FULLROWSELECT );
	m_ListBox.InsertColumn(0, "Name", LVCFMT_LEFT, 75);
	m_ListBox.InsertColumn(1, "Zone", LVCFMT_LEFT, 75);
	m_ListBox.InsertColumn(2, "Server Host", LVCFMT_LEFT, 110);
	m_ListBox.InsertColumn(3, "Port", LVCFMT_LEFT, 75);

	for(UINT i = 1; i <= latest; i++)
	{
		FillBoxes(i, true);
	}

	int count = m_ListBox.GetItemCount();

	if(count > 0)
	{
		VERIFY(m_ListBox.SetItemState(count-1, 0xFFFFFFFF, LVIS_SELECTED));
	}

	// set the last login
	int last_login = pApp->GetProfileInt("History", "LastLogin", 0);
	if(last_login == 0) /* no last login */
	{
		if(latest > 0)
		{
			last_login = latest;
		}
	}
	if(last_login > 0)
	{
		FillBoxes(last_login, false);
	}

	CButton *cbox = (CButton *)GetDlgItem(IDC_CHECK_PRELOGINS);
	if(pApp->GetProfileInt("ShowPreviousLogins", "YesNo", 1) == 0)
	{
		cbox->SetCheck(BST_UNCHECKED);
	}
	else
	{
		cbox->SetCheck(BST_CHECKED);
	}
	OnBnClickedCheckPrelogins();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:60,代码来源:Login.cpp

示例7: LANG_INIT

// sélection de la langue
void LANG_INIT() {
  CWinApp* pApp = AfxGetApp();
  if (pApp) {
    int test = pApp->GetProfileInt("Language","IntId",0);
    LANG_T(pApp->GetProfileInt("Language","IntId",0));
  }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:httrack-windows,代码行数:8,代码来源:newlang.cpp

示例8: AfxGetApp

void ImageDialog::OnBnClickedBrowse()
{
    CWinApp* theApp = AfxGetApp();

    char buffer[MAX_PATH];
    string lastSave;
    lastSave = theApp->GetProfileString("Last Config", "lastSave");
    int trim = lastSave.rfind("\\");
    lastSave = lastSave.substr(0, trim);

    buffer[0] = '\0';
    OPENFILENAME browse;
    ZeroMemory(&browse, sizeof(browse));
    browse.lStructSize = sizeof(browse);
    browse.hwndOwner = this->m_hWnd;
    browse.lpstrFile = buffer;
    browse.nMaxFile = sizeof(buffer);
    browse.lpstrFilter = "All Files\0*.*\0";
    browse.nFilterIndex = 1;
    browse.lpstrTitle = "Select Save Path/Filename";
    browse.lpstrFileTitle = 0;
    browse.lpstrInitialDir = lastSave.c_str();
    browse.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

    if (GetSaveFileName(&browse) != 0)
    {
        string file(buffer);
        pngwriter->SetFileName(file);
        filePath.SetWindowText(pngwriter->GetFileName().c_str());
    }
}
开发者ID:grayshen,项目名称:particlevis,代码行数:31,代码来源:ImageDialog.cpp

示例9: main

//------------------------------------------------------------------
// main
//------------------------------------------------------------------
void main()
{

CWinApp* pApp = AfxGetApp();

pApp->InitApplication();
pApp->InitInstance();
pApp->Run();

CMyDoc* pMyDoc = new CMyDoc;
CMyView* pMyView = new CMyView;
CWnd* pMyWnd = pApp->m_pMainWnd;

cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CMyDoc))     " << pMyDoc->IsKindOf(RUNTIME_CLASS(CMyDoc))       << "\n";
cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CDocument))  " << pMyDoc->IsKindOf(RUNTIME_CLASS(CDocument))    << "\n";
cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CCmdTarget)) " << pMyDoc->IsKindOf(RUNTIME_CLASS(CCmdTarget))   << "\n";
cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CObject))    " << pMyDoc->IsKindOf(RUNTIME_CLASS(CObject))      << "\n";
cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CWinApp))    " << pMyDoc->IsKindOf(RUNTIME_CLASS(CWinApp))      << "\n";
cout << "pMyDoc->IsKindOf(RUNTIME_CLASS(CView))      " << pMyDoc->IsKindOf(RUNTIME_CLASS(CView))        << "\n";

cout << "pMyView->IsKindOf(RUNTIME_CLASS(CView))     " << pMyView->IsKindOf(RUNTIME_CLASS(CView))       << "\n";
cout << "pMyView->IsKindOf(RUNTIME_CLASS(CObject))   " << pMyView->IsKindOf(RUNTIME_CLASS(CObject))     << "\n";
cout << "pMyView->IsKindOf(RUNTIME_CLASS(CWnd))      " << pMyView->IsKindOf(RUNTIME_CLASS(CWnd))        << "\n";
cout << "pMyView->IsKindOf(RUNTIME_CLASS(CFrameWnd)) " << pMyView->IsKindOf(RUNTIME_CLASS(CFrameWnd))   << "\n";

cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd))  " << pMyWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd))    << "\n";
cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CWnd))       " << pMyWnd->IsKindOf(RUNTIME_CLASS(CWnd))         << "\n";
cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CObject))    " << pMyWnd->IsKindOf(RUNTIME_CLASS(CObject))      << "\n";
cout << "pMyWnd->IsKindOf(RUNTIME_CLASS(CDocument))  " << pMyWnd->IsKindOf(RUNTIME_CLASS(CDocument))    << "\n";

}
开发者ID:alannet,项目名称:example,代码行数:34,代码来源:MY.CPP

示例10: shutdown

LRESULT CFileSendDlg::OnNoThanksFileTransfer (WPARAM wParam, LPARAM lParam)
{
    /*
    ::EnterCriticalSection(& CFileTransSock::Instance().m_CS);

    if( (DWORD)m_pSpckObjMap->m_pThreadObj != 0xfeeefeee &&
    		(DWORD)m_pSpckObjMap->m_pSockObj != 0xfeeefeee	)
    {
    	CFileTransSock::Instance().RemoveSocketObj(m_pSpckObjMap->m_pThreadObj, m_pSpckObjMap->m_pSockObj);
    	CFileTransSock::Instance().FreeSocketObj( m_pSpckObjMap->m_pSockObj);
    	CFileTransSock::Instance().RenumberThreadArray(m_pSpckObjMap->m_pThreadObj); //20080707
    }

    ::LeaveCriticalSection(& CFileTransSock::Instance().m_CS);
    */

    shutdown (m_pSpckObjMap->m_pSockObj->s ,SD_BOTH ) ;
    //closesocket(m_pSpckObjMap->m_pSockObj->s);

    AfxMessageBox("상대방이 전송을 취소하였습니다.");


    CWinApp *pApp = AfxGetApp();
    CWnd *pMainWnd = pApp->GetMainWnd();
    pMainWnd->PostMessage(WM_FILE_SENDDLG_CLOSE, (WPARAM)m_szSockObjID, (LPARAM)0);


    //CDialog::OnOK();
    return TRUE;
}
开发者ID:jeremyko,项目名称:IDMS_Messenger,代码行数:30,代码来源:FileSendDlg.cpp

示例11: ResetContent

// removes all the items from the history list, and optionally deletes
// the registry items. Note that if the history list is generated from
// a CRecentFileList, then registry entries will not be deleted
void CHistoryCombo::ClearHistory(BOOL bDeleteRegistryEntries/*=TRUE*/)
{
	ResetContent();
	if (! m_sSection.IsEmpty() && bDeleteRegistryEntries)
	{
		// remove profile entries
		CWinApp* pApp = AfxGetApp();
		ASSERT(pApp);
		CString sKey;

		for (int n = 0; n < 1000/* prevent runaway*/; n++)
		{
			sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n);
			CString sText = pApp->GetProfileString(m_sSection, sKey);
			if (sText.IsEmpty())
				break;
			pApp->WriteProfileString(m_sSection, sKey, NULL); // remove entry
		}

		if (! m_sKeyCurItem.IsEmpty())
			sKey = m_sKeyCurItem;
		else if (m_sKeyPrefix.IsEmpty())
			sKey = _T("Last");
		else
			sKey = m_sKeyPrefix;

		pApp->WriteProfileString(m_sSection, sKey, NULL);
	}
}
开发者ID:KurzedMetal,项目名称:Jaangle,代码行数:32,代码来源:XHistoryCombo.cpp

示例12: SPLITPATH_S

void CXTPSyntaxEditPropertiesPageColor::OnDblClickSchema()
{
	int iIndex = m_lboxName.GetCurSel();
	if (iIndex == LB_ERR)
		return;

	XTP_EDIT_SCHEMAFILEINFO* pSchemaInfo = (XTP_EDIT_SCHEMAFILEINFO*)m_lboxName.GetItemData(iIndex);
	if (pSchemaInfo == NULL)
		return;

	if (!FILEEXISTS_S(pSchemaInfo->csValue))
		return;

	TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFileName[_MAX_FNAME], szEx[_MAX_EXT];
	SPLITPATH_S(pSchemaInfo->csValue, szDrive, szDir, szFileName, szEx);

	CString csBuffer;
	XTPResourceManager()->LoadString(
		&csBuffer, XTP_IDS_EDIT_OPENSCHEMAMSG);

	CString csMessage;
	csMessage.Format(csBuffer, szFileName, szEx);
	if (AfxMessageBox(csMessage, MB_ICONQUESTION | MB_YESNO) == IDYES)
	{
		// close the options dialog.
		CPropertySheet* pWndParent = DYNAMIC_DOWNCAST(CPropertySheet, GetParent());
		if (pWndParent)
			pWndParent->EndDialog(IDCANCEL);

		// open the document.
		CWinApp* pWinApp = AfxGetApp();
		if (pWinApp)
			pWinApp->OpenDocumentFile(pSchemaInfo->csValue);
	}
}
开发者ID:lai3d,项目名称:ThisIsASoftRenderer,代码行数:35,代码来源:XTPSyntaxEditPropertiesPageColor.cpp

示例13: dlgOpen

void CMainWizard::OnScImportSettings(void)
{
	CString strFilter;
	CString strTitle;
	CProcessPrivileges processPrivileges;

	enum { fdwFlags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST };
	strFilter.LoadString(IDS_SETTINGS_FILTER);
#if (_MFC_VER < 0x0700)
	CFileDialogEx dlgOpen(TRUE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter);
#else
	CFileDialog dlgOpen(TRUE, _T("hive"), AfxGetAppName(), fdwFlags, strFilter);
#endif   // _MFC_VER
	strTitle.LoadString(IDS_TITLE_IMPORT);
	dlgOpen.m_ofn.lpstrTitle = strTitle;
	if (dlgOpen.DoModal() == IDOK)
	{
		BeginWaitCursor();
		CWinApp* pApp = AfxGetApp();
		ASSERT_VALID(pApp);
		processPrivileges[SE_RESTORE_NAME] = SE_PRIVILEGE_ENABLED;
		HKEY hAppKey = pApp->GetAppRegistryKey();
		::RegRestoreKey(hAppKey, dlgOpen.GetPathName(), REG_FORCE_RESTORE);
		::RegCloseKey(hAppKey);
		processPrivileges[SE_RESTORE_NAME] = 0;
		EndWaitCursor();
	}
}
开发者ID:zephyrer,项目名称:update-it,代码行数:28,代码来源:MainWizard.cpp

示例14: AfxGetApp

//--------------------------------------------------------------------------------------------------------------//
UINT CChildView::GetProfileInt(LPCTSTR lpszEntry, int nDefault)
{
	UINT nResult = nDefault;
	CWinApp* pApp = AfxGetApp();
	if (pApp) nResult = pApp->GetProfileInt(REG_SECTION_LOG, lpszEntry, nDefault);
	return nResult;
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:8,代码来源:ChildView.cpp

示例15: dlgFolder

void COptionsPage::OnButtonSource(void)
{
	CString strPrompt;

	strPrompt.LoadString(IDS_CHOOSE_SOURCE);
	CFolderDialog dlgFolder(strPrompt, m_strSource, this, BIF_NEWDIALOGSTYLE);
	if (dlgFolder.DoModal() == IDOK)
	{
		m_strSource = dlgFolder.GetFolderPath();
		SetDlgItemText(IDC_EDIT_SOURCE, m_strSource);
#if (_MFC_VER < 0x0700)
		CWinApp* pApp = AfxGetApp();
		ASSERT_VALID(pApp);
		if ((m_timeWrite = pApp->GetProfileInt(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#else
		CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
		ASSERT_VALID(pApp);
		if ((m_timeWrite = pApp->GetProfileTime(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#endif   // _MFC_VER
		{
			m_dtpWrite.SetTime(&m_timeWrite);
		}
		CString strDefTarget = m_strSource + _T(".Update");
		SetDlgItemText(IDC_EDIT_TARGET, pApp->GetProfileString(SZ_REGK_TARGETS, m_strSource, strDefTarget));
	}
}
开发者ID:zephyrer,项目名称:update-it,代码行数:26,代码来源:OptionsPage.cpp


注:本文中的CWinApp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。