Esempio n. 1
0
void CvSqlQueryLowerView::PrintPageHeader(CDC* pDC, int pageNum)
{
	// Select the printer font
	CFont* pOldFont = pDC->SelectObject(&m_printerFont);

	// Title on the left
	CdSqlQueryRichEditDoc* pDoc =(CdSqlQueryRichEditDoc*)GetDocument();
	ASSERT (pDoc);
	CString csHeader = pDoc->GetTitle();
	pDC->TextOut(0, 0, csHeader);

	// Page number right-aligned
	CString csPageNum;
	csPageNum.Format(_T("Page No %d"), pageNum);
	CSize size = pDC->GetTextExtent(csPageNum);
	int hPos = m_nPageWidth - size.cx;
	pDC->TextOut(hPos, 0, csPageNum);

	// underline full width of page
	pDC->MoveTo(0, m_nLineHeight);
	pDC->LineTo(m_nPageWidth, m_nLineHeight);

	// Deselect the printer font
	pDC->SelectObject(pOldFont);

	// MANDATORY : MUST update m_nHeaderHeight
	m_nHeaderHeight = m_nLineHeight * 3;
}
Esempio n. 2
0
void CuDlgSqlQueryStatement::LoadDocument() 
{
	CvSqlQueryUpperView* pParent1 = (CvSqlQueryUpperView*)GetParent ();                 // CvSqlQueryUpperView.
	ASSERT (pParent1);
	CdSqlQueryRichEditDoc* pDoc =  (CdSqlQueryRichEditDoc*)pParent1->GetDocument();     // CdSqlQueryRichEditDoc.
	ASSERT (pDoc);
	if (pDoc && pDoc->IsLoadedDoc())
	{
		m_strCom  = pDoc->m_strCom;
		m_strExec = pDoc->m_strExec;
		m_strElap = pDoc->m_strElap;
		m_strCost = pDoc->m_strCost;
		UpdateData (FALSE);
	}
}
Esempio n. 3
0
long CuDlgSqlQueryPageXML::OnChangeSetting(WPARAM wParam, LPARAM lParam)
{
	CdSqlQueryRichEditDoc* pDoc = (CdSqlQueryRichEditDoc*)lParam;
	if (pDoc)
	{
		CaSqlQueryProperty& property = pDoc->GetProperty();
		if (property.GetFont())
		{
			CuWebBrowser2* pIe = (CuWebBrowser2*)GetDlgItem (IDC_EXPLORER1);
			if (pIe && IsWindow (pIe->m_hWnd))
			{
				pIe->SendMessage (WM_SETFONT, (WPARAM)property.GetFont(), MAKELPARAM(TRUE, 0));
			}
		}
	}
	return 0;
}
Esempio n. 4
0
void CvSqlQueryRichEditView::OnInitialUpdate() 
{
	CRichEditView::OnInitialUpdate();
	HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
	if (hFont == NULL)
		hFont = (HFONT)GetStockObject(ANSI_VAR_FONT);
	if (hFont)
		SendMessage(WM_SETFONT, (WPARAM)hFont);

	CdSqlQueryRichEditDoc* pDoc =(CdSqlQueryRichEditDoc*)GetDocument();
	CfSqlQueryFrame* pFrame  = (CfSqlQueryFrame*)GetParentFrame();
	CuDlgSqlQueryResult* pDlgResult = pFrame->GetDlgSqlQueryResult();
	CaSqlQueryProperty& property = pDoc->GetProperty();
	if (pDlgResult && property.IsTraceActivated() && property.IsTraceToTop())
	{
		pDlgResult->SelectRawPage();
	}
}
Esempio n. 5
0
BOOL CuDlgSqlQueryPageXML::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CfSqlQueryFrame* pFrame = (CfSqlQueryFrame*)GetParentFrame();
	CdSqlQueryRichEditDoc* pDoc = (CdSqlQueryRichEditDoc*)pFrame->GetActiveDocument();
	if (pDoc)
		m_bXMLSource = !(pDoc->GetProperty().GetXmlDisplayMode() == 1);
	else
		m_bXMLSource = FALSE;
	m_pQueryRowParam->SetMode(m_bXMLSource);
	m_strPreview.LoadString (IDS_PREVIEW);
	m_cButtonXML.GetWindowText (m_strXmlSource);
	if (m_bXMLSource)
		m_cButtonXML.SetWindowText (m_strPreview);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 6
0
BOOL CuDlgSqlQueryStatement::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CvSqlQueryUpperView* pParent1 = (CvSqlQueryUpperView*)GetParent ();                 // CvSqlQueryUpperView.
	ASSERT (pParent1);
	CdSqlQueryRichEditDoc* pDoc =  (CdSqlQueryRichEditDoc*)pParent1->GetDocument();     // CdSqlQueryRichEditDoc.
	ASSERT (pDoc);
	if (pDoc && pDoc->IsLoadedDoc())
	{
		m_strCom  = pDoc->m_strCom;
		m_strExec = pDoc->m_strExec;
		m_strElap = pDoc->m_strElap;
		m_strCost = pDoc->m_strCost;
		UpdateData (FALSE);
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 7
0
void CvSqlQueryLowerView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) 
{
	// Necessary to pick informations from the printer dc
	pDC->SetMapMode(MM_TEXT);
	// Pick printer information
	m_ScalingFactorX = pDC->GetDeviceCaps(SCALINGFACTORX);  // power of 2
	m_ScalingFactorY = pDC->GetDeviceCaps(SCALINGFACTORY);  // power of 2
	m_nPageWidth = pDC->GetDeviceCaps(PHYSICALWIDTH) - 2*pDC->GetDeviceCaps(PHYSICALOFFSETX);
	m_nPageHeight = pDC->GetDeviceCaps(PHYSICALHEIGHT) - 2*pDC->GetDeviceCaps(PHYSICALOFFSETY);
	//
	// create printer font and store useful information
	//

	// Get screen font
	HFONT hScreenFont = NULL;
	CdSqlQueryRichEditDoc* pDoc =(CdSqlQueryRichEditDoc*)GetDocument();
	ASSERT (pDoc);
	LOGFONT lf;
	hScreenFont = pDoc->GetProperty().GetFont();
	if (!hScreenFont)
	{
		CWnd* pCurrentPage = m_pQueryResultDlg->GetCurrentPage();
		if (pCurrentPage)
			hScreenFont = (HFONT)pCurrentPage->SendMessage (WMUSRMSG_GETFONT, 0, 0); 
		if (!hScreenFont)
			hScreenFont = (HFONT)GetFont();
	}
	ASSERT (hScreenFont);
	// Create wysiwig printer fonts
	CFont* pScreenFont = CFont::FromHandle(hScreenFont);
	int success = pScreenFont->GetLogFont(&lf);
	ASSERT (success);

	CDC* pScreenDC = GetDC();
	ASSERT (pScreenDC);
	int printerLogPixelsX = pDC->GetDeviceCaps(LOGPIXELSX);
	int screenLogPixelsX  = pScreenDC->GetDeviceCaps(LOGPIXELSX);
	int printerLogPixelsY = pDC->GetDeviceCaps(LOGPIXELSY);
	int screenLogPixelsY  = pScreenDC->GetDeviceCaps(LOGPIXELSY);
	ReleaseDC(pScreenDC);
	
	// Scales: rounded to the nearest for print scales, rounded up for font
	m_PixelXPrintScale = ( ( printerLogPixelsX + screenLogPixelsX / 2 - 1) / screenLogPixelsX) << m_ScalingFactorX;
	m_PixelYPrintScale = ( ( printerLogPixelsY + screenLogPixelsY / 2 - 1) / screenLogPixelsY) << m_ScalingFactorY;
	int fontYScale = ( (printerLogPixelsY + screenLogPixelsY - 1) / screenLogPixelsY ) << m_ScalingFactorY;
	lf.lfHeight *= fontYScale;
	
	// Normal font
	lf.lfWeight = FW_NORMAL;      // So that displayed result is not too heavy looking at - SIDE EFFECT IF SCREEN FONT IS BOLD
	lf.lfUnderline = FALSE;
	BOOL bSuccess = m_printerFont.CreateFontIndirect(&lf);
	ASSERT (bSuccess);
	
	// underlined font
	lf.lfUnderline = TRUE;
	bSuccess = m_printerCaptFont.CreateFontIndirect(&lf);
	ASSERT (bSuccess);
	
	// Bold font
	lf.lfUnderline = FALSE;
	lf.lfWeight = FW_BOLD;
	bSuccess = m_printerBoldFont.CreateFontIndirect(&lf);
	ASSERT (bSuccess);
	
	// calculate reference text sizes
	TEXTMETRIC tm;
	CFont* pOldFont = pDC->SelectObject(&m_printerFont);
	pDC->GetTextMetrics(&tm);
	m_nLineHeight = tm.tmHeight + tm.tmExternalLeading;
	pDC->SelectObject(&m_printerCaptFont);
	pDC->GetTextMetrics(&tm);
	m_nCaptLineHeight = tm.tmHeight + tm.tmExternalLeading;
	pDC->SelectObject(&m_printerBoldFont);
	pDC->GetTextMetrics(&tm);
	m_nBoldLineHeight = tm.tmHeight + tm.tmExternalLeading;
	pDC->SelectObject(pOldFont);
	
	// Reset number of pages to be printed, will be calculated at first call to PrintPage()
	m_nbPrintPage = 0;
	
	// Call special method of CuDlgSqlQueryResult, in order to get current property page data
	// Code here rather than in OnPrint() so it will not be called for each printed page
	m_pPageData = m_pQueryResultDlg->GetCurrentPageData();
	// Can be null (freshly created sql with no statement executed yet
}
Esempio n. 8
0
void CvSqlQueryRichEditView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	int nHint = (int)lHint;
	CdSqlQueryRichEditDoc* pDoc =(CdSqlQueryRichEditDoc*)GetDocument();
	switch (nHint)
	{
	case UPDATE_HINT_LOAD:
		if (pHint && pHint == pDoc)
		{
			// Load document from the serialization:
			if (!pDoc->IsLoadedDoc())
				return;
			//
			// Put the global statement.
			CRichEditCtrl& redit = GetRichEditCtrl();
			LONG oldEventMask = redit.SetEventMask(ENM_NONE); // Do not send EN_CHANGE.
			redit.SetWindowText (pDoc->m_strStatement);
			// Set the highlight statement.
			if (pDoc->m_bHighlight)
			{
				redit.SetSel (0, -1);
				OnColorPick (pDoc->m_crColorText);
				redit.SetSel (pDoc->m_nStart, pDoc->m_nEnd);
				OnColorPick (pDoc->m_crColorSelect);
				redit.SetSel (-1, 0);
			}
			redit.SetEventMask(oldEventMask);// Restore the old event mask
			pDoc->SetTitle (pDoc->m_strTitle);
			//
			// Splitbar placement
			CfSqlQueryFrame* pFrame  = (CfSqlQueryFrame*)GetParentFrame();
			CSplitterWnd* pNestSplitter = pFrame->GetNestSplitterWnd();
			ASSERT (pNestSplitter); 
			CSplitterWnd* pMainSplitter = pFrame->GetMainSplitterWnd();
			ASSERT (pMainSplitter); 
			if (!(pMainSplitter && pNestSplitter))
				return;

			pMainSplitter->SetRowInfo(0, pDoc->GetSplitterCyCurMainSplit(), pDoc->GetSplitterCyMinMainSplit());
			pMainSplitter->RecalcLayout();
			pNestSplitter->SetRowInfo(0, pDoc->GetSplitterCyCurNestSplit(), pDoc->GetSplitterCyMinNestSplit());
			pNestSplitter->RecalcLayout();
		}
		break;
	case UPDATE_HINT_SETTINGCHANGE:
/*UKS
		if (pHint && pHint == pDoc && pDoc->GetSetting().GetFont())
		{
			long nStart;
			long nEnd;
			GetRichEditCtrl().GetSel(nStart, nEnd);
			//
			// The control simply uses the WM_SETFONT message to change the font.
			// There is no need to use the member:
			//    SetSelectionCharFormat,
			//    SetDefaultCharFormat,
			//    SetParaFormat,
			//    SetCharFormat,
			// because the control does not manage the text in different font.
			CString strText;
			GetRichEditCtrl().GetWindowText (strText);
			LONG oldEventMask = GetRichEditCtrl().SetEventMask(ENM_NONE); // Do not send EN_CHANGE.
			GetRichEditCtrl().Clear();
			SendMessage(WM_SETFONT, (WPARAM)pDoc->GetSetting().GetFont());
			Invalidate();
			GetRichEditCtrl().SetWindowText(strText);
			if (pDoc->m_bHighlight)
			{
				GetRichEditCtrl().SetSel (pDoc->m_nStart, pDoc->m_nEnd);
				OnColorPick (pDoc->m_crColorSelect);
				GetRichEditCtrl().SetSel (nStart, nEnd);
			}
			GetRichEditCtrl().SetEventMask(oldEventMask); 
		}
*/
		break;

	default:
		break;
	}
}