1.Load(pstm);pstm可以为file来自MSDN Figure 6 CPictureCtrl PictCtrl.h //////////////////////////////////////////////////////////////// // MSDN Magazine — October 2001 // If this code works, it was written by Paul DiLascia. // If not, I don't know who wrote it. // Compiles with Visual C++ 6.0 for Windows 98 and probably Windows 2000 // too. // Set tabsize = 3 in your editor. // #include "picture.h" #include "StatLink.h" #pragma once////////////////// // Class to encapsulate IPicture. This does not wrap all IPicture methods, // only the ones I needed to implement ImgView — feel free to add the // others yourself. // class CPictureCtrl : public CStaticLink { public: CPictureCtrl(BOOL bAutoLoadImage=TRUE); ~CPictureCtrl(); // brainless wrappers call CPicture BOOL LoadImage(UINT nIDRes) { Invalidate(); return m_pict.Load(nIDRes); } BOOL LoadImage(LPCTSTR pszPathName) { Invalidate(); return m_pict.Load(pszPathName); } BOOL LoadImage(CArchive& ar) { Invalidate(); return m_pict.Load(ar); } BOOL LoadImage(IStream* pstm) { Invalidate(); return m_pict.Load(pstm); } CSize GetImageSize() { return m_pict.GetImageSize(); } const CPicture* GetPicture() { return &m_pict; }protected: CPicture m_pict; // picture BOOL m_bAutoLoadImage; // automatically load image w/same Ctrl ID virtual void PreSubclassWindow(); // message handlers afx_msg void OnPaint(); afx_msg int OnCreate(LPCREATESTRUCT lpcs); afx_msg BOOL OnEraseBkgnd(CDC* pDC); DECLARE_DYNAMIC(CPictureCtrl) DECLARE_MESSAGE_MAP() };
BLOB类型
VC导出时关联的变量是什么类型?
Variant
如何显示在对话框上呢?
CPicture控件2:如果需要通过Socket传输一幅图片,该怎么做呢?
用CSocketFile类
BLOB类型
VC导出时关联的变量是什么类型?
Variant
如何显示在对话框上呢?
CPicture控件2:如果需要通过Socket传输一幅图片,该怎么做呢?
用CSocketFile类
Figure 6 CPictureCtrl PictCtrl.h
////////////////////////////////////////////////////////////////
// MSDN Magazine — October 2001
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 6.0 for Windows 98 and probably Windows 2000
// too.
// Set tabsize = 3 in your editor.
//
#include "picture.h"
#include "StatLink.h"
#pragma once//////////////////
// Class to encapsulate IPicture. This does not wrap all IPicture methods,
// only the ones I needed to implement ImgView — feel free to add the
// others yourself.
//
class CPictureCtrl : public CStaticLink {
public:
CPictureCtrl(BOOL bAutoLoadImage=TRUE);
~CPictureCtrl(); // brainless wrappers call CPicture
BOOL LoadImage(UINT nIDRes) {
Invalidate();
return m_pict.Load(nIDRes);
}
BOOL LoadImage(LPCTSTR pszPathName) {
Invalidate();
return m_pict.Load(pszPathName);
}
BOOL LoadImage(CArchive& ar) {
Invalidate();
return m_pict.Load(ar);
}
BOOL LoadImage(IStream* pstm) {
Invalidate();
return m_pict.Load(pstm);
} CSize GetImageSize() {
return m_pict.GetImageSize();
} const CPicture* GetPicture() {
return &m_pict;
}protected:
CPicture m_pict; // picture
BOOL m_bAutoLoadImage; // automatically load image w/same Ctrl ID virtual void PreSubclassWindow(); // message handlers
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpcs);
afx_msg BOOL OnEraseBkgnd(CDC* pDC); DECLARE_DYNAMIC(CPictureCtrl)
DECLARE_MESSAGE_MAP()
};
我想实现的方法肯定不止一种,但是用CSocketFile类估计是最简单的;Good Luck
象bmp格式用CPictureCtrl这个控件跟CEdit控件都是VC自带的普通控件呀