SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
This sample illustrates RichEdit control output.
The source code is located at C:\Program Files (x86)\Softelvdm\SftPrintPreview DLL 2.0\Samples\MFC\PreviewRichEdit\PreviewRichEditDlg.cpp or C:\Program Files\Softelvdm\SftPrintPreview DLL 2.0\Samples\MFC\PreviewRichEdit\PreviewRichEditDlg.cpp (on 32-bit Windows versions).
#include "stdafx.h" CPreviewRichEditDlg::CPreviewRichEditDlg(CWnd* pParent /*=NULL*/) : CDialog(CPreviewRichEditDlg::IDD, pParent) { //{{AFX_DATA_INIT(CPreviewRichEditDlg) //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CPreviewRichEditDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_RICHEDIT, m_Edit); //{{AFX_DATA_MAP(CPreviewRichEditDlg) //}}AFX_DATA_MAP } /*static*/ DWORD CALLBACK CPreviewRichEditDlg::EditStreamCallback(SFTPRINTPREVIEW_DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) { HANDLE hFile = (HANDLE) dwCookie; DWORD dwdRead = 0; if (ReadFile(hFile, pbBuff, cb, &dwdRead, NULL)) { //_ASSERT(cb == dwdRead); *pcb = dwdRead; return 0; } return -1; } void CPreviewRichEditDlg::LoadEditControlWithFile(const CString& strFileName) { HANDLE hFile = CreateFile(strFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { CWaitCursor wait; m_Edit.SetWindowText(TEXT("Loading ...")); ShowWindow(SW_SHOW); UpdateWindow(); EDITSTREAM es; es.dwCookie = (SFTPRINTPREVIEW_DWORD_PTR) hFile; // use our file handle as cookie es.dwError = 0; es.pfnCallback = EditStreamCallback; m_Edit.StreamIn(SF_RTF, es); // load file CloseHandle(hFile); } } void CPreviewRichEditDlg::LoadEditControl() { CFileDialog fd(TRUE, NULL, NULL, OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, _T("RTF Files (*.rtf)|*.rtf||"), this); if (fd.DoModal() == IDOK) LoadEditControlWithFile(fd.GetPathName()); else { DWORD dwd = CommDlgExtendedError(); if (dwd != 0) _ASSERT(0); } } BOOL CPreviewRichEditDlg::OnInitDialog() { CDialog::OnInitDialog(); CenterWindow(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // load Loading... text into edit control m_Edit.LimitText(0x7fffffff);//need all the space we can get // Load contents LoadEditControlWithFile(CString(_T("SftPrintPreview.rtf"))); m_Edit.SetFocus(); m_Edit.SetSel(0, 0); return FALSE; } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CPreviewRichEditDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CPreviewRichEditDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CPreviewRichEditDlg::OnLoadfileClicked() { LoadEditControl(); } void CPreviewRichEditDlg::OnPreviewClicked() { CPreviewDialog pd; pd.DoModal(&m_Edit); } BEGIN_MESSAGE_MAP(CPreviewRichEditDlg, CDialog) //{{AFX_MSG_MAP(CPreviewRichEditDlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_LOADFILE, OnLoadfileClicked) ON_WM_SYSCOMMAND() ON_BN_CLICKED(IDC_PREVIEW, OnPreviewClicked) //}}AFX_MSG_MAP END_MESSAGE_MAP()