MFC在对话框中实现打印和打印预览

2024-08-21 21:28

本文主要是介绍MFC在对话框中实现打印和打印预览,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

首先在这里感谢互联网的大哥们!同时我讨厌动不动就是要vip才能查看!所以我写的不需要vip就能看。只求点个赞。

直接上代码,新建6个文件CPrintFrame.cpp;CPrintFrame.h;CPrintPreviewView.cpp;CPrintPreviewView.h;CPrintView.cpp;CPrintView.h;

下面是代码

CPrintFrame.h

#pragma once// CPrintFrame 框架
#include "CPrintView.h"
#include "CertEditPage.h"
#include "DemarManageDlg.h"class CPrintFrame : public CFrameWnd
{DECLARE_DYNCREATE(CPrintFrame)
protected:CPrintFrame();           // 动态创建所使用的受保护的构造函数virtual ~CPrintFrame();public:CPrintFrame(CCertEditPage* pCCertEditPage, CDemarManageDlg* pDemarManageDlg, BOOL bPreview);CCertEditPage* m_pCCertEditPage;CPrintView* m_pCPrintView;CDemarManageDlg* m_pDemarManageDlg;BOOL m_bPreview;
protected:DECLARE_MESSAGE_MAP()
public:afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);afx_msg void OnClose();void SetOrientation(short orientation);virtual BOOL PreCreateWindow(CREATESTRUCT& cs);virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
};

CPrintFrame.cpp

// CPrintFrame.cpp: 实现文件
//#include "stdafx.h"
#include "CPrintFrame.h"// CPrintFrameIMPLEMENT_DYNCREATE(CPrintFrame, CFrameWnd)CPrintFrame::CPrintFrame():m_pCCertEditPage(NULL),m_pCPrintView(NULL), m_bPreview(TRUE)
{m_pCCertEditPage = NULL;
}CPrintFrame::CPrintFrame(CCertEditPage* pCCertEditPage, CDemarManageDlg* pDemarManageDlg,BOOL bPreview): m_pCCertEditPage(NULL), m_pCPrintView(NULL)
{m_bPreview = bPreview;m_pCCertEditPage = pCCertEditPage;m_pDemarManageDlg = pDemarManageDlg;CString title;if (m_bPreview)title = L"打印预览";elsetitle = L"打印";if (Create(NULL, title, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, CRect(200, 200, 500, 500))){//创建失败return;}SetOrientation(DMORIENT_LANDSCAPE);
}CPrintFrame::~CPrintFrame()
{//CWinApp* pApp = AfxGetApp();//pApp->m_pMainWnd = m_pDemarManageDlg;if (m_pCCertEditPage)m_pCCertEditPage->ShowWindow(SW_SHOW);
}BEGIN_MESSAGE_MAP(CPrintFrame, CFrameWnd)ON_WM_CREATE()ON_WM_CLOSE()
END_MESSAGE_MAP()// CPrintFrame 消息处理程序int CPrintFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{if (CFrameWnd::OnCreate(lpCreateStruct) == -1)return -1;if (!m_pCCertEditPage)return -1;// TODO:  在此添加您专用的创建代码CCreateContext context;context.m_pNewViewClass = RUNTIME_CLASS(CPrintView);context.m_pCurrentFrame = this;context.m_pCurrentDoc = NULL;context.m_pLastView = NULL;m_pCPrintView = STATIC_DOWNCAST(CPrintView, CreateView(&context));if (!m_pCPrintView)return -1;if (m_bPreview){m_pCPrintView->ShowWindow(SW_SHOW);}SetActiveView(m_pCPrintView);SetIcon(m_pCCertEditPage->GetIcon(FALSE), FALSE);SetIcon(m_pCCertEditPage->GetIcon(TRUE), TRUE);//ShowWindow(SW_MAXIMIZE);CRect rect;m_pCCertEditPage->GetWindowRect(rect);MoveWindow(rect);ShowWindow(SW_SHOW);m_pCPrintView->m_pCPrintFrame = this;CWinApp* pApp = AfxGetApp();pApp->m_pMainWnd = this;if (m_bPreview){m_pCPrintView->OnFilePrintPreview();m_pCCertEditPage->ShowWindow(SW_HIDE);}elsem_pCPrintView->SendMessage(WM_COMMAND, ID_FILE_PRINT);return 0;
}void CPrintFrame::OnClose()
{// TODO: 在此添加消息处理程序代码和/或调用默认值CWinApp* pApp = AfxGetApp();pApp->m_pMainWnd = m_pDemarManageDlg;this->DestroyWindow();//CFrameWnd::OnClose();
}
void CPrintFrame::SetOrientation(short orientation)
{PRINTDLG pd;pd.lStructSize = (DWORD)sizeof(PRINTDLG);BOOL bRet = AfxGetApp()->GetPrinterDeviceDefaults(&pd);if (bRet){LPDEVMODE lpDevMode = (LPDEVMODE) ::GlobalLock(pd.hDevMode);if (lpDevMode != NULL)lpDevMode->dmOrientation = orientation;::GlobalUnlock(pd.hDevMode);}
}BOOL CPrintFrame::PreCreateWindow(CREATESTRUCT& cs)
{// TODO: 在此添加专用代码和/或调用基类if (!CFrameWnd::PreCreateWindow(cs))return FALSE;// TODO: Modify the Window class or styles here by modifying//  the CREATESTRUCT cscs.dwExStyle &= ~WS_EX_CLIENTEDGE;cs.lpszClass = AfxRegisterWndClass(0);return TRUE;//return CFrameWnd::PreCreateWindow(cs);
}BOOL CPrintFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{// TODO: 在此添加专用代码和/或调用基类if (m_pCPrintView && m_pCPrintView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))return TRUE;return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

CPrintView.h

#pragma once
#include <afxpriv.h>// CPrintView 视图class CPrintView : public CScrollView
{DECLARE_DYNCREATE(CPrintView)protected:CPrintView();           // 动态创建所使用的受保护的构造函数virtual ~CPrintView();public:
#ifdef _DEBUGvirtual void AssertValid() const;
#ifndef _WIN32_WCEvirtual void Dump(CDumpContext& dc) const;
#endif
#endifprotected:virtual void OnDraw(CDC* pDC);      // 重写以绘制该视图virtual void OnInitialUpdate();     // 构造后的第一次DECLARE_MESSAGE_MAP()
public:void SetPaper(short dmOrientation, short dmPaperSize);void OnFilePrintPreview();afx_msg void OnFilePrint();void DrawCertification(CDC* pDC, CPrintInfo* pInfo);virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);CFrameWnd* m_pCPrintFrame;virtual void OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView);virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);void DrawCardData(CDC* pDC, CPrintInfo* pInfo);afx_msg void OnClose();BOOL DoPrintPreview(UINT nIDResource, CView* pPrintView, CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState);
};

CPrintView.cpp

// CPrintView.cpp: 实现文件
//#include "stdafx.h"
#include "DemarManage.h"
#include "CPrintView.h"
#include "DemarManageDlg.h"
#include "CPrintFrame.h"
#include "CPrintPreviewView.h"
// CPrintViewIMPLEMENT_DYNCREATE(CPrintView, CScrollView)CPrintView::CPrintView():m_pCPrintFrame(NULL)
{m_nMapMode = MM_TEXT;}CPrintView::~CPrintView()
{
}BOOL CALLBACK _AfxMyPreviewCloseProc(CFrameWnd* pFrameWnd)
{ASSERT_VALID(pFrameWnd);CPrintPreviewView* pView = (CPrintPreviewView*)pFrameWnd->GetDlgItem(AFX_IDW_PANE_FIRST);ASSERT_KINDOF(CPrintPreviewView, pView);pView->OnPreviewClose();return FALSE;
}BEGIN_MESSAGE_MAP(CPrintView, CScrollView)ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CPrintView::OnFilePrintPreview)ON_COMMAND(ID_FILE_PRINT, &CPrintView::OnFilePrint)ON_WM_CLOSE()
END_MESSAGE_MAP()// CPrintView 诊断#ifdef _DEBUG
void CPrintView::AssertValid() const
{CScrollView::AssertValid();
}#ifndef _WIN32_WCE
void CPrintView::Dump(CDumpContext& dc) const
{CScrollView::Dump(dc);
}
#endif
#endif //_DEBUG// CPrintView 绘图void CPrintView::OnInitialUpdate()
{CScrollView::OnInitialUpdate();CSize sizeTotal;// TODO:  计算此视图的合计大小sizeTotal.cx = sizeTotal.cy = 100;SetScrollSizes(MM_TEXT, sizeTotal);
}void CPrintView::OnDraw(CDC* pDC)
{CDocument* pDoc = GetDocument();// TODO:  在此添加绘制代码}/************************************************************************/
/* 设置纸张                                                              */
/************************************************************************/
void CPrintView::SetPaper(short dmOrientation, short dmPaperSize)
{PRINTDLG pd;pd.lStructSize = (DWORD)sizeof(PRINTDLG);BOOL bRet = AfxGetApp()->GetPrinterDeviceDefaults(&pd);if (bRet){LPDEVMODE lpDevMode = (LPDEVMODE) ::GlobalLock(pd.hDevMode);if (lpDevMode != NULL){lpDevMode->dmOrientation = dmOrientation;lpDevMode->dmPaperSize = dmPaperSize;}::GlobalUnlock(pd.hDevMode);}
}void CPrintView::OnFilePrintPreview()
{CPrintFrame* pCPrintFrame = (CPrintFrame*)m_pCPrintFrame;if (!pCPrintFrame || !pCPrintFrame->m_pCCertEditPage)return;switch (pCPrintFrame->m_pCCertEditPage->m_nPrintMode){case 1:SetPaper(DMORIENT_PORTRAIT, DMPAPER_A5);break;case 2:SetPaper(DMORIENT_PORTRAIT, DMPAPER_A5);break;case 4:SetPaper(DMORIENT_PORTRAIT, DMPAPER_A5);break;}//CView::OnFilePrintPreview();CPrintPreviewState* pState = new CPrintPreviewState;pState->lpfnCloseProc = _AfxMyPreviewCloseProc;if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this, RUNTIME_CLASS(CPrintPreviewView), pState)){TRACE0("Error: DoPrintPreview failed.\n");AfxMessageBox(AFX_IDP_COMMAND_FAILURE);delete pState;}
}
BOOL CPrintView::DoPrintPreview(UINT nIDResource, CView* pPrintView, CRuntimeClass* pPreviewViewClass, CPrintPreviewState* pState)
{ASSERT_VALID_IDR(nIDResource);if (!m_pCPrintFrame || !pPrintView || !pPreviewViewClass)return FALSE;ASSERT(pPreviewViewClass->IsDerivedFrom(RUNTIME_CLASS(CPreviewView)));if(!pState)return FALSE;CCreateContext context;context.m_pCurrentFrame = m_pCPrintFrame;context.m_pCurrentDoc = GetDocument();context.m_pLastView = this;// Create the preview view objectCPrintPreviewView* pView = (CPrintPreviewView*)pPreviewViewClass->CreateObject();if (!pView){TRACE0("Error: Failed to create preview view.\n");return FALSE;}ASSERT_KINDOF(CPreviewView, pView);pView->m_pPreviewState = pState;        // save pointerm_pCPrintFrame->OnSetPreviewMode(TRUE, pState);    // Take over Frame Window//Create the toolbar from the dialog resourcepView->m_pToolBar = new CDialogBar;if (!pView->m_pToolBar->Create(m_pCPrintFrame, MAKEINTRESOURCE(nIDResource),CBRS_TOP, AFX_IDW_PREVIEW_BAR)){TRACE0("Error: Preview could not create toolbar dialog.\n");m_pCPrintFrame->OnSetPreviewMode(FALSE, pState);   // restore Frame Windowdelete pView->m_pToolBar;       // not autodestruct yetpView->m_pToolBar = NULL;pView->m_pPreviewState = NULL;  // do not delete state structuredelete pView;return FALSE;}pView->m_pToolBar->m_bAutoDelete = TRUE;    // automatic cleanupif (!pView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,CRect(0, 0, 0, 0), m_pCPrintFrame, AFX_IDW_PANE_FIRST, &context)){TRACE0("Error: couldn't create preview view for frame.\n");m_pCPrintFrame->OnSetPreviewMode(FALSE, pState);   // restore Frame WindowpView->m_pPreviewState = NULL;  // do not delete state structuredelete pView;return FALSE;}pState->pViewActiveOld = m_pCPrintFrame->GetActiveView();CPrintView* pActiveView = (CPrintView*)m_pCPrintFrame->GetActiveFrame()->GetActiveView();if (pActiveView != NULL)pActiveView->OnActivateView(FALSE, pActiveView, pActiveView);if (!pView->SetPrintView(pPrintView)){pView->OnPreviewClose();return TRUE;            // signal that OnEndPrintPreview was called}m_pCPrintFrame->SetActiveView(pView);  // set active view - even for MDI// update toolbar and redraw everythingpView->m_pToolBar->SendMessage(WM_IDLEUPDATECMDUI, (WPARAM)TRUE);m_pCPrintFrame->RecalcLayout();            // position and size everythingm_pCPrintFrame->UpdateWindow();return TRUE;
}void CPrintView::OnFilePrint()
{// TODO: 在此添加命令处理程序代码CPrintFrame* pCPrintFrame = (CPrintFrame*)m_pCPrintFrame;if (!pCPrintFrame || !pCPrintFrame->m_pCCertEditPage)return;if (!pCPrintFrame->m_bPreview)pCPrintFrame->ShowWindow(SW_HIDE);switch (pCPrintFrame->m_pCCertEditPage->m_nPrintMode){case 1:SetPaper(DMORIENT_PORTRAIT, DMPAPER_A5);break;case 2:SetPaper(DMORIENT_PORTRAIT, DMPAPER_A5);break;case 4:SetPaper(DMORIENT_PORTRAIT, DMPAPER_A5);break;}CView::OnFilePrint();if (!pCPrintFrame->m_bPreview){CWinApp* pApp = AfxGetApp();pApp->m_pMainWnd = pCPrintFrame->m_pDemarManageDlg;pCPrintFrame->DestroyWindow();}
}void CPrintView::DrawCertification(CDC* pDC, CPrintInfo* pInfo)
{if (!pDC)return;CPrintFrame* pCPrintFrame = (CPrintFrame*)m_pCPrintFrame;if(!pCPrintFrame || !pCPrintFrame->m_pDemarManageDlg)return;POINT point = { 0, 0 };SIZE size = { pDC->GetDeviceCaps(HORZRES),pDC->GetDeviceCaps(VERTRES) };CRect clientRect(point, size);double nLeftSpace(0.8), nTopSpace(0.8), nRightSpace(0.8), nBottomSpace(0.8);int iLeftSpace(0), iTopSpace(0), iRightSpace(0), iBottomSpace(0);iLeftSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSX),nLeftSpace);iTopSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSY),nTopSpace);iRightSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSX),nRightSpace);iBottomSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSY),nBottomSpace);//这里添加打印代码,打印自己想要的
}BOOL CPrintView::OnPreparePrinting(CPrintInfo* pInfo)
{CPrintFrame* pCPrintFrame = (CPrintFrame*)m_pCPrintFrame;if (!pCPrintFrame || !pCPrintFrame->m_pCCertEditPage)return FALSE;// TODO:  调用 DoPreparePrinting 以调用“打印”对话框switch (pCPrintFrame->m_pCCertEditPage->m_nPrintMode){case 1:pInfo->SetMaxPage(1);pInfo->m_bDirect = FALSE;break;case 2:pInfo->SetMaxPage(1);pInfo->m_bDirect = FALSE;break;case 4:pInfo->SetMaxPage(2);pInfo->m_bDirect = FALSE;break;default:break;}return DoPreparePrinting(pInfo);
}void CPrintView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{// TODO: 在此添加专用代码和/或调用基类CPrintFrame* pCPrintFrame = (CPrintFrame*)m_pCPrintFrame;if (!pCPrintFrame || !pCPrintFrame->m_pCCertEditPage)return;switch (pCPrintFrame->m_pCCertEditPage->m_nPrintMode){case 1:DrawCertification(pDC, pInfo);break;case 2:DrawCardData(pDC, pInfo);break;case 4:if (pInfo->m_nCurPage == 1)DrawCertification(pDC, pInfo);else if (pInfo->m_nCurPage == 2)DrawCardData(pDC, pInfo);break;default:break;}//CScrollView::OnPrint(pDC, pInfo);
}void CPrintView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView)
{// TODO: 在此添加专用代码和/或调用基类if (!m_pCPrintFrame || !pView || !pDC)return;//pInfo->m_nCurPage = 1;//CScrollView::OnEndPrintPreview(pDC, pInfo, point, pView);CPrintPreviewView* pCPrintPreviewView = (CPrintPreviewView*)pView;if (!pCPrintPreviewView->m_pPrintView)OnEndPrinting(pDC, pInfo);// restore the old main windowm_pCPrintFrame->OnSetPreviewMode(FALSE, pCPrintPreviewView->m_pPreviewState);// Force active view back to old onem_pCPrintFrame->SetActiveView(pCPrintPreviewView->m_pPreviewState->pViewActiveOld);if (m_pCPrintFrame != GetParentFrame())OnActivateView(TRUE, this, this);pView->DestroyWindow();m_pCPrintFrame->RecalcLayout();m_pCPrintFrame->SendMessage(WM_SETMESSAGESTRING, (WPARAM)AFX_IDS_IDLEMESSAGE, 0L);m_pCPrintFrame->UpdateWindow();
}void CPrintView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{// TODO: 在此添加专用代码和/或调用基类CScrollView::OnEndPrinting(pDC, pInfo);//CPrintFrame* pCPrintFrame = (CPrintFrame*)m_pCPrintFrame;//if (!pCPrintFrame || !pCPrintFrame->m_pDemarManageDlg)//	return;//if(pInfo->m_bPreview == 0)//	pCPrintFrame->PostMessageW(WM_CLOSE);
}
void CPrintView::DrawCardData(CDC* pDC, CPrintInfo* pInfo)
{if (!pDC || !pInfo) return;CPrintFrame* pMainFrm = (CPrintFrame*)m_pCPrintFrame;if (!pMainFrm) return;POINT point = { 0, 0 };SIZE size = { pDC->GetDeviceCaps(HORZRES),pDC->GetDeviceCaps(VERTRES) };CRect clientRect(point, size);chartParam.m_showRect = clientRect;double nLeftSpace(0.8), nTopSpace(0.8), nRightSpace(0.8), nBottomSpace(0.8);int iLeftSpace(0), iTopSpace(0), iRightSpace(0), iBottomSpace(0);iLeftSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSX),nLeftSpace);iTopSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSY),nTopSpace);iRightSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSX),nRightSpace);iBottomSpace = (int)Transfer::Cm2Unit(Transfer::GetScale(pDC, LOGPIXELSY),nBottomSpace);//这里添加打印代码,打印自己想要的}void CPrintView::OnClose()
{// TODO: 在此添加消息处理程序代码和/或调用默认值CScrollView::OnClose();
}

CPrintPreviewView.h

#pragma once// CPrintPreviewView 视图class CPrintPreviewView : public CPreviewView
{DECLARE_DYNCREATE(CPrintPreviewView)protected:CPrintPreviewView();           // 动态创建所使用的受保护的构造函数virtual ~CPrintPreviewView();public:
#ifdef _DEBUGvirtual void AssertValid() const;
#ifndef _WIN32_WCEvirtual void Dump(CDumpContext& dc) const;
#endif
#endiffriend class CPrintView;
protected:DECLARE_MESSAGE_MAP()afx_msg void OnPreviewClose();afx_msg void OnPreviewPrint();friend BOOL CALLBACK _AfxMyPreviewCloseProc(CFrameWnd* pFrameWnd);virtual void OnDraw(CDC* pDC);
};

CPrintPreviewView.cpp

// CPrintPreviewView.cpp: 实现文件
//#include "stdafx.h"
#include "DemarManage.h"
#include "CPrintPreviewView.h"// CPrintPreviewViewIMPLEMENT_DYNCREATE(CPrintPreviewView, CPreviewView)CPrintPreviewView::CPrintPreviewView()
{}CPrintPreviewView::~CPrintPreviewView()
{
}BEGIN_MESSAGE_MAP(CPrintPreviewView, CPreviewView)ON_COMMAND(AFX_ID_PREVIEW_CLOSE, OnPreviewClose)ON_COMMAND(AFX_ID_PREVIEW_PRINT, OnPreviewPrint)
END_MESSAGE_MAP()// CPrintPreviewView 诊断#ifdef _DEBUG
void CPrintPreviewView::AssertValid() const
{CPreviewView::AssertValid();
}#ifndef _WIN32_WCE
void CPrintPreviewView::Dump(CDumpContext& dc) const
{CPreviewView::Dump(dc);
}
#endif
#endif //_DEBUG// CPrintPreviewView 消息处理程序
#include "CPrintFrame.h"
void CPrintPreviewView::OnPreviewClose()
{CPrintFrame* pf = (CPrintFrame*)::AfxGetMainWnd();CWinApp * pApp = AfxGetApp();pApp->m_pMainWnd = pf->m_pDemarManageDlg;pf->DestroyWindow();
}void CPrintPreviewView::OnPreviewPrint()
{m_pPrintView->SendMessage(WM_COMMAND, ID_FILE_PRINT);OnPreviewClose();
}void CPrintPreviewView::OnDraw(CDC* pDC)
{// TODO: 在此添加专用代码和/或调用基类CPreviewView::OnDraw(pDC);m_pToolBar->PostMessage(WM_IDLEUPDATECMDUI, (WPARAM)TRUE);// 控制条的命令状态更新
}

这篇关于MFC在对话框中实现打印和打印预览的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1094328

相关文章

python使用watchdog实现文件资源监控

《python使用watchdog实现文件资源监控》watchdog支持跨平台文件资源监控,可以检测指定文件夹下文件及文件夹变动,下面我们来看看Python如何使用watchdog实现文件资源监控吧... python文件监控库watchdogs简介随着Python在各种应用领域中的广泛使用,其生态环境也

el-select下拉选择缓存的实现

《el-select下拉选择缓存的实现》本文主要介绍了在使用el-select实现下拉选择缓存时遇到的问题及解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的... 目录项目场景:问题描述解决方案:项目场景:从左侧列表中选取字段填入右侧下拉多选框,用户可以对右侧

Python pyinstaller实现图形化打包工具

《Pythonpyinstaller实现图形化打包工具》:本文主要介绍一个使用PythonPYQT5制作的关于pyinstaller打包工具,代替传统的cmd黑窗口模式打包页面,实现更快捷方便的... 目录1.简介2.运行效果3.相关源码1.简介一个使用python PYQT5制作的关于pyinstall

使用Python实现大文件切片上传及断点续传的方法

《使用Python实现大文件切片上传及断点续传的方法》本文介绍了使用Python实现大文件切片上传及断点续传的方法,包括功能模块划分(获取上传文件接口状态、临时文件夹状态信息、切片上传、切片合并)、整... 目录概要整体架构流程技术细节获取上传文件状态接口获取临时文件夹状态信息接口切片上传功能文件合并功能小

python实现自动登录12306自动抢票功能

《python实现自动登录12306自动抢票功能》随着互联网技术的发展,越来越多的人选择通过网络平台购票,特别是在中国,12306作为官方火车票预订平台,承担了巨大的访问量,对于热门线路或者节假日出行... 目录一、遇到的问题?二、改进三、进阶–展望总结一、遇到的问题?1.url-正确的表头:就是首先ur

C#实现文件读写到SQLite数据库

《C#实现文件读写到SQLite数据库》这篇文章主要为大家详细介绍了使用C#将文件读写到SQLite数据库的几种方法,文中的示例代码讲解详细,感兴趣的小伙伴可以参考一下... 目录1. 使用 BLOB 存储文件2. 存储文件路径3. 分块存储文件《文件读写到SQLite数据库China编程的方法》博客中,介绍了文

Redis主从复制实现原理分析

《Redis主从复制实现原理分析》Redis主从复制通过Sync和CommandPropagate阶段实现数据同步,2.8版本后引入Psync指令,根据复制偏移量进行全量或部分同步,优化了数据传输效率... 目录Redis主DodMIK从复制实现原理实现原理Psync: 2.8版本后总结Redis主从复制实

JAVA利用顺序表实现“杨辉三角”的思路及代码示例

《JAVA利用顺序表实现“杨辉三角”的思路及代码示例》杨辉三角形是中国古代数学的杰出研究成果之一,是我国北宋数学家贾宪于1050年首先发现并使用的,:本文主要介绍JAVA利用顺序表实现杨辉三角的思... 目录一:“杨辉三角”题目链接二:题解代码:三:题解思路:总结一:“杨辉三角”题目链接题目链接:点击这里

基于Python实现PDF动画翻页效果的阅读器

《基于Python实现PDF动画翻页效果的阅读器》在这篇博客中,我们将深入分析一个基于wxPython实现的PDF阅读器程序,该程序支持加载PDF文件并显示页面内容,同时支持页面切换动画效果,文中有详... 目录全部代码代码结构初始化 UI 界面加载 PDF 文件显示 PDF 页面页面切换动画运行效果总结主

SpringBoot实现基于URL和IP的访问频率限制

《SpringBoot实现基于URL和IP的访问频率限制》在现代Web应用中,接口被恶意刷新或暴力请求是一种常见的攻击手段,为了保护系统资源,需要对接口的访问频率进行限制,下面我们就来看看如何使用... 目录1. 引言2. 项目依赖3. 配置 Redis4. 创建拦截器5. 注册拦截器6. 创建控制器8.