Esempio n. 1
0
void CPredView::OnFilePrint()
{
	CDC dc;
	CPrintDialog printDlg(false);
	if(printDlg.DoModal()==IDCANCEL)
		return;
	dc.Attach(printDlg.GetPrinterDC());
	dc.m_bPrinting=true;

	DOCINFO di;
	::ZeroMemory(&di,sizeof(DOCINFO));
	di.cbSize=sizeof(DOCINFO);
	di.lpszDocName="FCC Prediction";
	

	bool bPrintingOK=dc.StartDocA(&di);
	CPrintInfo info;
	info.m_rectDraw.SetRect(0,0,dc.GetDeviceCaps(HORZRES),dc.GetDeviceCaps(VERTRES));
	
	
	//OnPreparePrinting(&info);
	OnBeginPrinting(&dc,&info);
	OnPrint(&dc,&info);
	OnEndPrinting(&dc,&info);
	
	if(bPrintingOK)
		dc.EndDoc();
	else
		dc.AbortDoc();
	dc.Detach();
}
Esempio n. 2
0
BOOL CEditView::PaginateTo(CDC* pDC, CPrintInfo* pInfo)
	// attempts pagination to pInfo->m_nCurPage, TRUE == success
{
	ASSERT_VALID(this);
	ASSERT_VALID(pDC);

	CRect rectSave = pInfo->m_rectDraw;
	UINT nPageSave = pInfo->m_nCurPage;
	ASSERT(nPageSave > 1);
	ASSERT(nPageSave >= (UINT)m_aPageStart.GetSize());
	VERIFY(pDC->SaveDC() != 0);
	pDC->IntersectClipRect(0, 0, 0, 0);
	pInfo->m_nCurPage = m_aPageStart.GetSize();
	while (pInfo->m_nCurPage < nPageSave)
	{
		ASSERT(pInfo->m_nCurPage == (UINT)m_aPageStart.GetSize());
		OnPrepareDC(pDC, pInfo);
		ASSERT(pInfo->m_bContinuePrinting);
		pInfo->m_rectDraw.SetRect(0, 0,
			pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES));
		pDC->DPtoLP(&pInfo->m_rectDraw);
		OnPrint(pDC, pInfo);
		if (pInfo->m_nCurPage == (UINT)m_aPageStart.GetSize())
			break;
		++pInfo->m_nCurPage;
	}
	BOOL bResult = pInfo->m_nCurPage == nPageSave;
	pDC->RestoreDC(-1);
	pInfo->m_nCurPage = nPageSave;
	pInfo->m_rectDraw = rectSave;
	ASSERT_VALID(this);
	return bResult;
}
/*void rptDonthuoctonghop::OnSourceAddNew(){
	CMainFrame_E10 *pMF = (CMainFrame_E10*) AfxGetMainWnd();
	
} */
void rptDonthuoctonghop::OnPrintPreviewSelect(){
	CMainFrame_E10 *pMF = (CMainFrame_E10*) AfxGetMainWnd();
	UpdateData(TRUE);
	m_szStockName = m_wndStock.GetCurrent(1);
	OnPrint(true);

} 
Esempio n. 4
0
int CLabelView::OnPrintLabels(PrintContext &pc, int nCurrentPage, int nNumPages)
{
	CPmwDoc* pDoc = GetDocument();
	PPNT dims = pDoc->get_dimensions();

	int nError = 0;

	int nPrintCopies = pc.m_copies;

	while (nError == 0 && nPrintCopies-- > 0)
	{
	// Source will always be all of the label.

		pc.m_source.x0 = 0;
		pc.m_source.y0 = 0;
		pc.m_source.x1 = dims.x;
		pc.m_source.y1 = dims.y;

		OnPrepareDC(&pc.m_dcPrint, pc.m_pInfo);

	// Set up drawing rect to entire page (in logical coordinates)

		pc.m_pInfo->m_rectDraw.SetRect(0, 0,
							pc.m_dcPrint.GetDeviceCaps(HORZRES),
							pc.m_dcPrint.GetDeviceCaps(VERTRES));
		pc.m_dcPrint.DPtoLP(&pc.m_pInfo->m_rectDraw);

		CString strFmt;
		TRY
			LoadConfigurationString(IDS_PRINTPAGENUM, strFmt);
		END_TRY
		char szBuf[80];
		wsprintf(szBuf, strFmt, (int32)nCurrentPage+1, (int32)nNumPages);
		pc.m_dlgstatus->SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf);

		if (!pc.m_fBanding)
		{
			VERIFY(pc.m_dcPrint.StartPage());
		}
		nError = OnPrint(&pc, pc.m_pInfo) || UserAbort;
		if (!pc.m_fBanding)
		{
			if (pc.m_dcPrint.EndPage() < 0)
				nError = TRUE;
		}
	}
	return nError;
}
Esempio n. 5
0
// v7.2 update 04 - added to implement WM_PRINT handling for the top heading - TD 
LRESULT CUGCnrBtn::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	UNREFERENCED_PARAMETER(lParam);

	switch (message)
	{
		// TD - added to implement WM_PRINT handling for the grid
	case WM_PRINT:
		// call OnPrint to print the corner button
		InvalidateRect(NULL);
		OnPrint(CDC::FromHandle((HDC) wParam));
		return 0;
	default:
		return CWnd::WindowProc(message, wParam, lParam);
	}
}
	LRESULT CActiveXWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
	{
		LRESULT lRes=0;
		BOOL bHandled = TRUE;
		switch( uMsg ) {
		case WM_CREATE:        lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
		case WM_TIMER:         lRes = OnTimer(uMsg, wParam, lParam, bHandled); break;
		case WM_PAINT:         lRes = OnPaint(uMsg, wParam, lParam, bHandled); break;
		case WM_PRINT:		   lRes = OnPrint(uMsg, wParam, lParam, bHandled); break;
		case WM_SETFOCUS:      lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break;
		case WM_KILLFOCUS:     lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break;
		case WM_ERASEBKGND:    lRes = OnEraseBkgnd(uMsg, wParam, lParam, bHandled); break;
		case WM_MOUSEACTIVATE: lRes = OnMouseActivate(uMsg, wParam, lParam, bHandled); break;
		case WM_MOUSEWHEEL: break;
		default:
			bHandled = FALSE;
		}
		if( !bHandled ) return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
		return lRes;
	}
Esempio n. 7
0
void CView::OnFilePrint()
{
	// get default print info
	CPrintInfo printInfo;
	ASSERT(printInfo.m_pPD != NULL);    // must be set

	if (LOWORD(GetCurrentMessage()->wParam) == ID_FILE_PRINT_DIRECT)
	{
		CCommandLineInfo* pCmdInfo = AfxGetApp()->m_pCmdInfo;

		if (pCmdInfo != NULL)
		{
			if (pCmdInfo->m_nShellCommand == CCommandLineInfo::FilePrintTo)
			{
				printInfo.m_pPD->m_pd.hDC = ::CreateDC(pCmdInfo->m_strDriverName,
					pCmdInfo->m_strPrinterName, pCmdInfo->m_strPortName, NULL);
				if (printInfo.m_pPD->m_pd.hDC == NULL)
				{
					AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
					return;
				}
			}
		}

		printInfo.m_bDirect = TRUE;
	}

	if (OnPreparePrinting(&printInfo))
	{
		// hDC must be set (did you remember to call DoPreparePrinting?)
		ASSERT(printInfo.m_pPD->m_pd.hDC != NULL);

		// gather file to print to if print-to-file selected
		CString strOutput;
		if (printInfo.m_pPD->m_pd.Flags & PD_PRINTTOFILE && !printInfo.m_bDocObject)
		{
			// construct CFileDialog for browsing
			CString strDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULTEXT));
			CString strPrintDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULT));
			CString strFilter(MAKEINTRESOURCE(AFX_IDS_PRINTFILTER));
			CString strCaption(MAKEINTRESOURCE(AFX_IDS_PRINTCAPTION));
			CFileDialog dlg(FALSE, strDef, strPrintDef,
				OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, strFilter, NULL, 0);
			dlg.m_ofn.lpstrTitle = strCaption;

			if (dlg.DoModal() != IDOK)
				return;

			// set output device to resulting path name
			strOutput = dlg.GetPathName();
		}

		// set up document info and start the document printing process
		CString strTitle;
		CDocument* pDoc = GetDocument();
		if (pDoc != NULL)
			strTitle = pDoc->GetTitle();
		else
			EnsureParentFrame()->GetWindowText(strTitle);
		DOCINFO docInfo;
		memset(&docInfo, 0, sizeof(DOCINFO));
		docInfo.cbSize = sizeof(DOCINFO);
		docInfo.lpszDocName = strTitle;
		CString strPortName;
		if (strOutput.IsEmpty())
		{
			docInfo.lpszOutput = NULL;
			strPortName = printInfo.m_pPD->GetPortName();
		}
		else
		{
			docInfo.lpszOutput = strOutput;
			AfxGetFileTitle(strOutput,
				strPortName.GetBuffer(_MAX_PATH), _MAX_PATH);
		}

		// setup the printing DC
		CDC dcPrint;
		if (!printInfo.m_bDocObject)
		{
			dcPrint.Attach(printInfo.m_pPD->m_pd.hDC);  // attach printer dc
			dcPrint.m_bPrinting = TRUE;
		}
		OnBeginPrinting(&dcPrint, &printInfo);

		if (!printInfo.m_bDocObject)
			dcPrint.SetAbortProc(_AfxAbortProc);

		// disable main window while printing & init printing status dialog
		// Store the Handle of the Window in a temp so that it can be enabled 
		// once the printing is finished
		CWnd * hwndTemp = AfxGetMainWnd();
		hwndTemp->EnableWindow(FALSE);
		CPrintingDialog dlgPrintStatus(this);

		CString strTemp;
		dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_DOCNAME, strTitle);
		dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PRINTERNAME,
			printInfo.m_pPD->GetDeviceName());
		dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PORTNAME, strPortName);
		dlgPrintStatus.ShowWindow(SW_SHOW);
		dlgPrintStatus.UpdateWindow();

		// start document printing process
		if (!printInfo.m_bDocObject)
		{
			printInfo.m_nJobNumber = dcPrint.StartDoc(&docInfo);
			if (printInfo.m_nJobNumber == SP_ERROR)
			{
				// enable main window before proceeding
				hwndTemp->EnableWindow(TRUE);

				// cleanup and show error message
				OnEndPrinting(&dcPrint, &printInfo);
				dlgPrintStatus.DestroyWindow();
				dcPrint.Detach();   // will be cleaned up by CPrintInfo destructor
				AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
				return;
			}
		}

		// Guarantee values are in the valid range
		UINT nEndPage = printInfo.GetToPage();
		UINT nStartPage = printInfo.GetFromPage();

		if (nEndPage < printInfo.GetMinPage())
			nEndPage = printInfo.GetMinPage();
		if (nEndPage > printInfo.GetMaxPage())
			nEndPage = printInfo.GetMaxPage();

		if (nStartPage < printInfo.GetMinPage())
			nStartPage = printInfo.GetMinPage();
		if (nStartPage > printInfo.GetMaxPage())
			nStartPage = printInfo.GetMaxPage();

		int nStep = (nEndPage >= nStartPage) ? 1 : -1;
		nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep;

		VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM));

		// If it's a doc object, we don't loop page-by-page
		// because doc objects don't support that kind of levity.

		BOOL bError = FALSE;
		if (printInfo.m_bDocObject)
		{
			OnPrepareDC(&dcPrint, &printInfo);
			OnPrint(&dcPrint, &printInfo);
		}
		else
		{
			// begin page printing loop
			for (printInfo.m_nCurPage = nStartPage;
				printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep)
			{
				OnPrepareDC(&dcPrint, &printInfo);

				// check for end of print
				if (!printInfo.m_bContinuePrinting)
					break;

				// write current page
				TCHAR szBuf[80];
				ATL_CRT_ERRORCHECK_SPRINTF(_sntprintf_s(szBuf, _countof(szBuf), _countof(szBuf) - 1, strTemp, printInfo.m_nCurPage));
				
				dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf);

				// set up drawing rect to entire page (in logical coordinates)
				printInfo.m_rectDraw.SetRect(0, 0,
					dcPrint.GetDeviceCaps(HORZRES),
					dcPrint.GetDeviceCaps(VERTRES));
				dcPrint.DPtoLP(&printInfo.m_rectDraw);

				// attempt to start the current page
				if (dcPrint.StartPage() < 0)
				{
					bError = TRUE;
					break;
				}

				// must call OnPrepareDC on newer versions of Windows because
				// StartPage now resets the device attributes.
				OnPrepareDC(&dcPrint, &printInfo);

				ASSERT(printInfo.m_bContinuePrinting);

				// page successfully started, so now render the page
				OnPrint(&dcPrint, &printInfo);

				// If the user restarts the job when it's spooling, all 
				// subsequent calls to EndPage returns < 0. The first time
				// GetLastError returns ERROR_PRINT_CANCELLED
				if (dcPrint.EndPage() < 0 && (GetLastError()!= ERROR_SUCCESS))
				{
					HANDLE hPrinter;
					if (!OpenPrinter(LPTSTR(printInfo.m_pPD->GetDeviceName().GetBuffer()), &hPrinter, NULL))
					{
						bError = TRUE;
						break;
					}

					DWORD cBytesNeeded;
					if(!GetJob(hPrinter,printInfo.m_nJobNumber,1,NULL,0,&cBytesNeeded))
					{
						if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
						{
						   bError = TRUE;
						   break;
						}
					}

					JOB_INFO_1 *pJobInfo; 					
					if((pJobInfo = (JOB_INFO_1 *)malloc(cBytesNeeded))== NULL)
					{
						bError = TRUE;
						break;
					}

					DWORD cBytesUsed;

					BOOL bRet = GetJob(hPrinter,printInfo.m_nJobNumber,1,LPBYTE(pJobInfo),cBytesNeeded,&cBytesUsed);

					DWORD dwJobStatus = pJobInfo->Status;

					free(pJobInfo);
					pJobInfo = NULL;

					// if job status is restart, just continue
					if(!bRet || !(dwJobStatus & JOB_STATUS_RESTART) )
					{
						bError = TRUE;
						break;
					}
				}

				if(!_AfxAbortProc(dcPrint.m_hDC, 0))
				{		
					bError = TRUE;
					break;
				}
			}
		}

		// cleanup document printing process
		if (!printInfo.m_bDocObject)
		{
			if (!bError)
				dcPrint.EndDoc();
			else
				dcPrint.AbortDoc();
		}

		hwndTemp->EnableWindow();    // enable main window

		OnEndPrinting(&dcPrint, &printInfo);    // clean up after printing
		dlgPrintStatus.DestroyWindow();

		dcPrint.Detach();   // will be cleaned up by CPrintInfo destructor
	}
}
Esempio n. 8
0
void CPrint::OnPrint()
{
	if (ParentWnd == NULL) return;
	// get default print info
	CPrintInfo printInfo;
	ASSERT(printInfo.m_pPD != NULL);    // must be set
/*
	if (LOWORD(GetCurrentMessage()->wParam) == ID_FILE_PRINT_DIRECT)
	{
		CCommandLineInfo* pCmdInfo = AfxGetApp()->m_pCmdInfo;

		if (pCmdInfo != NULL)
		{
			if (pCmdInfo->m_nShellCommand == CCommandLineInfo::FilePrintTo)
			{
				printInfo.m_pPD->m_pd.hDC = ::CreateDC(pCmdInfo->m_strDriverName,
					pCmdInfo->m_strPrinterName, pCmdInfo->m_strPortName, NULL);
				if (printInfo.m_pPD->m_pd.hDC == NULL)
				{
					AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
					return;
				}
			}
		}

		printInfo.m_bDirect = TRUE;
	}
*/
	if (OnPreparePrinting(&printInfo))
	{
		// hDC must be set (did you remember to call DoPreparePrinting?)
		ASSERT(printInfo.m_pPD->m_pd.hDC != NULL);

		// gather file to print to if print-to-file selected
		CString strOutput;
		if (printInfo.m_pPD->m_pd.Flags & PD_PRINTTOFILE && !printInfo.m_bDocObject)
		{
			// construct CFileDialog for browsing
			CString strDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULTEXT));
			CString strPrintDef(MAKEINTRESOURCE(AFX_IDS_PRINTDEFAULT));
			CString strFilter(MAKEINTRESOURCE(AFX_IDS_PRINTFILTER));
			CString strCaption(MAKEINTRESOURCE(AFX_IDS_PRINTCAPTION));
			CFileDialog dlg(FALSE, strDef, strPrintDef,
				OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, strFilter);
			dlg.m_ofn.lpstrTitle = strCaption;

			if (dlg.DoModal() != IDOK)
				return;

			// set output device to resulting path name
			strOutput = dlg.GetPathName();
		}

		// set up document info and start the document printing process
		DOCINFO docInfo;
		memset(&docInfo, 0, sizeof(DOCINFO));
		docInfo.cbSize = sizeof(DOCINFO);
		docInfo.lpszDocName = PrintTitle;
		CString strPortName;
		int nFormatID;
		if (strOutput.IsEmpty())
		{
			docInfo.lpszOutput = NULL;
			strPortName = printInfo.m_pPD->GetPortName();
			nFormatID = AFX_IDS_PRINTONPORT;
		}
		else
		{
			docInfo.lpszOutput = strOutput;

			strPortName = "Miracle";
			/*AfxGetFileTitle(strOutput,
				strPortName.GetBuffer(_MAX_PATH), _MAX_PATH);*/
			nFormatID = AFX_IDS_PRINTTOFILE;
		}
		
		// setup the printing DC
		CDC dcPrint;
		if (!printInfo.m_bDocObject)
		{
			dcPrint.Attach(printInfo.m_pPD->m_pd.hDC);  // attach printer dc
			dcPrint.m_bPrinting = TRUE;
		}
		OnBeginPrinting(&dcPrint, &printInfo);

		if (!printInfo.m_bDocObject)
			dcPrint.SetAbortProc(AbortProc);

		// disable main window while printing & init printing status dialog
		AfxGetMainWnd()->EnableWindow(FALSE);
		CPrintingDialog dlgPrintStatus(ParentWnd);
		ghwndAbort = dlgPrintStatus.m_hWnd;
		CString strTemp;
		dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_DOCNAME, PrintTitle);
		dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PRINTERNAME,
			printInfo.m_pPD->GetDeviceName());
		AfxFormatString1(strTemp, nFormatID, strPortName);
		dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PORTNAME, strTemp);
		dlgPrintStatus.ShowWindow(SW_SHOW);
		dlgPrintStatus.UpdateWindow();

		// start document printing process
		if (!printInfo.m_bDocObject && dcPrint.StartDoc(&docInfo) == SP_ERROR)
		{
			// enable main window before proceeding
			AfxGetMainWnd()->EnableWindow(TRUE);

			// cleanup and show error message
			OnEndPrinting(&dcPrint, &printInfo);
			dlgPrintStatus.DestroyWindow();
			dcPrint.Detach();   // will be cleaned up by CPrintInfo destructor
			AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
			return;
		}

		// Guarantee values are in the valid range
		UINT nEndPage = printInfo.GetToPage();
		UINT nStartPage = printInfo.GetFromPage();

		if (nEndPage < printInfo.GetMinPage())
			nEndPage = printInfo.GetMinPage();
		if (nEndPage > printInfo.GetMaxPage())
			nEndPage = printInfo.GetMaxPage();

		if (nStartPage < printInfo.GetMinPage())
			nStartPage = printInfo.GetMinPage();
		if (nStartPage > printInfo.GetMaxPage())
			nStartPage = printInfo.GetMaxPage();

		int nStep = (nEndPage >= nStartPage) ? 1 : -1;
		nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep;

		VERIFY(strTemp.LoadString(AFX_IDS_PRINTPAGENUM));

		// If it's a doc object, we don't loop page-by-page
		// because doc objects don't support that kind of levity.

		BOOL bError = FALSE;
		
		// Print Loop // Burada DocObject kýsmý silindi
		{
			// begin page printing loop
			for (printInfo.m_nCurPage = nStartPage;
				printInfo.m_nCurPage != nEndPage; printInfo.m_nCurPage += nStep)
			{
				OnPrepareDC(&dcPrint, &printInfo);

				// check for end of print
				if (!printInfo.m_bContinuePrinting)
					break;

				// write current page
				TCHAR szBuf[80];
				wsprintf(szBuf, strTemp, printInfo.m_nCurPage);
				dlgPrintStatus.SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf);

				// set up drawing rect to entire page (in logical coordinates)
				printInfo.m_rectDraw.SetRect(0, 0,
					dcPrint.GetDeviceCaps(HORZRES),
					dcPrint.GetDeviceCaps(VERTRES));
				dcPrint.DPtoLP(&printInfo.m_rectDraw);

				// attempt to start the current page
				if (dcPrint.StartPage() < 0)
				{
					DebugMessage("Error on print 2");
					bError = TRUE;
					break;
				}

				// must call OnPrepareDC on newer versions of Windows because
				// StartPage now resets the device attributes.
				//if (afxData.bMarked4)
					OnPrepareDC(&dcPrint, &printInfo);

				ASSERT(printInfo.m_bContinuePrinting);

				// page successfully started, so now render the page
				OnPrint(&dcPrint, &printInfo);
				TRACE("on print\n");
				int stat = dcPrint.EndPage();
				if (stat < 0 || !AbortProc(dcPrint.m_hDC, 0))
				{
					bError = TRUE;
					CString str;
					str.Format("End Page = %ld,Abort = %ld",stat,gbAbort);
					DebugMessage(str);
					DebugMessage("Error on print");
					break;
				}
			}
		}

		// cleanup document printing process
		if (!printInfo.m_bDocObject)
		{
			if (!bError)
				dcPrint.EndDoc();
			else
				dcPrint.AbortDoc();
		}

		AfxGetMainWnd()->EnableWindow();    // enable main window

		OnEndPrinting(&dcPrint, &printInfo);    // clean up after printing
		dlgPrintStatus.DestroyWindow();

		dcPrint.Detach();   // will be cleaned up by CPrintInfo destructor
	}
}
Esempio n. 9
0
void CMenuWndHook::OnNcPaint()
{
    HDC dc=GetWindowDC(m_hWnd);
    OnPrint(dc);
    ReleaseDC(m_hWnd,dc);
}
Esempio n. 10
0
bool TextViewBase::HandleWndProc(UINT msg, WPARAM wParam, LPARAM lParam, LONG *pResult)
{
	HIMC hIMC = NULL;
	switch (msg)
	{
		// Draw contents of TextView whenever window needs updating
	case WM_ERASEBKGND:
		*pResult = 1;
		return true;
		// Need to custom-draw the border for XP/Vista themes
	case WM_NCPAINT:
		*pResult = OnNcPaint((HRGN)wParam);
		return true;

	case WM_PAINT:
		*pResult = OnPaint();
		return true;
		// Set a new font 
	case WM_SETFONT:
		*pResult = OnSetFont((HFONT)wParam);
		return true;

	case WM_SIZE:
		*pResult = OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
		return true;

	case WM_VSCROLL:
		*pResult = OnVScroll(LOWORD(wParam), HIWORD(wParam));
		return true;

	case WM_HSCROLL:
		*pResult = OnHScroll(LOWORD(wParam), HIWORD(wParam));
		return true;

	case WM_MOUSEACTIVATE:
		*pResult = OnMouseActivate((HWND)wParam, LOWORD(lParam), HIWORD(lParam));
		return true;

		//case WM_CONTEXTMENU:
		//	return OnContextMenu((HWND)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));

	case WM_MOUSEWHEEL:
		if (IsKeyPressed(VK_CONTROL))
			return false;
		else
			*pResult = OnMouseWheel((short)HIWORD(wParam));
		return true;

	case WM_SETFOCUS:
		*pResult = OnSetFocus((HWND)wParam);
		return true;

	case WM_KILLFOCUS:
		*pResult = OnKillFocus((HWND)wParam);
		return true;

		// make sure we get arrow-keys, enter, tab, etc when hosted inside a dialog
	case WM_GETDLGCODE:
		*pResult = DLGC_WANTALLKEYS;//DLGC_WANTMESSAGE;//DLGC_WANTARROWS;
		return true;

	case WM_LBUTTONDOWN:
		*pResult = OnLButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_LBUTTONUP:
		*pResult = OnLButtonUp(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_LBUTTONDBLCLK:
		*pResult = OnLButtonDblClick(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_RBUTTONDOWN:
		*pResult = OnRButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;
	case WM_MOUSEMOVE:
		*pResult = OnMouseMove(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_KEYDOWN:
		*pResult = OnKeyDown(wParam, lParam);
		return true;

	case WM_UNDO: case TXM_UNDO: case EM_UNDO:
		*pResult = Undo();
		return true;

	case TXM_REDO : case EM_REDO:
		*pResult = Redo();
		return true;

	case TXM_CANUNDO: case EM_CANUNDO:
		*pResult = CanUndo();
		return true;

	case TXM_CANREDO: case EM_CANREDO:
		*pResult = CanRedo();
		return true;

	case WM_CHAR:
		OutputDebugString(L"WM_CHAR\n");
		*pResult = OnChar(wParam, lParam);
		return true;

	case WM_SETCURSOR:

		if (LOWORD(lParam) == HTCLIENT)
		{
			*pResult = TRUE;
			return true;
		}
		else
			return false;
	case WM_COPY:
		*pResult = OnCopy();
		return true;

	case WM_CUT:
		*pResult = OnCut();
		return true;

	case WM_PASTE:
		*pResult = OnPaste();
		return true;

	case WM_CLEAR:
		*pResult = OnClear();
		return true;
	
	case WM_GETTEXT:
		*pResult = GetText((WCHAR*)lParam, 0, (ULONG)wParam);
		return true;

	case WM_SETTEXT:
		*pResult = OnSetText((WCHAR*)lParam, lstrlen((WCHAR*)lParam));
		return true;
		//case TXM_SETTEXT:
		//	{
		//		ClearFile();
		//		EnterText((WCHAR*)lParam, (LONG)wParam);
		//		return 0;
		//	}
	case WM_TIMER:
		*pResult = OnTimer(wParam);
		return true;

	case WM_IME_STARTCOMPOSITION:
		OutputDebugString(L"WM_IME_STARTCOMPOSITION\n");
		*pResult = OnStartComposition(wParam, lParam);
		return true;
		//return DefWindowProc(m_hWnd, WM_IME_STARTCOMPOSITION, wParam, lParam);

	case WM_IME_COMPOSITION:
		OutputDebugString(L"WM_IME_COMPOSITION\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_COMPOSITION, wParam, lParam);
		return true;
		//return OnComposition(wParam, lParam);

	case WM_IME_ENDCOMPOSITION:
		OutputDebugString(L"WM_IME_ENDCOMPOSITION\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_ENDCOMPOSITION, wParam, lParam);
		return true;
		//return OnEndComposition(wParam, lParam);

	case WM_IME_CHAR:
		OutputDebugString(L"WM_IME_CHAR\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_CHAR, wParam, lParam);
		return true;

	case WM_IME_CONTROL:
		OutputDebugString(L"WM_IME_CONTROL\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_CONTROL, wParam, lParam);
		return true;


	case WM_IME_NOTIFY:
		OutputDebugString(L"WM_IME_NOTIFY\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_NOTIFY, wParam, lParam);
		return true;
		//return HandleImeNotify(wParam, lParam);

	case WM_IME_REQUEST:
		OutputDebugString(L"WM_IME_REQUEST\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_REQUEST, wParam, lParam);
		return true;
	case WM_INPUTLANGCHANGE:
		*pResult = OnInputLanChange(wParam, lParam);
		return true;

	case TXM_PRINT:
		*pResult = OnPrint((HDC)wParam, (int)lParam);
		return true;

		//
	case TXM_OPENFILE:
		*pResult = OpenFile((TCHAR *)lParam);
		return true;


	case TXM_SAVEFILE:
		*pResult = SaveFile((TCHAR *)lParam);
		return true;

	case TXM_IMPORTFILE:
		*pResult = ImportFile((TCHAR *)lParam, (int)wParam);
		return true;

	case TXM_EXPORTFILE:
	{
		int convertype = LOWORD(wParam);
		int utf_type = HIWORD(wParam);
		*pResult = ExportFile((TCHAR *)lParam, convertype, utf_type);
		return true;
	}

	case TXM_CLEAR:
		*pResult = ClearFile();
		return true;

	case TXM_GETFORMAT:
		*pResult = m_pTextDoc->getformat();
		return true;

	case TXM_SETFORMAT:
		*pResult = m_pTextDoc->setformat((int)wParam);
		return true;

	case TXM_GETSELSIZE:
		*pResult = SelectionSize();
		return true;

	case TXM_SETSELALL:
		*pResult = SelectAll();
		return true;

	case TXM_GETCURPOS:
		*pResult = m_CurrentCharPos.get();
		return true;

	case TXM_GETCURLINE_D:
		*pResult = m_nCurrentLine_D;
		return true;

	case TXM_GETCURLINE_V:
		*pResult = OnGetCurLineV();
		return true;

	case TXM_GETCURCOL:
		*pResult = OnGetCurCol();
		return true;

	case TXM_GETEDITMODE:
		*pResult = m_nEditMode;
		return true;

	case TXM_SETEDITMODE:
		lParam = m_nEditMode;
		m_nEditMode = wParam;
		*pResult = lParam;
		return true;
	case TXM_FIND_INIT:
		FindInitial((WCHAR*)lParam);
		*pResult = 0;
		return true;
	case TXM_FIND:
	{
		BOOL m = (BOOL)LOWORD(wParam);
		BOOL b = (BOOL)HIWORD(wParam);
		//FindText()
		if (b)
			*pResult = FindBackward(m, NULL);
		else
			*pResult = FindForward(m, NULL);
		return true;
	}
	case TXM_FIND_TEXT:
	{
		FIND_OPTION* fp = (FIND_OPTION*)(lParam);
		*pResult = Find_Text(fp->text, lstrlen(fp->text), fp->fBackward, fp->fMachCase, fp->fWarp);
		return true;
	}
	case TXM_REPLACE_TEXT:
	{
		*pResult = Replace_Text((REPLACE_OPTION*)(lParam));
		return true;
	}
	case TXM_SETRESMODULE:
	{
		*pResult = OnSetResModule((HMODULE)lParam);
		return true;
	}
	case WM_GETTEXTLENGTH:
	case TXM_GETTEXTLEN:
	{
		*pResult = OnGetTextLen();
		return true;
	}
	case TXM_REPLACE:
	{
		BOOL ra = (BOOL)LOWORD(wParam);
		WORD mb = (WORD)HIWORD(wParam);
		BOOL m = (BOOL)LOBYTE(mb);
		BOOL b = (BOOL)HIBYTE(mb);
		if (b)
			*pResult = FindBackward(m, (WCHAR*)lParam, ra);
		else
			*pResult = FindForward(m, (WCHAR*)lParam, ra);
		return true;
	}
	case TXM_FIND_GETTEXTLENGTH:
		*pResult = m_pFndIterator->find_text_length();
		return true;
	case TXM_GETSELSTART:
		*pResult = m_nSelectionStart;
		return true;
	case TXM_GETSELEND:
		*pResult = m_nSelectionEnd;
		return true;
	case TXM_GETSELTEXT:
		*pResult = OnGetSelText((WCHAR*)wParam, ULONG(lParam));
		return true;
	case TXM_SETTESTERMODE:
		OnTesterMode((bool)wParam);
		*pResult = 0;
		return true;
	case TXM_SETCONTEXTMENU:
		m_hUserMenu = (HMENU)wParam;
		*pResult = 0;
		return true;
	case TXM_STATISTIC:
		*pResult = OnDoStatistic((STATISTIC*)(lParam));
		return true;
	case TXM_GETCONVERTTYPES:
		*pResult = OnGetConvertTypes((convert_type*)(lParam));
		return true;
	case EM_GETSEL:
		*pResult = OnMsg_EM_GETSEL((ULONG*)wParam, (ULONG*)lParam);
		return true;
	case EM_SETSEL:
		*pResult = OnMsg_EM_SETSEL((LONG)wParam, (LONG)lParam);
		return true;
	default:
		return false;
	}
}
Esempio n. 11
0
// Handles a menu item selection
LRESULT CNoteDlg::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	switch (LOWORD(wParam))
	{
	case IDR_MENU_NEWNOTE:
		OnNewNote();
		break;
	case IDR_MENU_SAVE:
		OnSave(true);
		break;
	case IDR_MENU_SAVETOFILE:
		OnSaveToFile();
		break;
	case IDR_MENU_IMPORTFROMFILE:
		OnImportFromFile();
		break;
	case IDR_MENU_DELETE:
		OnDelete();
		break;
	case IDR_MENU_SETFONT:
		OnSetFont();
		break;
	case ID_EDIT_SETTITLE:
		OnSetTitle();
		break;
	case IDR_MENU_CLOSE:
		CloseDialog(0);
		break;
	case IDR_MENU_BLUE:
		OnChangeBkgndColor(BLUE);
		break;
	case IDR_MENU_GREEN:
		OnChangeBkgndColor(GREEN);
		break;
	case IDR_MENU_PINK:
		OnChangeBkgndColor(PINK);
		break;
	case IDR_MENU_YELLOW:
		OnChangeBkgndColor(YELLOW);
		break;
	case IDR_MENU_WHITE:
		OnChangeBkgndColor(WHITE);
		break;
	case IDR_MENU_0:
		MakeTransparent(255);
		break;
	case IDR_MENU_10:
		MakeTransparent(225);
		break;
	case IDR_MENU_20:
		MakeTransparent(200);
		break;
	case IDR_MENU_30:
		MakeTransparent(175);
		break;
	case IDR_MENU_40:
		MakeTransparent(150);
		break;
	case IDR_MENU_50:
		MakeTransparent(125);
		break;
	case IDR_MENU_60:
		MakeTransparent(100);
		break;
	case IDR_MENU_70:
		MakeTransparent(75);
		break;
	case IDR_MENU_80:
		MakeTransparent(50);
		break;
	case IDR_MENU_90:
		MakeTransparent(25);
		break;
	case ID_FILE_PAGE_SETUP:
		OnPageSetup();
		break;
	case ID_FILE_PRINT:
		OnPrint();
		break;
	default:
		break;
	}

	return 0;
}
Esempio n. 12
0
BOOL CMlsPrint::Print(CMlsPrintInfo* pInfo, CWnd* pParent)
{
	BOOL fSuccess = FALSE;
	
	ASSERT(pInfo != NULL);
	
	m_pInfo = pInfo;
	m_pParent = pParent;
	
	if (OnPreparePrinting())
	{
		fSuccess = TRUE;
		
		ASSERT(m_pInfo->m_pPD->m_pd.hDC != NULL);

		CDC dcPrint;
		dcPrint.Attach(m_pInfo->m_pPD->m_pd.hDC);
		dcPrint.m_bPrinting = TRUE;
		m_pDC = &dcPrint;

		OnBeginPrinting();
		OnCreatePrintingDialog();
		
		dcPrint.SetAbortProc(MlsPrintAbortProc);

		CString docTitle;
		GetTitle(docTitle);
		
		if (docTitle.GetLength() > 31)
		{
			docTitle.ReleaseBuffer(31);
		}

		DOCINFO docInfo;
		memset(&docInfo, 0, sizeof(DOCINFO));
		docInfo.cbSize = sizeof(DOCINFO);
		docInfo.lpszDocName = docTitle;
//		docInfo.lpszOutput = NULL;

		if (dcPrint.StartDoc(&docInfo) != SP_ERROR)
		{
			UINT nEndPage = m_pInfo->GetToPage();
			UINT nStartPage = m_pInfo->GetFromPage();
	
			// Guarantee values are in the valid range
			if (nEndPage < m_pInfo->GetMinPage())
				nEndPage = m_pInfo->GetMinPage();
			if (nEndPage > m_pInfo->GetMaxPage())
				nEndPage = m_pInfo->GetMaxPage();
	
			if (nStartPage < m_pInfo->GetMinPage())
				nStartPage = m_pInfo->GetMinPage();
			if (nStartPage > m_pInfo->GetMaxPage())
				nStartPage = m_pInfo->GetMaxPage();
	
			int nStep = (nEndPage >= nStartPage) ? 1 : -1;
			nEndPage = (nEndPage == 0xffff) ? 0xffff : nEndPage + nStep;
	
			BOOL bError = FALSE;
			for (m_pInfo->m_nCurPage = nStartPage; !bError && m_pInfo->m_nCurPage != nEndPage; m_pInfo->m_nCurPage += nStep)
			{
				OnPrepareDC();
	
				if (!m_pInfo->m_bContinuePrinting)
				{
					break;
				}
	
				// Set up drawing rect to entire page (in logical coordinates)
				m_pInfo->m_rectDraw.SetRect(0, 0, dcPrint.GetDeviceCaps(HORZRES), dcPrint.GetDeviceCaps(VERTRES));
				dcPrint.DPtoLP(&m_pInfo->m_rectDraw);
				
				OnUpdatePrintingDialog();
				
				VERIFY(dcPrint.StartPage());
				
				OnPrint();
				
				if (dcPrint.EndPage() < 0)
				{
					bError = TRUE;
				}
			}
	
			if (!bError)
			{
				dcPrint.EndDoc();
			}
		}
		
		else
		{
			AfxMessageBox(AFX_IDP_FAILED_TO_START_PRINT);
		}
		
		OnEndPrinting();
		OnReleasePrintingDialog();
		
		m_pDC = NULL;
	}
	
	m_pInfo = NULL;
	
	return fSuccess;
}