Ejemplo n.º 1
0
BOOL CIbnCommandWnd::SendScreenCaptureCommand(CComBSTR Command, CComBSTR Mode, CComBSTR RecipientsXml)
{
	// Create Hwnd String
	WCHAR wsTmpBuf[20];
	_ltow((long)pMessenger->GetSafeHwnd(),wsTmpBuf,10);
	
	CComBSTR bstrClientHwnd = wsTmpBuf;
	
	// Create Xml Command
	CComBSTR sendXML;
	
	sendXML += CComBSTR(L"<");
	sendXML += Command;
	sendXML += CComBSTR(L">");
	
	sendXML += CComBSTR(L"<request>");
	sendXML += CComBSTR(L"<ibnClientHandle>");
	sendXML += bstrClientHwnd;
	sendXML += CComBSTR(L"</ibnClientHandle>");
	
	sendXML += CComBSTR(L"<mode>");
	sendXML += Mode;
	sendXML += L"</mode>";
	
	if(RecipientsXml.Length()>0)
	{
		sendXML += CComBSTR(L"<recipients>");
		sendXML += RecipientsXml; 
		sendXML += L"</recipients>";
	}
	
	sendXML += CComBSTR(L"</request>");
	
	sendXML += CComBSTR(L"</");
	sendXML += Command;
	sendXML += CComBSTR(L">");

	// Test Only
	//sendXML = L"<clientInfo></clientInfo>";

	// TODO: Find Screen Capture Window
	LPCTSTR szScreenCaptureClassName = _T("#32770");
	LPCTSTR szScreenCaptureWindowName = _T("{19791104-A59E-42e5-BB49-200706080000}");
	
	CWnd *pScreenCaptureCommandWnd = FindWindow(szScreenCaptureClassName,szScreenCaptureWindowName);
	
	if(pScreenCaptureCommandWnd==NULL)
	{
		// TODO:
		CString screenCapurePath = pMessenger->ScreenCapturePath();

		// Run Screen Capture
		if(screenCapurePath.GetLength()>0)
		{
			HINSTANCE retVal = ShellExecute(::GetDesktopWindow(),NULL,screenCapurePath,_T(""),NULL,SW_SHOWNORMAL);
			
			if((int)retVal>32)
			{
				// Find Screen Capture Window Again
				for(int index=0;index<20;index++)
				{
					Sleep(500);

					pScreenCaptureCommandWnd = FindWindow(szScreenCaptureClassName,szScreenCaptureWindowName);
					if(pScreenCaptureCommandWnd!=NULL)
						break;
				}
			}
		}

	}

	if(pScreenCaptureCommandWnd!=NULL)
	{
		// Send WM_COPYDATA
		COPYDATASTRUCT copyDs = {0};
		
		copyDs.cbData = (sendXML.Length()+1)*2; // Specifies the size, in bytes, of the data pointed to by the lpData member. 
		copyDs.lpData = (PVOID)(BSTR)sendXML; // Pointer to data to be passed to the receiving application. This member can be NULL. 
		
		LRESULT bResult = pScreenCaptureCommandWnd->SendMessage(WM_COPYDATA, 
			(WPARAM)GetSafeHwnd(), 
			(LPARAM)&copyDs);
		
		return TRUE;
	}
	
	return FALSE;
}
Ejemplo n.º 2
0
void CCustomPropSheet::ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag)
{
	TEXTMETRIC tmCurrent = { 0 }, tmNew = { 0 };
	CRect rectWindow;
	CString strClassName;

	// grab current and new text metrics
	CDC* pDC = pWnd->GetDC();
	CFont* pPrevFont = pDC->SelectObject(pWnd->GetFont());
	pDC->GetTextMetrics(&tmCurrent);
	pDC->SelectObject(pFont);
	pDC->GetTextMetrics(&tmNew);
	pDC->SelectObject(pPrevFont);
	pWnd->ReleaseDC(pDC);

#if defined(_DEBUG)
	LOGFONT lfCurrent = { 0 }, lfNew = { 0 };
	pWnd->GetFont()->GetLogFont(&lfCurrent);
	TRACE(_T("Current font: %s, %i\n"), lfCurrent.lfFaceName, lfCurrent.lfHeight);
	pFont->GetLogFont(&lfNew);
	TRACE(_T("New font: %s, %i\n"), lfNew.lfFaceName, lfNew.lfHeight);
#endif   // _DEBUG

	long nCurHeight = tmCurrent.tmHeight + tmCurrent.tmExternalLeading;
	long nNewHeight = tmNew.tmHeight + tmNew.tmExternalLeading;

	if (nFlag != CDF_NONE)
	{
		// calculate new dialog window rectangle
		CRect rectClient, rectNewClient, rectNewWindow;

		pWnd->GetWindowRect(rectWindow);
		pWnd->GetClientRect(rectClient);
		long dxWidth = rectWindow.Width() - rectClient.Width();
		long dyHeight = rectWindow.Height() - rectClient.Height();

		rectNewClient.left = rectNewClient.top = 0;
		rectNewClient.right = rectClient.right * tmNew.tmAveCharWidth / tmCurrent.tmAveCharWidth;
		rectNewClient.bottom = rectClient.bottom * nNewHeight / nCurHeight;

		switch (nFlag)
		{
		case CDF_TOPLEFT:
			// resize with origin at top/left of window
			rectNewWindow.left = rectWindow.left;
			rectNewWindow.top = rectWindow.top;
			rectNewWindow.right = rectWindow.left + rectNewClient.right + dxWidth;
			rectNewWindow.bottom = rectWindow.top + rectNewClient.bottom + dyHeight;
			break;
		case CDF_CENTER:
			// resize with origin at center of window
			rectNewWindow.left = rectWindow.left - (rectNewClient.right - rectClient.right) / 2;
			rectNewWindow.top = rectWindow.top - (rectNewClient.bottom - rectClient.bottom) / 2;
			rectNewWindow.right = rectNewWindow.left + rectNewClient.right + dxWidth;
			rectNewWindow.bottom = rectNewWindow.top + rectNewClient.bottom + dyHeight;
			break;
		}
#if !defined(_BUGFIX_)
		pWnd->MoveWindow(rectNewWindow);
#else
		if (pWnd->IsKindOf(RUNTIME_CLASS(CPropertyPage)))
		{
			CRect rectParent;
			CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, pWnd->GetParent());
			ASSERT(pSheet != NULL);
			pSheet->GetClientRect(rectParent);
			pSheet->ScreenToClient(rectNewWindow);
			rectNewWindow.left = min(rectParent.right, max(0L, rectNewWindow.left));
			rectNewWindow.top = min(rectParent.bottom, max(0L, rectNewWindow.top));
			rectNewWindow.right = min(rectNewWindow.right, rectParent.right - rectNewWindow.left);
			rectNewWindow.bottom = min(rectNewWindow.bottom, rectParent.bottom - rectNewWindow.top);
			pWnd->MoveWindow(rectNewWindow);
			if (m_fIsFirstChangeFont)
			{
				::CopyRect(&m_rcPage, rectNewWindow);
				m_fIsFirstChangeFont = false;
			}
		}
		else
		{
			pWnd->MoveWindow(rectNewWindow);
		}
#endif   // _BUGFIX_
	}

	pWnd->SetFont(pFont);

	// iterate through and move all child windows and change their font
	CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD);
	while (pChildWnd != NULL)
	{
		if (!pChildWnd->IsKindOf(RUNTIME_CLASS(CPropertyPage)))
		{
			bool fNoResize = false;

			pChildWnd->SetFont(pFont);
			pChildWnd->GetWindowRect(rectWindow);

			// window class specific cases
			::GetClassName(*pChildWnd, strClassName.GetBuffer(_MAX_PATH), _MAX_PATH);
			strClassName.ReleaseBuffer();
			strClassName.MakeUpper();
			if (strClassName == _T("COMBOBOX"))
			{
				CRect rectDropped;
				pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&rectDropped);
				rectWindow.right = rectDropped.right;
				rectWindow.bottom = rectDropped.bottom;
			}
			else if (strClassName == _T("STATIC"))
			{
				WORD wStaticType = LOWORD(pChildWnd->GetStyle() & SS_TYPEMASK);
				fNoResize = wStaticType == SS_ICON || wStaticType == SS_BITMAP;
			}

			pWnd->ScreenToClient(rectWindow);
			SIZE sizWindow = { rectWindow.Width(), rectWindow.Height() };
			rectWindow.left = rectWindow.left * tmNew.tmAveCharWidth / tmCurrent.tmAveCharWidth;
			rectWindow.top = rectWindow.top * nNewHeight / nCurHeight;
			if (fNoResize)
			{
				// just move
				rectWindow.right = rectWindow.left + sizWindow.cx;
				rectWindow.bottom = rectWindow.top + sizWindow.cy;
			}
			else
			{
				// resize
				rectWindow.right = rectWindow.right * tmNew.tmAveCharWidth / tmCurrent.tmAveCharWidth;
				rectWindow.bottom = rectWindow.bottom * nNewHeight / nCurHeight;
			}
			pChildWnd->MoveWindow(rectWindow);
		}

		pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
	}
}
void CKSInputDialog::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	CDC memDC;
	CBitmap bkBit,*oldBkBit;
	CRect client;
	RECT clientRect,edtRect;
	dc.GetClipBox(client);
	if(memDC.CreateCompatibleDC(&dc))
	{
		memDC.SetBkMode(TRANSPARENT);
		if(bkBit.CreateCompatibleBitmap(&dc,client.Width(),client.Height()))
		{
			oldBkBit = memDC.SelectObject(&bkBit);
			/*
			CBrush brh;
			brh.CreateSolidBrush( RGB(0,0,255) );
			brh.UnrealizeObject();
			memDC.FillRect( client , &brh );
			*/
			if(m_config)
			{
				CRect parentRect;
				CWnd * parentWnd = GetParent();
				ASSERT(parentWnd != NULL);
				parentWnd->GetWindowRect(parentRect);
				GetWindowRect(&clientRect);
				m_config->m_bkImg.m_Dest.x = -(clientRect.left);
				m_config->m_bkImg.m_Dest.y = -(clientRect.top);
				m_config->m_bkImg.m_DestSize.cx = parentRect.Width();
				m_config->m_bkImg.m_DestSize.cy = parentRect.Height();
				m_config->m_bkImg.m_Src.x = 0;
				m_config->m_bkImg.m_Src.y = 0;
				m_config->m_bkImg.m_SrcSize.cx = m_config->m_bkImg.GetWidth();
				m_config->m_bkImg.m_SrcSize.cy = m_config->m_bkImg.GetHeight();
				m_config->m_bkImg.Display(&memDC);
				/*
				dc.StretchBlt(0,0,client.Width(),client.Height(),&memDC
				,0,0,m_config->m_bkImg.GetWidth(),m_config->m_bkImg.GetHeight(),SRCCOPY);
				*/
			}
			//////////////////////////////////////////////////////////////////////////
			// 设置字体
			LOGFONT lf;
			memset(&lf,0,sizeof lf);
			lf.lfCharSet = GB2312_CHARSET;
			strcpy(lf.lfFaceName,m_fontName.GetBuffer(1));
			lf.lfHeight = m_fontSize;
			lf.lfWeight = FW_BOLD;			

			CFont font;
			CFont *pOldFont;						// 新添加的老字体资源
			font.CreateFontIndirect(&lf);
			// memDC.SelectObject(font);			// 隐掉
			pOldFont = memDC.SelectObject(&font);	// 新添加获得老字体资源		
			//////////////////////////////////////////////////////////////////////////
			// 取得字体属性
			TEXTMETRIC tm;
			memset(&tm,0,sizeof tm);
			memDC.GetTextMetrics(&tm);
			CSize fs = memDC.GetTextExtent(m_prompt);
			int textWidth = fs.cx;//tm.tmAveCharWidth * (m_prompt.GetLength() + 1);
			//////////////////////////////////////////////////////////////////////////
			// 设置字体颜色
			memDC.SetTextColor(m_fontColor);
			//////////////////////////////////////////////////////////////////////////
			GetWindowRect(&clientRect);
			ScreenToClient(&clientRect);
			m_edtInput.GetWindowRect(&edtRect);
			ScreenToClient(&edtRect);
			int x,y;
			RECT textRect;
			if(clientRect.right > textWidth)
			{
				x = (clientRect.right - textWidth) / 2;
				textRect.left = x;
				textRect.right = textRect.left + textWidth;
			}
			else
			{
				x = 20;
				textRect.left = x;
				textRect.right = clientRect.right - 20;
			}
			
			//y = (edtRect.top - tm.tmHeight - 2);
			y = 5;
			memDC.MoveTo(x,y);
			textRect.top = y;
			
			textRect.bottom = y + GetTextLineHeight(fs.cy,textRect.right-textRect.left
				,fs.cx);
			memDC.DrawText(m_prompt,&textRect,DT_WORDBREAK|DT_CENTER);
			//////////////////////////////////////////////////////////////////////////
			
			dc.BitBlt(0,0,client.Width(),client.Height(),&memDC,0,0,SRCCOPY);
			memDC.SelectObject(pOldFont);				// 新添加的把老字体资源选回去
			font.DeleteObject();
			//brh.DeleteObject();
			memDC.SelectObject(oldBkBit);
			memDC.DeleteDC();
		}
	}
}
Ejemplo n.º 4
0
long CCompileEditView::Compile(CDlgFormulaEdit* pDlg, LPARAM lParam /*= 0*/)
{
	if(m_pListCtrl != NULL)
	{ 
		m_pListCtrl->DeleteAllItems();
	}

	if( m_pParentDlg == NULL && pDlg != NULL )
	{
		m_pParentDlg = pDlg;
	}
	if( pDlg == NULL )
		return 0;

	this->SetFocus();

	CString strValue;
	GetRichEditCtrl().GetWindowText(strValue);
	if(strValue.IsEmpty()) 
		return -1;

	CString strName;
	CWnd* pNameEdit = pDlg->GetDlgItem(IDC_NAMEEDIT); // 名称
	if( pNameEdit != NULL )
	{
		pNameEdit->GetWindowText(strName);
	}

	if(strName.IsEmpty())
	{
		MessageBox(_T("请输入名称!"),_T("提示"),MB_ICONINFORMATION);
		if(pNameEdit != NULL)
		{
			pNameEdit->SetFocus();
		}
		return FALSE;
	}

	strName.TrimLeft();
	strName.TrimRight();
	strName.MakeUpper();
	CValue* pValoare = NULL;
	if( pDlg->IsType(CDlgFormulaEdit::Update) )
	{
		if( strName.CompareNoCase(pDlg->m_strOldName) &&
			m_pExternExpression->Lookup(strName,pDlg->m_nExpressType,pValoare) )
		{
			CString strPrompt;
			strPrompt.Format(_T("公式 \"%s\" 已经存在,请改名保存"),strName);
			MessageBox(strPrompt,_T("提示"),MB_ICONINFORMATION);
			pNameEdit->SetFocus();
			((CEdit*)pNameEdit)->SetSel(0,-1);
			return 0;
		}

		if( m_pExternExpression->Lookup(pDlg->m_strOldName,pDlg->m_nExpressType,pValoare) )
		{
		}
	}
	else if ( m_pExternExpression->Lookup(strName,pDlg->m_nExpressType,pValoare) )
	{
		if( pDlg->IsType(CDlgFormulaEdit::NewExp) )
		{
			CString strPrompt;
			strPrompt.Format(_T("公式 \"%s\" 已经存在,请改名保存"),strName);
			MessageBox(strPrompt,_T("提示"),MB_ICONINFORMATION);
			pNameEdit->SetFocus();
			((CEdit*)pNameEdit)->SetSel(0,-1);
			return 0;
		}
	}
	
	CExpression* pExpresie = new CExpression(m_pExternExpression,
		m_pExternVariabile,m_pExternFunction);

	if( pDlg)
	{
		pDlg->AddToParamerList(pExpresie);
	}

	//CWnd* pPromptWnd = m_pParentDlg->GetDlgItem(IDC_PROMTEDIT);
	//CWnd* pBtError = m_pParentDlg->GetDlgItem(IDC_ERROR);
	CWnd* pPromptWnd = m_pParentDlg->m_pErrorDlg;
	CString strErroText;

	nodErrorInfo info(0,0,0,strName);
	int nErrorCount = pExpresie->ChangeExpression(strValue);
	if( nErrorCount == 0 )
	{
		strErroText = _T("公式编译(测试)通过!");
		CTreeCtrlFormula* pHxTreeCtrl = NULL;	

		BOOL bAdd = FALSE;
		CExpValue* pValue = NULL;
		if(pValoare != NULL)
		{
			pValue = (CExpValue*)pValoare;
			CExpression* pOldExpress = pValue->GetExp();
			if(pOldExpress != NULL)
			{
				pExpresie->SetExpressType(pDlg->m_nExpressType);
				//qinhn 20090729 Add 保证在修改编译公式时,其"常用指标"的属性不变
				if (pOldExpress->IsStyle(HS_EXP_DEFAULT_TECH))
				{
					pExpresie->AddStyle(HS_EXP_DEFAULT_TECH);
				}
				//qinhn 20090729 Add End
			}
			pValue->Clean();

			if( pDlg->IsType(CDlgFormulaEdit::Update) &&
				strName.CompareNoCase(pDlg->m_strOldName) )
			{
				m_pExternExpression->RemoveKey(pDlg->m_strOldName,pDlg->m_nExpressType);
				bAdd = TRUE;
			}
		}
		else
		{
			pExpresie->SetExpressType(pDlg->m_nExpressType);
		}

		if(pValue == NULL)
		{
			pValue = new CExpValue;
			bAdd   = TRUE;
		}

		pValue->SetValue(pExpresie);
		pExpresie->SetName(strName);
		//qinhn 20090727 modify  设置类型,只编译保存则类型不变
		if (CDlgFormulaEdit::bNeedChangeStyle )
			pExpresie->AddStyle( ((!pDlg->m_nMainChart)?HS_EXP_MAINCHART:HS_EXP_SUBCHART) );
		else
			pExpresie->AddStyle(((!pDlg->m_CharType)?HS_EXP_MAINCHART:HS_EXP_SUBCHART));
		pExpresie->AddStyle( HS_EXP_OUTTYPE(pDlg->m_dStyle) );
		CDlgFormulaEdit::bNeedChangeStyle = false;
		//qinhn 20090717 modify End

		if( bAdd )
		{
			m_pExternExpression->AddExpress(strName,pValue);
		}

		CString strText;
		CWnd* pWnd = pDlg->GetDlgItem(IDC_DESCRIBEEDIT);    // 公式描述
		if(pWnd != NULL)
		{
			pWnd->GetWindowText(strText);
			pExpresie->SetDescribe(strText);
		}
		pWnd = pDlg->GetDlgItem(IDC_PWDEDIT);        // 密码
		if(pWnd != NULL && !(pWnd->GetStyle() & WS_DISABLED) )
		{
			pWnd->GetWindowText(strText);
			pExpresie->SetPWD(strText);
		}
		
		if(pDlg->m_pDlgNotes != NULL)  // 注释
		{
			strText = pDlg->m_pDlgNotes->GetText();
			pExpresie->SetNotes(strText); 
		}
		
		if( pDlg->m_pDlgEidolon )       // 参数精灵
		{
			strText = pDlg->m_pDlgEidolon->GetText();
			pExpresie->SetEidolon(strText);
		}

		if( m_pEstopPeriodDlg != NULL )
		{
			*pExpresie->GetEstopPeriod()   = m_pEstopPeriodDlg->GetEstopPeriod();   // 禁用周期
			*pExpresie->GetDefaultPeriod() = m_pEstopPeriodDlg->GetDefaultPeriod(); // 缺省周期
		}

		// 更新树
		if( pDlg->m_pFormulaMan != NULL )
		{
			pHxTreeCtrl = pDlg->m_pFormulaMan->GetCurTree((WORD)pDlg->m_nExpressType);
			if(pHxTreeCtrl != NULL)
			{
				//pExpresie->SetExpressType(pHxTreeCtrl->GetType());

				if(pValoare != NULL)
				{	
					//pHxTreeCtrl->UpdateTreeItemData(pValoare,pValue);
				}
				else
				{
					if(pDlg != NULL)
					{
						pDlg->SetTitle(pExpresie->GetExpressType(),strName);
					}

					pHxTreeCtrl->AddItem(strName,pValue,m_pExternExpression);

					if( pDlg->IsType(CDlgFormulaEdit::NewExp) )
					{
						pDlg->m_strOldName = strName;
						pExpresie->AddStyle(HS_EXP_USEREDIT);
						pDlg->SetType(CDlgFormulaEdit::Update | pDlg->IsType(CDlgFormulaEdit::SpeedNew));
					}
				}
			}
		}

		// 更新绘图窗口
		ExpPropery NameProp;
		NameProp.m_dExpType = pExpresie->GetExpressType();
		NameProp.m_strName.Format("%s", pExpresie->GetName());
		NameProp.m_strDescribe.Format("%s",  pExpresie->GetDescribe());
		NameProp.m_bStyle = pExpresie->GetStyle();
		if ( g_pFormulaMan )
			g_pFormulaMan->SendLinkMsg(DiagramMsg_FormulaParamChanged,(LPARAM)&NameProp);

		if(pPromptWnd != NULL)
		{
			pPromptWnd->SendMessage(HX_USER_COMPILE_INFO,0,0);
			//pPromptWnd->SetWindowText(strErroText);
		}

		m_pParentDlg->ShowResult(CDlgFormulaEdit::CompileResult);
		::SendMessage(g_hParentWnd,g_SendReLoadTabItemMsg,0,0); //qinhn 20090721 Add 重新载入T指标ab页,防止点修改公式对话框里面的"保存"后出错
		
		return (long)pExpresie;
	}
	else
	{
		/*strErroText = "公式有几个错误!";
		if(pBtError != NULL)
		{
			pBtError->EnableWindow(TRUE);
		}
		if(pPromptWnd != NULL)
		{
			pPromptWnd->SetWindowText(strErroText);
		}*/

		//AddCompileInfotoList(11,(LPARAM)&info);


		m_pParentDlg->ShowResult(CDlgFormulaEdit::CompileResult);

		delete pExpresie;
	}

	return 0;
}
Ejemplo n.º 5
0
void COXDragDockContext::EndDrag()
{
    CancelDrag();
	if (m_ptStart == m_ptLast)
		return;
	
	m_dwOverDockStyle = m_bForceFrame ? 0 : CanDock();
	if (m_dwOverDockStyle != 0)
	{
		// dockbar we're going to dock at.
		CDockBar* pDockBar = GetDockBar();
        ASSERT(pDockBar != NULL);
    
        // check the original dockbar - if a valid CSizeDockBar...
		// work out the row number.
		CDockBar* pOrigDockBar = m_pBar->m_pDockBar;
		int nOrigCheckSum = -1;
		if (pOrigDockBar != NULL && 
			pOrigDockBar->IsKindOf(RUNTIME_CLASS(COXSizeDockBar)))
			nOrigCheckSum = ((COXSizeDockBar*)pOrigDockBar)->CheckSumBars();

		// Now we're going to actually dock the window.
		
		// Update the appropriate size in the control bar.
		if (HORZF(m_dwOverDockStyle)) 
		{
			((COXSizeControlBar*)m_pBar)->m_HorzDockSize = m_rectDragDock.Size();
		}
		else
		{
			((COXSizeControlBar*)m_pBar)->m_VertDockSize = m_rectDragDock.Size();
		}
		
        m_pDockSite->DockControlBar(m_pBar, pDockBar, m_rectDragDock);
        
		// if into a sizeable dockbar (always we be !), then adjust other bars in the same row
		// to attempt to maintain size
		if (pDockBar->IsKindOf(RUNTIME_CLASS(COXSizeDockBar)))
		{
			if (pOrigDockBar != pDockBar || 
				((COXSizeDockBar*)pDockBar)->CheckSumBars() != nOrigCheckSum)
			{
				((COXSizeDockBar*)pDockBar)->AdjustForNewBar(m_pBar);
			}
			// force RecalcLayout below to adjust sizes always for the bar into 
			// which we have docked  - this is needed as if the bar doesn't 
			// actually changed position in the array, but has changed size 
			// (because the docking algorithm above guess the size wrong, then 
			// we need to set it back again.
			((COXSizeDockBar*)pDockBar)->m_CountBars = 0;			
		}
		// This RecalcLayout is what will adjust the size.
		m_pDockSite->RecalcLayout();
	}
    else
	{
    	m_ptMRUFloatPos = m_rectFrameDragHorz.TopLeft();
		m_pDockSite->FloatControlBar(m_pBar, m_rectFrameDragHorz.TopLeft(),
			CBRS_ALIGN_TOP | (m_dwDockStyle & CBRS_FLOAT_MULTI));
		m_pBar->SendMessage(WM_OX_APP_AFTERFLOAT_MSG);
		
		// set flag to indicate user has moved the bar - done as a style flag on the window.
		CWnd* pFrameWnd = m_pBar->GetParentFrame();
		ASSERT(pFrameWnd->IsKindOf(RUNTIME_CLASS(CMiniDockFrameWnd)));
		pFrameWnd->ModifyStyle(0, CBRS_MOVED_BY_USER);		
	}
}
Ejemplo n.º 6
0
BOOL CInputDoc::doRunProcessors(CRemoteCommand* pRemoteCmd/*=NULL*/)
{
	CWnd* pWnd = getWindow();
	if(pWnd)
		pWnd->BringWindowToTop();

	if(IsModified())	// if changed the contents of the file we're processing
		OnSaveDocument(GetPathName());

	CCarlaLanguage *pSourceLang = getProcessingPrefs()->getSrcLang(); // could be null
	CCarlaLanguage *pTargetLang = getProcessingPrefs()->getTarLang(); // could be null
	ASSERTX(m_strPathName.GetLength());

	#define GOAL getProcessingPrefs()->getGoal()

	// on remote calls, we can override user prefs. Sorry this is all so ugly
	if(pRemoteCmd)
	{
		getProcessingPrefs()->setGoal(pRemoteCmd->iGoal);
		pSourceLang = pRemoteCmd->pSourceLang ;
		if(pSourceLang)
			getProcessingPrefs()->setSrcLang(pSourceLang);
		pTargetLang = pRemoteCmd->pTargetLang;
		if(pTargetLang)
			getProcessingPrefs()->setTarLang(pTargetLang);
		SetModifiedFlag(TRUE);// will also fix the title
	}

	// make the new status structure, which keeps track of which files have been
	// created and are in line for processing, among other things

	if(m_pProcessStatus)
		delete m_pProcessStatus;
	m_pProcessStatus = new CProcessStatus(m_strPathName,
								getProcessingPrefs(),
								pSourceLang,
								(pSourceLang!=0)?pSourceLang->getMFS():NULL,
								pTargetLang,
								(pTargetLang!=0)?pTargetLang->getMFS():NULL);

	//----- ask Shoebox, if it is running, to do a save all
	// note: if this was invoked by a call from CSRemote, then the send will hang us forever
	// thus, we have this bRemoteCall flag to prevent that.  If we are called from
	// Shoebox, it will have saved everything anyways as part of its batch file command
	if(!pRemoteCmd)
		SendMessage(HWND_BROADCAST, wm_RemoteSaveAll, NULL, NULL);

	//------ SETUP THE TEMP DIRECTORY ----------------------

	if( getCanDoAnalysis() || getProcessingPrefs()->getDoTransfer()
			|| getProcessingPrefs()->getDoInterlinearize()) // JDH 5/28/99 Added to allow Interlinearizing ANA files
	{
		ASSERTX(pSourceLang);
		if (!m_pProcessStatus->setupTempDir(pSourceLang->getName()))
			return FALSE;
	}
	else	// synthesis only
	{
		ASSERTX(pTargetLang);
		if (!m_pProcessStatus->setupTempDir(pTargetLang->getName()))
			return FALSE;
	}

	// load stuff that processors will commonly need, but which doesn't really
	// belong conceptually to the mfs into it, so that the processors can avoid
	// having to know about CCarlaLanguage just to get at the comment character, for example

	if(pSourceLang)
		pSourceLang->prepareMFSForProcessors();
	if(pTargetLang)
		pTargetLang->prepareMFSForProcessors();

	//---- SETUP PROGRESS BAR
	if( getCanDoAnalysis())
		m_pProcessStatus->expectSequenceWithCount(getSrcLang()->getAnalysisSequence()->getProcessorCount());
	if( getProcessingPrefs()->getDoInterlinearize())
		m_pProcessStatus->expectSequenceWithCount(getSrcLang()->getInterlinearSequence()->getProcessorCount());

	if(getProcessingPrefs()->getDoTransfer())
	{
		CTransferProcessSequence* pTSeq = getSrcLang()->getTransferSequence( pTargetLang);
		if(pTSeq)
			m_pProcessStatus->expectSequenceWithCount(pTSeq->getProcessorCount());
	}
	if(getProcessingPrefs()->getDoSynthesis())	// actually, i think you *always* have a synth seq
	{
		CSynthesisProcessSequence* pSSeq = getSrcLang()->getSynthesisSequence();
		if(pSSeq)
			m_pProcessStatus->expectSequenceWithCount(pSSeq->getProcessorCount());
	}


	//---- BRING THE CONTROL FILES UP TO DATE ON THE DISK
	theApp.getProject()->synchronizeExternals();

	//---- ANALYSIS ----------------------------------------------------------

	BOOL bOK = TRUE;
	if( getCanDoAnalysis())
	{
		CProcessSequence* pAnalysisSequence = getSrcLang()->getAnalysisSequence();

		m_pProcessStatus->setCurrentSequenceFunction(pAnalysisSequence->getFunctionCode());
		m_pProcessStatus->setInputLang(pSourceLang);
		m_pProcessStatus->setOutputLang(NULL);
		// do the analysis

		bOK = pAnalysisSequence->continueProcessing(m_pProcessStatus);

		// copy the analyzed text to the user's directory
		if(bOK )
		{
			CPathDescriptor newPath(pSourceLang->getMFS()->getOutputDirAnalyzedANA()+m_pProcessStatus->m_sFileNameRoot+".ana");
			redirectOutputFile(GOAL, CProcessingPrefs::kSourceAna,
				m_pProcessStatus->sANAPath,
				newPath,
				m_pProcessStatus);
		}
	}

	//---- INTERLINEAR ----------------------------------------------------------

	if(bOK && getProcessingPrefs()->getDoInterlinearize())
	{
		ASSERTX(pSourceLang);
		CProcessSequence* pS = pSourceLang->getInterlinearSequence();
		ASSERTX(pS);

		m_pProcessStatus->setInputLang(pSourceLang);
#ifndef hab15a4
		m_pProcessStatus->setOutputLang(pSourceLang); // hab 1999.09.17
		// a final CC pass will use the Output Language;
		// it needs to be set to the Source lang here (at least it worked for me...)
#else
		m_pProcessStatus->setOutputLang(NULL);
#endif
		m_pProcessStatus->setCurrentSequenceFunction(pS->getFunctionCode());
		bOK = pS->continueProcessing(m_pProcessStatus);

		if(bOK )//&& GOAL==CProcessingPrefs::kGlossedInterlinear)
		{
			CString sDestDir;
			CPathDescriptor newPath ;
			if(pRemoteCmd)
			{
				switch(pRemoteCmd->eOutputLocation)
				{
					case CRemoteCommand::csSameFolderAsInput:
							sDestDir = ::getDirectory(m_strPathName);
							break;
					case CRemoteCommand::csSpecifiedPath:
					case CRemoteCommand::csReplaceInput:
							newPath = pRemoteCmd->sDesiredOutputPath;
							break;
					default: throw("Unknown OutputLocation setting");
							break;
				}
			}
			else if(getProcessingPrefs()->m_dwFlags & CProcessingPrefs::kOutputItxToSameDir) // for morris
				sDestDir = ::getDirectory(m_strPathName);
			else // copy to interlinear output dir
				sDestDir = pSourceLang->getMFS()->getOutputDirInterlinear();

			if(newPath.GetLength() == 0)
				newPath = sDestDir+m_pProcessStatus->m_sFileNameRoot+".itx";
			//m_pProcessStatus->sInterlinearPath.copyTo(newPath);

			redirectOutputFile(GOAL, CProcessingPrefs::kGlossedInterlinear,
				m_pProcessStatus->sInterlinearPath,
				newPath,
				m_pProcessStatus);

			if(pRemoteCmd)
				pRemoteCmd->sActualOutputPath=newPath;
		}
	}

	//---- TRANSFER ----------------------------------------------------------

	if(bOK && getProcessingPrefs()->getDoTransfer())
	{
		//CCarlaLanguage* pTarget = getProcessingPrefs()->getTarLang();
		ASSERTX(pTargetLang);
		CTransferProcessSequence* pTransferSequence = getSrcLang()->getTransferSequence(pTargetLang);
		ASSERTX(pTransferSequence);
		m_pProcessStatus->setInputLang(pSourceLang);
		m_pProcessStatus->setOutputLang(pTargetLang);
		m_pProcessStatus->setCurrentSequenceFunction(pTransferSequence->getFunctionCode());

		bOK = pTransferSequence->continueProcessing(m_pProcessStatus);
		if(bOK )//&& GOAL==CProcessingPrefs::kTargetANA)
		{
			//CPathDescriptor x = pTargetLang->getMFS()->getOutputDirTransferedANA();
			//CString z = "s" + x  + "v";

			CPathDescriptor newPath(pTargetLang->getMFS()->getOutputDirTransferedANA()+m_pProcessStatus->m_sFileNameRoot+".ana");
			redirectOutputFile(GOAL, CProcessingPrefs::kTargetANA,
				m_pProcessStatus->sANAPath,
				newPath,
				m_pProcessStatus);
			//m_pProcessStatus->sANAPath.copyTo(pTargetLang->getMFS()->getOutputDirTransferedANA()+m_pProcessStatus->m_sFileNameRoot+".ana");

			if(pRemoteCmd)
				pRemoteCmd->sActualOutputPath=newPath;
		}
	}

	//---- SYNTHESIS ----------------------------------------------------------

	if(bOK && getProcessingPrefs()->getDoSynthesis())
	{
		ASSERTX(pTargetLang);
		//CCarlaLanguage* pTarget = getProcessingPrefs()->getTarLang();
		CProcessSequence* pS = pTargetLang->getSynthesisSequence();
		ASSERTX(pS);
#ifndef hab15a4
		m_pProcessStatus->setInputLang(pTargetLang); // hab 1999.09.17
		// a final CC pass will use the Input Language;
		// it needs to be set to the Target lang here  (at least it worked for me...)
#else
		m_pProcessStatus->setInputLang(NULL);
#endif
		m_pProcessStatus->setOutputLang(pTargetLang);
		m_pProcessStatus->setCurrentSequenceFunction(pS->getFunctionCode());
		bOK = pS->continueProcessing(m_pProcessStatus);

		// copy the synthesized text to the user's directory
		if(bOK)// && GOAL==CProcessingPrefs::kTargetText)
		{
			CPathDescriptor newPath;
			CString sDestDir;
			if(pRemoteCmd)
			{
				switch(pRemoteCmd->eOutputLocation)
				{
					case CRemoteCommand::csSameFolderAsInput:
							sDestDir = ::getDirectory(m_strPathName);
							break;
					case CRemoteCommand::csSpecifiedPath:
							newPath = pRemoteCmd->sDesiredOutputPath;
							break;
					// this case now allowed by csbridge, but would be if they scripted directly
					case CRemoteCommand::csReplaceInput:
							throw("Whoops.  You probably didn't mean to say that CStudio should do a transfer that overwrites the initial file.");
							break;
					default: throw("Unknown OutputLocation setting");
							break;
				}
			}
			else
				sDestDir = pTargetLang->getMFS()->getOutputDirSynthesizedText();

			if(newPath.GetLength() == 0)
				newPath = sDestDir+m_pProcessStatus->m_sFileNameRoot+"_"+pTargetLang->getAbrev()+".txt";

			redirectOutputFile(GOAL, CProcessingPrefs::kTargetText,
				m_pProcessStatus->sRAWPath,
				newPath,
				m_pProcessStatus);
			if(pRemoteCmd)
					pRemoteCmd->sActualOutputPath=newPath;
		}
	}

	if(bOK)
		m_pProcessStatus->finishedProcessing();
		storeAvailablePanels();

	loadResultPanels(bOK, m_pProcessStatus); // don't warn about missing files if there was an error already reported
	m_pProcessStatus->closeProgressDialog();

	ASSERTX(m_pView);	//!!!!!!!WHO'S SETTING THIS?
	m_pView->updatePanels();

#ifndef rde265
	//----- ask Shoebox, to refresh all (if this isn't a remote command)
	if(!pRemoteCmd)
#else
	//----- ask Shoebox, if it is running, to do a save all
#endif  // rde265
	PostMessage(HWND_BROADCAST, wm_RemoteRefreshAll, NULL, NULL);	// don't wait for it to finish that

	return bOK;
}
Ejemplo n.º 7
0
void CSplitterWndEx::RecalcLayout()
{
    ASSERT_VALID(this);
    ASSERT(m_nRows > 0 && m_nCols > 0); // must have at least one pane

    CRect rectClient;
    GetClientRect(rectClient);
    rectClient.InflateRect(-m_cxBorder, -m_cyBorder);
    rectClient.top += m_upBorder;

    CRect rectInside;
    GetInsideRect(rectInside);

    // layout columns (restrict to possible sizes)
    LayoutRowCol(m_pColInfo, m_nCols, rectInside.Width(), m_cxSplitterGap);
    LayoutRowCol(m_pRowInfo, m_nRows, rectInside.Height(), m_cySplitterGap);

    // adjust the panes (and optionally scroll bars)

    // give the hint for the maximum number of HWNDs
    AFX_SIZEPARENTPARAMS layout;
    layout.hDWP = ::BeginDeferWindowPos((m_nCols + 1) * (m_nRows + 1) + 1);

    // size of scrollbars
    int cx = (rectClient.right - rectInside.right - bNotWin4);// - afxData.bNotWin4;
    int cy = (rectClient.bottom - rectInside.bottom - bNotWin4);// - afxData.bNotWin4;

    // reposition size box
    if (m_bHasHScroll && m_bHasVScroll) {
        CWnd* pScrollBar = GetDlgItem(AFX_IDW_SIZE_BOX);
        ASSERT(pScrollBar != NULL);

        // fix style if necessary
        BOOL bSizingParent = (GetSizingParent() != NULL);
        // modifyStyle returns TRUE if style changes
        if (pScrollBar->ModifyStyle(SBS_SIZEGRIP|SBS_SIZEBOX,
                bSizingParent ? SBS_SIZEGRIP : SBS_SIZEBOX))
            pScrollBar->Invalidate();
        pScrollBar->EnableWindow(bSizingParent);

        // reposition the size box
        DeferClientPos(&layout, pScrollBar,
            rectInside.right + bNotWin4,
            rectInside.bottom + bNotWin4, cx, cy, TRUE);
    }

    // reposition scroll bars
    if (m_bHasHScroll) {
        int cxSplitterBox = m_cxSplitter + bNotWin4;// split box bigger
        int x = rectClient.left;
        int y = rectInside.bottom + bNotWin4;
        for (int col = 0; col < m_nCols; col++) {
            CWnd* pScrollBar = GetDlgItem(AFX_IDW_HSCROLL_FIRST + col);
            ASSERT(pScrollBar != NULL);
            int cx = m_pColInfo[col].nCurSize;
            if (col == 0 && m_nCols < m_nMaxCols)
                x += cxSplitterBox, cx -= cxSplitterBox;
            DeferClientPos(&layout, pScrollBar, x, y, cx, cy, TRUE);
            x += cx + m_cxSplitterGap;
        }
    }

    if (m_bHasVScroll) {
        int cySplitterBox = m_cySplitter + bNotWin4;// split box bigger
        int x = rectInside.right + bNotWin4;
        int y = rectClient.top;
        for (int row = 0; row < m_nRows; row++)
        {
            CWnd* pScrollBar = GetDlgItem(AFX_IDW_VSCROLL_FIRST + row);
            ASSERT(pScrollBar != NULL);
            int cy = m_pRowInfo[row].nCurSize;
            if (row == 0 && m_nRows < m_nMaxRows)
                y += cySplitterBox, cy -= cySplitterBox;
            DeferClientPos(&layout, pScrollBar, x, y, cx, cy, TRUE);
            y += cy + m_cySplitterGap;
        }
    }

    //BLOCK: Reposition all the panes
    {
        int x = rectClient.left;
        for (int col = 0; col < m_nCols; col++) {
            int cx = m_pColInfo[col].nCurSize;
            int y = rectClient.top;
            for (int row = 0; row < m_nRows; row++) {
                int cy = m_pRowInfo[row].nCurSize;
                CWnd* pWnd = GetPane(row, col);
                DeferClientPos(&layout, pWnd, x, y, cx, cy, FALSE);
                y += cy + m_cySplitterGap;
            }
            x += cx + m_cxSplitterGap;
        }
    }

    // move and resize all the windows at once!
    if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP))
        TRACE0("Warning: DeferWindowPos failed - low system resources.\n");

    // invalidate all the splitter bars (with NULL pDC)
    DrawAllSplitBars(NULL, rectInside.right, rectInside.bottom);
}
void CDirEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
    CDlgWnd *pp;                           // Parent = the dialog itself
    VERIFY(pp = (CDlgWnd *)GetParent());

    if (nChar == '\t')
    {
        // Because we are getting all keys (see OnGetDlgCode()) so that we can get the Return key,
        // we also get the tab key as a side-effect.  This means that the tabbing between controls
        // in the dialog will stop at the edit control unless we force it to go to the next control.
        CWnd *pWnd = pp->GetDlgItem(IDC_OPEN);
        ASSERT(pWnd != NULL);
        pWnd->SetFocus();                       // Set focus to Open button
    }
    else if (nChar == '\r' || nChar == '\n')
    {
        // If return key is pressed we change to the directory specified OR
        // if the directory name appears valid but does not exist we ask the
        // user if they want to create it.  Note that the string is not
        // validated (although some validation may be done by Windows
        // via the CheckDir() call).  The name is only checked to see if
        // it is possible that a directory needs to be created.
        // Full validation is deferred till the "Open" button is clicked.

        CString ss;
        GetWindowText(ss);
        int len = ss.GetLength();

        // Remove trailing backslash unless root directory or network root
        if (strcmp(ss,"\\") != 0 && strcmp(ss,"\\\\") != 0 && strcmp((const char *)ss+1,":\\") != 0 &&
            len > 0 && ss[len-1] == '\\' )
        {
            ss = ss.Left(--len);
        }

        if (len == 0 || 
            len == 1 && ss[0] == '\\' ||
            len >= 2 && ss[0] == '\\' && ss[1] == '\\' && strchr((const char *)ss+2, '\\') == NULL ||
            len == 2 && ss[1] == ':' ||
            len == 3 && ss[1] == ':' && ss[2] == '\\' )
        {
            // Definitely not a createable directory
            pp->CheckDir(ss);
        }
        else
        {
            // Check if it's an existing directory
            CFileStatus fs;

            DWORD attr = GetFileAttributes(ss);
            if (attr == 0xFFFFFFFF)
            {
                // Directory not found but maybe it's an invalid drive
                _TCHAR rootdir[4] = _T("?:\\");
                rootdir[0] = ss[0];

                if (len == 1 || (len > 1 && ss[1] != ':') ||
                    GetDriveType(rootdir) > DRIVE_NO_ROOT_DIR)
                {
                    // Appears to be a valid drive (or relative path)
                    CString mess(ss);
                    mess += _T("\nThis folder does not exist.\n\n"
                          "Do you want to create it?");
                    if (AfxMessageBox(mess, MB_YESNO) == IDYES)
                    {
                        if (!::MakeSureDirectoryPathExists(ss + _T("\\")))
                        {
                            switch (GetDriveType(rootdir))
                            {
                            case DRIVE_CDROM:
                                AfxMessageBox(_T("You cannot create this folder\n"
                                              "as the CD ROM medium is read-only."));
                                break;
                            case DRIVE_REMOVABLE:
                                AfxMessageBox(_T("You cannot create this folder.\n"
                                              "The medium may be write-protected."));
                                break;
                            case DRIVE_REMOTE:
                                AfxMessageBox(_T("You do not have permission to create\n"
                                              "this folder on the network."));
                                break;
                            default:
                                AfxMessageBox(_T("You do not have permission or\n"
                                              "otherwise cannot create this folder."));
                                break;
                            }
                            return;
                        }
                    }
                    else
                        return;
                }
            }
            pp->CheckDir(ss);
            // Make sure the directory name ends with backslash so user can type sub-drectory name
            GetWindowText(ss);
            if (ss[ss.GetLength()-1] != '\\')
            {
                ss += "\\";
                SetWindowText(ss);
            }
            SetSel(ss.GetLength(), -1);
        }
        SetFocus();                         // Make sure caret stays in this edit control
    }
    else
    {
        CEdit::OnChar(nChar, nRepCnt, nFlags);

        // Get the text and check whether it is a valid directory
        CString ss;                         // Current text in the edit control
        GetWindowText(ss);

        int len = ss.GetLength();
        int start, end;                     // Current selection
        GetSel(start, end);

        if (ss.Compare(_T("\\\\")) == 0)
        {
            // Don't check \\ else we get a message about "\\" being an invalid filename
            ;
        }
        else if (ss.Compare(_T("\\")) == 0)
        {
            // Show root directory
            pp->CheckDir(ss);
        }
        else if (len == 3 && ss[1] == ':' && ss[2] == '\\')
        {
            // Check that it's a valid drive
            if (GetDriveType(ss) > DRIVE_NO_ROOT_DIR)
            {
                pp->CheckDir(ss);
            }
        }
        else if (len > 0 && ss[len-1] == '\\')
        {
            // Check that it's a valid directory
            // xxx does not handle "\\anwar\"
            DWORD attr = GetFileAttributes(ss);
            if (attr != 0xFFFFFFFF && (attr & FILE_ATTRIBUTE_DIRECTORY) != 0)
            {
                pp->CheckDir(ss);
            }
        }
        else if (start == len && nChar != '\b')
        {
            // Try to do completion of the directory name
            CFileFind ff;                   // Used to find directory names that start with ss
            int count = 0;                  // Number of matching directory names
            CString strMatch;               // The last directory found that matches

            BOOL bContinue = ff.FindFile(ss + "*");

            while (bContinue)
            {
                // At least one match - check them all
                bContinue = ff.FindNextFile();

                if (ff.IsDirectory())
                {
                    // Found a matching directory
                    ++count;
                    strMatch = ff.GetFileName();
                }
            }

            // If there was exactly one matching directory use it
            if (count == 1)
            {
                int ii;
                // The file open dialog changes all uppercase names to lower case with an initial
                // capital (eg WINDOWS displays as Windows).  We do the same so things look nicer.
                for (ii = 0; ii < strMatch.GetLength(); ++ii)
                {
                    // Don't change if it contains spaces or lowercase letters
                    if (isspace(strMatch[ii]) || islower(strMatch[ii]))
                        break;
                }

                ASSERT(ii <= strMatch.GetLength());
                if (!strMatch.IsEmpty() && ii == strMatch.GetLength())
                {
                    CString temp = strMatch.Mid(1);
                    temp.MakeLower();
                    strMatch = strMatch.Left(1) + temp;
                }


                // Get the bit of the directory name that the user has not yet typed
                int lb_len;             // Length of last bit (after \ or :)
                lb_len = ss.ReverseFind('\\');
                if (lb_len == -1) lb_len = ss.ReverseFind('/');
                if (lb_len == -1) lb_len = ss.ReverseFind(':');
                if (lb_len == -1)
                    lb_len = ss.GetLength();
                else
                    lb_len = ss.GetLength() - (lb_len+1);

                // Check if the last char is the same case as the same char in the matched name
                if (!ss.IsEmpty() && lb_len > 0 && strMatch[lb_len-1] != ss[ss.GetLength()-1])
                {
                    // The user used different case to that of the corresponding character in
                    // the matched directory so change the matched name to be the user's case.
                    if (isupper(ss[ss.GetLength()-1]))
                        strMatch.MakeUpper();
                    else
                        strMatch.MakeLower();
                }

#ifdef _DEBUG
                CString temp = strMatch.Left(lb_len);
                ASSERT(temp.CompareNoCase(ss.Right(lb_len)) == 0);
#endif
                end += strMatch.GetLength() - lb_len;
                SetWindowText(ss + strMatch.Mid(lb_len));
                SetSel(start, end);
            }

            // else if (count > 1) pop-up some sort of selection list???
        }
        SetFocus();                         // Make sure caret stays in this edit control
    }
}
void CDirDialog::OnInitDone()
{
    CRect rct;                          // Used to move/resize controls
    CWnd *pp;                           // Parent = the dialog window itself
    VERIFY(pp = GetParent());

    ASSERT(pp->GetDlgItem(stc3) != NULL);
    pp->GetDlgItem(stc3)->SetWindowText(_T("Folder:"));

    // Create a new CDlgWnd so we can catch dialog control notifications
    VERIFY(m_DlgWnd.SubclassWindow(pp->m_hWnd));

    // Create a new edit control where edt1 now is
    ASSERT(pp->GetDlgItem(edt1) != NULL);
    pp->GetDlgItem(edt1)->GetWindowRect(rct); //Get edt1 rectangle
    pp->ScreenToClient(rct);

    VERIFY(m_Edit.Create(WS_TABSTOP | WS_VISIBLE | WS_CHILD,
                           rct, pp, IDC_DIR));
    if (m_ofn.lpstrInitialDir  != NULL)
        m_Edit.SetWindowText(m_ofn.lpstrInitialDir);
    m_Edit.SetFont(pp->GetDlgItem(edt1)->GetFont());
    m_Edit.ModifyStyleEx(0, WS_EX_CLIENTEDGE, SWP_DRAWFRAME);
    m_Edit.SetWindowPos(pp->GetDlgItem(stc3), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
//  m_Edit.SetSel(0, strlen(m_ofn.lpstrInitialDir));

    CWnd *pCancel = pp->GetDlgItem(IDCANCEL);
    ASSERT(pCancel != NULL);

    // Create a new button where the OK button now is
    ASSERT(pp->GetDlgItem(IDOK) != NULL);
    pp->GetDlgItem(IDOK)->GetWindowRect(rct); //Get OK button rectangle
    pp->ScreenToClient(rct);

    m_Open.Create(_T("Open"), WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
                    rct, pp, IDC_OPEN);
    m_Open.SetFont(pp->GetDlgItem(IDOK)->GetFont());
    m_Open.SetWindowPos(&m_Edit, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

    pCancel->SetWindowPos(&m_Open, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);

    // Change default push button
    pp->GetDlgItem(IDOK)->ModifyStyle(BS_DEFPUSHBUTTON, 0);
    pp->SendMessage(DM_SETDEFID, IDC_OPEN);

#ifdef DIRDIALOG_TESTING
    // Move controls (rather than hide them) for testing

    // Increase size of dialog
    pp->GetWindowRect(rct);
    pp->SetWindowPos(NULL, 0, 0, rct.Width(), rct.Height() + 70, SWP_NOZORDER | SWP_NOMOVE);

    // Move the replaced controls down
    ASSERT(pp->GetDlgItem(IDOK) != NULL);
    pp->GetDlgItem(IDOK)->GetWindowRect(rct);
    pp->ScreenToClient(rct);
    pp->GetDlgItem(IDOK)->SetWindowPos(NULL, rct.left, rct.top+70,
                   0, 0, SWP_NOZORDER | SWP_NOSIZE);

    ASSERT(pp->GetDlgItem(edt1) != NULL);
    pp->GetDlgItem(edt1)->GetWindowRect(rct);
    pp->ScreenToClient(rct);
    pp->GetDlgItem(edt1)->SetWindowPos(NULL, rct.left, rct.top+70,
                   0, 0, SWP_NOZORDER | SWP_NOSIZE);

#else
    // Hide the controls we don't want the user to use
    HideControl(IDOK);
    HideControl(edt1);
#endif

    CFileDialog::OnInitDone();
}
Ejemplo n.º 10
0
void CFileManagerDlg::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu)
{
  // 	CDialogEx::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
  AfxCancelModes(m_hWnd);

  if (bSysMenu)
    return;     // don't support system menu

  ENSURE_VALID(pMenu);

  // check the enabled state of various menu items

  CCmdUI state;
  state.m_pMenu = pMenu;
  ASSERT(state.m_pOther == NULL);
  ASSERT(state.m_pParentMenu == NULL);

  // determine if menu is popup in top-level menu and set m_pOther to
  //  it if so (m_pParentMenu == NULL indicates that it is secondary popup)
  HMENU hParentMenu;
  if (AfxGetThreadState()->m_hTrackingMenu == pMenu->m_hMenu)
    state.m_pParentMenu = pMenu;    // parent == child for tracking popup
  else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
  {
    CWnd* pParent = GetTopLevelParent();
    // child windows don't have menus -- need to go to the top!
    if (pParent != NULL &&
      (hParentMenu = pParent->GetMenu()->GetSafeHmenu()) != NULL)
    {
      int nIndexMax = ::GetMenuItemCount(hParentMenu);
      for (int nItemIndex = 0; nItemIndex < nIndexMax; nItemIndex++)
      {
        if (::GetSubMenu(hParentMenu, nItemIndex) == pMenu->m_hMenu)
        {
          // when popup is found, m_pParentMenu is containing menu
          state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
          break;
        }
      }
    }
  }

  state.m_nIndexMax = pMenu->GetMenuItemCount();
  for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
    state.m_nIndex++)
  {
    state.m_nID = pMenu->GetMenuItemID(state.m_nIndex);
    if (state.m_nID == 0)
      continue; // menu separator or invalid cmd - ignore it

    ASSERT(state.m_pOther == NULL);
    ASSERT(state.m_pMenu != NULL);
    if (state.m_nID == (UINT)-1)
    {
      // possibly a popup menu, route to first item of that popup
      state.m_pSubMenu = pMenu->GetSubMenu(state.m_nIndex);
      if (state.m_pSubMenu == NULL ||
        (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
        state.m_nID == (UINT)-1)
      {
        continue;       // first item of popup can't be routed to
      }
      state.DoUpdate(this, FALSE);    // popups are never auto disabled
    }
    else
    {
      // normal menu item
      // Auto enable/disable if frame window has 'm_bAutoMenuEnable'
      //    set and command is _not_ a system command.
      state.m_pSubMenu = NULL;
      state.DoUpdate(this, state.m_nID < 0xF000);
    }

    // adjust for menu deletions and additions
    UINT nCount = pMenu->GetMenuItemCount();
    if (nCount < state.m_nIndexMax)
    {
      state.m_nIndex -= (state.m_nIndexMax - nCount);
      while (state.m_nIndex < nCount &&
        pMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
      {
        state.m_nIndex++;
      }
    }
    state.m_nIndexMax = nCount;
  }
}
Ejemplo n.º 11
0
LRESULT CTxMsgChildFrame::vUserCommand(WPARAM wParam, LPARAM lParam)
{

    if( m_pomTxMsgBlocksView != NULL &&
            m_pomTxMsgDetailsView != NULL &&
            m_pomTxMsgListView != NULL &&
            m_pomFunctionsView != NULL )
    {
        INT nBase              = 0;
        BOOL bTxON             = FALSE;
        BOOL bConnect          = FALSE;
        eUSERSELCTION eUserSel = eDATABASEIMPORTCMD;
        //CFlags * pouFlag       = NULL;

        eUserSel               = static_cast <eUSERSELCTION>(wParam);
        switch(eUserSel)
        {
            case eHEXDECCMD:
                //// Get the flag status.
                //pouFlag = pouGetFlagsPtr();
                //if ( pouFlag != NULL )
                //{
                //    nBase    = pouFlag->nGetFlagStatus( HEX );
                //}
                nBase = (INT)lParam;
                // Check if the flag is changed and if so,
                // change the display format.
                if(nBase != CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_HEX))
                {
                    CTxMsgManager::s_TxFlags.vSetFlagStatus(TX_HEX, nBase);
                    // Hide any edit controls if it is visible
                    m_pomTxMsgDetailsView->m_omLctrSigList.SetFocus();

                    if ( m_pomTxMsgBlocksView->m_psMsgBlockList != NULL )
                    {
                        PSMSGBLOCKLIST psMsgBlock =
                            m_pomTxMsgBlocksView->psGetMsgBlockPointer(
                                m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex,
                                m_pomTxMsgBlocksView->m_psMsgBlockList );
                        if(psMsgBlock != NULL)
                        {
                            m_pomTxMsgListView->
                            m_omLctrMsgList.DeleteAllItems();
                            m_pomTxMsgBlocksView->
                            vDisplayMsgBlockDetails(psMsgBlock);
                        }
                    }
                    m_pomTxMsgBlocksView->vSetControlProperties();
                    m_pomTxMsgDetailsView->vSetControlProperties();
                    // Clear the controls after changing the properties.
                    m_pomTxMsgDetailsView->vSetValues(NULL);
                    // Remove all entries in the list and disable
                    m_pomTxMsgDetailsView->vDisableSignalComponents();
                    // Disable Delete Button & Send Button as the focus is lost
                    m_pomTxMsgListView->
                    m_omButtonDeleteSelMsg.EnableWindow(FALSE);
                    m_pomTxMsgListView->
                    m_omButtonSendMsg.EnableWindow(FALSE);
                    m_pomTxMsgListView->m_nSelectedMsgIndex = -1;
                    // Set Lable to indicate Mode
                    CString omStrText = CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_HEX) ?
                                        _(defSTR_HEX_MODE) : _(defSTR_DEC_MODE);
                    CWnd* pomLabel =
                        m_pomTxMsgDetailsView->GetDlgItem(IDC_STAT_HEADER2);
                    if( pomLabel != NULL )
                    {
                        // Set the text with Hex/Dec mode
                        pomLabel->SetWindowText(omStrText);
                    }
                }
                break;
            case eTXMSGCMD:
                // Get the flag status.
                /*pouFlag = pouGetFlagsPtr();
                if(pouFlag != NULL )
                {
                    bTxON    =
                        static_cast<BOOL> (pouFlag->nGetFlagStatus( SENDMESG ));
                }*/
                bTxON = (BOOL)lParam;
                // If transmission is ON, user should not be able to
                // delete any message or block.
                if(bTxON != CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_SENDMESG))
                {
                    CTxMsgManager::s_TxFlags.vSetFlagStatus(TX_SENDMESG, bTxON);
                    // Get the message count and disable if
                    // there is some message list in the currently
                    // selected block.
                    if ( m_pomTxMsgBlocksView->m_psMsgBlockList != NULL )
                    {
                        PSMSGBLOCKLIST psMsgBlock =
                            m_pomTxMsgBlocksView->psGetMsgBlockPointer(
                                m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex,
                                m_pomTxMsgBlocksView->m_psMsgBlockList );

                        if(psMsgBlock != NULL)
                        {
                            if( psMsgBlock->m_unMsgCount > 0 )
                            {
                                m_pomTxMsgListView->m_omButtonDeleteAllMsg.
                                EnableWindow(!bTxON);
                            }
                        }
                        //If it is key triggered then Enable/Diable All Messages
                        //Check box and Key val edit box
                        if( IS_KEY_TRIGGERED (psMsgBlock->m_ucTrigger) )
                        {
                            /*m_pomTxMsgBlocksView->m_omButtonTxAllFrame.
                            EnableWindow(!bTxON);*/
                            m_pomTxMsgBlocksView->m_omComboAllMsgs.EnableWindow(!bTxON);
                            m_pomTxMsgBlocksView->m_omEditTrgKeyVal.
                            EnableWindow(!bTxON);
                        }

                        if(bTxON)
                        {
                            m_pomTxMsgBlocksView->m_omComboAllMsgs.EnableWindow(!bTxON);
                            m_pomTxMsgBlocksView->m_omEditTrgKeyVal.
                            EnableWindow(!bTxON);
                        }


                        //AUC
                        //only if DElay btn msg blocks check box is not checked den check time trigger button
                        if(((CButton*) m_pomTxMsgBlocksView->
                                GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->GetCheck() == BST_UNCHECKED)
                        {
                            m_pomTxMsgBlocksView->m_omButtonTimeTrigger.
                            EnableWindow(!bTxON);
                            // If it is time triggered then time interval edit box
                            if( IS_TIME_TRIGGERED (psMsgBlock->m_ucTrigger) )
                            {
                                m_pomTxMsgBlocksView->m_omEditTrgTimeIntervalVal.
                                EnableWindow(!bTxON);
                            }
                        }
                        ((CButton*) m_pomTxMsgBlocksView->GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->EnableWindow(!bTxON);

                        if((((CButton*) m_pomTxMsgBlocksView->
                                GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->IsWindowEnabled() == TRUE)&&
                                ((CButton*) m_pomTxMsgBlocksView->
                                 GetDlgItem(IDC_CHECK_MSG_BLOCK_DELAY))->GetCheck() == BST_CHECKED)
                        {
                            ((CEdit*) m_pomTxMsgBlocksView->
                             GetDlgItem(IDC_EDIT_BLOCK_TRG_TIMER_VAL))->EnableWindow(TRUE);
                        }
                        else
                        {
                            ((CEdit*) m_pomTxMsgBlocksView->
                             GetDlgItem(IDC_EDIT_BLOCK_TRG_TIMER_VAL))->EnableWindow(FALSE);
                        }
                        m_pomTxMsgBlocksView->m_omButtonKeyTrigger.
                        EnableWindow(!bTxON);
                        CButton* pRadioMonoshot = (CButton*)m_pomTxMsgBlocksView->GetDlgItem(IDC_RADIOMONOSHOT);
                        CButton* pRadioCyclic = (CButton*)m_pomTxMsgBlocksView->GetDlgItem(IDC_RADIOCYCLIC);
                        if ((pRadioMonoshot != NULL) && (pRadioCyclic != NULL))
                        {
                            pRadioMonoshot->EnableWindow(!bTxON);
                            pRadioCyclic->EnableWindow(!bTxON);
                        }
                        m_pomTxMsgBlocksView->m_omButtonAddMsgBlock.EnableWindow(!bTxON);
                        m_pomTxMsgBlocksView->m_omEditMsgBlockName.EnableWindow(!bTxON);
                        /*m_pomTxMsgBlocksView->m_omButtonTriggerType.
                                                        EnableWindow(!bTxON);*/
                    }

                    if( m_pomTxMsgListView->m_nSelectedMsgIndex != -1 )
                    {
                        m_pomTxMsgListView->m_omButtonDeleteSelMsg.
                        EnableWindow(!bTxON);
                    }
                    if(m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex !=
                            -1 )
                    {
                        m_pomTxMsgBlocksView->m_omButtonDeleteMsgBlock.
                        EnableWindow(!bTxON);
                    }

                    // Set the focus to the block list control if transmission is started
                    // to capture the key events
                    if (bTxON)
                    {
                        m_pomTxMsgBlocksView->m_omLctrMsgBlockName.SetFocus();
                    }
                }
                break;
            case eCONNECTCMD:
                // Get the flag status.
                /*pouFlag = pouGetFlagsPtr();
                if(pouFlag != NULL )
                {
                    bConnect = static_cast<BOOL>
                                  (pouFlag->nGetFlagStatus( CONNECTED ));
                }*/
                bConnect = (BOOL)lParam;
                // If the tool is disconnected, user should not be able
                // send any message.

                if(bConnect != CTxMsgManager::s_TxFlags.nGetFlagStatus(TX_CONNECTED))
                {
                    if( m_pomTxMsgListView->m_nSelectedMsgIndex != -1 )
                    {
                        m_pomTxMsgListView->m_omButtonSendMsg.
                        EnableWindow(bConnect);
                    }
                    else
                    {
                        m_pomTxMsgListView->m_omButtonSendMsg.
                        EnableWindow(FALSE);
                    }
                    CTxMsgManager::s_TxFlags.vSetFlagStatus(TX_CONNECTED, bConnect);
                }
                break;

            case eDATABASEIMPORTCMD:

                m_pomTxMsgDetailsView->m_omComboMsgIDorName.ResetContent();
                m_pomTxMsgDetailsView->vPopulateMessageComboBox();

                // The icon for database message may change to change the
                // display.
                if ( m_pomTxMsgBlocksView->m_psMsgBlockList != NULL )
                {
                    PSMSGBLOCKLIST psMsgBlock =
                        m_pomTxMsgBlocksView->psGetMsgBlockPointer(
                            m_pomTxMsgBlocksView->m_nSelectedMsgBlockIndex,
                            m_pomTxMsgBlocksView->m_psMsgBlockList );
                    if(psMsgBlock != NULL)
                    {
                        m_pomTxMsgListView->m_omLctrMsgList.DeleteAllItems();
                        m_pomTxMsgBlocksView->
                        vDisplayMsgBlockDetails(psMsgBlock);
                        m_pomTxMsgDetailsView->vUpdateAllBlocksFrmDB();
                        m_pomTxMsgBlocksView->AutoUpdateChanges();
                    }
                }
                m_pomTxMsgDetailsView->vSetValues(NULL);
                // Clear Signal Components
                m_pomTxMsgDetailsView->vDisableSignalComponents();
                // Disable Delete Button & Send Button as the focus is lost
                m_pomTxMsgListView->m_omButtonDeleteSelMsg.EnableWindow(FALSE);
                m_pomTxMsgListView->m_omButtonSendMsg.EnableWindow(FALSE);
                m_pomTxMsgListView->m_nSelectedMsgIndex = -1;
                break;

            case eCHANNELCOUNTUPDATED:
                m_pomTxMsgDetailsView->vUpdateChannelIDInfo();
                break;

            default:
                ASSERT( FALSE );
                break;
        }
    }

    return 0;
}
Ejemplo n.º 12
0
void CFileManagerDlg::DrawBackground(CDC * pDC)
{
  int xx, ww;
  int iSaved = pDC->SaveDC();

  CRect rt;
  GetClientRect(&rt);

  if (m_bmpBGTop.m_hObject == NULL)
    return;

  BITMAP bmTop, bmBottom;
  BITMAP bmNavBar, bmTitle, bmLogo, bmRBCorner;
  m_bmpBGTop.GetBitmap(&bmTop);
  m_bmpBGBottom.GetBitmap(&bmBottom);
  m_bmpNavBar.GetBitmap(&bmNavBar);
  m_bmpTitle.GetBitmap(&bmTitle);
  m_bmpLogo.GetBitmap(&bmLogo);
  m_bmpRBCorner.GetBitmap(&bmRBCorner);

  // Draw Top
  CBrush brush;
  brush.CreatePatternBrush(&m_bmpBGTop);
  CRect rtTop(rt.left, rt.top, rt.right, bmTop.bmHeight);
  pDC->FillRect(&rtTop, &brush);

  BLENDFUNCTION bf;
  memset(&bf, 0, sizeof(bf));
  bf.BlendOp = AC_SRC_OVER;
  bf.BlendFlags = 0;
  bf.SourceConstantAlpha = 255;
  bf.AlphaFormat = AC_SRC_ALPHA;

  CDC dcMem;
  dcMem.CreateCompatibleDC(pDC);

  /*if (!m_bMaximized)*/ {
    CRect rtItem;
    CWnd *pWnd = GetDlgItem(IDC_PIC_SYSMENU);
    if (pWnd != NULL) {
      pWnd->GetWindowRect(&rtItem);
      ScreenToClient(&rtItem);
      int sz = min(rtItem.Width(), rtItem.Height());
      ::DrawIconEx(*pDC, rtItem.left, rtItem.top, m_hIcon,
        sz, sz, 0, NULL, DI_NORMAL);
    }
    pWnd = GetDlgItem(IDC_PIC_TITLE);
    if (pWnd != NULL) {
      pWnd->GetWindowRect(&rtItem);
      ScreenToClient(&rtItem);
      dcMem.SelectObject(&m_bmpTitle);
      int margin = 2;
      pDC->AlphaBlend(
        rtItem.left, rtItem.top, bmTitle.bmWidth, bmTitle.bmHeight,
        &dcMem, 0, 0, bmTitle.bmWidth, bmTitle.bmHeight, bf);
    }
  }

//   CPoint pntLogo = GetLogoPos();
//   dcMem.SelectObject(&m_bmpLogo);
//   pDC->AlphaBlend(pntLogo.x, pntLogo.y, bmLogo.bmWidth, bmLogo.bmHeight,
//     &dcMem, 0, 0, bmLogo.bmWidth, bmLogo.bmHeight, bf);

  // Draw Navigation Bar
  dcMem.SelectObject(&m_bmpNavBar);
  ww = bmNavBar.bmWidth;
  for (xx = rt.left; xx < rt.right; xx += ww) {
    pDC->BitBlt(xx, rt.top + bmTop.bmHeight, ww, bmNavBar.bmHeight,
      &dcMem, 0, 0, SRCCOPY);
  }

  // Draw Bottom
  dcMem.SelectObject(&m_bmpBGBottom);
  ww = bmBottom.bmWidth;
  for (xx = rt.left; xx < rt.right; xx += ww) {
    pDC->BitBlt(xx, rt.bottom - bmBottom.bmHeight, ww, bmBottom.bmHeight,
      &dcMem, 0, 0, SRCCOPY);
  }

  // Draw Right-Bottom Corner
  dcMem.SelectObject(&m_bmpRBCorner);
  int margin = 2;
  pDC->AlphaBlend(
    rt.right - bmRBCorner.bmWidth - margin,
    rt.bottom - bmRBCorner.bmHeight - margin,
    bmRBCorner.bmWidth, bmRBCorner.bmHeight,
    &dcMem, 0, 0, bmRBCorner.bmWidth, bmRBCorner.bmHeight, bf);

  pDC->RestoreDC(iSaved);
}
Ejemplo n.º 13
0
/*******************************************************************************
  Function Name    :  OnInitDialog
  Input(s)         :    -
  Output           :    -
  Functionality    :  Called by the framework to when the dialog control is
                      initialised. The control will be initialised with last
                      used value or default value.
  Member of        :  CDriverInfoDlg
  Friend of        :      -
  Author(s)        :  Raja N
  Date Created     :  07.09.2004
  Modifications    :
*******************************************************************************/
BOOL CDriverInfoDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    // Resize the dialog in USB build
    // Pointer to components
    CWnd* pomWnd = NULL;
    // Hide Copywright message
    pomWnd = GetDlgItem(IDC_STAT_COPYRIGHT);

    if( pomWnd != NULL )
    {
        //pomWnd->SetWindowText("USB driver from Peak Systems");
        pomWnd->ShowWindow ( SW_HIDE );
        // Invalidate
        pomWnd = NULL;
    }

    // Store current control rect and dialog rect
    CRect omRect, omWndRect;
    // Get Dialog Size
    GetWindowRect( &omWndRect );
    // Get the Bottom line object
    pomWnd = GetDlgItem( IDC_STAT_LINE3 );

    if( pomWnd != NULL )
    {
        // Get the position
        pomWnd->GetWindowRect(&omRect);
        omWndRect.bottom = omRect.bottom;
        // Resize the dialog upto botton line
        MoveWindow( omWndRect.left, omWndRect.top, omWndRect.Width(),
                    omWndRect.Height() );
        // Update dialog size
        GetWindowRect( &omWndRect );
        // Invalidate
        pomWnd = NULL;
    }

    // Offset is 1/4th of dialog size
    int nOffset = omWndRect.Height() / 4;
    // Center the Version Label
    pomWnd = GetDlgItem( IDC_STAT_DRIVER_VERSION );

    if( pomWnd != NULL )
    {
        int nWidth = 0, nHeight = 0;
        pomWnd->CenterWindow();
        pomWnd->GetWindowRect( omRect );
        ScreenToClient(omRect);
        nWidth = omRect.Width();
        nHeight = omRect.Height();
        // Move the top to First quarter
        omRect.top =  nOffset - nHeight / 2;
        // Move the window to the new position
        pomWnd->MoveWindow( omRect.left, omRect.top, nWidth, nHeight );
        pomWnd = NULL;
    }

    // Change the position of OK Button
    pomWnd = GetDlgItem ( IDOK );

    if( pomWnd != NULL )
    {
        // Move the button to the center of the dialog
        pomWnd->CenterWindow();
        pomWnd->GetWindowRect( omRect );
        ScreenToClient(omRect);
        int nWidth = 0, nHeight = 0;
        nWidth = omRect.Width();
        nHeight = omRect.Height();
        // Move it to the thired Quarter
        omRect.top = nOffset * 2 - nHeight / 2;
        // Move the window to its new location
        pomWnd->MoveWindow( omRect.left, omRect.top, nWidth, nHeight, TRUE );
        pomWnd = NULL;
    }

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 14
0
void CPolyDlg::OnEnterKey( UINT ctlID )
{
	CString csMsg, csEditstr, csItemNum, newitmstr ;
	int itemnum ;
	CComboBox& combo = m_Combo_Corner ; //convenience

	//Get editbox string
	CWnd* pWnd = (combo.GetWindow(GW_CHILD)) ;
	CWnd* pEditWnd = (pWnd->GetNextWindow()); //pointer to editbox window
	pEditWnd->GetWindowText( csEditstr );
	csEditstr.TrimLeft() ; csEditstr.TrimRight() ;

	int numtokens = GetNumTokens( csEditstr ) ;
	int numitems = combo.GetCount() ;

	//check for too few or too many tokens in the entry string
	if( numtokens < 2 )
	{
		csMsg = "Each entry must have at least X & Y positions " ;
		AfxMessageBox( csMsg + "\n" + csEditstr ) ;
		return ;
	}

	else if( numtokens > 7 )
	{
		csMsg = "Each line can have no more than seven items" ;
		AfxMessageBox( csMsg + "\n" + csEditstr ) ;
		return ;
	}

	//OK, 2 or 3 tokens: get valid X/Y pos
	Vector3D vcrnr = GetCnrVector( csEditstr ) ;

	//3 tokens are considered to be [X Position] [Y Position] [Z Position]
	if( numtokens == 3 )
	{
		//prepend item num & add to end
		itemnum = numitems + 1 ;
		FormatNumStr( csItemNum, itemnum ) ;
		newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, 0, 0, 0 ) ;
		csEditstr = csItemNum + newitmstr ;
		combo.AddString( csEditstr ) ;
		itemnum = GetItemNum( csEditstr ) ;
	}

	// 6 tokens are assumed to be [X Position] [Y Position] [Z Position] [R] [G] [B]
	else if( numtokens == 6 )
	{
		COLORREF col = GetCnrColor( csEditstr ) ;
		int R = GetRValue( col ) ;
		int G = GetGValue( col ) ;
		int B = GetBValue( col ) ;

		//prepend item num & add to end
		itemnum = numitems + 1 ;
		FormatNumStr( csItemNum, itemnum ) ;
		newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
		csEditstr = csItemNum + newitmstr ;
		combo.AddString( csEditstr ) ;
		itemnum = GetItemNum( csEditstr ) ;
	}

	//otherwise we assume  [Item #] [X Position] [Y Position] [Z Position] [R] [G] [B]
	else
	{
		itemnum = GetItemNum( csEditstr ) ;
		COLORREF col = GetCnrColor( csEditstr ) ;
		int R = GetRValue( col ) ;
		int G = GetGValue( col ) ;
		int B = GetBValue( col ) ;

		//insert at item number or add to end
		if( itemnum > numitems )
		{
			//prepend correct item num & add to end
			itemnum = numitems + 1 ;
			FormatNumStr( csItemNum, itemnum ) ;
			newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
			csEditstr = csItemNum + newitmstr ;
			combo.AddString( csEditstr ) ;

		}
		else if( itemnum < numitems )
		{
			combo.DeleteString( itemnum - 1 ) ;
			FormatNumStr( csItemNum, itemnum ) ;
			newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
			csEditstr = csItemNum + newitmstr ;
			combo.InsertString( itemnum - 1, csEditstr ) ;
		}
		else //itemnum points to last string
		{
			combo.DeleteString( itemnum - 1 ) ;
			FormatNumStr( csItemNum, itemnum ) ;
			newitmstr.Format( m_csCoordFmtStr, vcrnr.x, vcrnr.y, vcrnr.z, R, G, B ) ;
			csEditstr = csItemNum + newitmstr ;
			combo.AddString( csEditstr ) ;
		}
	}

	//leave this item selected
	combo.SetCurSel( itemnum - 1 ) ;

	UpdateControls() ; //added 07/10/03
}
Ejemplo n.º 15
0
void CuDlgIpmTabCtrl::DisplayPage (CuPageInformation* pPageInfo, LPCTSTR lpszHeader, int nSel)
{
	CRect   r;
	TCITEM  item;
	int     i, nPages;
	UINT*   nTabID;
	UINT*   nDlgID;
	CString strTab;
	CString strTitle;
	UINT    nIDD; 
	CWnd*   pDlg;
	try
	{
		CView*   pView = (CView*)GetParent();
		ASSERT (pView);
		CdIpmDoc* pDoc  = (CdIpmDoc*)pView->GetDocument();
		ASSERT (pDoc);
		
		if (m_bIsLoading)
		{
			m_bIsLoading = FALSE;
			pDoc->SetLoadDoc(FALSE);
			// Masqued Emb April 9, 97 for bug fix
			// return;
		}
		if (!pPageInfo)
		{
			if (m_pCurrentPage)
				m_pCurrentPage->ShowWindow (SW_HIDE);
			m_cTab1.DeleteAllItems();
			if (m_pCurrentProperty)
			{
				m_pCurrentProperty->SetPageInfo (NULL);
				delete m_pCurrentProperty;
				m_pCurrentProperty = NULL;
				m_pCurrentPage     = NULL;
			}

			if (lpszHeader)
				m_staticHeader.SetWindowText (lpszHeader);
			else
				m_staticHeader.SetWindowText (_T(""));
			UINT uFlags = SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER;
			m_staticHeader.ResetBitmap (NULL); // No Image
			m_staticHeader.SetWindowPos (NULL, 0, 0, 0, 0, uFlags);
			return;
		}
		ASSERT (!lpszHeader);
		if (!m_pCurrentProperty)
		{
			m_pCurrentProperty = new CuIpmProperty (0, pPageInfo);
			//
			// Set up the Title:
			pPageInfo->GetTitle (strTitle);
			m_staticHeader.SetWindowText (strTitle);

			UINT uFlags = SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER;
			if (!strTitle.IsEmpty())
			{
				switch (pPageInfo->GetImageType())
				{
				case 0:
					m_staticHeader.ResetBitmap (pPageInfo->GetIconImage());
					break;
				case 1:
					m_staticHeader.ResetBitmap (pPageInfo->GetBitmapImage(), pPageInfo->GetImageMask());
					break;
				default:
					m_staticHeader.ResetBitmap (NULL);
				}
			}
			else
				m_staticHeader.ResetBitmap (NULL);
			m_staticHeader.SetWindowPos(NULL, 0, 0, 0, 0, uFlags);
			
			nPages = pPageInfo->GetNumberOfPage();
			if (nPages < 1)
			{
				m_pCurrentPage = NULL;
				return;
			}
			//
			// Construct the Tab(s)
			nTabID = pPageInfo->GetTabID();
			nDlgID = pPageInfo->GetDlgID();
			memset (&item, 0, sizeof (item));
			item.mask       = TCIF_TEXT;
			item.cchTextMax = 32;
			m_cTab1.DeleteAllItems();
			for (i=0; i<nPages; i++)
			{
				strTab.LoadString (nTabID [i]);
				item.pszText = (LPTSTR)(LPCTSTR)strTab;
				m_cTab1.InsertItem (i, &item);
			}
			//
			// Display the default (the first) page, except if context-driven specified tab
			int initialSel = (nSel != -1)? nSel: 0;
			if (initialSel >= nPages)
				initialSel = 0;

			nIDD = pPageInfo->GetDlgID (initialSel); 
			pDlg= GetPage (nIDD);
			m_cTab1.SetCurSel (initialSel);
			m_cTab1.GetClientRect (r);
			m_cTab1.AdjustRect (FALSE, r);
			pDlg->MoveWindow (r);
			pDlg->ShowWindow(SW_SHOW);
			m_pCurrentPage = pDlg;
			//
			// Properties:
			UINT nMask = IPMMASK_FONT|IPMMASK_SHOWGRID;
			m_pCurrentPage->SendMessage (WMUSRMSG_CHANGE_SETTING, (WPARAM)nMask, (LPARAM)&(pDoc->GetProperty()));
			//
			// Update data:
			m_pCurrentPage->SendMessage (WM_USER_IPMPAGE_UPDATEING, (WPARAM)pDoc, (LPARAM)pPageInfo->GetUpdateParam());
		}
		else // !m_pCurrentProperty
		{
			CuPageInformation* pCurrentPageInfo = m_pCurrentProperty->GetPageInfo();
			pPageInfo->GetTitle (strTitle);
			m_staticHeader.SetWindowText (strTitle);
		
			UINT uFlags = SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER;
			if (!strTitle.IsEmpty())
			{
				switch (pPageInfo->GetImageType())
				{
				case 0:
					m_staticHeader.ResetBitmap (pPageInfo->GetIconImage());
					break;
				case 1:
					m_staticHeader.ResetBitmap (pPageInfo->GetBitmapImage(), pPageInfo->GetImageMask());
					break;
				default:
					m_staticHeader.ResetBitmap (NULL);
				}
			}
			else
				m_staticHeader.ResetBitmap (NULL);
			m_staticHeader.SetWindowPos(NULL, 0, 0, 0, 0, uFlags);

			// Cloned from dgdomc02.cpp : pCurrentPageInfo can have become NULL
			// example: current selection was system obj, and system checkbox has been unchecked
			BOOL bNoMoreCurrentClassName = FALSE;
			CString CurrentClassName;
			if (pCurrentPageInfo)
				CurrentClassName = pCurrentPageInfo->GetClassName();
			else
			{
				bNoMoreCurrentClassName = TRUE;
				CurrentClassName = _T("No More Current Class Name!!!");
			}
			CString ClassName        = pPageInfo->GetClassName();
			if ((CurrentClassName == ClassName) && (!bNoMoreCurrentClassName) )
			{
				m_pCurrentProperty->SetPageInfo (pPageInfo);
				//
				// wParam, and lParam will contain the information needed
				// by the dialog to refresh itself.
				if (m_pCurrentPage) 
					m_pCurrentPage->SendMessage (WM_USER_IPMPAGE_UPDATEING, (WPARAM)pDoc, (LPARAM)pPageInfo->GetUpdateParam());
				//
				// Special re-initialize the Activity page of a Static Replication Item
				// It is not optimal, but we have to do like this due to no specification for replication.
				int i;
				for (i=0; i<pPageInfo->GetNumberOfPage(); i++)
				{
					nIDD = pPageInfo->GetDlgID (i); 
					if (nIDD == IDD_REPSTATIC_PAGE_ACTIVITY)
					{
						pDlg= GetPage (nIDD);
						//
						// Properties:
						UINT nMask = IPMMASK_FONT|IPMMASK_SHOWGRID;
						pDlg->SendMessage (WMUSRMSG_CHANGE_SETTING, (WPARAM)nMask, (LPARAM)&(pDoc->GetProperty()));

						//
						// Update data:
						pDlg->SendMessage (WM_USER_IPMPAGE_UPDATEING, (WPARAM)pDoc, (LPARAM)pPageInfo->GetUpdateParam());
						break;
					}
				}
			}
			else
			{
				int initialSel = (nSel != -1)? nSel: 0;
				if (initialSel >= pPageInfo->GetNumberOfPage())
					initialSel = 0;
				if (m_pCurrentPage) 
					m_pCurrentPage->ShowWindow (SW_HIDE);
				m_cTab1.DeleteAllItems();
				nPages = pPageInfo->GetNumberOfPage();
				m_pCurrentProperty->SetPageInfo (pPageInfo);
				m_pCurrentProperty->SetCurSel (initialSel);
				
				if (nPages < 1)
				{
					m_pCurrentPage = NULL;
					return;
				}
				UINT nIDD; 
				CWnd* pDlg;
				//
				// Construct the Tab(s)
				nTabID = pPageInfo->GetTabID();
				nDlgID = pPageInfo->GetDlgID();
				memset (&item, 0, sizeof (item));
				item.mask       = TCIF_TEXT;
				item.cchTextMax = 32;
				m_cTab1.DeleteAllItems();
				for (i=0; i<nPages; i++)
				{
					strTab.LoadString (nTabID [i]);
					item.pszText = (LPTSTR)(LPCTSTR)strTab;
					m_cTab1.InsertItem (i, &item);
				}
				//
				// Display the default (the first) page.
				nIDD = pPageInfo->GetDlgID (initialSel); 
				pDlg= GetPage (nIDD);
				m_cTab1.SetCurSel (initialSel);
				m_cTab1.GetClientRect (r);
				m_cTab1.AdjustRect (FALSE, r);
				pDlg->MoveWindow (r);
				pDlg->ShowWindow(SW_SHOW);
				m_pCurrentPage = pDlg;
				//
				// Properties:
				UINT nMask = IPMMASK_FONT|IPMMASK_SHOWGRID;
				m_pCurrentPage->SendMessage (WMUSRMSG_CHANGE_SETTING, (WPARAM)nMask, (LPARAM)&(pDoc->GetProperty()));
				//
				// Update Data:
				m_pCurrentPage->SendMessage (WM_USER_IPMPAGE_UPDATEING, (WPARAM)pDoc, (LPARAM)pPageInfo->GetUpdateParam());
			}
		}
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		if (m_pCurrentPage)
			m_pCurrentPage->ShowWindow (SW_HIDE);
		if (m_pCurrentProperty)
		{
			m_pCurrentProperty->SetPageInfo (NULL);
			delete m_pCurrentProperty;
		}
		m_pCurrentPage = NULL;
		m_pCurrentProperty = NULL;
		e->Delete();
		return;
	}
	catch (CResourceException* e)
	{
		AfxMessageBox (IDS_E_LOAD_RESOURCE);//"Load resource failed"
		if (m_pCurrentPage)
			m_pCurrentPage->ShowWindow (SW_HIDE);
		if (m_pCurrentProperty)
		{
			m_pCurrentProperty->SetPageInfo (NULL);
			delete m_pCurrentProperty;
		}
		m_pCurrentPage = NULL;
		m_pCurrentProperty = NULL;
		e->Delete();
		return;
	}
}
Ejemplo n.º 16
0
//*******************************************************************************************
BOOL CBCGPFrameWnd::PreTranslateMessage(MSG* pMsg)
{
    BOOL bProcessAccel = TRUE;

    switch (pMsg->message)
    {
    case WM_SYSKEYDOWN:
#ifndef BCGP_EXCLUDE_RIBBON
        if (m_Impl.m_pRibbonBar != NULL && m_Impl.m_pRibbonBar->OnSysKeyDown (this, pMsg->wParam, pMsg->lParam))
        {
            return TRUE;
        }

        if (pMsg->wParam == VK_F4 && m_Impl.m_pRibbonBar != NULL && m_Impl.m_pRibbonBar->IsBackstageViewActive())
        {
            break;
        }
#endif
        if (CBCGPPopupMenu::GetSafeActivePopupMenu() == NULL)
        {
            m_Impl.CancelToolbarMode();
        }

    case WM_CONTEXTMENU:
        if (!globalData.m_bSysUnderlineKeyboardShortcuts && !globalData.m_bUnderlineKeyboardShortcuts)
        {
            globalData.m_bUnderlineKeyboardShortcuts = TRUE;
            CBCGPToolBar::RedrawUnderlines ();
        }

        if (CBCGPPopupMenu::GetSafeActivePopupMenu() != NULL && (pMsg->wParam == VK_MENU || pMsg->wParam == VK_F10))
        {
            CBCGPPopupMenu::m_pActivePopupMenu->SendMessage (WM_CLOSE);
            return TRUE;
        }
        else if (m_Impl.ProcessKeyboard ((int) pMsg->wParam))
        {
            return TRUE;
        }
        break;

    case WM_SYSKEYUP:
        if (m_Impl.ProcessSysKeyUp(pMsg->wParam, pMsg->lParam))
        {
            return TRUE;
        }
        break;

    case WM_KEYDOWN:
        //-----------------------------------------
        // Pass keyboard action to the active menu:
        //-----------------------------------------
        if (!CBCGPFrameImpl::IsHelpKey (pMsg) &&
                m_Impl.ProcessKeyboard ((int) pMsg->wParam, &bProcessAccel))
        {
            return TRUE;
        }

        if (pMsg->wParam == VK_ESCAPE)
        {
            if (IsFullScreen())
            {
                if (!IsPrintPreview())
                {
                    m_Impl.InvokeFullScreenCommand();
                    return TRUE;
                }
            }

            CBCGPSmartDockingManager* pSDManager = NULL;
            if ((pSDManager = m_dockManager.GetSDManagerPermanent()) != NULL &&
                    pSDManager->IsStarted())
            {
                pSDManager->CauseCancelMode ();
            }

            CBCGPSlider* pSlider = DYNAMIC_DOWNCAST (CBCGPSlider, GetCapture ());
            if (pSlider != NULL)
            {
                pSlider->SendMessage (WM_CANCELMODE);
                return TRUE;
            }
        }

        if (!bProcessAccel)
        {
            return FALSE;
        }
        break;

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_RBUTTONUP:
    case WM_MBUTTONDOWN:
    case WM_MBUTTONUP:
    {
        CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam));
        CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd);

        if (pWnd != NULL && ::IsWindow (pMsg->hwnd))
        {
            pWnd->ClientToScreen (&pt);
        }

        if (m_Impl.ProcessMouseClick (pMsg->message, pt, pMsg->hwnd))
        {
            return TRUE;
        }

        if (!::IsWindow (pMsg->hwnd))
        {
            return TRUE;
        }
    }
    break;

    case WM_NCLBUTTONDOWN:
    case WM_NCLBUTTONUP:
    case WM_NCRBUTTONDOWN:
    case WM_NCRBUTTONUP:
    case WM_NCMBUTTONDOWN:
    case WM_NCMBUTTONUP:
        if (m_Impl.ProcessMouseClick (pMsg->message,
                                      CPoint (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)),
                                      pMsg->hwnd))
        {
            return TRUE;
        }
        break;

    case WM_MOUSEWHEEL:
        if (m_Impl.ProcessMouseWheel (pMsg->wParam, pMsg->lParam))
        {
            return TRUE;
        }
        break;

    case WM_MOUSEMOVE:
    {
        CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam));
        CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd);

        if (pWnd != NULL)
        {
            pWnd->ClientToScreen (&pt);
        }

        if (m_Impl.ProcessMouseMove (pt))
        {
            return TRUE;
        }
    }
    }

    return CFrameWnd::PreTranslateMessage(pMsg);
}
Ejemplo n.º 17
0
/**
 * \param bEnable TRUE to enable and FALSE to disable
 *
 * To enable/disable replay UI components
 */
void CReplayFileConfigDlg::vEnableReplayComps( BOOL bEnable )
{
    // File Name
    m_omEditReplayFileName.EnableWindow( bEnable );
    // Time Mode
    m_omChkRetainDelay.EnableWindow( bEnable );
    // User Specific Msg Delay
    // Retain Delay is enabled. So Disable this edit control
    if( m_omChkRetainDelay.GetCheck() == TRUE )
    {
        m_omEditMsgDelay.EnableWindow( FALSE );
    }
    else
    {
        m_omEditMsgDelay.EnableWindow( bEnable );
    }

    // Session Mode
    m_omChkRetainSessionDelay.EnableWindow( bEnable );
    // User Specific session Delay
    // Retain session Delay is enabled. So Disable this edit control
    if( m_omChkRetainSessionDelay.GetCheck() == TRUE )
    {
        m_omEditSessionDelay.EnableWindow( FALSE );
    }
    else
    {
        m_omEditSessionDelay.EnableWindow( bEnable );
    }

    // Delay Between Cycles
    if( m_nReplayMode == 0 )
    {
        m_omEditCycleDelay.EnableWindow( FALSE );
    }
    else
    {
        m_omEditCycleDelay.EnableWindow( bEnable );
    }
    // Interactive Replay Option
    m_omChkInteractive.EnableWindow( bEnable );
    // Repolay Mode Option buttons
    CWnd* pWnd = nullptr;
    // Monoshot
    pWnd = GetDlgItem( IDC_RADIO_REPLAY_MODE_MONO );
    if( pWnd != nullptr )
    {
        pWnd->EnableWindow( bEnable );
    }
    // Cyclic
    pWnd = GetDlgItem( IDC_RADIO_REPLAY_MODE_CYCLIC );
    if( pWnd != nullptr )
    {
        pWnd->EnableWindow( bEnable );
    }
    // Filter Button
    pWnd = GetDlgItem( IDC_BTN_FILTER );
    if( pWnd != nullptr )
    {
        pWnd->EnableWindow( bEnable );
    }
    // Msg Button
    pWnd = GetDlgItem( IDC_COMBO_MSG_TYPE );
    if( pWnd != nullptr )
    {
        pWnd->EnableWindow( bEnable );
    }
}
Ejemplo n.º 18
0
USAGEMODE HRESULT TXFlexRay_vShowConfigureMsgWindow(void* pParentWnd)
{
    //Place this code at the beginning of the export function.
    //Save previous resource handle and switch to current one.
    HINSTANCE hInst = AfxGetResourceHandle();
    AfxSetResourceHandle(TXFlexRayWindowDLL.hResource);
    //AFX_MANAGE_STATE(AfxGetStaticModuleState());

    if( g_pomTxMsgFlexChildWindow == NULL )
    {
        // Create New Instance
        g_pomTxMsgFlexChildWindow = new CTxMsgFlexChildFrame;
        if( g_pomTxMsgFlexChildWindow != NULL )
        {
            //// Register Window Class
            LPCTSTR strMDIClass = AfxRegisterWndClass(
                                      CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS,
                                      LoadCursor(NULL, IDC_CROSS), 0,
                                      ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICO_SEND_MSG)) );

            // Set the size got from configuration module
            WINDOWPLACEMENT sTxWndPlacement;
            SetDefaultWindowPos(sTxWndPlacement);
            WINDOWPLACEMENT* psTxWndPlacement = &sTxWndPlacement;
            CTxFlexRayDataStore::ouGetTxFlexRayDataStoreObj().bGetTxData(TX_WINDOW_PLACEMENT, (void**)&psTxWndPlacement);
            if (sTxWndPlacement.rcNormalPosition.top == -1 ||
                    sTxWndPlacement.length == 0)//Load default configuration
            {
                CRect omRect;
                CWnd* pWnd = (CWnd*)pParentWnd;
                pWnd->GetClientRect(&omRect);
                omRect.NormalizeRect();
                //    // Reduce the size propotionally
                omRect.bottom -= (LONG)(omRect.Height() * defTX_MSG_WND_BOTTOM_MARGIN);
                omRect.right -= (LONG)(omRect.Width() * defTX_MSG_WND_RIGHT_MARGIN);
                //    // Update the size
                //sTxWndPlacement.rcNormalPosition = omRect;

                sTxWndPlacement.flags = 1;
                sTxWndPlacement.length = 44;
                sTxWndPlacement.ptMaxPosition.x = 0;
                sTxWndPlacement.ptMaxPosition.x = 0;
                sTxWndPlacement.ptMinPosition.x = 0;
                sTxWndPlacement.ptMinPosition.y = 0;
                sTxWndPlacement.rcNormalPosition.top = 1;
                sTxWndPlacement.rcNormalPosition.bottom = 661;
                sTxWndPlacement.rcNormalPosition.left = 4;
                sTxWndPlacement.rcNormalPosition.right = 864;
                sTxWndPlacement.showCmd = 1;
            }
            CRect omRect(&(sTxWndPlacement.rcNormalPosition));

            // Create Tx Message Configuration window
            //CRect omRect(0,0,200,200);
            if( g_pomTxMsgFlexChildWindow->Create( strMDIClass,
                                                   "Configure Transmission Messages - FLEXRAY",
                                                   WS_CHILD | WS_OVERLAPPEDWINDOW,
                                                   omRect, (CMDIFrameWnd*)pParentWnd ) == TRUE )
            {
                // Show window and set focus
                g_pomTxMsgFlexChildWindow->ShowWindow( SW_SHOW);
                g_pomTxMsgFlexChildWindow->SetFocus();
                if (sTxWndPlacement.rcNormalPosition.top != -1 &&
                        sTxWndPlacement.length != 0)
                {
                    g_pomTxMsgFlexChildWindow->SetWindowPlacement(&sTxWndPlacement);
                }

            }
        }
        else
        {
            return S_FALSE;
        }
    }
    // If already exist then activate and set the focus
    else
    {
        g_pomTxMsgFlexChildWindow->ShowWindow( SW_RESTORE );
        g_pomTxMsgFlexChildWindow->MDIActivate();
        g_pomTxMsgFlexChildWindow->SetActiveWindow();
    }
    //Place this at the end of the export function.
    //switch back to previous resource handle.
    //   CWnd objParent;
    //objParent.Attach(((CWnd*)pParentWnd)->m_hWnd);

    //objParent.Detach();

    AfxSetResourceHandle(hInst);
    return S_OK;
}
Ejemplo n.º 19
0
LRESULT CALLBACK CCoolMenu::MenuProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	WNDPROC pWndProc = (WNDPROC)::GetProp( hWnd, wpnOldProc );
	
	switch ( uMsg )
	{
	case WM_NCCALCSIZE:
		{
			NCCALCSIZE_PARAMS* pCalc = (NCCALCSIZE_PARAMS*)lParam;
			pCalc->rgrc[0].left ++;
			pCalc->rgrc[0].top ++;
			pCalc->rgrc[0].right --;
			pCalc->rgrc[0].bottom --;
		}
		return 0;
		
	case WM_WINDOWPOSCHANGING:
		if ( WINDOWPOS* pWndPos = (WINDOWPOS*)lParam )
		{
			DWORD nStyle	= GetWindowLong( hWnd, GWL_STYLE );
			DWORD nExStyle	= GetWindowLong( hWnd, GWL_EXSTYLE );
			CRect rc( 0, 0, 32, 32 );
			
			AdjustWindowRectEx( &rc, nStyle, FALSE, nExStyle );
			
			pWndPos->cx -= ( rc.Width() - 34 );
			pWndPos->cy -= ( rc.Height() - 34 ) - 1;
			
			if ( pWndPos->x != m_nEdgeLeft || pWndPos->y != m_nEdgeTop )
				pWndPos->x ++;
		}
		break;
		
	case WM_PRINT:
		if ( ( lParam & PRF_CHECKVISIBLE ) && ! IsWindowVisible( hWnd ) ) return 0;
		if ( lParam & PRF_NONCLIENT )
		{
			CWnd* pWnd = CWnd::FromHandle( hWnd );
			CDC* pDC = CDC::FromHandle( (HDC)wParam );
			CRect rc;
			
			pWnd->GetWindowRect( &rc );
			BOOL bEdge = ( rc.left == m_nEdgeLeft && rc.top == m_nEdgeTop );
			rc.OffsetRect( -rc.left, -rc.top );
			
			pDC->Draw3dRect( &rc, CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
			if ( bEdge ) pDC->FillSolidRect( rc.left + 1, rc.top, min( rc.Width(), m_nEdgeSize ) - 2, 1, CoolInterface.m_crBackNormal );
		}
		if ( lParam & PRF_CLIENT )
		{
			CWnd* pWnd = CWnd::FromHandle( hWnd );
			CDC* pDC = CDC::FromHandle( (HDC)wParam );
			CBitmap bmBuf, *pbmOld;
			CDC dcBuf;
			CRect rc;
			
			pWnd->GetClientRect( &rc );
			dcBuf.CreateCompatibleDC( pDC );
			bmBuf.CreateCompatibleBitmap( pDC, rc.Width(), rc.Height() );
			pbmOld = (CBitmap*)dcBuf.SelectObject( &bmBuf );
			
			m_bPrinted = TRUE;
			dcBuf.FillSolidRect( &rc, GetSysColor( COLOR_MENU ) );
			SendMessage( hWnd, WM_PRINTCLIENT, (WPARAM)dcBuf.GetSafeHdc(), 0 );
			
			pDC->BitBlt( 1, 1, rc.Width(), rc.Height(), &dcBuf, 0, 0, SRCCOPY );
			dcBuf.SelectObject( pbmOld );
		}
		return 0;
		
	case WM_NCPAINT:
		{
			CWnd* pWnd = CWnd::FromHandle( hWnd );
			CWindowDC dc( pWnd );
			CRect rc;
			
			pWnd->GetWindowRect( &rc );
			BOOL bEdge = ( rc.left == m_nEdgeLeft && rc.top == m_nEdgeTop );
			rc.OffsetRect( -rc.left, -rc.top );
			
			dc.Draw3dRect( &rc, CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
			if ( bEdge ) dc.FillSolidRect( rc.left + 1, rc.top, min( rc.Width(), m_nEdgeSize ) - 2, 1, CoolInterface.m_crBackNormal );
		}
		return 0;
		
	case WM_PAINT:
		m_bPrinted = FALSE;
		break;
		
	case WM_NCDESTROY:
		::RemoveProp( hWnd, wpnOldProc );
		break;
	}
	
	return CallWindowProc( pWndProc, hWnd, uMsg, wParam, lParam );
}
BOOL CDialogParticleEditor::OnInitDialog() {
	
	com_editors |= EDITOR_PARTICLE;

	particleMode = ( cvarSystem->GetCVarInteger( "g_editEntityMode" ) == 4 );
	mapModified = false;

	CDialog::OnInitDialog();
	
	sliderBunching.SetRange( 0, 20 );
	sliderBunching.SetValueRange( 0.0f, 1.0f );
	sliderFadeIn.SetRange( 0, 20 );
	sliderFadeIn.SetValueRange( 0.0f, 1.0f );
	sliderFadeOut.SetRange( 0, 20 );
	sliderFadeOut.SetValueRange( 0.0f, 1.0f );
	sliderCount.SetRange( 0, 1024 );
	sliderCount.SetValueRange( 0, 4096 );
	sliderTime.SetRange( 0, 200 );
	sliderTime.SetValueRange( 0.0f, 10.0f );
	sliderGravity.SetRange( 0, 600 );
	sliderGravity.SetValueRange( -300.0f, 300.0f );
	sliderSpeedFrom.SetRange( 0, 600 );
	sliderSpeedFrom.SetValueRange( -300.0f, 300.0f );
	sliderSpeedTo.SetRange( 0, 600 );
	sliderSpeedTo.SetValueRange( -300.0f, 300.0f );
	sliderRotationFrom.SetRange( 0, 100 );
	sliderRotationFrom.SetValueRange( 0.0f, 100.0f );
	sliderRotationTo.SetRange( 0, 100 );
	sliderRotationTo.SetValueRange( 0.0f, 100.0f );
	sliderSizeFrom.SetRange( 0, 256 );
	sliderSizeFrom.SetValueRange( 0.0f, 128.0f );
	sliderSizeTo.SetRange( 0, 256 );
	sliderSizeTo.SetValueRange( 0.0f, 128.0f );
	sliderAspectFrom.SetRange( 0, 256 );
	sliderAspectFrom.SetValueRange( 0.0f, 128.0f );
	sliderAspectTo.SetRange( 0, 256 );
	sliderAspectTo.SetValueRange( 0.0f, 128.0f );
	sliderFadeFraction.SetRange( 0, 20 );
	sliderFadeFraction.SetValueRange( 0.0f, 1.0f );
	
	EnumParticles();
	SetParticleView();

	toolTipCtrl.Create( this );
	toolTipCtrl.Activate( TRUE );

	CWnd* wnd = GetWindow( GW_CHILD );
	CString str;
	while ( wnd ) {
		if ( str.LoadString( wnd->GetDlgCtrlID() ) ) {
			toolTipCtrl.AddTool( wnd, str );
		}
		wnd = wnd->GetWindow( GW_HWNDNEXT );
	}
	
	wnd = GetDlgItem( IDC_BUTTON_SAVE_PARTICLEENTITIES );
	if ( wnd ) {
		wnd->EnableWindow( FALSE );
	}
	EnableEditControls();

	vectorControl.SetVectorChangingCallback( VectorCallBack );

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 21
0
//////////////////
// User pressed mouse: intialize and enter drag state
//
void CSizerBar::OnLButtonDown(UINT nFlags, CPoint pt)
{
	m_bDragging=TRUE;
	m_ptOriginal = m_ptPrevious = Rectify(pt);
	
	GetWindowRect(&m_rcBar); // bar location in screen coords
	
	DrawBar();					 // draw it
	SetCapture();				 // all mouse messages are MINE
	m_hwndPrevFocus = ::SetFocus(m_hWnd);  // set focus to me to get Escape key

	ASSERT(m_pWinMgr);
	CWinMgr& wm = *m_pWinMgr;

	// get WINRECTs on either side of me
	WINRECT* pwrcSizeBar = wm.FindRect(GetDlgCtrlID());
	ASSERT(pwrcSizeBar);
	WINRECT* prev = pwrcSizeBar->Prev();
	ASSERT(prev);
	WINRECT* next = pwrcSizeBar->Next();
	ASSERT(next);

	// get rectangles on eithr side of me
	CRect rcPrev = prev->GetRect();
	CRect rcNext = next->GetRect();

	// get parent window
	CWnd * pParentWnd = GetParent();
	ASSERT(pParentWnd);

	// Get size info for next/prev rectangles, so I know what the min/max
	// sizes are and don't violate them. Max size never tested.
	SIZEINFO szi;
	wm.OnGetSizeInfo(szi, prev, pParentWnd);
	CRect rcPrevMin(rcPrev.TopLeft(),szi.szMin);
	CRect rcPrevMax(rcPrev.TopLeft(),szi.szMax);

	wm.OnGetSizeInfo(szi, next, pParentWnd);
	CRect rcNextMin(rcNext.BottomRight()-szi.szMin, rcNext.BottomRight());
	CRect rcNextMax(rcNext.BottomRight()-szi.szMax, rcNext.BottomRight());

	// Initialize m_rcConstrain. This is the box the user is allowed to move
	// the sizer bar in. Can't go outside of this--would violate min/max
	// constraints of windows on either side.
	m_rcConstrain.SetRect(
		max(rcPrevMin.right, rcNextMax.left),
		max(rcPrevMin.bottom,rcNextMax.top),
		min(rcPrevMax.right, rcNextMin.left),
		min(rcPrevMax.bottom,rcNextMin.top));

	// convert to my client coords
	pParentWnd->ClientToScreen(&m_rcConstrain);
	ScreenToClient(&m_rcConstrain);

	// Now adjust m_rcConstrain for the fact the bar is not a pure line, but
	// has solid width -- so I have to make a little bigger/smaller according
	// to the offset of mouse coords within the sizer bar rect iteself.
	ClientToScreen(&pt);
	m_rcConstrain.SetRect(m_rcConstrain.TopLeft() + (pt - m_rcBar.TopLeft()),
		m_rcConstrain.BottomRight() - (m_rcBar.BottomRight()-pt));
}
Ejemplo n.º 22
0
BOOL EVOpenDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	if(!SelectDefaultSource())
	{
		MessageBox(_T("未检测到扫描仪!"));
		OnCancel();
		return TRUE;
	}
	m_bTwainConfig = false;

	OnBnClickedButtonconfig();
	if ( !m_bTwainConfig )
	{
		int iReturn=MessageBox(_T("未检测到扫描仪或扫描仪扫描失败!\r\n是否手动选择扫描仪"),"注意",MB_YESNO|MB_DEFBUTTON2);
		if ( iReturn==IDNO )
		{
			OnCancel();
			return TRUE;
		}
		else
		{
			if(!SelectSource())
			{
				MessageBox(_T("未检测到扫描仪!"));
				OnCancel();
				return TRUE;
			}
			m_bTwainConfig = false;
			OnBnClickedButtonconfig();

			if ( !m_bTwainConfig )
			{
				MessageBox(_T("未检测到扫描仪或扫描仪扫描失败!"));
				OnCancel();
				return TRUE;
			}

		}
	}

	CWnd *pWnd = GetDlgItem(IDC_NEWEDIT3);
	CRect rc;
	if(!pWnd) return TRUE;
	pWnd->GetWindowRect(rc);
	pWnd->DestroyWindow(); //pWnd was just a placeholder;
	ScreenToClient(rc);
	m_DateTime.Create(WS_CHILD|WS_VISIBLE|DTS_LONGDATEFORMAT,rc,this,IDC_NEWEDIT3);
	m_DateTime.SendMessage((UINT)DTM_SETSYSTEMTIME,GDT_NONE, NULL);

	CString caption = EVUtil::GetInstance().ODBCGetConfig(_T("select * from Config where 所属界面='扫描界面' and 类型='标题' "));
	SetWindowText(caption);
	CString user = EVUtil::GetInstance().ODBCGetConfig(_T("select * from Config where 所属界面='扫描界面' and 类型='用户' "));
	SetDlgItemText(IDC_NEWSTATICUSER,user);
	InitInfos();

	SetDlgItemText(IDC_NEWEDIT1,"");
	CString szLJBH = EVUtil::GetInstance().ODBCGetConfig(_T("select * from Config where 所属界面='扫描界面' and 类型='零件编号' "));
	SetDlgItemText(IDC_NEWEDIT2,szLJBH);
	SetDlgItemText(IDC_NEWEDIT3,"");

	INIT_EASYSIZE;

	int   nCX   =   GetSystemMetrics(SM_CXSCREEN);
	int   nCY   =   GetSystemMetrics(SM_CYSCREEN);
	nCY = nCY-40;
	nCY = MIN(nCY,nCX);
	CRect   rtDlg;
	GetWindowRect(&rtDlg); 
	SetWindowPos(NULL,(nCX-nCY)/2,0,nCY,nCY,SWP_NOZORDER);//*/

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
Ejemplo n.º 23
0
long CCompileEditView::AddCompileInfotoList(WPARAM wParam /*= 0*/, LPARAM lParam /*= 0*/)
{
	if(m_pParentDlg == NULL)
		return 0;

	CWnd* pPromptWnd = m_pParentDlg->GetDlgItem(IDC_PROMTEDIT);
	if(pPromptWnd == NULL)
		return 0;

	CWnd* pBtError = m_pParentDlg->GetDlgItem(IDC_ERROR);

	nodErrorInfo* pError = (nodErrorInfo*)lParam;
	int nCount = GetErrorCount();
	CString strText;
	if(pError != NULL)
	{
		/*
		if(wParam == 10)
		{
		}
		else if(wParam == 11)
		{
		}
		else if(wParam == 12)
		{
		}
		else*/
		{			
			if(pBtError != NULL)
			{
				pBtError->EnableWindow(TRUE);
			}
			if(nCount == 0 && pError->m_nBegin >= 0 && pError->m_nEnd >= 0)
			{
				strText = _T("公式有几个错误!");
				pPromptWnd->SetWindowText(strText);
			}
		}		
		if(CDlgFormulaEdit::m_pErrorDlg != NULL)
		{
			CDlgFormulaEdit::m_pErrorDlg->SendMessage(HX_USER_COMPILE_INFO, wParam, lParam);
		}
	}
	else
	{
		strText = _T("公式编译(测试)通过!");
		if(pBtError != NULL)
		{
			pBtError->EnableWindow(FALSE);
		}
		pPromptWnd->SetWindowText(strText);
	}
	
	return 0;
	/*
	if(m_pParentDlg == NULL)
		return;

	CWnd* pPromptWnd = m_pParentDlg->GetDlgItem(IDC_PROMTEDIT);
	if(pPromptWnd != NULL)
	{
		CString strText;
		nodErrorInfo* pError = (nodErrorInfo*)lParam;
		int nCount = GetErrorCount();
		if(pError != NULL)
		{	
			if(wParam == 10)
			{
				strText.Format("%s",pError->GetError());
			}
			else if(wParam == 11)
			{
				strText.Format("%s - %i 错误,%i 警告",pError->GetError(),nCount,0);
			}
			else if(wParam == 12)
			{
				strText.Format("%s - %i 错误,%i 警告",pError->GetError(),nCount>0?nCount-1:nCount,0);
			}
			else
			{
				strText.Format("错误号:%i;错误信息:%s (%s)错误行列:%i-%i",pError->m_nError,
					hxRelaceReturnKey(pError->GetError(),"\r\n"),hxGetErrorInfoByErrorNum(pError->m_nError),pError->m_nBegin,pError->m_nEnd);
				
				if(nCount == 1 && pError->m_nBegin >= 0 && pError->m_nEnd >= 0)
				{
					this->GetRichEditCtrl().SetSel(pError->m_nBegin,pError->m_nEnd);
				}
			}
		}
		else
		{
			strText = "公式编译(测试)通过!";
		}

//		CString strOldText;
//		pPromptWnd->GetWindowText(strOldText);
		pPromptWnd->SetWindowText(strText);
	}
	*/


	/*
	if(m_pListCtrl == NULL)
		return;

	CString strText;
	short nImage;
	nodErrorInfo* pError = (nodErrorInfo*)lParam;
	int nCount = m_pListCtrl->GetItemCount();
	if(pError != NULL)
	{	
		if(wParam == 10)
		{
			nImage = 2;
			strText.Format("%s",pError->GetError());
		}
		else if(wParam == 11)
		{
			nImage = 2;
			strText.Format("%s - %i 错误,%i 警告",pError->GetError(),nCount,0);
		}
		else if(wParam == 12)
		{
			nImage = 2;
			strText.Format("%s - %i 错误,%i 警告",pError->GetError(),nCount>0?nCount-1:nCount,0);
		}
		else
		{
			nImage = 0;
			strText.Format("错误号:%i;错误信息:%s (%s)错误行列:%i-%i",pError->m_nError,
				hxRelaceReturnKey(pError->GetError(),"\r\n"),hxGetErrorInfoByErrorNum(pError->m_nError),pError->m_nBegin,pError->m_nEnd);

			if(nCount == 0 && pError->m_nBegin >= 0 && pError->m_nEnd >= 0)
			{
				this->GetRichEditCtrl().SetSel(pError->m_nBegin,pError->m_nEnd);
			}
		}
	}
	else
	{
		strText = "公式编译(测试)通过!";
		nImage = 1;
	}	
	m_pListCtrl->InsertItem(nCount,strText,nImage);
	*/
}
Ejemplo n.º 24
0
xpr_bool_t HistoryDlg::OnInitDialog(void) 
{
    super::OnInitDialog();

    SetIcon(mIcon, XPR_TRUE);

    HICON sIconHandle;
    sIconHandle = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_NOT));
    mTreeImgList.Create(16, 16, ILC_COLOR32 | ILC_MASK, -1, -1);
    mTreeImgList.Add(sIconHandle);
    ::DestroyIcon(sIconHandle);

    mTreeCtrl.SetImageList(&mTreeImgList, TVSIL_NORMAL);

    //-----------------------------------------------------------------------------

    if (mToolBar.Create(this) == XPR_FALSE)
    {
        XPR_TRACE(XPR_STRING_LITERAL("Failed to create toolbar\n"));
        return -1;
    }

    mToolBarImgList.Create(IDB_TB_DRIVEDLG, 16, 1, RGB(255,0,255));
    mToolBar.GetToolBarCtrl().SetImageList(&mToolBarImgList);
    mToolBar.GetToolBarCtrl().SetBitmapSize(CSize(16,16));

    mToolBar.ModifyStyle(0, TBSTYLE_LIST | TBSTYLE_FLAT);
    mToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS | TBSTYLE_EX_MIXEDBUTTONS);

    mToolBar.SetBorders(0, 0, 0, 0);

    DWORD sStyle = mToolBar.GetBarStyle();
    sStyle &= ~CBRS_BORDER_TOP;
    sStyle |= CBRS_FLYBY;
    mToolBar.SetBarStyle(sStyle);

    //-----------------------------------------------------------------------------

    TBBUTTON sTbButton = {0};
    sTbButton.idCommand = ID_HISTORY_REFRESH;
    sTbButton.iBitmap = 0;
    sTbButton.fsState = TBSTATE_ENABLED;
    sTbButton.fsStyle = TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE | BTNS_SHOWTEXT;
    sTbButton.iString = mToolBar.GetToolBarCtrl().AddStrings(gApp.loadString(XPR_STRING_LITERAL("popup.history.toolbar.refresh")));

    mToolBar.GetToolBarCtrl().AddButtons(1, &sTbButton);

    //-----------------------------------------------------------------------------
    // ControlBar Reposition

    CRect sClientStartRect;
    CRect sClientNowRect;
    GetClientRect(sClientStartRect);
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0, reposQuery, sClientNowRect);

    CPoint sOffsetPoint(sClientNowRect.left - sClientStartRect.left, sClientNowRect.top - sClientStartRect.top); 
    CRect sChildRect;
    CWnd *sChildWnd = GetWindow(GW_CHILD);
    while (XPR_IS_NOT_NULL(sChildWnd))
    {
        sChildWnd->GetWindowRect(sChildRect);
        ScreenToClient(sChildRect);
        sChildRect.OffsetRect(sOffsetPoint);
        sChildWnd->MoveWindow(sChildRect, XPR_FALSE);
        sChildWnd = sChildWnd->GetNextWindow();
    }
    CRect sWindowRect;
    GetWindowRect(sWindowRect);
    sWindowRect.right += sClientStartRect.Width() - sClientNowRect.Width();
    sWindowRect.bottom += sClientStartRect.Height() - sClientNowRect.Height();
    MoveWindow(sWindowRect, XPR_FALSE);

    RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);

    //----------------------------------------------------------------------

    if (mHistoryDispDeque.size() == 1)
    {
        mTabCtrl.ShowWindow(SW_HIDE);

        CRect sTabRect;
        mTabCtrl.GetWindowRect(&sTabRect);
        ScreenToClient(&sTabRect);

        CRect sTreeRect;
        mTreeCtrl.GetWindowRect(&sTreeRect);
        ScreenToClient(&sTreeRect);

        sTreeRect.top = sTabRect.top;
        mTreeCtrl.MoveWindow(&sTreeRect);
    }

    // CResizingDialog -------------------------------------------
    HideSizeIcon();

    //sizeNone:     Don't resize at all  
    //sizeResize:   The control will be stretched in the appropriate direction 
    //sizeRepos:    The control will be moved in the appropriate direction 
    //sizeRelative: The control will be moved proportionally in the appropriate direction 
    AddControl(IDC_HISTORY_TREE,   sizeResize, sizeResize);
    AddControl(IDC_HISTORY_STATUS, sizeResize, sizeRepos);
    //------------------------------------------------------------

    HistoryDisp *sHistoryDisp;
    HistoryDispDeque::iterator sIterator;

    sIterator = mHistoryDispDeque.begin();
    for (; sIterator != mHistoryDispDeque.end(); ++sIterator)
    {
        sHistoryDisp = *sIterator;
        if (sHistoryDisp == XPR_NULL)
            continue;

        mTabCtrl.InsertItem(mTabCtrl.GetItemCount(), sHistoryDisp->mTabText);
    }

    mTabCtrl.SetCurSel((xpr_sint_t)mCurHistoryDisp);
    showTab(mCurHistoryDisp);

    mDlgState = DlgStateManager::instance().getDlgState(XPR_STRING_LITERAL("History"));
    if (XPR_IS_NOT_NULL(mDlgState))
    {
        mDlgState->setDialog(this, XPR_TRUE);
        mDlgState->load();
    }

    return XPR_TRUE;
}
Ejemplo n.º 25
0
// start dragging. This is the only routine exposed externally. 
// pt = mouse position at start of drag (screen co-ords) 
void COXDragDockContext::StartDrag(CPoint pt)
{
   	ASSERT_VALID(m_pBar);
   	ASSERT(m_pBar->IsKindOf(RUNTIME_CLASS(COXSizeControlBar)));

   	COXSizeControlBar* pSzBar = (COXSizeControlBar*)m_pBar;

    // get styles from bar
   	m_dwDockStyle = m_pBar->m_dwDockStyle;
   	m_dwStyle = m_pBar->m_dwStyle & CBRS_ALIGN_ANY;
   	ASSERT(m_dwStyle != 0);
	
	// check to see we're not hanging from a COXMDIFloatWnd. 
	// Disallow dragging if we are...
	if (m_pBar->IsFloating())
	{
		CFrameWnd* pFrameWnd = m_pBar->GetParentFrame();
		ASSERT(pFrameWnd != NULL);
		ASSERT(pFrameWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)));
		if (pFrameWnd->IsKindOf(RUNTIME_CLASS(COXMDIFloatWnd)))
			return;				// do nothing if floating inside a COXMDIFloatWnd
	}
	
	// dragging has started message (only if window will actually dock !)
    if ((m_dwDockStyle & CBRS_ALIGN_ANY) == CBRS_ALIGN_ANY)
		AfxGetMainWnd()->SendMessage(WM_SETMESSAGESTRING, IDS_OX_MRC_STARTDOCKING);
	
    // handle pending WM_PAINT messages
    MSG msg;
    while (::PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_NOREMOVE))
	{
		if (!GetMessage(&msg, NULL, WM_PAINT, WM_PAINT))
			return;
		ASSERT(msg.message == WM_PAINT);
        DispatchMessage(&msg);
	}
	
    // initialize drag state
   	m_rectLast.SetRectEmpty();
   	m_sizeLast.cx = m_sizeLast.cy = 0;
   	m_bForceFrame = m_bFlip = m_bDitherLast = FALSE;
	
	
   	// get current bar location 
   	CRect rect;
   	m_pBar->GetWindowRect(rect);
   	m_ptLast = pt;
   	m_ptStart = pt;
	BOOL bHorz = HORZF(m_dwStyle);
	
   	// MFC includes code for flipping orientation using the shift key - I wasn't keen
	// on this... (sorry) so I've left it out for now. Some references are still left
	// in for it, in case I decide to implement it.
   	
   	// Start by working out the possible rectangles that dragging could result in.
	// These are:
	// m_rectFrameDragHorz	: floating frame, horizontal orientation
	// m_rectFrameDragVert	: floating frame, vertical orientation (not used, 'cos
	//									flipping not allowed)
	//
	// m_rectDragHorz		: docking horizontally, another bar already on this row
	// m_rectDragVert		: docking vertically, another bar already on this row
	
	// m_rectDragHorzAlone  : docking horizontally, on a new row
	// m_rectDragVertAlone  : docking vertically, on a new row
	
	
	// calculate dragging rects if you drag on the new row/column
	//
	CRect rectBorder;
	m_pDockSite->RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST, 
		CFrameWnd::reposQuery,&rectBorder);
	m_pDockSite->ClientToScreen(rectBorder);
	CWnd* pLeftDockBar=m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT);
	if(pLeftDockBar!=NULL && pLeftDockBar->GetStyle()&WS_VISIBLE)
	{
		CRect rectDockBar;
		pLeftDockBar->GetWindowRect(rectDockBar);
		rectBorder.left-=rectDockBar.Width();
	}
	CWnd* pRightDockBar=m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_RIGHT);
	if(pRightDockBar!=NULL && pRightDockBar->GetStyle()&WS_VISIBLE)
	{
		CRect rectDockBar;
		pRightDockBar->GetWindowRect(rectDockBar);
		rectBorder.right+=rectDockBar.Width();
	}
	m_rectDragHorzAlone=CRect(CPoint(rectBorder.left,rect.top),rectBorder.Size());
	m_rectDragVertAlone=CRect(CPoint(rect.left,rectBorder.top),rectBorder.Size());
	m_rectDragHorzAlone.bottom=m_rectDragHorzAlone.top+pSzBar->m_HorzDockSize.cy;
	m_rectDragVertAlone.right=m_rectDragVertAlone.left+pSzBar->m_VertDockSize.cx;
	//
	//////////////////////////////////////////////////////////////


	//////////////////
	//
	int nDockAreaWidth = rectBorder.Width();
	int nDockAreaHeight = rectBorder.Height();

	CSize HorzAloneSize(nDockAreaWidth, pSzBar->m_HorzDockSize.cy);
	CSize VertAloneSize(pSzBar->m_VertDockSize.cx, nDockAreaHeight);
	
	// sizes to use when docking into a row that already has some bars.
	// use the stored sizes - unless they are > the max dock area - 
	// in which case make a guess.
	if (pSzBar->m_VertDockSize.cy >= nDockAreaHeight - 16)
		VertAloneSize.cy = nDockAreaHeight / 3;
	else 
		VertAloneSize.cy = pSzBar->m_VertDockSize.cy;
	
	if (pSzBar->m_HorzDockSize.cx >= nDockAreaWidth - 16)
		HorzAloneSize.cx = nDockAreaWidth / 3;
	else
		HorzAloneSize.cx = pSzBar->m_HorzDockSize.cx;
	

	m_rectDragHorz = CRect(rect.TopLeft(), HorzAloneSize);
	m_rectDragVert = CRect(rect.TopLeft(), VertAloneSize);
	//
	///////////////////


   	// rectangle for the floating frame...
   	m_rectFrameDragVert = m_rectFrameDragHorz = 
		CRect(rect.TopLeft(), pSzBar->m_FloatSize);
   	
   	// To work out the size we actually create a floating mini frame, and then see how big
   	// it is
	CMiniDockFrameWnd* pFloatFrame =
		m_pDockSite->CreateFloatingFrame(bHorz ? CBRS_ALIGN_TOP : CBRS_ALIGN_LEFT);
   	if (pFloatFrame == NULL)
		AfxThrowMemoryException();
   	pFloatFrame->CalcWindowRect(&m_rectFrameDragHorz);
   	pFloatFrame->CalcWindowRect(&m_rectFrameDragVert);
// 	m_rectFrameDragHorz.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
// 	m_rectFrameDragVert.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
   	pFloatFrame->DestroyWindow();

	// adjust rectangles so that point is inside
	AdjustRectangle(m_rectDragHorzAlone, pt);
	AdjustRectangle(m_rectDragVertAlone, pt);
   	AdjustRectangle(m_rectDragHorz, pt);
   	AdjustRectangle(m_rectDragVert, pt);
   	AdjustRectangle(m_rectFrameDragHorz, pt);
   	AdjustRectangle(m_rectFrameDragVert, pt);
	
   	// lock window update while dragging
   	ASSERT(m_pDC == NULL);
   	CWnd* pWnd = CWnd::GetDesktopWindow();
#ifndef _MAC
    if (pWnd->LockWindowUpdate()) 
		m_pDC = pWnd->GetDCEx(NULL, DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE);
    else
#endif
		m_pDC = pWnd->GetDCEx(NULL, DCX_WINDOW|DCX_CACHE);
    ASSERT(m_pDC != NULL); 
	
	// initialize tracking state and enter tracking loop
	m_dwOverDockStyle = CanDock();
    Move(pt);   // call it here to handle special keys
    Track();
}
BOOL CPropPageRestore::CheckData()
{
    switch(m_iSource)
    {
    case FILE_MODE:
        if(m_strBackupPath.IsEmpty())
        {
            ::AfxMessageBox(IDS_ERR_NO_BACKUP_PATH);
            CWnd*   pWnd = GetDlgItem(IDC_BACKUP_PATH_EDIT);
            GotoDlgCtrl(pWnd);
            return FALSE;
        }
        else
        {
            if(m_strBackupPath.Find(_T('.')) == -1)
            {
                m_strBackupPath += _T(".4cb");
                CWnd*   pWnd = GetDlgItem(IDC_BACKUP_PATH_EDIT);
                pWnd->SetWindowText(m_strBackupPath);
                pWnd->UpdateWindow();
            }
            CFileStatus tStatus;
            if(!CFile::GetStatus(m_strBackupPath, tStatus))
            {
                ::AfxMessageBox(_T("Specified backup file does not exist."));
                CWnd*   pWnd = GetDlgItem(IDC_BACKUP_PATH_EDIT);
                GotoDlgCtrl(pWnd);
                return FALSE;
            }
        }
        break;
    case TARGET_MODE:
        if(m_strAddress.IsEmpty())
        {
            ::AfxMessageBox(IDS_ERR_NO_ADDRESS);
            CWnd*   pWnd = GetDlgItem(IDC_ADDRESS_EDIT);
            GotoDlgCtrl(pWnd);
            return FALSE;
        }
        break;
    }

    if(m_strProjectPath.IsEmpty())
    {
        ::AfxMessageBox(IDS_ERR_NO_PROJECT_PATH);
        CWnd*   pWnd = GetDlgItem(IDC_PROJECT_PATH_EDIT);
        GotoDlgCtrl(pWnd);
        return FALSE;
    }

    CFileStatus tStatus;
    if(CFile::GetStatus(m_strProjectPath, tStatus))
    {
        CString strMessage(_T("Project Path already exists."));
        ::AfxMessageBox(strMessage);
        m_pMainSheet->SetStatusText(strMessage);
        CWnd*   pWnd = GetDlgItem(IDC_PROJECT_PATH_EDIT);
        GotoDlgCtrl(pWnd);
        return FALSE;
    }
    return TRUE;
}
Ejemplo n.º 27
0
BOOL CPreferencesOnlinePage::OnInitDialog() 
{
   CComboBox   *pDialupsCombo;
   CButton     *pBtnModem, *pBtnDirect;
   CString     csResource;

   m_bSetActiveOnce = FALSE;

	CDialog::OnInitDialog();

   m_bVisitedThisPage = FALSE;

#if 0
	BOOL bAG = GetConfiguration()->Product() == CPrintMasterConfiguration::plAmericanGreetings;
	if(bAG)
	{
		CWnd* pWndDesign = GetDlgItem(IDC_DESIGN_CHECK);
		if(pWndDesign )
			pWndDesign->ShowWindow(SW_HIDE);

		CWnd* pWndCheck = GetDlgItem(IDC_USE_PROMPT);
		if(pWndCheck )
			pWndCheck->ShowWindow(SW_HIDE);
	}
#endif

   m_bOwnSettings = FALSE;
   DeInit();
   if(m_pConnSettings == NULL)
      {
        m_bOwnSettings = TRUE;
        m_pConnSettings = new CConnectionSettings;
        m_pConnSettings->Update(FALSE, FALSE);
      }

   pBtnModem   = (CButton *)     GetDlgItem(IDC_CONNECTION_MODEM);
   ASSERT(pBtnModem);
   pBtnDirect  = (CButton *)     GetDlgItem(IDC_CONNECTION_DIRECT);
   ASSERT(pBtnDirect);
   if(m_pConnSettings->GetType() != CConnectionSettings::typeDirect)
      {
         if(pBtnModem)
            pBtnModem->SetCheck(1);
         m_comboDialups.EnableWindow(TRUE);
         m_btnAdvanced.EnableWindow(TRUE);
      }
   else
      {
         if(pBtnDirect)
            pBtnDirect->SetCheck(1);
         m_comboDialups.EnableWindow(FALSE);
         m_btnAdvanced.EnableWindow(FALSE);
      }
   pDialupsCombo = (CComboBox*)  GetDlgItem(IDC_DIALUP_CONNECTIONS);
   if(pDialupsCombo)
      {
         CDialupConnections   *pDialups;
         int                  nItemIndex=-1;
         int                  nModemAOLIndex, nCompuServeIndex;
         int                  nModemDialupIndex, nDirectIndex, nModemCustomIndex;
         BOOL                 bEnableAdvanced;

         nModemAOLIndex = nModemDialupIndex = nDirectIndex = nModemCustomIndex = -1;
         if(m_pConnSettings->IsAOL95Installed())
            {
               csResource.LoadString(IDS_AOL);
               ASSERT(!csResource.IsEmpty());
               if(!csResource.IsEmpty())
                  nModemAOLIndex = pDialupsCombo->AddString(csResource);
               ASSERT(nModemAOLIndex >= 0);
               if(nModemAOLIndex >= 0)
                  pDialupsCombo->SetItemData(
                     nModemAOLIndex,
                     (DWORD) CConnectionSettings::typeModemAOL);
            }
         if(m_pConnSettings->IsCompuServeInstalled())
            {
               csResource.LoadString(IDS_COMPUSERVE);
               ASSERT(!csResource.IsEmpty());
               if(!csResource.IsEmpty())
                  nCompuServeIndex = pDialupsCombo->AddString(csResource);
               ASSERT(nCompuServeIndex >= 0);
               if(nCompuServeIndex >= 0)
                  pDialupsCombo->SetItemData(
                     nCompuServeIndex,
                     (DWORD) CConnectionSettings::typeModemCompuServe);
            }
         pDialups = m_pConnSettings->GetDialups();
         ASSERT(pDialups);
         if(pDialups->GetEntryCount())
            {
               csResource.LoadString(IDS_DIALUP);
               ASSERT(!csResource.IsEmpty());
               if(!csResource.IsEmpty())
                  nModemDialupIndex = pDialupsCombo->AddString(csResource);
               ASSERT(nModemDialupIndex >= 0);
               if(nModemDialupIndex >= 0)
                  pDialupsCombo->SetItemData(
                     nModemDialupIndex,
                     (DWORD) CConnectionSettings::typeModemDialup);
            }

         csResource.LoadString(IDS_CUSTOM_CONNECTION);
         ASSERT(!csResource.IsEmpty());
         if(!csResource.IsEmpty())
            nModemCustomIndex = pDialupsCombo->AddString(csResource);
         ASSERT(nModemCustomIndex >= 0);
         if(nModemCustomIndex >= 0)
            pDialupsCombo->SetItemData(
               nModemCustomIndex,
               (DWORD) CConnectionSettings::typeModemCustom);


         bEnableAdvanced = FALSE;
         switch(m_pConnSettings->GetType())
            {
               case CConnectionSettings::typeModemAOL:
                  nItemIndex = nModemAOLIndex;
                  break;
               case CConnectionSettings::typeModemCompuServe:
                  nItemIndex = nCompuServeIndex;
                  break;
               case CConnectionSettings::typeModemDialup:
                  nItemIndex =  nModemDialupIndex;
                  break;
               case CConnectionSettings::typeModemCustom:
                  nItemIndex = nModemCustomIndex;
                  if(nItemIndex >= 0)
                     bEnableAdvanced = TRUE;
                  break;
               case CConnectionSettings::typeDirect:
                  nItemIndex = nDirectIndex;
                  break;
               case CConnectionSettings::typeNone:
               default:
                  nItemIndex = -1;
                  break;
            }
         if(m_pConnSettings->GetType() != CConnectionSettings::typeDirect)
            m_btnAdvanced.EnableWindow(bEnableAdvanced);
         if(nItemIndex < 0)
            nItemIndex = 0;
         m_nCurDialup = nItemIndex;
         UpdateData(FALSE);
         // Simulate SelChange(), Why doesn't UpdateData() do this?
         OnSelchangeDialupConnections();
         m_pConnSettings->GetSettings();
      }
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 28
0
void CuDlgIpmTabCtrl::LoadPage (CuIpmProperty* pCurrentProperty)
{
	CRect   r;
	TC_ITEM item;
	int     i, nPages;
	UINT*   nTabID;
	UINT*   nDlgID;
	CString strTab;
	CString strTitle;
	UINT    nIDD; 
	CWnd*   pDlg;
	CuPageInformation* pPageInfo = NULL;
	
	if (m_pCurrentProperty)
	{
		m_pCurrentProperty->SetPageInfo (NULL);
		delete m_pCurrentProperty;
	}
	pPageInfo = pCurrentProperty->GetPageInfo();
	m_pCurrentProperty = new CuIpmProperty (pCurrentProperty->GetCurSel(), pPageInfo);
	
	//
	// Set up the Title:
	pPageInfo->GetTitle (strTitle);
	m_staticHeader.SetWindowText (strTitle);

	UINT uFlags = SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER;
	if (!strTitle.IsEmpty())
	{
		switch (pPageInfo->GetImageType())
		{
		case 0:
			m_staticHeader.ResetBitmap (pPageInfo->GetIconImage());
			break;
		case 1:
			m_staticHeader.ResetBitmap (pPageInfo->GetBitmapImage(), pPageInfo->GetImageMask());
			break;
		default:
			m_staticHeader.ResetBitmap (NULL);
		}
	}
	else
		m_staticHeader.ResetBitmap (NULL);
	m_staticHeader.SetWindowPos(NULL, 0, 0, 0, 0, uFlags);

	nPages = pPageInfo->GetNumberOfPage();
	if (nPages < 1)
	{
		m_pCurrentPage = NULL;
		return;
	}
	//
	// Construct the Tab(s)
	nTabID = pPageInfo->GetTabID();
	nDlgID = pPageInfo->GetDlgID();
	memset (&item, 0, sizeof (item));
	item.mask       = TCIF_TEXT;
	item.cchTextMax = 32;
	m_cTab1.DeleteAllItems();
	for (i=0; i<nPages; i++)
	{
		strTab.LoadString (nTabID [i]);
		item.pszText = (LPTSTR)(LPCTSTR)strTab;
		m_cTab1.InsertItem (i, &item);
	}
	//
	// Display the selected page.
	nIDD = pPageInfo->GetDlgID (pCurrentProperty->GetCurSel()); 
	pDlg = GetPage (nIDD);
	m_cTab1.SetCurSel (pCurrentProperty->GetCurSel());
	m_cTab1.GetClientRect (r);
	m_cTab1.AdjustRect (FALSE, r);
	pDlg->MoveWindow (r);
	pDlg->ShowWindow(SW_SHOW);
	m_pCurrentPage = pDlg;
	//
	// Display the content (data) of this page.
	CuIpmPropertyData* pData = pCurrentProperty->GetPropertyData();
	pData->NotifyLoad (m_pCurrentPage);

	//
	// Properties:
	CView*   pView = (CView*)GetParent();
	ASSERT (pView);
	CdIpmDoc* pDoc  = (CdIpmDoc*)pView->GetDocument();
	ASSERT (pDoc);
	if (pDoc)
	{
		UINT nMask = IPMMASK_FONT|IPMMASK_SHOWGRID;
		m_pCurrentPage->SendMessage (WMUSRMSG_CHANGE_SETTING, (WPARAM)nMask, (LPARAM)&(pDoc->GetProperty()));
	}
}
Ejemplo n.º 29
0
/**
	@brief	

	@author BHK	

	@date 2009-04-13 오후 2:44:21	

	@param	

	@return		
*/
BOOL CShowCableDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	BeginWaitCursor();
	CDialog::SetIcon(AfxGetApp()->LoadIcon(IDI_CABLE) , FALSE);

	if(m_pLoadItem)
	{
		const string rLoadName = m_pLoadItem->prop()->GetValue(_T("General") , _T("ITEM ID"));
		SetDlgItemText(IDC_EDIT_LOAD_ID , rLoadName.c_str());
	}

	m_wndCalculatedResultList.InsertColumn(0 , _T("Size") , 0 , 50);
	m_wndCalculatedResultList.InsertColumn(1 , _T("Length"), 0 , 50);
	m_wndCalculatedResultList.SendMessage (LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);

	/// 이미지리스트
	/*
	UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_CLASS_VIEW_HC : IDB_CLASS_VIEW;

	CBitmap bmp;
	if (!bmp.LoadBitmap (uiBmpId))
	{
		TRACE(_T ("Can't load bitmap: %x\n"), uiBmpId);
		ASSERT (FALSE);
		return FALSE;
	}

	BITMAP bmpObj;
	bmp.GetBitmap (&bmpObj);

	UINT nFlags = ILC_MASK;
	nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4;

	m_imgList.Create (16, bmpObj.bmHeight, nFlags, 0, 0);
        m_imgList.Add (&bmp, RGB (255, 0, 0));
	m_imgList.Add(AfxGetApp()->LoadIcon(IDI_BUS_GROUP));
	m_imgList.Add(AfxGetApp()->LoadIcon(IDI_BUS));
	m_imgList.Add(AfxGetApp()->LoadIcon(IDI_LOAD));
	m_imgList.Add(AfxGetApp()->LoadIcon(IDI_MOTOR));
	m_imgList.Add(AfxGetApp()->LoadIcon(IDI_TRANSFORMER));
	m_imgList.Add(AfxGetApp()->LoadIcon(IDI_CABLE));
	*/
	CELOADApp* pApp = (CELOADApp*)AfxGetApp();
	m_wndCableTreeCtrl.SetImageList(&(pApp->m_ELoadImages) , TVSIL_NORMAL);

	CELoadDocData& docData = CELoadDocData::GetInstance();
	{
		const string rProjectMDBFilePath = docData.GetProjectMDBFilePath();

		CHVCableCreationSettingTable& HVCableCreationgSettingTable = CHVCableCreationSettingTable::GetInstance();
		HVCableCreationgSettingTable.Load(rProjectMDBFilePath);
		CLV3PHCableCreationSettingTable& LV3PHCableCreationgSettingTable = CLV3PHCableCreationSettingTable::GetInstance();
		LV3PHCableCreationgSettingTable.Load(rProjectMDBFilePath);
		CLV1PHCableCreationSettingTable& LV1PHCableCreationgSettingTable = CLV1PHCableCreationSettingTable::GetInstance();
		LV1PHCableCreationgSettingTable.Load(rProjectMDBFilePath);
		CDCCableCreationSettingTable& DCCableCreationgSettingTable = CDCCableCreationSettingTable::GetInstance();
		DCCableCreationgSettingTable.Load(rProjectMDBFilePath);
		DisplayData();
	}

	CRect rect;
	CWnd* pWnd = GetDlgItem(IDC_STATIC_PROPERTY);
	pWnd->GetWindowRect(&rect);
	ScreenToClient(&rect);
	if (!m_wndCablePropList.Create (WS_VISIBLE | WS_CHILD, rect, this, IDC_STATIC_PROPERTY))
	{
		TRACE0("Failed to create Properies Grid \n");
		return FALSE;      // fail to create
	}
	m_wndCablePropList.EnableHeaderCtrl (FALSE);
	m_wndCablePropList.EnableDescriptionArea ();
	m_wndCablePropList.SetVSDotNetLook ();
	m_wndCablePropList.MarkModifiedProperties ();
	
	map<string,CELoadItemProp*>::iterator where = docData.m_ItemPropMap.find(CCableItem::TypeString());
	if(where != docData.m_ItemPropMap.end()) m_wndCablePropList.InitPropList( where->second );
	
	const COLORREF TextHotColor = docData.GetColorCode(_T("TEXT_HOT_COLOR"));
	m_wndCancel.SetTextHotColor(TextHotColor);
	
	HICON hCancelIcon = (HICON)::LoadImage( AfxGetInstanceHandle(), 
		MAKEINTRESOURCE(IDI_CANCEL_18X18),
		IMAGE_ICON,
		18,18, 0 );
	m_wndCancel.SetImage(hCancelIcon);

	m_hIcon = AfxGetApp()->LoadIcon(IDI_GRABBER);

	INIT_EASYSIZE;

	GetDlgItem(IDC_BUTTON_REST_MODIFIED_VALUES)->EnableWindow(FALSE);

	EndWaitCursor();
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 30
0
BOOL CAdminGen::OnInitDialog()
{
	/*CDialogEx::OnInitDialog();*/
	CDialogEx::OnInitDialog();
  

    // 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)   
    {   
        BOOL bNameValid;   
        CString strAboutMenu;   
        bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);   
        ASSERT(bNameValid);   
        if (!strAboutMenu.IsEmpty())   
        {   
            pSysMenu->AppendMenu(MF_SEPARATOR);   
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);   
        }   
    }   
  
    // Set the icon for this dialog.  The framework does this automatically   
    //  when the application's main window is not a dialog   
    SetIcon(m_hIcon, TRUE);         // Set big icon   
    SetIcon(m_hIcon, FALSE);        // Set small icon   
  
    // TODO: Add extra initialization here  
	//设置CComBox下拉框为只读防止用户自己输入造成不必要的错误
	CEdit* pEdit = (CEdit*)(((CComboBox*)GetDlgItem(IDC_ADMINTYPE_COMBO))->GetWindow(GW_CHILD));	
	pEdit->SetReadOnly(TRUE);
	CEdit* pEdit1 = (CEdit*)(((CComboBox*)GetDlgItem(IDC_PAPERTYPE_COMBO))->GetWindow(GW_CHILD));	
	pEdit1->SetReadOnly(TRUE);


	CWnd *cWnd = GetDlgItem(IDC_THETITLE_STATIC);
	cWnd->SetFont(&font);
	if(adm_index_array[0][0] == ADM_UPDATA)
	{
		cWnd->SetWindowText("更新管理员");
		SetDlgItemText(IDC_ADMINNAME_EDIT, m_adminname); 
		SetDlgItemText(IDC_ADMINPHONE_EDIT,adm_phoneNum_cs); 
		SetDlgItemText(IDC_PHONENUMBER_EDIT,adm_paperNum_cs); 
		SetDlgItemText(IDC_PAPERTYPE_COMBO,adm_paperType_cs); 
		SetDlgItemText(IDC_ADMINMAXCOUNT_EDIT,adm_maxNum_cs); 
		SetDlgItemText(IDC_ADMINTYPE_COMBO, _T("设备管理员"));
		m_adm_max_count.SetReadOnly(TRUE);
	}
	else
	{
		cWnd->SetWindowText("添加管理员");
		SetDlgItemText(IDC_PAPERTYPE_COMBO, _T("身份证"));
		SetDlgItemText(IDC_ADMINTYPE_COMBO, _T("设备管理员"));
		
	}
		
	 m_papertype.AddString(_T("身份证"));     
	 m_papertype.AddString(_T("其他")); 

	m_adminType.AddString(_T("设备管理员"));
	m_adminType.AddString(_T("密钥授权员"));
	m_adminType.AddString(_T("安全审计员"));

	//获取最大管理员数
	int ret = 0;
	DEVKEYINFO devInfo={0x00};
	char outString[100]={0x00};
	ret = Km_GetDevKeyInfo(phHandle,&devInfo);
	if(0 != ret)
	{
		retValueParse(ret,outString);
		MessageBox("获取设备密钥信息失败,错误码:"+(CString)outString,"提示",MB_ICONEXCLAMATION);
		return TRUE;
	}
	algID = devInfo.uiAlgo;
	keyLength = devInfo.uiKeyLen;
	if(keyLength == 2048)
		keyLength = 1024;
	isAddOK = TRUE;
//	int admMax_forLogin = devInfo.uiBakTotalKey;
	i_adm_log_num = admCountInGen;
//	int i_adm_log_num = 0.5*admMax_forLogin+1;
	if(1 <= admCountInGen)
	{
		CString admz_num;
		admz_num.Format("%d",admCountInGen);
		SetDlgItemText(IDC_ADMINMAXCOUNT_EDIT,admz_num);
		m_adm_max_count.SetReadOnly(TRUE);
	}
//	if(i_adm_log_num >= admMax_forLogin)
		//isAddOK = FALSE;
    return FALSE;  // return TRUE  unless you set the focus to a control   

}