ZC: 先把 自己尝试成功的代码 记录下来,不要 弄没了之后 又忘了怎么弄...
ZC: 代码 有点乱,没整理。没写 哪些是 原来MFC里面的 哪些是我自己写的,参考上一篇文章来看吧
1、VC6 的一个随便的MFC程序
2、class CDrawDibDraw_MFCDlg : public CDialog
添加成员:
public: HDRAWDIB m_hDrawDib; // 视频函数 HANDLE mhBitsSrc; // 位图文件句柄(内存) LPSTR mpBitsSrc; // 位图文件地址(内存) BITMAPINFOHEADER *mpBitmapInfo; // 位图信息头 CPoint mPos; CRect mDispR; int mFullViewTog; int mDispMethod; void GraphicDraw(); public: HANDLE FhFileBMP; //char FbufBmpMem[1024 * 1024 * 5]; char* FbufBmpMem; DWORD FdwRead;
2.1、
#include <windows.h> #include <Vfw.h> #pragma comment(lib,"Vfw32.lib")
2.2、
CDrawDibDraw_MFCDlg::CDrawDibDraw_MFCDlg(CWnd* pParent /*=NULL*/) : CDialog(CDrawDibDraw_MFCDlg::IDD, pParent) { //{{AFX_DATA_INIT(CDrawDibDraw_MFCDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_hDrawDib= DrawDibOpen(); mDispMethod = 10; mFullViewTog = 0; // *** //* DWORD dwDesiredAccess = GENERIC_READ | GENERIC_WRITE; DWORD dwShareMode = 0; LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL; DWORD dwCreationDisposition = OPEN_EXISTING;//OPEN_ALWAYS; DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; HANDLE hTemplateFile = NULL; FhFileBMP = CreateFile("C:\24bmp.bmp", dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); if (FhFileBMP == NULL) { char bufErr[128] = {0}; sprintf(bufErr, "CreateFile failed : (%ld)", GetLastError()); printf("CreateFile fail(%ld)", GetLastError()); MessageBox(bufErr, "1", 0); return; } DWORD dwReadBufLen = 1024 * 1024 * 5; FbufBmpMem = new char[dwReadBufLen]; FdwRead = 0; int iRtn = ReadFile(FhFileBMP, FbufBmpMem, dwReadBufLen, &FdwRead, NULL); if (iRtn == 0) { printf("ReadFile fail(%ld) ", GetLastError()); char bufErr[128] = {0}; sprintf(bufErr, "ReadFile failed : (%ld)", GetLastError()); MessageBox(bufErr, "2", 0); return; } else { //凡是从文件流中读出来的字符串都不会自动补 ,需要手动填充 FbufBmpMem[FdwRead / sizeof(char)] = '