// PrintPreview.cpp : implementation file // #include "stdafx.h" #include "LYFZIPManage.h" #include "PrintPreview.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // PrintPreview dialog PrintPreview::PrintPreview(CWnd* pParent /*=NULL*/) : CDialog(PrintPreview::IDD, pParent) { //{{AFX_DATA_INIT(PrintPreview) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pDC=NULL; m_rc.right =0; } void PrintPreview::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(PrintPreview) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(PrintPreview, CDialog) //{{AFX_MSG_MAP(PrintPreview) ON_WM_CLOSE() ON_WM_PAINT() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_WM_MOUSEWHEEL() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_BN_CLICKED(IDC_BUTTON4, OnButton4) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // PrintPreview message handlers void PrintPreview::OnOK() { // TODO: Add extra validation here CDialog::OnOK(); } void PrintPreview::OnCancel() { // TODO: Add extra cleanup here } void PrintPreview::OnClose() { // TODO: Add your message handler code here and/or call default CDialog::OnCancel(); } BOOL PrintPreview::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here DEVMODE dm; dm.dmSize = sizeof(DEVMODE) ; EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dm); ::SetWindowPos(m_hWnd,HWND_TOP,0 ,0,dm.dmPelsWidth,dm.dmPelsHeight,SWP_SHOWWINDOW); CRect rc,rc2; GetClientRect(rc); RectFitDes(m_w,m_h, rc); GetDlgItem(IDOK)->GetWindowRect(rc2); ScreenToClient(rc2); int wid=rc2.Width (); rc2.right =rc.left -10; rc2.left =rc2.right -wid; GetDlgItem(IDOK)->MoveWindow(rc2); GetDlgItem(IDC_BUTTON1)->GetWindowRect(rc2); ScreenToClient(rc2); rc2.right =rc.left -10; rc2.left =rc2.right -wid; GetDlgItem(IDC_BUTTON1)->MoveWindow(rc2); GetDlgItem(IDC_BUTTON2)->GetWindowRect(rc2); ScreenToClient(rc2); rc2.right =rc.left -10; rc2.left =rc2.right -wid; GetDlgItem(IDC_BUTTON2)->MoveWindow(rc2); GetDlgItem(IDC_BUTTON3)->GetWindowRect(rc2); ScreenToClient(rc2); rc2.right =rc.left -10; rc2.left =rc2.right -wid; GetDlgItem(IDC_BUTTON3)->MoveWindow(rc2); GetDlgItem(IDC_BUTTON4)->GetWindowRect(rc2); ScreenToClient(rc2); rc2.right =rc.left -10; rc2.left =rc2.right -wid; GetDlgItem(IDC_BUTTON4)->MoveWindow(rc2); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void PrintPreview::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here if(m_pDC) { CRect rc; GetClientRect(rc); if(m_rc.right ==0) { m_rc=rc; ////////// float fscale=(float)m_w/(float)m_h; float rcscale=((float)m_rc.Width ())/((float)m_rc.Height ()); int rcwid=m_rc.Width (); int rchei=m_rc.Height (); int dt=0; if(rcscaleWidth ()*0.1; dty=pRc->Height ()*0.1; pRc->left -= dtx; pRc->right += dtx; pRc->top -= dty; pRc->bottom = pRc->top+pRc->Width ()*(m_h)/(m_w); Invalidate(); } void PrintPreview::OnButton3() { // TODO: Add your control notification handler code here CRect *pRc=&m_rc; int dtx; int dty; dtx=pRc->Width ()*0.1; dty=pRc->Height ()*0.1; if(dtx<10 || dty<10)return; pRc->left += dtx; pRc->right -= dtx; pRc->top += dty; pRc->bottom = pRc->top+pRc->Width ()*(m_h)/(m_w); Invalidate(); } BOOL PrintPreview::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { // TODO: Add your message handler code here and/or call default if(zDelta>0) { CRect *pRc=&m_rc; int dtx; int dty; dtx=pRc->Width ()*0.1; dty=pRc->Height ()*0.1; pRc->left -= dtx; pRc->right += dtx; pRc->top -= dty; pRc->bottom = pRc->top+pRc->Width ()*(m_h)/(m_w); Invalidate(); } else { CRect *pRc=&m_rc; int dtx; int dty; dtx=pRc->Width ()*0.1; dty=pRc->Height ()*0.1; if(dtx<10 || dty<10)return 1; pRc->left += dtx; pRc->right -= dtx; pRc->top += dty; pRc->bottom = pRc->top+pRc->Width ()*(m_h)/(m_w); Invalidate(); } return CDialog::OnMouseWheel(nFlags, zDelta, pt); } void PrintPreview::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default SetCapture(); m_startpt=point; CDialog::OnLButtonDown(nFlags, point); } void PrintPreview::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(GetCapture()!=this)return; ReleaseCapture(); m_rc.left +=point.x-m_startpt.x; m_rc.right +=point.x-m_startpt.x; m_rc.top +=point.y-m_startpt.y; m_rc.bottom +=point.y-m_startpt.y; m_startpt=point; Invalidate(); CDialog::OnLButtonUp(nFlags, point); } void PrintPreview::OnButton4() { // TODO: Add your control notification handler code here m_rc.right =0; Invalidate(); }