Esempio n. 1
0
BOOL CPropertiesGeneral::OnInitDialog() {
	CPropertyPage::OnInitDialog();

	CARMDlg* dlg=(CARMDlg*)this->GetParentOwner()->GetParent();
	TCHAR szTemp[MAX_PATH];
	arfile* arFile=(arfile*)dlg->m_lstFiles.GetItemDataPtr(dlg->m_lstFiles.GetCurSel());
	HANDLE hFile;
	FILETIME fileTime;
	size_t fileSize;
	SYSTEMTIME stUTC, stLocal;
	TCITEM ti={0};
	HZIP hZip;
	ZIPENTRY ze;
	LPTSTR pszTemp, pszBuffer, pszTok;
	CString szBytes;
	szBytes.LoadString(IDS_BYTES);

	_tcscpy(szTemp,arFile->fileName);
	*_tcsrchr(szTemp,'\\')=0;
	SetDlgItemText(IDC_PROP_DESC,arFile->description);
	SetDlgItemText(IDC_PROP_FILENAME,szTemp+_tcslen(szTemp)+1);
	SetDlgItemText(IDC_PROP_LOCATION,szTemp);
	_itot(arFile->size,szTemp,10);
	_tcscat(szTemp,szBytes);
	SetDlgItemText(IDC_PROP_UNCOMPRESSED,szTemp);

	hFile=CreateFile(arFile->fileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
	fileSize=GetFileSize(hFile,NULL);
	GetFileTime(hFile,NULL,NULL,&fileTime);
	FileTimeToSystemTime(&fileTime, &stUTC);
	SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
	CloseHandle(hFile);
	
	_itot((int)fileSize,szTemp,10);
	_tcscat(szTemp,szBytes);

	SetDlgItemText(IDC_PROP_FILESIZE,szTemp);
	_stprintf(szTemp,"%4d/%2d/%2d %2d:%2d:%2d",stLocal.wYear,stLocal.wMonth,stLocal.wDay,stLocal.wHour,stLocal.wMinute,stLocal.wSecond);
	SetDlgItemText(IDC_PROP_MODIFIED,szTemp);

	_stprintf(szTemp,"%d - ",arFile->features);
	ti.mask=TCIF_TEXT;
	ti.pszText=szTemp+_tcslen(szTemp);
	ti.cchTextMax=MAX_PATH-(int)_tcslen(szTemp);
	dlg->m_tab.GetItem(dlg->m_tab.GetCurSel(),&ti);
	SetDlgItemText(IDC_PROP_FILETYPE,szTemp);

	hZip=OpenZip(arFile->fileName,0,ZIP_FILENAME);
	if (hZip) {
		for (int c=0; GetZipItem(hZip,c,&ze)!=ZR_ARGS; c++) {
			_tcslwr(ze.name);
			if (!_tcsncmp(ze.name,"tune/",5) && _tcsstr(ze.name,".info")) {
				pszTemp=(LPTSTR)malloc(ze.unc_size);
				UnzipItem(hZip,c,pszTemp,ze.unc_size,ZIP_MEMORY);

				pszBuffer=_tcsstr(pszTemp,"Colors=");
				if (pszBuffer) {
					pszBuffer+=7;
					if (_tcschr(pszBuffer,'\r')) *_tcschr(pszBuffer,'\r')=0;
					if (_tcschr(pszBuffer,'\n')) *_tcschr(pszBuffer,'\n')=0;
					pszTok=_tcstok(pszBuffer,"|");
					while (pszTok) {
						((CListBox*)this->GetDlgItem(IDC_PROP_VARIATIONS))->AddString(pszTok);
						pszTok=_tcstok(NULL,"|");
					}
				}
				free(pszTemp);
			}
		}
		CloseZip(hZip);
	}
	return FALSE;
}
void CQuestionnaireButtonPage::OnEdit() 
{
    const MSG* pMsg = GetCurrentMessage( );

    int iAction = -1;
    CString csTitle;
    switch (WPARAM(pMsg->wParam))
    {
    case IDC_EDIT_PASSIV:
        csTitle.LoadString(IDS_PREVIEW_PASSIV);
        iAction = CButtonAppearanceSettings::ACTION_PASSIV;
        break;
    case IDC_EDIT_NORMAL:
        csTitle.LoadString(IDS_PREVIEW_NORMAL);
        iAction = CButtonAppearanceSettings::ACTION_NORMAL;
        break;
    case IDC_EDIT_MOUSEOVER:
        csTitle.LoadString(IDS_PREVIEW_MOUSEOVER);
        iAction = CButtonAppearanceSettings::ACTION_OVER;
        break;
    case IDC_EDIT_PRESSED:
        csTitle.LoadString(IDS_PREVIEW_PRESSED);
        iAction = CButtonAppearanceSettings::ACTION_PRESSED;
        break;
    }

    // TODO Error message
    if (iAction < 0)
        return;

    if (m_wndChoosebuttonTypes.GetCurSel() == 0) {
        CEditInteractionTextDialog dlgEdit(this);

        dlgEdit.Init(csTitle, m_csButtonText, m_rcArea, m_pButtonVisualSettings->m_clrFill[iAction], m_pButtonVisualSettings->m_clrLine[iAction],
            m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]);

        if (dlgEdit.DoModal() == IDOK) {

            dlgEdit.SetUserEntries(m_rcArea, m_pButtonVisualSettings->m_clrFill[iAction], m_pButtonVisualSettings->m_clrLine[iAction],
                m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]);

            m_wndPreview[iAction].SetColors(m_pButtonVisualSettings->m_clrFill[iAction], m_pButtonVisualSettings->m_clrLine[iAction],
                m_pButtonVisualSettings->m_clrText[iAction]);
            m_wndPreview[iAction].SetButtonFont(&m_pButtonVisualSettings->m_lf[iAction]);
        }
    } else {
        CEditInteractionButtonDialog dlgEdit(this);

        dlgEdit.Init(csTitle, m_csButtonText, m_rcArea, m_pButtonVisualSettings->m_csFileNames[iAction],
            m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]);

        if (dlgEdit.DoModal() == IDOK) {
            dlgEdit.SetUserEntries(m_rcArea, m_pButtonVisualSettings->m_csFileNames[iAction],
                m_pButtonVisualSettings->m_clrText[iAction], &m_pButtonVisualSettings->m_lf[iAction]);

            m_wndPreview[iAction].SetTextColor(m_pButtonVisualSettings->m_clrText[iAction]);
            m_wndPreview[iAction].SetButtonFont(&m_pButtonVisualSettings->m_lf[iAction]);
            m_wndPreview[iAction].SetImage(m_pButtonVisualSettings->m_csFileNames[iAction]);
            m_wndPreview[iAction].GetImageDimension(m_pButtonVisualSettings->m_siImageDimension[iAction]);

            // if passive button was changed, apply to all other buttons
            if (WPARAM(pMsg->wParam) == IDC_EDIT_PASSIV) {
                CString csImagePath = m_pButtonVisualSettings->m_csFileNames[iAction];
                int iSlashPos = csImagePath.ReverseFind('\\');
                csImagePath = csImagePath.Left(iSlashPos);

                m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_NORMAL] = csImagePath;
                m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_NORMAL] += "\\Normal.png";
                m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_OVER] = csImagePath;
                m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_OVER] += "\\MouseOver.png";
                m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_PRESSED] = csImagePath;
                m_pButtonVisualSettings->m_csFileNames[CButtonAppearanceSettings::ACTION_PRESSED] += "\\MouseDown.png";

                for (int i = 1; i < CButtonAppearanceSettings::ACTION_EVENT_COUNT; ++i) {
                    m_wndPreview[i].SetImage(m_pButtonVisualSettings->m_csFileNames[i]);
                    m_wndPreview[i].GetImageDimension(m_pButtonVisualSettings->m_siImageDimension[i]);
                }
            }
        }
    }

    m_wndPreview[iAction].SetText(m_csButtonText);
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	BOOL bNameValid;
	// set the visual manager and style based on persisted value
	OnApplicationLook(theApp.m_nAppLook);

	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

	// prevent the menu bar from taking the focus on activation
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	CString strToolBarName;
	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
	ASSERT(bNameValid);
	m_wndToolBar.SetWindowText(strToolBarName);

	CString strCustomize;
	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);

	// Allow user-defined toolbars operations:
	InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndMenuBar);
	DockPane(&m_wndToolBar);


	// enable Visual Studio 2005 style docking window behavior
	CDockingManager::SetDockingMode(DT_SMART);
	// enable Visual Studio 2005 style docking window auto-hide behavior
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// Enable toolbar and docking window menu replacement
	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// enable quick (Alt+drag) toolbar customization
	CMFCToolBar::EnableQuickCustomization();

	if (CMFCToolBar::GetUserImages() == NULL)
	{
		// load user-defined toolbar images
		if (m_UserImages.Load(_T(".\\UserImages.bmp")))
		{
			CMFCToolBar::SetUserImages(&m_UserImages);
		}
	}

	// enable menu personalization (most-recently used commands)
	// TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command.
	CList<UINT, UINT> lstBasicCommands;

	lstBasicCommands.AddTail(ID_FILE_NEW);
	lstBasicCommands.AddTail(ID_FILE_OPEN);
	lstBasicCommands.AddTail(ID_FILE_SAVE);
	lstBasicCommands.AddTail(ID_FILE_PRINT);
	lstBasicCommands.AddTail(ID_APP_EXIT);
	lstBasicCommands.AddTail(ID_EDIT_CUT);
	lstBasicCommands.AddTail(ID_EDIT_PASTE);
	lstBasicCommands.AddTail(ID_EDIT_UNDO);
	lstBasicCommands.AddTail(ID_APP_ABOUT);
	lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
	lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7);

	CMFCToolBar::SetBasicCommands(lstBasicCommands);

	return 0;
}
Esempio n. 4
0
// **************************************************************************
// OnInitDialog ()
//
// Description:
//	Called immediately before the dialog box is displayed.  Use opportunity
//	to initialize controls.
//
// Parameters:
//  none
//
// Returns:
//	BOOL - TRUE.
// **************************************************************************
BOOL CKServerInterfacesPage::OnInitDialog () 
{
	CListCtrl *pList = NULL;
	CString strLoader;
	CString strYes;
	CString strNo;
	int nIndex;

	// Perform default processing:
	CPropertyPage::OnInitDialog ();

	// Get a pointer to our list control:
	pList = (CListCtrl *) GetDlgItem (IDC_LIST);
	ASSERT (pList != NULL);

	// Initialize the image list for the interfaces. The bitmap must use a 
	// purple background color, RGB (255, 0, 255), so that the CImageList
	// object can construct a mask.  The images are 16x16 pixels.  Set the
	// image list background color to CLR_NONE so masked pixels will be
	// transparent. 
	// Image number		Use
	//	0				not used
	//	1				not used
	//	2				Interface
	m_cImageList.Create (IDB_COMPONENTS, 16, 4, RGB (255, 0, 255));
	m_cImageList.SetBkColor (CLR_NONE);
	pList->SetImageList (&m_cImageList, LVSIL_SMALL);

	// Create interface column:
	strLoader.LoadString (IDS_INTERFACE);
	pList->InsertColumn (0, strLoader, LVCFMT_LEFT, 200);

	// Create required column:
	strLoader.LoadString (IDS_REQUIRED);
	pList->InsertColumn (1, strLoader, LVCFMT_LEFT, 75);

	// Creaete supported column:
	strLoader.LoadString (IDS_SUPPORTED);
	pList->InsertColumn (2, strLoader, LVCFMT_LEFT, 75);

	// The server had better have been set by now (check for debug):
	ASSERT (m_pServer != NULL);

	// Load "Yes" and "No" strings from string resources:
	strNo.LoadString (IDS_NO);
	strYes.LoadString (IDS_YES);

	// Loop over interfaces and set list control items (one per interface):
	nIndex = 0;
	while (nIndex < NUMGROUPINTERFACES)
	{
		switch (nIndex)
		{
		case 0:
			// IOPCServer:
			pList->InsertItem (nIndex, _T ("IOPCServer"), ILI_INTERFACE);		// interface
			pList->SetItemText (nIndex, 1, strYes);				// required

			pList->SetItemText (nIndex, 2, 
				m_pServer->IsIServerSupported () ? strYes : strNo);	// supported
			break;

		case 1:
			// IOPCBrowseServerAddressSpace:
			pList->InsertItem (nIndex, _T ("IOPCBrowseServerAddressSpace"), ILI_INTERFACE);	
			pList->SetItemText (nIndex, 1, strNo);						

			pList->SetItemText (nIndex, 2, 
				m_pServer->IsIBrowsingSupported () ? strYes : strNo);
			break;

		case 2:
			// IOPCServerPublicGroups:
			pList->InsertItem (nIndex, _T ("IOPCServerPublicGroups"), ILI_INTERFACE);			
			pList->SetItemText (nIndex, 1, strNo);					

			pList->SetItemText (nIndex, 2, 
				m_pServer->IsIServerPublicGroupsSupported () ? strYes : strNo);
			break;

		case 3:
			// IPersistFile:
			pList->InsertItem (nIndex, _T ("IPersistFile"), ILI_INTERFACE);			
			pList->SetItemText (nIndex, 1, strNo);					

			pList->SetItemText (nIndex, 2, 
				m_pServer->IsIPersistFileSupported () ? strYes : strNo);				
			break;

		case 4:
			// IOPCCommon:
			pList->InsertItem (nIndex, _T ("IOPCCommon (2.0 only)"), ILI_INTERFACE);			
			pList->SetItemText (nIndex, 1, strYes);					

			pList->SetItemText (nIndex, 2, 
				m_pServer->IsICommonSupported () ? strYes : strNo);				
			break;

		case 5:
			// IOPCItemProperties:
			pList->InsertItem (nIndex, _T ("IOPCItemProperties (2.0 only)"), ILI_INTERFACE);			
			pList->SetItemText (nIndex, 1, strYes);					

			pList->SetItemText (nIndex, 2, 
				m_pServer->IsIItemPropertiesSupported () ? strYes : strNo);				
			break;

		case 6:
			// IConnectionPointContainer:
			pList->InsertItem (nIndex, _T ("IConnectionPointContainer (2.0 only)"), ILI_INTERFACE);	
			pList->SetItemText (nIndex, 1, strYes);						

			pList->SetItemText (nIndex, 2, 
				m_pServer->IsIConnectionPointContainerSupported () ? strYes : strNo);				
			break;

		default:
			// Unexpected interface index - programmer error:
			ASSERT (FALSE);
			break;
		}

		// Increment interface index:
		nIndex++;
	}
	SetDlgItemText(IDOK,_T("确定"));
	SetDlgItemText(IDCANCEL,_T("关闭"));
	// return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
	return (TRUE);  
}
Esempio n. 5
0
void CSetEditDlg::InitLang()
{
	CString strTemp;
	BOOL bNameVaild = strTemp.LoadString(IDOK);
	ASSERT(bNameVaild);
	SetDlgItemText(IDOK, strTemp);

	bNameVaild = strTemp.LoadString(IDCANCEL);
	ASSERT(bNameVaild);
	SetDlgItemText(IDCANCEL, strTemp);

	bNameVaild = strTemp.LoadString(IDD_SYNEDIT_SET);
	ASSERT(bNameVaild);
	SetWindowText(strTemp);

	bNameVaild = strTemp.LoadString(IDC_BUTTON_DEFAULTEXT);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_BUTTON_DEFAULTEXT, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_EDITFONT);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_EDITFONT, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_EDITSTYLE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_EDITSTYLE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_EDITSIZE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_EDITSIZE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_BACK);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_BACK, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_LINEOUTLINE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_LINEOUTLINE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_SYN);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_SYN, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_TEXT);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_TEXT, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_BACKOUTLINE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_BACKOUTLINE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_TYPE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_TYPE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_LINENUMBER);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_LINENUMBER, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_BACKSELACTIVE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_BACKSELACTIVE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_STRING);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_STRING, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_LINENUMBERBACK);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_LINENUMBERBACK, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_BACKSELINACTIVE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_BACKSELINACTIVE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_NUMBER);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_NUMBER, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_SIDEBAR);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_SIDEBAR, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_TEXTSELACTIVE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_TEXTSELACTIVE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_CHAR);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_CHAR, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_LINK);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_LINK, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_TEXTSELINACTIVE);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_TEXTSELINACTIVE, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR_COMMENT);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR_COMMENT, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_FONT);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_FONT, strTemp);

	bNameVaild = strTemp.LoadString(IDC_STATIC_COLOR);
	ASSERT(bNameVaild);
	SetDlgItemText(IDC_STATIC_COLOR, strTemp);

	bNameVaild = strTemp.LoadString(IDS_EDITSTYLE_DATA);
	ASSERT(bNameVaild);
	m_editStyle.ResetContent();
	int nStart = 0;
	int nEnd = strTemp.Find(_T(";"), nStart);
	while (nEnd != -1)
	{
		m_editStyle.AddString(strTemp.Mid(nStart, nEnd - nStart));
		nStart = nEnd + 1;
		nEnd = strTemp.Find(_T(";"), nStart);
	}
}
//******************************************************************************************************
void CStartStopParticleSystem::goPreRender()
{	
	if (!_ActiveNode) return;
	NL3D::CParticleSystem *ps = _ActiveNode->getPSPointer();
	sint currNumParticles = (sint) ps->getCurrNumParticles();
	sint maxNumParticles = (sint) ps->getMaxNumParticles();
	// if linked with scene animation, restart if animation ends
	if (m_LinkPlayToScenePlay) // is scene animation subordinated to the fx animation
	{		
		// start animation for the scene too
		if (_AnimationDLG && isRunning())
		{
			if (_LastSceneAnimFrame > _AnimationDLG->CurrentFrame) // did animation restart ?
			{			
				restartAllFX();
			}
			_LastSceneAnimFrame = _AnimationDLG->CurrentFrame;
		}
	}
	else
	if (_AutoRepeat && !m_LinkPlayToScenePlay) // auto repeat feature
	{
		if (isRunning())
		{		
			bool allFXFinished = true;
			bool fxStarted = false;
			for(uint k = 0; k < _PlayingNodes.size(); ++k)
			{
				if (_PlayingNodes[k])
				{					
					if (isRunning(_PlayingNodes[k]))
					{					
						fxStarted = true;
						if (_PlayingNodes[k]->getPSPointer()->getSystemDate() <= _PlayingNodes[k]->getPSPointer()->evalDuration())
						{												
							allFXFinished = false;
							break;						
						}
						else
						{
							if (_PlayingNodes[k]->getPSPointer()->getCurrNumParticles() != 0)
							{						
								allFXFinished = false;
								break;
							}
						}
					}
				}
			}
			if (fxStarted && allFXFinished)
			{
				restartAllFX();
			}
		}
	}
	if (_State == RunningMultiple || _State == PausedMultiple)
	{
		std::set<std::string> currAnims;
		CObjectViewer *ov = _ParticleDlg->getObjectViewer();
		for(uint k = 0; k < ov->getNumInstance(); ++k)
		{
			CInstanceInfo *ci = ov->getInstance(k);
			uint animIndex = ci->Playlist.getAnimation(0);
			if (animIndex != NL3D::CAnimationSet::NotFound)
			{			
				std::string animName = ci->AnimationSet.getAnimationName(animIndex);
				if (!animName.empty())
				{
					currAnims.insert(animName);
				}
			}
		}				
		// check fx that have a trigger anim
		for(uint k = 0; k < _PlayingNodes.size(); ++k)
		{
			if (_PlayingNodes[k])
			{							
				if (!isRunning(_PlayingNodes[k]) || !_PlayingNodes[k]->getPSModel()->hasActiveEmitters())
				{
					// see if chosen anim is currently running
					if (_PlayingNodes[k]->getTriggerAnim().empty() || currAnims.count(_PlayingNodes[k]->getTriggerAnim()))
					{
						// if the fx was shutting down, stop then restart it
						if (!_PlayingNodes[k]->getPSModel()->hasActiveEmitters())
						{
							nlassert(isRunning(_PlayingNodes[k]));
							stop(*_PlayingNodes[k]);
						}
						// yes -> trigger the fx	
						play(*_PlayingNodes[k]);
					}
					else if (!_PlayingNodes[k]->getPSPointer()->hasParticles()) // fx is being shut down, stop it when necessary
					{					
						stop(*_PlayingNodes[k]); // no more particles so stop the system
					}					
				}
				else
				{					
					if (!_PlayingNodes[k]->getTriggerAnim().empty())
					{
						if (_PlayingNodes[k]->getPSModel()->hasActiveEmitters())
						{
							// see if anim if already playing. If this is not the case then shutdown the emitters
							if (!currAnims.count(_PlayingNodes[k]->getTriggerAnim()))
							{
								_PlayingNodes[k]->getPSModel()->activateEmitters(false);
							}
						}
					}					
				}
			}
		}
	}
	if (_ActiveNode)
	{	
		// display number of particles for the currently active node
		if (currNumParticles != _LastCurrNumParticles || maxNumParticles != _LastMaxNumParticles)
		{	
			CString numParts;	
			numParts.LoadString(IDS_NUM_PARTICLES);
			numParts += CString(NLMISC::toString("%d / %d",(int) currNumParticles, (int) maxNumParticles).c_str());
			GetDlgItem(IDC_NUM_PARTICLES)->SetWindowText((LPCTSTR) numParts);
			_LastCurrNumParticles = currNumParticles;
			_LastMaxNumParticles = maxNumParticles;
		}
		// display max number of wanted faces
		NLMISC::CMatrix camMat = ps->getScene()->getCam()->getMatrix();
		sint numWantedFaces = (uint) ps->getWantedNumTris((ps->getSysMat().getPos() - camMat.getPos()).norm());
		if (numWantedFaces != _LastNumWantedFaces)
		{	
			CString numWF;
			numWF.LoadString(IDS_NUM_WANTED_FACES);
			numWF += CString(NLMISC::toString("%d",(int) numWantedFaces).c_str());
			GetDlgItem(IDC_NUM_ASKED_FACES)->SetWindowText((LPCTSTR) numWF);
			_LastNumWantedFaces = numWantedFaces;		
		}
		// display system date
		if (ps->getSystemDate() != _LastSystemDate)
		{
			_LastSystemDate = ps->getSystemDate();
			CString sysDate;	
			sysDate.LoadString(IDS_SYSTEM_DATE);
			sysDate += CString(NLMISC::toString("%.2f s",_LastSystemDate).c_str());
			GetDlgItem(IDC_SYSTEM_DATE)->SetWindowText((LPCTSTR) sysDate);
		}	
	}
	if (_ParticleDlg)
	{
		CParticleWorkspace *pws = _ParticleDlg->getParticleWorkspace();
		if (pws)
		{
			for(uint k = 0; k < pws->getNumNode(); ++k)
			{
				if (pws->getNode(k)->isLoaded())
				{				
					if (pws->getNode(k) == _ActiveNode)
					{
						pws->getNode(k)->getPSModel()->enableDisplayTools(!isRunning(pws->getNode(k)) || m_DisplayHelpers);
					}
					else
					{
						pws->getNode(k)->getPSModel()->enableDisplayTools(false);
					}
					// hide / show the node
					if (_State == RunningMultiple || _State == PausedMultiple)
					{
						if (isRunning(pws->getNode(k)))
						{
							pws->getNode(k)->getPSModel()->show();
						}
						else
						{
							pws->getNode(k)->getPSModel()->hide();
						}
					}
					else
					{
						if (pws->getNode(k) == _ActiveNode)
						{
							pws->getNode(k)->getPSModel()->show();
						}
						else
						{
							pws->getNode(k)->getPSModel()->hide();
						}
					}
				}
			}
		}
	}
}
Esempio n. 7
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	BOOL bNameValid;
	// 基于持久值设置视觉管理器和样式
	OnApplicationLook(theApp.m_nAppLook);

	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("未能创建菜单栏\n");
		return -1;      // 未能创建
	}

	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

	// 防止菜单栏在激活时获得焦点
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
	{
		TRACE0("未能创建工具栏\n");
		return -1;      // 未能创建
	}

	CString strToolBarName;
	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
	ASSERT(bNameValid);
	m_wndToolBar.SetWindowText(strToolBarName);

	CString strCustomize;
	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);

	// 允许用户定义的工具栏操作:
	InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("未能创建状态栏\n");
		return -1;      // 未能创建
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	// TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndMenuBar);
	DockPane(&m_wndToolBar);


	// 启用 Visual Studio 2005 样式停靠窗口行为
	CDockingManager::SetDockingMode(DT_SMART);
	// 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// 启用工具栏和停靠窗口菜单替换
	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// 启用快速(按住 Alt 拖动)工具栏自定义
	CMFCToolBar::EnableQuickCustomization();

	if (CMFCToolBar::GetUserImages() == NULL)
	{
		// 加载用户定义的工具栏图像
		if (m_UserImages.Load(_T(".\\UserImages.bmp")))
		{
			CMFCToolBar::SetUserImages(&m_UserImages);
		}
	}

	return 0;
}
Esempio n. 8
0
void CCalendarBar::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	CRect rectClient;
	GetClientRect(rectClient);

	dc.FillRect(rectClient, &afxGlobalData.brWindow);

	if (rectClient.bottom - m_nMyCalendarsY > 0)
	{
		CRect rectMyCalendarsCaption = rectClient;
		rectMyCalendarsCaption.top = m_nMyCalendarsY;
		rectMyCalendarsCaption.bottom = rectMyCalendarsCaption.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2;

		COLORREF clrText = CMFCVisualManager::GetInstance()->OnDrawPaneCaption(&dc, NULL, FALSE, rectMyCalendarsCaption, CRect(0, 0, 0, 0));

		CPen* pOldPen = dc.SelectObject(&afxGlobalData.penBarShadow);

		dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.top);
		dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.top);

		dc.SelectStockObject(BLACK_PEN);

		dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.bottom);
		dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.bottom);

		dc.SelectObject(pOldPen);

		CRect rectText = rectMyCalendarsCaption;
		rectText.DeflateRect(10, 0);

		dc.SetBkMode(TRANSPARENT);
		dc.SetTextColor(clrText);

		CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);

		BOOL bNameValid;
		CString str;

		bNameValid = str.LoadString(IDS_MYCALENDARS);
		ASSERT(bNameValid);
		dc.DrawText(str, rectText, DT_VCENTER | DT_LEFT | DT_SINGLELINE);

		CRect rectCalendar = rectClient;
		rectCalendar.top = rectMyCalendarsCaption.bottom + 5;
		rectCalendar.bottom = rectCalendar.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2 - 5;

		dc.FillSolidRect(rectCalendar, RGB(255, 255, 213));

		rectCalendar.DeflateRect(20, 0);
		m_Images.Draw(&dc, 3, rectCalendar.TopLeft(), 0);

		rectCalendar.left += 20;

		bNameValid = str.LoadString(IDS_CALENDAR);
		ASSERT(bNameValid);

		dc.SetTextColor(afxGlobalData.clrHotLinkNormalText);
		dc.DrawText(str, rectCalendar, DT_VCENTER | DT_LEFT | DT_SINGLELINE);

		dc.SelectObject(pOldFont);
	}
}
Esempio n. 9
0
BOOL CTryIconDriver::SetTooltipText(UINT nID)
{
    CString strText;
    VERIFY(strText.LoadString(nID));
    return SetTooltipText(strText);
}
Esempio n. 10
0
static void AppendMenuChecked(CMenu &menu, UINT nTextID, UINT_PTR nItemID, BOOL checked = FALSE, BOOL enabled = TRUE)
{
	CString text;
	text.LoadString(nTextID);
	menu.AppendMenu(MF_STRING | (enabled ? MF_ENABLED : MF_DISABLED) | (checked ? MF_CHECKED : MF_UNCHECKED), nItemID, text);
}
Esempio n. 11
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	BOOL bNameValid;
	// set the visual manager and style based on persisted value
	OnApplicationLook(theApp.m_nAppLook);

	CMDITabInfo mdiTabParams;
	mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; // other styles available...
	mdiTabParams.m_bActiveTabCloseButton = TRUE;      // set to FALSE to place close button at right of tab area
	mdiTabParams.m_bTabIcons = FALSE;    // set to TRUE to enable document icons on MDI taba
	mdiTabParams.m_bAutoColor = TRUE;    // set to FALSE to disable auto-coloring of MDI tabs
	mdiTabParams.m_bDocumentMenu = TRUE; // enable the document menu at the right edge of the tab area
	EnableMDITabbedGroups(TRUE, mdiTabParams);

	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

	// prevent the menu bar from taking the focus on activation
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	CString strToolBarName;
	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
	ASSERT(bNameValid);
	m_wndToolBar.SetWindowText(strToolBarName);

	CString strCustomize;
	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);

	// Allow user-defined toolbars operations:
	InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndMenuBar);
	DockPane(&m_wndToolBar);


	// enable Visual Studio 2005 style docking window behavior
	CDockingManager::SetDockingMode(DT_SMART);
	// enable Visual Studio 2005 style docking window auto-hide behavior
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// Load menu item image (not placed on any standard toolbars):
	CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0);

	// create docking windows
	if (!CreateDockingWindows())
	{
		TRACE0("Failed to create docking windows\n");
		return -1;
	}

	m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
	m_wndClassView.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndFileView);
	CDockablePane* pTabbedBar = NULL;
	m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);
	m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndOutput);
	m_wndProperties.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndProperties);


	// Enable enhanced windows management dialog
	EnableWindowsDialog(ID_WINDOW_MANAGER, ID_WINDOW_MANAGER, TRUE);

	// Enable toolbar and docking window menu replacement
	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// enable quick (Alt+drag) toolbar customization
	CMFCToolBar::EnableQuickCustomization();

	if (CMFCToolBar::GetUserImages() == NULL)
	{
		// load user-defined toolbar images
		if (m_UserImages.Load(_T(".\\UserImages.bmp")))
		{
			CMFCToolBar::SetUserImages(&m_UserImages);
		}
	}

	// enable menu personalization (most-recently used commands)
	// TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command.
	CList<UINT, UINT> lstBasicCommands;

	lstBasicCommands.AddTail(ID_FILE_NEW);
	lstBasicCommands.AddTail(ID_FILE_OPEN);
	lstBasicCommands.AddTail(ID_FILE_SAVE);
	lstBasicCommands.AddTail(ID_FILE_PRINT);
	lstBasicCommands.AddTail(ID_APP_EXIT);
	lstBasicCommands.AddTail(ID_EDIT_CUT);
	lstBasicCommands.AddTail(ID_EDIT_PASTE);
	lstBasicCommands.AddTail(ID_EDIT_UNDO);
	lstBasicCommands.AddTail(ID_APP_ABOUT);
	lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
	lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7);
	lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC);
	lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE);
	lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS);
	lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE);

	CMFCToolBar::SetBasicCommands(lstBasicCommands);

	// Switch the order of document name and application name on the window title bar. This
	// improves the usability of the taskbar because the document name is visible with the thumbnail.
	ModifyStyle(0, FWS_PREFIXTITLE);

	return 0;
}
Esempio n. 12
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	BOOL bNameValid;

	// set the visual manager used to draw all user interface elements
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008));

	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

	// prevent the menu bar from taking the focus on activation
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	// create a view to occupy the client area of the frame
	if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
	{
		TRACE0("Failed to create view window\n");
		return -1;
	}

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	CString strToolBarName;
	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
	ASSERT(bNameValid);
	m_wndToolBar.SetWindowText(strToolBarName);

	CString strCustomize;
	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndMenuBar);
	DockPane(&m_wndToolBar);


	// enable Visual Studio 2005 style docking window behavior
	CDockingManager::SetDockingMode(DT_SMART);
	// enable Visual Studio 2005 style docking window auto-hide behavior
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// Enable toolbar and docking window menu replacement
	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// enable quick (Alt+drag) toolbar customization
	CMFCToolBar::EnableQuickCustomization();

	return 0;
}
Esempio n. 13
0
void CSkillLogCommand::Parse( const MSGROOT* message, CListCtrl& listCtrl, CProgressCtrl& progressCtrl, CStatic& resultStatic, CButton& findButton, CButton& stopButton ) const
{
	switch( message->Protocol )
	{
	case MP_RM_SKILL_LOG_GET_ACK:
		{
			CString text;
			const MSG_RM_SKILL_LOG* m = ( MSG_RM_SKILL_LOG* )message;

			// 080401 LUJ, 이전 로그에 대한 인덱스 세트를 만들어 중복되지 않도록 체크한다
			std::set< DWORD > indexSet;
			{
				for( int row = 0; row < listCtrl.GetItemCount(); ++row )
				{
					indexSet.insert( _ttoi( listCtrl.GetItemText( row, 0 ) ) );
				}
			}

			for( DWORD i = 0; i < m->mSize; ++i )
			{
				const MSG_RM_SKILL_LOG::Log& data = m->mLog[ i ];

				const DWORD row		= listCtrl.GetItemCount();
				int			step	= 0;

				if( indexSet.end() != indexSet.find( data.mLogIndex ) )
				{
					continue;
				}

				CString text;
				text.Format( _T( "%d" ), data.mLogIndex );
				listCtrl.InsertItem( row, text, 0 );

				listCtrl.SetItemText( row, ++step, CA2WEX< sizeof( data.mDate ) >( data.mDate ) );
				listCtrl.SetItemText( row, ++step, mApplication.GetText( data.mType ) );

				text.Format( _T( "%d" ), data.mPoint );
				listCtrl.SetItemText( row, ++step, text );

				const ActiveSkillScript* script = mApplication.GetActiveSkillScript( data.mIndex );

				if( script )
				{
					text.Format( _T( "%d" ), data.mDbIndex );
					listCtrl.SetItemText( row, ++step, text );

					listCtrl.SetItemText( row, ++step, script->mName );

					text.Format( _T( "%d" ), data.mLevel );
					listCtrl.SetItemText( row, ++step, text );
				}

				listCtrl.SetItemText( row, ++step, CA2WEX< sizeof( data.mMemo ) >( data.mMemo ) );
			}

			{
				int minRange;
				int maxRange;
				progressCtrl.GetRange( minRange, maxRange );

				progressCtrl.SetPos( progressCtrl.GetPos() + int( m->mSize ) );

				text.Format( _T( "%d/%d" ), progressCtrl.GetPos(), maxRange );
				resultStatic.SetWindowText( text );

				// 080523 LUJ, 버튼 활성화 체크가 정상적으로 되도록 수정함
				if( progressCtrl.GetPos() == maxRange )
				{
					findButton.EnableWindow( TRUE );
					stopButton.EnableWindow( FALSE );
				}
			}

			break;
		}
	case MP_RM_SKILL_LOG_SIZE_ACK:
		{
			const MSG_DWORD* m = ( MSG_DWORD* )message;

			const DWORD size = m->dwData;

			CString text;
			text.Format( _T( "0/%d" ), size );

			resultStatic.SetWindowText( text );
			progressCtrl.SetRange32( 0, size );
			progressCtrl.SetPos( 0 );
			findButton.EnableWindow( FALSE );
			stopButton.EnableWindow( TRUE );

			listCtrl.DeleteAllItems();
			break;
		}
	case MP_RM_SKILL_LOG_SIZE_NACK:
		{
			CString textThereIsNoResult;
			textThereIsNoResult.LoadString( IDS_STRING1 );

			MessageBox( 0, textThereIsNoResult, _T( "" ), MB_ICONERROR | MB_OK );
			break;
		}
	case MP_RM_SKILL_LOG_STOP_ACK:
		{
			findButton.EnableWindow( TRUE );
			stopButton.EnableWindow( FALSE );

			CString textSearchWasStopped;
			textSearchWasStopped.LoadString( IDS_STRING2 );

			MessageBox( 0, textSearchWasStopped, _T( "" ), MB_ICONERROR | MB_OK );
			break;
		}
	case MP_RM_SKILL_LOG_NACK_BY_AUTH:
		{
			CString textYouHaveNoAuthority;
			textYouHaveNoAuthority.LoadString( IDS_STRING18 );

			MessageBox( 0, textYouHaveNoAuthority, _T( "" ), MB_OK | MB_ICONERROR );
			break;
		}
	default:
		{
			ASSERT( 0 );
			break;
		}
	}
}
Esempio n. 14
0
void CHttpDownloadDlg::SetStatus(UINT nID)
{
	CString sCaption;
	sCaption.LoadString(nID);
	SetStatus(sCaption);
}
Esempio n. 15
0
void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs)
{
	CIconMenu popupMenu;
	popupMenu.CreatePopupMenu();

	bool bAddSeparator = false;
	CString remoteName;

	if(selectedLeafs.size()==1)
	{
		bAddSeparator = true;

		bool bShowReflogOption				= false;
		bool bShowFetchOption				= false;
		bool bShowRenameOption				= false;
		bool bShowCreateBranchOption		= false;
		bool bShowEditBranchDescriptionOption = false;

		CString fetchFromCmd;

		if(selectedLeafs[0]->IsFrom(L"refs/heads/"))
		{
			bShowReflogOption = true;
			bShowRenameOption = true;
			bShowEditBranchDescriptionOption = true;
		}
		else if(selectedLeafs[0]->IsFrom(L"refs/remotes/"))
		{
			bShowReflogOption = true;
			bShowFetchOption  = true;
			bShowCreateBranchOption = true;

			CString remoteBranch;
			if (SplitRemoteBranchName(selectedLeafs[0]->GetRefName(), remoteName, remoteBranch))
				bShowFetchOption = false;
			else
				fetchFromCmd.Format(IDS_PROC_BROWSEREFS_FETCHFROM, remoteName);
		}
		else if(selectedLeafs[0]->IsFrom(L"refs/tags/"))
		{
		}

		CString temp;
		temp.LoadString(IDS_MENULOG);
		popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG);
		popupMenu.AppendMenuIcon(eCmd_RepoBrowser, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE);
		if(bShowReflogOption)
		{
			temp.LoadString(IDS_MENUREFLOG);
			popupMenu.AppendMenuIcon(eCmd_ShowReflog, temp, IDI_LOG);
		}

		popupMenu.AppendMenu(MF_SEPARATOR);
		bAddSeparator = false;

		if(bShowFetchOption)
		{
			bAddSeparator = true;
			popupMenu.AppendMenuIcon(eCmd_Fetch, fetchFromCmd, IDI_PULL);
		}

		if(bAddSeparator)
			popupMenu.AppendMenu(MF_SEPARATOR);

		bAddSeparator = false;
		if (m_bHasWC)
		{
			CString format, str;
			if (selectedLeafs[0]->GetRefName() != _T("refs/heads/") + g_Git.GetCurrentBranch())
			{
				format.LoadString(IDS_LOG_POPUP_MERGEREV);
				str.Format(format, g_Git.GetCurrentBranch());
				popupMenu.AppendMenuIcon(eCmd_Merge, str, IDI_MERGE);
			}
			popupMenu.AppendMenuIcon(eCmd_Switch, CString(MAKEINTRESOURCE(IDS_SWITCH_TO_THIS)), IDI_SWITCH);
			popupMenu.AppendMenu(MF_SEPARATOR);
		}

		if(bShowCreateBranchOption)
		{
			bAddSeparator = true;
			temp.LoadString(IDS_MENUBRANCH);
			popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY);
		}

		if (bShowEditBranchDescriptionOption)
		{
			bAddSeparator = true;
			popupMenu.AppendMenuIcon(eCmd_EditBranchDescription, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)), IDI_RENAME);
		}
		if(bShowRenameOption)
		{
			bAddSeparator = true;
			popupMenu.AppendMenuIcon(eCmd_Rename, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_RENAME)), IDI_RENAME);
		}
	}
	else if(selectedLeafs.size() == 2)
	{
		bAddSeparator = true;
		popupMenu.AppendMenuIcon(eCmd_Diff, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_COMPAREREFS)), IDI_DIFF);
		popupMenu.AppendMenuIcon(eCmd_UnifiedDiff, CString(MAKEINTRESOURCE(IDS_LOG_POPUP_GNUDIFF)), IDI_DIFF);
		CString menu;
		menu.Format(IDS_SHOWLOG_OF, GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("..")));
		popupMenu.AppendMenuIcon(eCmd_ViewLogRange, menu, IDI_LOG);
		menu.Format(IDS_SHOWLOG_OF, GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("...")));
		popupMenu.AppendMenuIcon(eCmd_ViewLogRangeReachableFromOnlyOne, menu, IDI_LOG);
	}

	if(!selectedLeafs.empty())
	{
		if(AreAllFrom(selectedLeafs, L"refs/remotes/"))
		{
			if(bAddSeparator)
				popupMenu.AppendMenu(MF_SEPARATOR);
			CString menuItemName;
			if(selectedLeafs.size() == 1)
				menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCH);
			else
				menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCHES, selectedLeafs.size());

			popupMenu.AppendMenuIcon(eCmd_DeleteRemoteBranch, menuItemName, IDI_DELETE);
			bAddSeparator = true;
		}
		else if(AreAllFrom(selectedLeafs, L"refs/heads/"))
		{
			if(bAddSeparator)
				popupMenu.AppendMenu(MF_SEPARATOR);
			CString menuItemName;
			if(selectedLeafs.size() == 1)
				menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEBRANCH);
			else
				menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEBRANCHES, selectedLeafs.size());

			popupMenu.AppendMenuIcon(eCmd_DeleteBranch, menuItemName, IDI_DELETE);
			bAddSeparator = true;
		}
		else if(AreAllFrom(selectedLeafs, L"refs/tags/"))
		{
			if(bAddSeparator)
				popupMenu.AppendMenu(MF_SEPARATOR);
			CString menuItemName;
			if(selectedLeafs.size() == 1)
				menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETETAG);
			else
				menuItemName.Format(IDS_PROC_BROWSEREFS_DELETETAGS, selectedLeafs.size());

			popupMenu.AppendMenuIcon(eCmd_DeleteTag, menuItemName, IDI_DELETE);
			bAddSeparator = true;
		}
	}


	if(hTreePos!=NULL && selectedLeafs.empty())
	{
		CShadowTree* pTree=(CShadowTree*)m_RefTreeCtrl.GetItemData(hTreePos);
		if(pTree->IsFrom(L"refs/remotes"))
		{
			if(bAddSeparator)
				popupMenu.AppendMenu(MF_SEPARATOR);
			popupMenu.AppendMenuIcon(eCmd_ManageRemotes, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_MANAGEREMOTES)), IDI_SETTINGS);
			bAddSeparator = true;
			if(selectedLeafs.empty())
			{
				CString remoteBranch;
				if (SplitRemoteBranchName(pTree->GetRefName(), remoteName, remoteBranch))
					remoteName = _T("");
				if(!remoteName.IsEmpty())
				{
					CString temp;
					temp.Format(IDS_PROC_BROWSEREFS_FETCHFROM, remoteName);
					popupMenu.AppendMenuIcon(eCmd_Fetch, temp, IDI_PULL);

					temp.LoadString(IDS_DELETEREMOTETAG);
					popupMenu.AppendMenuIcon(eCmd_DeleteRemoteTag, temp, IDI_DELETE);
				}
			}
		}
		if(pTree->IsFrom(L"refs/heads"))
		{
			if(bAddSeparator)
				popupMenu.AppendMenu(MF_SEPARATOR);
			CString temp;
			temp.LoadString(IDS_MENUBRANCH);
			popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY);
		}
		if(pTree->IsFrom(L"refs/tags"))
		{
			if(bAddSeparator)
				popupMenu.AppendMenu(MF_SEPARATOR);
			CString temp;
			temp.LoadString(IDS_MENUTAG);
			popupMenu.AppendMenuIcon(eCmd_CreateTag, temp, IDI_TAG);
			temp.LoadString(IDS_PROC_BROWSEREFS_DELETEALLTAGS);
			popupMenu.AppendMenuIcon(eCmd_DeleteAllTags, temp, IDI_DELETE);
		}
	}


	eCmd cmd=(eCmd)popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this, 0);
	switch(cmd)
	{
	case eCmd_ViewLog:
		{
			CLogDlg dlg;
			dlg.SetRange(g_Git.FixBranchName(selectedLeafs[0]->GetRefName()));
			dlg.DoModal();
		}
		break;
	case eCmd_ViewLogRange:
		{
			CLogDlg dlg;
			dlg.SetRange(GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("..")));
			dlg.DoModal();
		}
		break;
	case eCmd_ViewLogRangeReachableFromOnlyOne:
		{
			CLogDlg dlg;
			dlg.SetRange(GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("...")));
			dlg.DoModal();
		}
		break;
	case eCmd_RepoBrowser:
		CAppUtils::RunTortoiseGitProc(_T("/command:repobrowser /path:\"") + g_Git.m_CurrentDir + _T("\" /rev:") + selectedLeafs[0]->GetRefName());
		break;
	case eCmd_DeleteBranch:
	case eCmd_DeleteRemoteBranch:
		{
			if(ConfirmDeleteRef(selectedLeafs))
				DoDeleteRefs(selectedLeafs, true);
			Refresh();
		}
		break;
	case eCmd_DeleteTag:
		{
			if(ConfirmDeleteRef(selectedLeafs))
				DoDeleteRefs(selectedLeafs, true);
			Refresh();
		}
		break;
	case eCmd_ShowReflog:
		{
			CRefLogDlg refLogDlg(this);
			refLogDlg.m_CurrentBranch = selectedLeafs[0]->GetRefName();
			refLogDlg.DoModal();
		}
		break;
	case eCmd_Fetch:
		{
			CAppUtils::Fetch(remoteName);
			Refresh();
		}
		break;
	case eCmd_DeleteRemoteTag:
		{
			CDeleteRemoteTagDlg deleteRemoteTagDlg;
			deleteRemoteTagDlg.m_sRemote = remoteName;
			deleteRemoteTagDlg.DoModal();
		}
		break;
	case eCmd_Merge:
		{
			CString ref = selectedLeafs[0]->GetRefName();
			CAppUtils::Merge(&ref);
		}
		break;
	case eCmd_Switch:
		{
			CAppUtils::Switch(selectedLeafs[0]->GetRefName());
		}
		break;
	case eCmd_Rename:
		{
			POSITION pos = m_ListRefLeafs.GetFirstSelectedItemPosition();
			if(pos != NULL)
				m_ListRefLeafs.EditLabel(m_ListRefLeafs.GetNextSelectedItem(pos));
		}
		break;
	case eCmd_AddRemote:
		{
			CAddRemoteDlg(this).DoModal();
			Refresh();
		}
		break;
	case eCmd_ManageRemotes:
		{
			CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROCS_TITLE_GITREMOTESETTINGS)), new CSettingGitRemote(g_Git.m_CurrentDir), this).DoModal();
//			CSettingGitRemote W_Remotes(m_cmdPath);
//			W_Remotes.DoModal();
			Refresh();
		}
		break;
	case eCmd_CreateBranch:
		{
			CString *commitHash = NULL;
			if (selectedLeafs.size() == 1)
				commitHash = &(selectedLeafs[0]->m_csRefHash);
			CAppUtils::CreateBranchTag(false, commitHash);
			Refresh();
		}
		break;
	case eCmd_CreateTag:
		{
			CAppUtils::CreateBranchTag(true);
			Refresh();
		}
		break;
	case eCmd_DeleteAllTags:
		{
			for (int i = 0; i < m_ListRefLeafs.GetItemCount(); ++i)
			{
				m_ListRefLeafs.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
				selectedLeafs.push_back((CShadowTree*)m_ListRefLeafs.GetItemData(i));
			}
			if (ConfirmDeleteRef(selectedLeafs))
				DoDeleteRefs(selectedLeafs, true);
			Refresh();
		}
		break;
	case eCmd_Diff:
		{
			CFileDiffDlg dlg;
			dlg.SetDiff(
				NULL,
				selectedLeafs[1]->GetRefName() + L"^{}",
				selectedLeafs[0]->GetRefName() + L"^{}");
			dlg.DoModal();
		}
		break;
	case eCmd_UnifiedDiff:
		{
			CAppUtils::StartShowUnifiedDiff(nullptr, CTGitPath(), selectedLeafs[0]->m_csRefHash, CTGitPath(), selectedLeafs[1]->m_csRefHash);
		}
		break;
	case eCmd_EditBranchDescription:
		{
			CInputDlg dlg;
			dlg.m_sHintText = CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION));
			dlg.m_sInputText = selectedLeafs[0]->m_csDescription;
			dlg.m_sTitle = CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION));
			dlg.m_bUseLogWidth = true;
			if(dlg.DoModal() == IDOK)
			{
				CString key;
				key.Format(_T("branch.%s.description"), selectedLeafs[0]->m_csRefName);
				dlg.m_sInputText.Replace(_T("\r"), _T(""));
				dlg.m_sInputText.Trim();
				if (dlg.m_sInputText.IsEmpty())
					g_Git.UnsetConfigValue(key);
				else
					g_Git.SetConfigValue(key, dlg.m_sInputText);
				Refresh();
			}
		}
		break;
	}
}
Esempio n. 16
0
void CGame::_Event (int ID, int iTyp, char const * psText, int iVoice)
{

	ASSERT ((sizeof (aiRes) / sizeof (int)) == NUM_EVENTS);
	ASSERT ((sizeof (aiSfx) / sizeof (int)) == NUM_EVENTS);

	if ((ID < 0) || (NUM_EVENTS <= ID))
		{
		ASSERT (FALSE);
		return;
		}

	// if no HP then no events
	if ( ! theGame.HaveHP () )
		return;

	// not during cut scenes
	if ( ! theGame.DoOper () )
		return;

	// don't repeat ourselves too often
	if ( theGame.GettimeGetTime () - dwLastTime [ID] < dwTimeBetween [ID] * 1000 )
		return;
	dwLastTime [ID] = theGame.GettimeGetTime ();

	// if its clear it - do it now and leave
	if (iTyp == EVENT_OFF)
		{
		if (ID != iLastEvent)
			return;
		if (hTimer != NULL)
			{
			theApp.m_wndBar.KillTimer (hTimer);
			hTimer = NULL;
			}
		theApp.m_wndBar.SetStatusText (0, "");
		return; 
		}

	TRAP (ID == EVENT_ROAD_START);
	TRAP (ID == EVENT_VEH_UNDER_ATK);
	TRAP (ID == EVENT_PLAYER_LEFT);
	TRAP (ID == EVENT_PLAYER_JOINED);
	TRAP (ID == EVENT_HPR_SEAPORTS);
	TRAP (ID == EVENT_HPR_CARGOSHIP);
	TRAP (ID == EVENT_HPR_NOREACH);

	int iRes = aiRes [ID];
	int iSfx = aiSfx [ID];

	CString sMsg;
	sMsg.LoadString (iRes);
	if (psText != NULL)
		csPrintf (&sMsg, psText);

	CStatInst::IMPORTANCE iImp;
	int iShow;
	switch (iTyp)
	  {
		case EVENT_NOTIFY :
			iImp = CStatInst::status;
			iShow = 10;
			break;
		case EVENT_WARN :
			iImp = CStatInst::warn;
			iShow = 20;
			break;
		case EVENT_BAD :
			iImp = CStatInst::critical;
			iShow = 40;
			break;

		default:
			return;
	  }

	iLastEvent = ID;
	theApp.m_wndBar.SetStatusText (0, sMsg, iImp);

	// we kill the message after iShow seconds
	if (hTimer != NULL)
		theApp.m_wndBar.KillTimer (hTimer);
	hTimer = theApp.m_wndBar.SetTimer (99, iShow * 1000, NULL);

	if (iSfx > 0)
		{
		// keep at least 3 seconds apart
		static DWORD dwLastVoice = 0;
		if ( theGame.GettimeGetTime () - dwLastVoice > 3 * 1000 )
			{
			dwLastVoice = theGame.GettimeGetTime ();
			theMusicPlayer.PlayForegroundSound (VOICES::GetID (iSfx, iVoice), SFXPRIORITY::voice_pri );
			}
		}
}
Esempio n. 17
0
BOOL CBCGPMenuPage::OnInitDialog() 
{
	{
		CBCGPLocalResource locaRes;
		CPropertyPage::OnInitDialog();
	}

	if (m_iMenuAnimationType == (int) CBCGPPopupMenu::SYSTEM_DEFAULT_ANIMATION)
	{
		m_iMenuAnimationType = m_wndMenuAnimations.GetCount () - 1;
		UpdateData (FALSE);
	}

	POSITION pos = NULL;

	//----------------------------------------------------------
	// Find application Menu Bar object (assume that only one):
	//---------------------------------------------------------
	for (pos = gAllToolbars.GetHeadPosition (); 
		m_pMenuBar == NULL && pos != NULL;)
	{
		CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (pos);
		ASSERT (pToolBar != NULL);

		if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
		{
			ASSERT_VALID(pToolBar);
			m_pMenuBar = DYNAMIC_DOWNCAST (CBCGPMenuBar, pToolBar);
		}
	}

	if (m_pMenuBar != NULL)
	{
		m_pMenuBar->m_pMenuPage = this;

		int iCurrMenu = -1;

		//---------------------------
		// Save MenuBar current menu:
		//---------------------------
		m_hmenuCurr = m_pMenuBar->GetHMenu ();

		m_pMenuBar->OnChangeHot (-1);
		g_menuHash.SaveMenuBar (m_hmenuCurr, m_pMenuBar);

		//-------------------------------------------------------------------
		// Find all application document templates and fill menues combobox
		// by document template data:
		//------------------------------------------------------------------
		CDocManager* pDocManager = AfxGetApp ()->m_pDocManager;
		if (m_bAutoSet && pDocManager != NULL)
		{
			POSITION pos = NULL;

			//---------------------------------------
			// Walk all templates in the application:
			//---------------------------------------
			for (pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;)
			{
				CBCGPMultiDocTemplate* pTemplate = 
					(CBCGPMultiDocTemplate*) pDocManager->GetNextDocTemplate (pos);
				ASSERT_VALID (pTemplate);
				ASSERT_KINDOF (CDocTemplate, pTemplate);

				//-----------------------------------------------------
				// We are interessing CMultiDocTemplate objects with
				// the shared menu only....
				//-----------------------------------------------------
				if (!pTemplate->IsKindOf (RUNTIME_CLASS (CMultiDocTemplate)) ||
					pTemplate->m_hMenuShared == NULL)
				{
					continue;
				}

				//----------------------------------------------------
				// Maybe, the template with same ID is already exist?
				//----------------------------------------------------
				BOOL bIsAlreadyExist = FALSE;
				for (int i = 0; !bIsAlreadyExist && i < m_wndMenuesList.GetCount (); i++)
				{
					CBCGPMultiDocTemplate* pListTemplate = 
						(CBCGPMultiDocTemplate*) m_wndMenuesList.GetItemData (i);
					bIsAlreadyExist = pListTemplate != NULL &&
						pListTemplate->GetResId () == pTemplate->GetResId ();
				}

				if (!bIsAlreadyExist)
				{
					CString strName;
					pTemplate->GetDocString (strName, CDocTemplate::fileNewName);

					int iIndex = m_wndMenuesList.AddString (strName);
					m_wndMenuesList.SetItemData (iIndex, (DWORD_PTR) pTemplate);

					if (pTemplate->m_hMenuShared == m_hmenuCurr)
					{
						iCurrMenu = iIndex;
					}
				}
			}
		}

		//--------------------------
		// Add a default frame menu:
		//--------------------------
		CString strName;
		{
			CBCGPLocalResource locaRes;
			strName.LoadString (IDS_BCGBARRES_DEFUALT_MENU);
		}

		int iIndex = m_wndMenuesList.AddString (strName);
		m_wndMenuesList.SetItemData (iIndex, (DWORD_PTR) NULL);

		if (iCurrMenu == -1)
		{
			m_bIsDefaultMDIMenu = TRUE;
			iCurrMenu = iIndex;
		}

		m_hmenuSelected = m_hmenuCurr;
		m_wndMenuesList.SetCurSel (iCurrMenu);

		UpdateData (FALSE);
		OnSelchangeMenuList ();
	}
	else
	{
		//-------------------------------------------------
		// No menubar found, disable menu selecting engine:
		//-------------------------------------------------
		m_wndMenuesList.EnableWindow (FALSE);
		GetDlgItem(IDC_BCGBARRES_RESET_FRAME_MENU)->EnableWindow(FALSE);

		CBCGPLocalResource locaRes;
		m_strMenuDescr.LoadString (IDS_BCGBARRES_NO_MENUBAR);

		UpdateData (FALSE);
	}

	//--------------------------
	// Initialize context menus:
	//--------------------------
	{
		CBCGPLocalResource locaRes;

		CString strNoContextMenu;
		strNoContextMenu.LoadString (IDS_BCGBARRES_NO_CONTEXT);

		m_wndContextMenus.AddString (strNoContextMenu);
		m_wndContextMenus.SetCurSel (0);
	}

	if (g_pContextMenuManager != NULL)
	{
		CStringList listOfNames;
		g_pContextMenuManager->GetMenuNames (listOfNames);

		for (pos = listOfNames.GetHeadPosition (); pos != NULL;)
		{
			CString strName = listOfNames.GetNext (pos);
			m_wndContextMenus.AddString (strName);
		}

		m_wndContextMenuCaption.EnableWindow (m_wndContextMenus.GetCount () > 1);
		m_wndContextMenus.EnableWindow (m_wndContextMenus.GetCount () > 1);
	}
	else
	{
		//-------------------------------
		// Hide all context menus fields:
		//-------------------------------
		m_wndContextMenuCaption.ShowWindow (SW_HIDE);
		m_wndContextMenus.ShowWindow (SW_HIDE);
		m_wndContextHint.ShowWindow (SW_HIDE);
		m_wndContextFrame.ShowWindow (SW_HIDE);
		m_wndResetMenuButton.ShowWindow (SW_HIDE);
	}

	CBCGPToolbarCustomize* pWndParent = DYNAMIC_DOWNCAST (CBCGPToolbarCustomize, GetParent ());
	ASSERT (pWndParent != NULL);

	if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_SHADOWS) == 0)
	{
		m_wndMenuShadows.ShowWindow (SW_HIDE);
	}

	if ((pWndParent->GetFlags () & BCGCUSTOMIZE_MENU_ANIMATIONS) == 0)
	{
		m_wndMenuAnimationsLabel.ShowWindow (SW_HIDE);
		m_wndMenuAnimations.ShowWindow (SW_HIDE);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
/**
 * @param error - exception information.
 */
void CExpressModeDlg::HandleException(const std::exception& error)
{
	CString strProjectTitle;
	strProjectTitle.LoadString(IDS_PROJECTTITLE);
	MessageBox(CA2CT(error.what()), strProjectTitle, MB_OK | MB_ICONERROR);
}
Esempio n. 19
0
void CTinyCadView::OnSpecialCheck()
{
	// Get rid of any drawing tool
	GetCurrentDocument()->SelectObject(new CDrawEditItem(GetCurrentDocument()));

	CDlgERCBox theDialog;

	static union { ErrorTest e; WORD i; } theErrorTest;

	theErrorTest.i = CTinyCadRegistry::GetInt("ERC", 0xffff);


	// Get the user's options
	theDialog.SetErrorTest(theErrorTest.e);
	if (theDialog.DoModal() != IDOK)
	{
		return;
	}

	theErrorTest.e = theDialog.GetErrorTest();  
	CTinyCadRegistry::Set("ERC",theErrorTest.i);

	// Set the Busy icon
	SetCursor( AfxGetApp()->LoadStandardCursor( IDC_WAIT ) );

	// Generate the netlist
	CNetList netlist;
	netlist.m_follow_imports = false;
	CTinyCadMultiDoc *pDoc = static_cast<CTinyCadMultiDoc*>(GetDocument());
	netlist.MakeNet( pDoc );
	netCollection *nets = &netlist.m_nets;

	// Delete all the errors which are currently in the design
	theERCListBox.Close();
	// GetCurrentDocument()->DeleteErrors();
	theERCListBox.Open( pDoc );
	int CurrentError = 0;

	// Scan the design for duplicated references
	if ((theErrorTest.e).DupRef)
	{
		std::set<CString>	refs;

		CString last = "";

		for (int i = 0; i < pDoc->GetNumberOfSheets(); i++)
		{
			drawingIterator it = pDoc->GetSheet(i)->GetDrawingBegin();
			while (it != pDoc->GetSheet(i)->GetDrawingEnd()) 
			{
				CDrawingObject *pointer = *it;

				if (pointer->GetType()==xMethodEx3) 
				{
					CString ref = static_cast<CDrawMethod *>(pointer)->GetField(CDrawMethod::Ref);

					if (refs.find( ref ) != refs.end())
					{
						// We have a duplicate...
						CString buffer;
						buffer.LoadString( ERR_DUPREF );
						pDoc->GetSheet(i)->Add(new CDrawError(pDoc->GetSheet(i),static_cast<CDrawMethod *>(pointer)->GetFieldPos(CDrawMethod::Ref),CurrentError++));
						theERCListBox.AddString(buffer);
					}
					else
					{
						refs.insert( ref );
					}
				}

				++ it;
			}
		}
	}


	// Scan netlist to determine the type of each net
	netCollection::iterator nit = nets->begin();

	while (nit != nets->end()) 
	{
		nodeVector::iterator nv_it = (*nit).second.begin();

		int theNetType = nUnknown;
		CString lastPower = "";
		int connections = 0;

		CDPoint pos;
		int sheet = 0;

		while (theNetType < ERR_BASE && nv_it != (*nit).second.end()) 
		{
			CNetListNode& theNode = *nv_it;

			CDrawingObject* pObject = theNode.m_parent;
			
			if (pObject != NULL) 
			{
				// Determine the type of this node
				int node_type = nUnknown;
				switch (pObject->GetType()) 
				{
				case xPower:
					node_type = nPower;
					if (lastPower=="")
					{
						lastPower = static_cast<CDrawPower *>(pObject)->GetValue();
					}
					else 
					{
						if ( lastPower != static_cast<CDrawPower *>(pObject)->GetValue() ) 
						{
							theNetType = ERR_POWER;
							node_type = nUnknown;
							break;
						}
					}
					connections ++;
					pos = pObject->m_point_a;
					sheet = theNode.m_sheet;
					break;
				case xNoConnect:
					node_type = 1;
					connections ++;
					pos = pObject->m_point_a;
					sheet = theNode.m_sheet;
					break;
				case xPin:
				case xPinEx:
					{
						CDrawPin *pPin = static_cast<CDrawPin*>( pObject );
						switch(pPin->GetElec()) 
						{
						case 0:		// Input
							node_type = nInput; 
							break;
						case 1:		// Output
							node_type = nOutput; 
							break;
						case 2:		// Tristate
							node_type = nBiDir; 
							break;
						case 3:		// Open Collector
							node_type = nBiDir; 
							break;
						case 4:		// Passive
							node_type = nPassive; 
							break;
						case 5:		// Input/Output
							node_type = nBiDir; 
							break;
						case 6:		// Not Connected
							node_type = nNoConnect;
							break;
						}
						
						if (pPin->IsPower()) 
						{
							node_type = nPower;
						}

						pos = pPin->GetActivePoint(theNode.m_pMethod);
						sheet = theNode.m_sheet;
						connections ++;
					}
					break;
				}
				
				theNetType = (node_type!=nUnknown) ? ErcTable[theNetType][node_type] : theNetType;
			}

			++ nv_it;
		}

		int ErrorNumber = 0;

		if (connections == 1)
		{
			theNetType = ERR_UNCONNECT;
		}
	

		switch (theNetType) 
		{
			case nUnknown:
				if (connections > 0)
				{
					ErrorNumber = ERR_UNCONNECTED;
				}
				break;
			case nInput:
				ErrorNumber = ERR_NOUTPUT;
				break;
			case nNoConnect:
				if (connections > 2)
				{
					theNetType = ERR_UNCONNECT;
				}
				break;
			default:
				ErrorNumber = theNetType;
				break;
		}

		// Is this error to be reported?
		switch (ErrorNumber) 
		{
		case ERR_UNCONNECT:
			if (!((theErrorTest.e).UnConnect))
				ErrorNumber = -1;
			break;
		case ERR_POWER:
			if (!((theErrorTest.e).Power))
				ErrorNumber = -1;
			break;
		case ERR_NOCONNECT:
			if (!((theErrorTest.e).NoConnect))
				ErrorNumber = -1;
			break;
		case ERR_NOUTPUT:
			if (!((theErrorTest.e).NoOutput))
				ErrorNumber = -1;
			break;
		case ERR_DUPREF:
			if (!((theErrorTest.e).DupRef))
				ErrorNumber = -1;
			break;
		case ERR_OUTPUT:
			if (!((theErrorTest.e).Output))
				ErrorNumber = -1;
			break;
		case ERR_OUTPUTTOPWR:
			if (!((theErrorTest.e).OutputPwr))
				ErrorNumber = -1;
			break;
		case ERR_UNCONNECTED:
			if (!((theErrorTest.e).UnConnected))
				ErrorNumber = -1;
			break;
		case ERR_OUTPUTBIDIR:
			if (!((theErrorTest.e).Output))
				ErrorNumber = -1;
			break;
		case ERR_POWERBIDIR:
			if (!((theErrorTest.e).OutputPwr))
				ErrorNumber = -1;
			break;
		}

		if (ErrorNumber >= ERR_BASE) 
		{
			CString buffer;
			buffer.LoadString( ErrorNumber );
			pDoc->GetSheet(sheet-1)->Add(new CDrawError(pDoc->GetSheet(sheet-1),pos,CurrentError++));
			theERCListBox.AddString(buffer);
		}

		++ nit;
	}


	// Were any errors detected?
	if (CurrentError == 0) 
	{
		CString buffer;
		buffer.LoadString( ERR_NOERROR );
		theERCListBox.AddString(buffer);
	}

	// Set the normal icon
	SetCursor( AfxGetApp()->LoadStandardCursor( IDC_ARROW ) );

	// Re-Draw the window
	Invalidate();

}
Esempio n. 20
0
BOOL IPM_BuildItemPath (CdIpmDoc* pDoc, CTypedPtrList<CObList, CuIpmTreeFastItem*>& listItemPath)
{
	ASSERT(!pDoc->GetSelectKey().IsEmpty());
	if (pDoc->GetSelectKey().IsEmpty())
		return FALSE;

	BOOL bOK = FALSE;
	int  nLevel = 0;
	int  nParent0type = 0;
	int  nObjectType  = 0;
	CString strParent0 = _T("");
	CString strStaticParent = _T("");
	CStringArray& arrayItemPath = pDoc->GetItemPath();
	void* pStructParent = NULL;
	int narrayItemPathSize = arrayItemPath.GetSize();
	ASSERT(narrayItemPathSize >= 1);
	if (narrayItemPathSize < 1)
		return FALSE;
	CString strObject = arrayItemPath.GetAt(0);
	//
	// Default (from old class CuIpmObjDesc in vdba):
	BOOL bObjectNeedsNameCheck = FALSE;
	BOOL bObjectHasStaticBranch= TRUE;
	BOOL bStaticParentNeedsNameCheck= FALSE;

	if (pDoc->GetSelectKey().CompareNoCase (_T("SERVER")) == 0)
	{
		//
		// Old class CuIpmObjDesc_SERVER in vdba (no overwrite the 3 default booleans above.
		nObjectType  = OT_MON_SERVER;
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("SESSION")) == 0)
	{
		//
		// Old class CuIpmObjDesc_SESSION in vdba (no overwrite the 3 default booleans above.
		nLevel = 1; // Parent is the SERVER. EX: ii\ingres\158
		nParent0type = OT_MON_SERVER;
		nObjectType  = OT_MON_SESSION;
		ASSERT(narrayItemPathSize >= 2);
		if (narrayItemPathSize < 2)
			return FALSE;
		strParent0   = arrayItemPath.GetAt(0);
		strObject    = arrayItemPath.GetAt(1);
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("REPLICSERVER")) == 0)
	{
		//
		// Old class CuIpmObjDesc_REPLICSERVER in vdba (overwrite the 2 default booleans above.
		bStaticParentNeedsNameCheck = TRUE;
		bObjectHasStaticBranch = FALSE;
		nLevel = 1; // Parent is the database name
		nParent0type = OT_DATABASE;
		nObjectType  = OT_MON_REPLIC_SERVER;
		ASSERT(narrayItemPathSize >= 1);
		if (narrayItemPathSize < 1)
			return FALSE;
		strStaticParent = _T("Replication");
		strParent0   = arrayItemPath.GetAt(0);
		if (narrayItemPathSize > 1)
			strObject    = arrayItemPath.GetAt(1);
	}
	else
	if (pDoc->GetSelectKey().CompareNoCase (_T("LOGINFO")) == 0)
	{
		//
		// Old class CuIpmObjDesc_LOGINFO in vdba (overwrite the 1 default boolean above.
		bObjectNeedsNameCheck = TRUE;
		strObject.LoadString(IDS_TM_LOGINFO); // "Log information"
	}

	if (nLevel > 0)
	{
		ASSERT (nParent0type);
		ASSERT (!strParent0.IsEmpty());
		// Static parent
		if (bStaticParentNeedsNameCheck) 
		{
			//
			// Only for replication:
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type, NULL, TRUE, strStaticParent));
		}
		else
		{
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nParent0type));
		}

		int reqSize = IPM_StructSize(nParent0type);
		CPtrList listInfoStruct;
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof(ups));
		CaIpmQueryInfo queryInfo(pDoc, nParent0type, &ups, (LPVOID)NULL, reqSize);
		queryInfo.SetReportError(FALSE);

		bOK = IPM_QueryInfo (&queryInfo, listInfoStruct);
		if (bOK)
		{
			POSITION p = NULL, pos = listInfoStruct.GetHeadPosition();

			while (pos != NULL)
			{
				p = pos;
				LPVOID pObject = listInfoStruct.GetNext(pos);
				if (MatchedStruct (nParent0type, strParent0, pObject))
				{
					pStructParent = pObject;
					listInfoStruct.RemoveAt (p);
					listItemPath.AddTail(new CaTreeItemPath(FALSE, nParent0type, pObject)); // non-static
					break;
				}
			}
			while (!listInfoStruct.IsEmpty())
				delete listInfoStruct.RemoveHead();
		}

		if (!pStructParent)
			return FALSE;
	}

	//
	// Object itself:
	if (strObject.IsEmpty())
		return bOK;

	if (bObjectNeedsNameCheck)
	{
		listItemPath.AddTail(new CaTreeItemPath(TRUE,  nObjectType, NULL, TRUE, strObject));  // Root item
		bOK = TRUE;
	}
	else
	{
		if (bObjectHasStaticBranch)
			listItemPath.AddTail(new CaTreeItemPath(TRUE, nObjectType));  // static

		int reqSize = IPM_StructSize(nObjectType);
		CPtrList listInfoStruct;
		IPMUPDATEPARAMS ups;
		memset (&ups, 0, sizeof(ups));
		ups.nType   = nParent0type;
		ups.pStruct = pStructParent;
		ups.pSFilter= NULL;

		CaIpmQueryInfo queryInfo(pDoc, nObjectType, &ups, (LPVOID)NULL, reqSize);
		queryInfo.SetReportError(FALSE);

		BOOL bHasObjects = IPM_QueryInfo (&queryInfo, listInfoStruct);
		if (bHasObjects)
		{
#if !defined (_IGNORE_NOT_MATCHED_ITEM)
			bOK = FALSE;
#endif
			POSITION p = NULL, pos = listInfoStruct.GetHeadPosition();
			while (pos != NULL)
			{
				p = pos;
				LPVOID pObject = listInfoStruct.GetNext(pos);
				if (MatchedStruct (nObjectType, strObject, pObject))
				{
					bOK = TRUE;
					listInfoStruct.RemoveAt (p);
					listItemPath.AddTail(new CaTreeItemPath(FALSE, nObjectType, pObject)); // non-static
					break;
				}
			}
			while (!listInfoStruct.IsEmpty())
				delete listInfoStruct.RemoveHead();
		}
	}

	return bOK;
}
Esempio n. 21
0
// **************************************************************************
// OnInitDialog ()
//
// Description:
//	Called immediately before the dialog box is displayed.  Use opportunity
//	to initialize controls.
//
// Parameters:
//  none
//
// Returns:
//	BOOL - TRUE.
// **************************************************************************
BOOL CKServerStatusPage::OnInitDialog () 
{
	IOPCServer *pIServer = NULL;
	OPCSERVERSTATUS *pServerStatus;
	CString strLoader;
	CString strStatus;
	CString strTemp;

	// Perform default processing:
	CPropertyPage::OnInitDialog ();

	// Get IServer interface:
	ASSERT (m_pServer != NULL);
	pIServer = m_pServer->GetIServer ();

	// Add server name to status string:
	strLoader.FormatMessage (IDS_PROGID, m_pServer->GetProgID ());
	strStatus += strLoader;

	// Add remote machine (if applicable) to status string:
	if (m_pServer->GetRemoteMachine ())
	{
		strLoader.FormatMessage (IDS_REMOTEMACHINE, m_pServer->GetRemoteMachine ());
		strStatus += strLoader;
	}

	// Get the server status:
	if (pIServer && SUCCEEDED (pIServer->GetStatus (&pServerStatus)) && pServerStatus)
	{
		FILETIME ftLocal;
		TCHAR szBuffer [DEFBUFFSIZE];

		// Add vendor name to status string:
		if (pServerStatus->szVendorInfo)
		{
			// Convert venter name from UNICODE if needed:
		#ifdef _UNICODE
			lstrcpyn (szBuffer, pServerStatus->szVendorInfo, sizeof (szBuffer) / sizeof (TCHAR));
		#else
			_wcstombsz (szBuffer, pServerStatus->szVendorInfo, sizeof (szBuffer) / sizeof (TCHAR));
		#endif
			// Add vender name:
			strLoader.FormatMessage (IDS_VENDORNAME, szBuffer);
			strStatus += strLoader;

			// Free memory allocated for vender info:
			CoTaskMemFree (pServerStatus->szVendorInfo);
		}

		// Add start time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftStartTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_STARTTIME, strTemp);
				strStatus += strLoader;
			}
		}	

		// Add current time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftCurrentTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_CURRENTTIME, strTemp);
				strStatus += strLoader;
			}
		}

		// Add last update time to status string:
		if (FileTimeToLocalFileTime (&pServerStatus->ftLastUpdateTime, &ftLocal))
		{
			SYSTEMTIME systime;
			if (FileTimeToSystemTime (&ftLocal, &systime))
			{
				strTemp.Format (_T("%02d:%02d:%02d:%03d"), systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds);			
				strLoader.FormatMessage (IDS_LASTUPDATETIME, strTemp);
				strStatus += strLoader;
			}
		}

		// Create a string describing server state:
		switch (pServerStatus->dwServerState)
		{
		case OPC_STATUS_RUNNING:
			strTemp.LoadString (IDS_RUNNING);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_FAILED: 
			strTemp.LoadString (IDS_FAILED);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_NOCONFIG: 
			strTemp.LoadString (IDS_NOCONFIG);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_SUSPENDED:
			strTemp.LoadString (IDS_SUSPENDED);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		case OPC_STATUS_TEST: 
			strTemp.LoadString (IDS_TEST);
			strLoader.FormatMessage (IDS_SERVERSTATE, strTemp); 
			break;

		default: 
			strLoader.FormatMessage (IDS_SERVERSTATE, _T("???")); 
			break;			
		}

		// Add server state to status string:
		strStatus += strLoader;

		// Add group count to status string:
		strTemp.Format (_T("%d"), pServerStatus->dwGroupCount);
		strLoader.FormatMessage (IDS_GROUPCOUNT, strTemp);
		strStatus += strLoader;

		// Add major version number to status string:
		strTemp.Format (_T("%d"), pServerStatus->wMajorVersion);
		strLoader.FormatMessage (IDS_MAJORVERSION, strTemp);
		strStatus += strLoader;

		// Add minor version to status string:
		strTemp.Format (_T("%d"), pServerStatus->wMinorVersion);
		strLoader.FormatMessage (IDS_MINORVERSION, strTemp);
		strStatus += strLoader;

		// Add build number to status string:
		strTemp.Format (_T("%d"), pServerStatus->wBuildNumber);
		strLoader.FormatMessage (IDS_BUILDNUMBER, strTemp);
		strStatus += strLoader;

		// Free memeory allocated for server status:
		CoTaskMemFree (pServerStatus);
	}

	// Else if failed, add string stating unable to determin server status
	// to status string:
	else
	{
		strLoader.LoadString (IDS_UNABLE_TO_DETERMINE_STATUS);
		strStatus += strLoader;
	}

	// Display the status string:
	((CStatic *) GetDlgItem (IDC_STATUS))->SetWindowText (strStatus);

	// return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
	return (TRUE);  
}
Esempio n. 22
0
BOOL CWZStep4::OnInitDialog() 
{

	CString		csLine;
	CString		csHeading;
	LV_COLUMN	Column;
	CRect		ListRect;

	CPropertyPageEx::OnInitDialog();

	//-- load temp dir information begin
	// do not know MAX_PATH-1 or not, just use  MAX_PATH -1 for safe
	GetTempPath(MAX_PATH-1,g_RestoreInfo.szTempDir);
	CString strTempDir;
	strTempDir=g_RestoreInfo.szTempDir;
	strTempDir.TrimRight(L"\\");
	wcsncpy(g_RestoreInfo.szTempDir,(LPCTSTR)strTempDir,MAX_PATH-1);
	//-- load temp dir information end

    //-- the get more file will be placed in OnInitDialog begin
	
	// GetMoreFile(g_RestoreInfo.szImageFile);
	
	WCHAR szMainImageName[MAX_PATH];
	memset(szMainImageName,0,sizeof(szMainImageName));
	if( FALSE == GetLongMainName(g_RestoreInfo.szImageFile,szMainImageName) )
	{
		TRACE(L"\nGetLongMainName error in OnInitDialog.");
	}
	else
	{
		GetSeperateFile(g_RestoreInfo.szImageFile, szMainImageName, g_RestoreInfo.szTempDir);
	}
	
	//-- the get more file will be placed in OnInitDialog end

	//-- create image will be placed in oninitdialog begin
	
	// here we just use m_ImageList
	// we needn't use "new" to create a ImageList

	m_ImageList.Create(IDB_DRIVER, 16, 1, RGB (255, 0, 255));
	CBitmap FileBitmap;
	FileBitmap.LoadBitmap(IDB_FILE);
	m_ImageList.Add(&FileBitmap,RGB(255,0,255));
	//-- create image will be placed in oninitdialog end


	m_TimeStamp.GetClientRect(ListRect);

	Column.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT;
	Column.fmt = LVCFMT_LEFT;
	Column.cx  = ListRect.right-ListRect.left;
	// if (g_nRestoreType)	Column.cx /= 2;

	if(g_RestoreInfo.nRestoreType==RESTORE_PART)
	{
		Column.cx/=2;
	}

	csHeading.LoadString(IDS_TIME_STAMP);
	Column.pszText = csHeading.GetBuffer(0);
	Column.cchTextMax = 0;		// ignored
	Column.iSubItem = 0;		

	//-- for debug comment it
	// m_TimeStamp.InsertColumn(0,&Column);
	//--end for debug comment it
	
	switch (g_RestoreInfo.nRestoreType)
	{
	case RESTORE_ENTIRE:  // 0

	    // total restore, do not show the information of the tree
		m_DirTree.EnableWindow(FALSE);
		break;
	case RESTORE_PART: // 1

		// partial restore, show the information of the tree

		m_DirTree.EnableWindow(TRUE);
		csHeading.LoadString(IDS_STATE);
		Column.pszText = csHeading.GetBuffer(0);
		
		//-- for debug comment it
		// m_TimeStamp.InsertColumn(1,&Column);
		//-- end for debug comment it
		
		break;
	}
	// TODO: Add extra initialization here

	// now init the segment information

	DWORD dwSegmentSize;

	dwSegmentSize=SEGMENT_SIZE;
	
	g_SegmentInfo.dwCurrentOffset  = 0;
	g_SegmentInfo.dwCurrentSegment = 0;
    LoadSegment( g_RestoreInfo.szImageFile, g_SegmentInfo.PathArray,
		         g_SegmentInfo.dwCurrentSegment, dwSegmentSize );

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 23
0
void CSetEditDlg::OnOK()
{
	GetColor();
	GetFont();
	BOOL bRegVaild = TRUE;
	LPCTSTR lpszSubSection = _T("SynColor");
	CString strSection = theApp.GetRegSectionPath(lpszSubSection);

	CBCGPRegistrySP regSP;
	CBCGPRegistry& reg = regSP.Create (FALSE, FALSE);

	if (reg.CreateKey(strSection))
	{
		if (!reg.Write(_T("clrBack"), g_GlobalUtils.m_sColorScheme.m_clrBack))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrText"), g_GlobalUtils.m_sColorScheme.m_clrText))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackSelActive"), g_GlobalUtils.m_sColorScheme.m_clrBackSelActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackSelInActive"), g_GlobalUtils.m_sColorScheme.m_clrBackSelInActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrTextSelActive"), g_GlobalUtils.m_sColorScheme.m_clrTextSelActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrTextSelInActive"), g_GlobalUtils.m_sColorScheme.m_clrTextSelInActive))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackOutline"), g_GlobalUtils.m_sColorScheme.m_clrBackOutline))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrLineOutline"), g_GlobalUtils.m_sColorScheme.m_clrLineOutline))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackLineNumber"), g_GlobalUtils.m_sColorScheme.m_clrBackLineNumber))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrTextLineNumber"), g_GlobalUtils.m_sColorScheme.m_clrTextLineNumber))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrBackSidebar"), g_GlobalUtils.m_sColorScheme.m_clrBackSidebar))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrHyperlink"), g_GlobalUtils.m_sColorScheme.m_clrHyperlink))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrSyn"), g_GlobalUtils.m_sColorScheme.m_clrSyn))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrType"), g_GlobalUtils.m_sColorScheme.m_clrType))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrNumber"), g_GlobalUtils.m_sColorScheme.m_clrNumber))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrString"), g_GlobalUtils.m_sColorScheme.m_clrString))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrChar"), g_GlobalUtils.m_sColorScheme.m_clrChar))
		{
			bRegVaild = FALSE;
		}

		if (!reg.Write(_T("clrComment"), g_GlobalUtils.m_sColorScheme.m_clrComment))
		{
			bRegVaild = FALSE;
		}
	}
	else
	{
		bRegVaild = FALSE;
	}

	lpszSubSection = _T("SynStyle");
	strSection = theApp.GetRegSectionPath(lpszSubSection);

	CBCGPRegistrySP regSPFont;
	CBCGPRegistry& regFont = regSPFont.Create(FALSE, FALSE);

	if (regFont.CreateKey(strSection))
	{
		if (!regFont.Write(_T("EdtFontName"), g_GlobalUtils.m_sStyleScheme.m_strEdtFontName))
		{
			bRegVaild = FALSE;
		}

		if (!regFont.Write(_T("EdtFontBold"), g_GlobalUtils.m_sStyleScheme.m_bEdtFontBold))
		{
			bRegVaild = FALSE;
		}

		if (!regFont.Write(_T("EdtFontItalic"), g_GlobalUtils.m_sStyleScheme.m_bEdtFontItalic))
		{
			bRegVaild = FALSE;
		}

		if (!regFont.Write(_T("EdtFontSize"), (int)g_GlobalUtils.m_sStyleScheme.m_uEdtFontSize))
		{
			bRegVaild = FALSE;
		}
	}
	else
	{
		bRegVaild = FALSE;
	}

	if (!bRegVaild)
	{
		CString strTemp;
		bRegVaild = strTemp.LoadString(IDS_REG_ERROR);
		ASSERT(bRegVaild);
		CFMessageBox(strTemp, MB_ICONSTOP);
	}

	CBCGPDialog::OnOK();
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	// enable Office XP look:
	CBCGVisualManager::SetDefaultManager (RUNTIME_CLASS (CBCGVisualManagerXP));

	// Load toolbar user images:
	if (!m_UserImages.Load (_T(".\\UserImages.bmp")))
	{
		TRACE(_T("Failed to load user images\n"));
		ASSERT (FALSE);
	}
	else
	{
		CBCGToolBar::SetUserImages (&m_UserImages);
	}

	CBCGToolBar::EnableQuickCustomization ();

	EnableMDITabs ();

	if (!m_wndMenuBar.Create (this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	if (!m_wndWorkSpace.Create (_T("Sprite"), this, CSize (228, 150),
		TRUE /* Has gripper */, ID_VIEW_WORKSPACE,
		WS_CHILD | WS_VISIBLE | CBRS_LEFT))
	{
		TRACE0("Failed to create workspace bar\n");
		return -1;      // fail to create
	}

	if (!m_wndProperty.Create (_T("Properties"), this, CSize (228, 200),
		TRUE /* Has gripper */, ID_VIEW_PROPERTY,
		WS_CHILD | WS_VISIBLE | CBRS_BOTTOM))
	{
		TRACE0("Failed to create property bar\n");
		return -1;      // fail to create
	}


	if (!m_wndOutput.Create (_T("Output"), this, CSize (150, 150),
		TRUE /* Has gripper */, ID_VIEW_OUTPUT,
		WS_CHILD | CBRS_BOTTOM))
	{
		TRACE0("Failed to create output bar\n");
		return -1;      // fail to create
	}

	CString strMainToolbarTitle;
	strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR);
	m_wndToolBar.SetWindowText (strMainToolbarTitle);
	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY);
	m_wndProperty.EnableDocking(CBRS_ALIGN_ANY);
	m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndMenuBar);
	DockControlBar(&m_wndToolBar);
	DockControlBar(&m_wndWorkSpace);
	DockControlBarLeftOf(&m_wndProperty, &m_wndWorkSpace);
	DockControlBar(&m_wndOutput);


	// Allow user-defined toolbars operations:
	InitUserToobars (NULL,
					uiFirstUserToolBarId,
					uiLastUserToolBarId);

	// Enable windows manager:
	EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE);
	return 0;
}
Esempio n. 25
0
BOOL CWorkspaceDialog::OnInitDialog()
{
	CString strCaption;
	strCaption.LoadString(GetTitleId());
	if (!m_strName.IsEmpty())
		strCaption += " " + m_strName;
	SetWindowText(strCaption);

	// Initialize the url prior to calling CDHtmlDialog::OnInitDialog()
	if (m_strCurrentUrl.IsEmpty())
		m_strCurrentUrl = "about:blank";

	CDHtmlDialog::OnInitDialog();
	m_bUseHtmlTitle = false;

	// This magically makes the scroll bars appear and dis-allows text selection
	DWORD dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_THEME | DOCHOSTUIFLAG_DIALOG; // DOCHOSTUIFLAG_NO3DOUTERBORDER;
	SetHostFlags(dwFlags);

	// Add "About..." menu item to system menu.
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(false);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icons for this dialog
	SetIcon(m_hIcon, true);		// Set big icon
	SetIcon(m_hIcon, false);	// Set small icon

	// Set the window size and position
	if (!m_pRect)
		CenterWindow();
	else
	{
		CRect Rect = *m_pRect;
		SetWindowPos(NULL, Rect.left, Rect.top, Rect.Width(), Rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
	}

	// Copy this to CpDialog.cpp
	if (m_pBrowserApp)
	{
		m_pBrowserApp->put_RegisterAsDropTarget(VARIANT_FALSE);
		m_pBrowserApp->put_ToolBar(VARIANT_FALSE);
		m_pBrowserApp->put_StatusBar(VARIANT_TRUE);
		m_pBrowserApp->put_MenuBar(VARIANT_FALSE);
		m_pBrowserApp->put_Resizable(VARIANT_TRUE);
		m_pBrowserApp->put_AddressBar(VARIANT_FALSE);
	}

	Navigate(m_strUrl, navNoHistory/*dwFlags*/, "_self"/*lpszTargetFrameName*/, NULL/*lpszHeaders*/, NULL/*lpvPostData*/, 0/*dwPostDataLen*/);

	// Wait until the page is loaded
	if (m_pBrowserApp)
	{
		VARIANT_BOOL bBusy = true; // Initialize this to true if you want to wait for the document to load
		int i = 300;
		while (bBusy)
		{
			::Sleep(100);
			m_pBrowserApp->get_Busy(&bBusy);
			if (--i <= 0)
				break;
		}
	}

	ShowWindow(SW_NORMAL);

	DragAcceptFiles(false);

	return true;  // return TRUE  unless you set the focus to a control
}
Esempio n. 26
0
NDUPDATE_API
BOOL
WINAPI
NdasUpdateDoUpdate(
	IN HWND hWndParent,
	IN LPCTSTR szBaseURL,
	IN PNDUPDATE_SYSTEM_INFO pSystemInformation)
{
	HINSTANCE hResInst = _NdasUpdateDllInstance;
	NDUPDATE_UPDATE_INFO_V2 updateInformation = {0};

	CDownloadUI downloadUI;
	TCHAR szUpdaterTitle[MAX_STR_CAPTION];
	::LoadString(
		hResInst, 
		IDS_UPDATER_TITLE, 
		szUpdaterTitle, 
		MAX_STR_CAPTION);

	BOOL fSuccess = downloadUI.Initialize(
		hResInst,
		hWndParent,
		szUpdaterTitle);

	CString strBanner;
	strBanner.LoadString(IDS_STATUS_CHECK_UPDATE);
	downloadUI.SetBannerText(strBanner);

	fSuccess = ::NdasUpdateGetUpdateInfo(
		&CDownloadBindStatusCallback(&downloadUI), 
		szBaseURL,
		pSystemInformation,
		&updateInformation);


	if (!fSuccess) {

		CString strDescr;
		strDescr.LoadString(IDS_UPDATER_ERROR_UPDATE_CHECK);

		CString strFormatted;
		strFormatted.FormatMessage(
			IDS_UPDATER_ERROR_FMT, 
			(LPCTSTR)strDescr, 
			::GetLastError());

		::MessageBox(
			hWndParent, 
			strFormatted, 
			szUpdaterTitle, 
			MB_OK | MB_ICONERROR);

		downloadUI.Terminate();
		return FALSE;
	}

	strBanner.LoadString(IDS_STATUS_CHECK_UPDATE_DONE);
	downloadUI.SetBannerText(strBanner);

	if (!updateInformation.fNeedUpdate) {
		CString strMsg;
		strMsg.LoadString(IDS_NO_UPDATE);
		::MessageBox(
			hWndParent,
			strMsg,
			szUpdaterTitle,
			MB_OK | MB_ICONINFORMATION);
		downloadUI.Terminate();
		return TRUE;
	}

	CString strMsg;
	strMsg.LoadString(IDS_NEW_UPDATE);

	UINT_PTR uiResponse = ::MessageBox(
		hWndParent,
		strMsg,
		szUpdaterTitle,
		MB_YESNO | MB_ICONQUESTION);

	if (IDYES != uiResponse) {
		downloadUI.Terminate();
		return TRUE;
	}

	strBanner.LoadString(IDS_STATUS_DOWNLOAD_UPDATE);
	downloadUI.SetBannerText(strBanner);

	TCHAR szDownloaded[MAX_PATH];

	LPCTSTR szDownloadingURL = 
		updateInformation.dwSmallSetupFileSize > 0 ?
		updateInformation.szSmallSetupFileURL :
		updateInformation.szFullSetupFileURL;

	HRESULT hr = ::URLDownloadToCacheFile(
		NULL,
		szDownloadingURL,
		szDownloaded,
		sizeof(szDownloaded),
		0,
		&CDownloadBindStatusCallback(&downloadUI));

	if (!downloadUI.HasUserCanceled() && FAILED(hr)) {

		CString strDescr;
		strDescr.LoadString(IDS_UPDATER_ERROR_DOWNLOAD);

		CString strFormatted;
		strFormatted.FormatMessage(
			IDS_UPDATER_ERROR_FMT, 
			(LPCTSTR)strDescr, 
			hr);

		::MessageBox(
			hWndParent, 
			strFormatted, 
			szUpdaterTitle, 
			MB_OK | MB_ICONERROR);

		downloadUI.Terminate();
		return FALSE;
	}

	strBanner.LoadString(IDS_STATUS_DOWNLOAD_UPDATE_DONE);
	downloadUI.SetBannerText(strBanner);
	
	downloadUI.Terminate();

	STARTUPINFO si = {0};
	si.cb = sizeof(STARTUPINFO);
	PROCESS_INFORMATION pi = {0};

	::CreateProcess(
		szDownloaded,
		NULL,
		NULL,
		NULL,
		FALSE,
		0,
		NULL,
		NULL,
		&si,
		&pi);

	return TRUE;
}
BOOL CQuestionnaireButtonPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
   
   DWORD dwIds[] = {IDC_LABEL_DELETE,
                    IDC_LABEL_SUBMIT,
                    IDC_LABEL_CONFIRM,
                    IDC_GROUP_BUTTONTEXTS,
                    IDC_GROUP_BUTTONVIEW,
                    IDC_LABEL_BUTTON_TYPE,
                    IDC_LABEL_PASSIV,
                    IDC_LABEL_NORMAL,
                    IDC_LABEL_MOUSEOVER,
                    IDC_LABEL_MOUSEDOWN,
                    IDC_EDIT_PASSIV,
                    IDC_EDIT_NORMAL,
                    IDC_EDIT_MOUSEOVER,
                    IDC_EDIT_PRESSED,
                    -1};
   MfcUtils::Localize(this, dwIds);

   CString csType;
   csType.LoadString(IDS_TEXT_BUTTON);
   m_wndChoosebuttonTypes.AddString(csType);
   csType.LoadString(IDS_IMAGE_BUTTON);
   m_wndChoosebuttonTypes.AddString(csType);
   m_wndChoosebuttonTypes.SetCurSel(0);   

   m_wndChoosebuttonTypes.SetCurSel(m_nButtonType);
   bool bIsImagebutton = m_nButtonType != 0;

   for (int i = 0; i < CButtonAppearanceSettings::ACTION_EVENT_COUNT; ++i)
   {
      m_wndPreview[i].IsImageButton(bIsImagebutton);
      m_wndPreview[i].SetImage(m_pButtonVisualSettings->m_csFileNames[i]);
      m_wndPreview[i].GetImageDimension(m_pButtonVisualSettings->m_siImageDimension[i]);
      m_wndPreview[i].SetFillColor(m_pButtonVisualSettings->m_clrFill[i]);
      m_wndPreview[i].SetLineColor(m_pButtonVisualSettings->m_clrLine[i]);

      m_wndPreview[i].SetTextColor(m_pButtonVisualSettings->m_clrText[i]);
      m_wndPreview[i].SetButtonFont(&m_pButtonVisualSettings->m_lf[i]);
      m_wndPreview[i].SetText(m_csButtonText);
   }

   CEdit *pEdit = NULL;
   
   pEdit = (CEdit *)GetDlgItem(IDC_EDIT_DELETE);
   if (pEdit)
      pEdit->SetWindowText(m_csDelete);

   pEdit = (CEdit *)GetDlgItem(IDC_EDIT_SEND);
   if (pEdit)
      pEdit->SetWindowText(m_csSubmit);

   pEdit = (CEdit *)GetDlgItem(IDC_EDIT_APPROVE);
   if (pEdit)
      pEdit->SetWindowText(m_csOk);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
}
Esempio n. 28
0
BOOL CDocManagerEx::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate)
{
	CFileDialog dlgFile(bOpenFileDialog); // this is the only modified line!

	CString title;
	VERIFY(title.LoadString(nIDSTitle));

	dlgFile.m_ofn.Flags |= lFlags;

	CString strFilter;
	CString strDefault;
	if (pTemplate != NULL)
	{
		ASSERT_VALID(pTemplate);
		AppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, &strDefault);
	}
	else
	{
		// do for all doc template
		POSITION pos = m_templateList.GetHeadPosition();
		BOOL bFirst = TRUE;
		while (pos != NULL)
		{
			CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
			AppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate,
				bFirst ? &strDefault : NULL);
			bFirst = FALSE;
		}
	}
/*
	// append the "*.*" all files filter
	CString allFilter;
	VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
	strFilter += allFilter;
	strFilter += (TCHAR)'\0';   // next string please
#ifndef _MAC
	strFilter += _T("*.*");
#else
	strFilter += _T("****");
#endif
	strFilter += (TCHAR)'\0';   // last string
	dlgFile.m_ofn.nMaxCustFilter++;
*/
	dlgFile.m_ofn.lpstrFilter = strFilter;
#ifndef _MAC
	dlgFile.m_ofn.lpstrTitle = title;
#else
	dlgFile.m_ofn.lpstrPrompt = title;
#endif
	dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH);

	BOOL bResult = dlgFile.DoModal() == IDOK ? TRUE : FALSE;
	fileName.ReleaseBuffer();
/*
	 CString strFilterExt;
	ASSERT_VALID(pTemplate);
	//Get the file extension of the template
	pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt);

	//Get the file extension of the selected file
	CString cstrSelFileExt = fileName.Right(fileName.GetLength() - fileName.ReverseFind('.'));
	cstrSelFileExt.MakeLower();
	strFilterExt.MakeLower();

	//compare both if not the same extension then return false
	if(strFilterExt.Find(cstrSelFileExt) == -1)
	{
		AfxMessageBox("Invalid extension", MB_OK | MB_ICONHAND);
		return FALSE;
	}
*/
	return bResult;
}
Esempio n. 29
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	BOOL bNameValid;

	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("未能创建菜单栏\n");
		return -1;      // 未能创建
	}

	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

	// 防止菜单栏在激活时获得焦点
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
	{
		TRACE0("未能创建工具栏\n");
		return -1;      // 未能创建
	}

	CString strToolBarName;
	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
	ASSERT(bNameValid);
	m_wndToolBar.SetWindowText(strToolBarName);

	CString strCustomize;
	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);

	// 允许用户定义的工具栏操作:
	InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("未能创建状态栏\n");
		return -1;      // 未能创建
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	// TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行
	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndMenuBar);
	DockPane(&m_wndToolBar);


	// 启用 Visual Studio 2005 样式停靠窗口行为
	CDockingManager::SetDockingMode(DT_SMART);
	// 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// 加载菜单项图像(不在任何标准工具栏上):
	CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0);

	// 创建停靠窗口
	if (!CreateDockingWindows())
	{
		TRACE0("未能创建停靠窗口\n");
		return -1;
	}

	m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
	m_wndClassView.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndFileView);
	CDockablePane* pTabbedBar = NULL;
	m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);
	m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndOutput);
	m_wndProperties.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndProperties);

	// 基于持久值设置视觉管理器和样式
	OnApplicationLook(theApp.m_nAppLook);

	// 启用增强的窗口管理对话框
	EnableWindowsDialog(ID_WINDOW_MANAGER, ID_WINDOW_MANAGER, TRUE);

	// 启用工具栏和停靠窗口菜单替换
	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// 启用快速(按住 Alt 拖动)工具栏自定义
	CMFCToolBar::EnableQuickCustomization();

	if (CMFCToolBar::GetUserImages() == NULL)
	{
		// 加载用户定义的工具栏图像
		if (m_UserImages.Load(_T(".\\UserImages.bmp")))
		{
			CMFCToolBar::SetUserImages(&m_UserImages);
		}
	}

	// 启用菜单个性化(最近使用的命令)
	// TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。
	CList<UINT, UINT> lstBasicCommands;

	lstBasicCommands.AddTail(ID_FILE_NEW);
	lstBasicCommands.AddTail(ID_FILE_OPEN);
	lstBasicCommands.AddTail(ID_FILE_SAVE);
	lstBasicCommands.AddTail(ID_FILE_PRINT);
	lstBasicCommands.AddTail(ID_APP_EXIT);
	lstBasicCommands.AddTail(ID_EDIT_CUT);
	lstBasicCommands.AddTail(ID_EDIT_PASTE);
	lstBasicCommands.AddTail(ID_EDIT_UNDO);
	lstBasicCommands.AddTail(ID_APP_ABOUT);
	lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
	lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA);
	lstBasicCommands.AddTail(ID_VIEW_APPLOOK_WINDOWS_7);
	lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC);
	lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE);
	lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS);
	lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE);

	CMFCToolBar::SetBasicCommands(lstBasicCommands);

	return 0;
}
Esempio n. 30
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	BOOL bNameValid;

	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}

	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

	// prevent the menu bar from taking the focus on activation
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	CString strToolBarName;
	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
	ASSERT(bNameValid);
	m_wndToolBar.SetWindowText(strToolBarName);

	CString strCustomize;
	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);

	if (!m_wndStatusBar.Create(this))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));

	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
// 	m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
// 	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
// 	EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndMenuBar);
// 	DockPane(&m_wndToolBar);


	// enable Visual Studio 2005 style docking window behavior
	CDockingManager::SetDockingMode(DT_SMART);
	// enable Visual Studio 2005 style docking window auto-hide behavior
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// Load menu item image (not placed on any standard toolbars):
	CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0);

	// create docking windows
	if (!CreateDockingWindows())
	{
		TRACE0("Failed to create docking windows\n");
		return -1;
	}

	m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndFileView);
	CDockablePane* pTabbedBar = NULL;
	m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
	DockPane(&m_wndOutput);


	// set the visual manager used to draw all user interface elements
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2008));

	// Enable toolbar and docking window menu replacement
	EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// enable quick (Alt+drag) toolbar customization
	CMFCToolBar::EnableQuickCustomization();

	// enable menu personalization (most-recently used commands)
	// TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command.
	CList<UINT, UINT> lstBasicCommands;

	lstBasicCommands.AddTail(ID_FILE_NEW);
	lstBasicCommands.AddTail(ID_FILE_OPEN);
	lstBasicCommands.AddTail(ID_FILE_SAVE);
	lstBasicCommands.AddTail(ID_FILE_PRINT);
	lstBasicCommands.AddTail(ID_APP_EXIT);
	lstBasicCommands.AddTail(ID_EDIT_CUT);
	lstBasicCommands.AddTail(ID_EDIT_PASTE);
	lstBasicCommands.AddTail(ID_EDIT_UNDO);
	lstBasicCommands.AddTail(ID_APP_ABOUT);
	lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
	lstBasicCommands.AddTail(ID_VIEW_TOOLBAR);
	lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC);
	lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE);
	lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS);
	lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE);

	CMFCToolBar::SetBasicCommands(lstBasicCommands);

	return 0;
}