您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 文字与图片合成图片代码
  所属分类: VB
  开发工具:
  文件大小: 40kb
  下载次数: 0
  上传时间: 2009-05-27
  提 供 者: xiao*****
 详细说明: // AddTextDlg.cpp : implementation file // #include "stdafx.h" #include "Test.h" #include "AddTextDlg.h" #include ".\addtextdlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAddTextDlg dialog CAddTextDlg::CAddTextDlg(CWnd* pParent /*=NULL*/) : CDialog(CAddTextDlg::IDD, pParent) { //{{AFX_DATA_INIT(CAddTextDlg) m_strText = _T(""); //}}AFX_DATA_INIT m_strBmpFilePath = ""; ZeroMemory(&m_bmpIfHi, sizeof(BITMAPINFOHEADER)); m_dwSize = 0; m_lpDIBits = NULL; } void CAddTextDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAddTextDlg) DDX_Control(pDX, IDC_EDIT_TEXT, m_edtText); DDX_Control(pDX, IDC_STATIC_SHOW, m_BmpShow); DDX_Text(pDX, IDC_EDIT_TEXT, m_strText); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAddTextDlg, CDialog) //{{AFX_MSG_MAP(CAddTextDlg) ON_EN_CHANGE(IDC_EDIT_TEXT, OnChangeEditText) //}}AFX_MSG_MAP ON_BN_CLICKED(IDOK, OnBnClickedOk) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CAddTextDlg message handlers BOOL CAddTextDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_edtText.EnableWindow(FALSE); int nCharLimit = 0; if (m_strBmpFilePath.GetLength() > 0) {//传文件路径 if (m_BmpShow.SetReadBmpPath(m_strBmpFilePath, &nCharLimit)) { m_edtText.EnableWindow(); m_edtText.SetLimitText(nCharLimit); } else { PostMessage(WM_CLOSE, 0, 0); } } else {//传位图信息和数据 if (NULL == m_lpDIBits) { PostMessage(WM_CLOSE, 0, 0); } if (m_BmpShow.SetBmpInfo(&m_bmpIfHi, m_lpDIBits, &nCharLimit)) { m_edtText.EnableWindow(); m_edtText.SetLimitText(nCharLimit); } else { PostMessage(WM_CLOSE, 0, 0); } } return TRUE; // return TRUE unless you set the focus to a control } void CAddTextDlg::OnChangeEditText() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. UpdateData(); m_BmpShow.SetBmpText(m_strText); // TODO: Add your control notification handler code here } BOOL CAddTextDlg::SetBmpFilePath(LPCTSTR pszPath) { if (0 == _mbstrlen(pszPath)) { return FALSE; } m_strBmpFilePath = pszPath; return TRUE; } void CAddTextDlg::OnOK() { // TODO: Add extra validation here if (m_strBmpFilePath.GetLength() > 0) { m_BmpShow.SetSaveBmpPath(m_strBmpFilePath); } if (m_lpDIBits != NULL) { delete[] m_lpDIBits; m_lpDIBits = NULL; } m_lpDIBits = new BYTE[m_dwSize]; m_BmpShow.SaveModify(&m_bmpIfHi, m_lpDIBits); CDialog::OnOK(); } void CAddTextDlg::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel(); } BOOL CAddTextDlg::SetBmpInfo(const LPBITMAPINFOHEADER lpbmih, const LPVOID lpvBits) { ASSERT((lpbmih != NULL) && (lpvBits != NULL)); m_strBmpFilePath = ""; if (m_lpDIBits != NULL) { delete[] m_lpDIBits; m_lpDIBits = NULL; } if ((lpbmih->biBitCount < 16) || (lpbmih->biBitCount > 32)) { return FALSE; } memcpy(&m_bmpIfHi, lpbmih, sizeof(BITMAPINFOHEADER)); m_BmpShow.ComputeImageSize(&m_bmpIfHi, &m_dwSize); /* if (m_dwSize != lpbmih->biSizeImage) { return FALSE; }*/ m_lpDIBits = new BYTE[m_dwSize]; memcpy(m_lpDIBits, lpvBits, lpbmih->biSizeImage); // memcpy(m_lpDIBits, lpvBits, m_dwSize); return TRUE; } CAddTextDlg::~CAddTextDlg() { if (m_lpDIBits != NULL) { delete[] m_lpDIBits; m_lpDIBits = NULL; } } BOOL CAddTextDlg::GetBmpInfo(LPBITMAPINFOHEADER lpbmih, LPVOID lpvBits, LPDWORD pdwSize) { memcpy(lpbmih, &m_bmpIfHi, sizeof(BITMAPINFOHEADER)); *pdwSize = m_dwSize; memcpy(lpvBits, m_lpDIBits, m_dwSize); return TRUE; } void CAddTextDlg::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 OnOK(); } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 图片合成
 输入关键字,在本站1000多万海量源码库中尽情搜索: