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 SftDirectory and SftPrintPreview/OCX to print and preview file/folder listings.
The source code is located at C:\Program Files (x86)\Softelvdm\SftDirectory 3.5\Samples\VC++\PrintPreview\PrintPreviewDlg.cpp or C:\Program Files\Softelvdm\SftDirectory 3.5\Samples\VC++\PrintPreview\PrintPreviewDlg.cpp (on 32-bit Windows versions).
// PrintPreviewDlg.cpp : implementation file // #include "stdafx.h" #include "PrintPreview.h" #include "PrintPreviewDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPrintPreviewDlg dialog CPrintPreviewDlg::CPrintPreviewDlg(CWnd* pParent /*=NULL*/) : CDialog(CPrintPreviewDlg::IDD, pParent) { //{{AFX_DATA_INIT(CPrintPreviewDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_Menu.LoadMenu(IDR_MENU1); } void CPrintPreviewDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPrintPreviewDlg) DDX_Control(pDX, IDC_SFTDIRECTORY1, m_Dir1); DDX_Control(pDX, IDC_SFTPRINTPREVIEW1, m_Preview1); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPrintPreviewDlg, CDialog) //{{AFX_MSG_MAP(CPrintPreviewDlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_SIZE() ON_COMMAND(IDM_DIRECTORY, OnDirectory) ON_COMMAND(IDM_PREVIEW, OnPreview) ON_COMMAND(IDM_EXIT, OnExit) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPrintPreviewDlg message handlers BOOL CPrintPreviewDlg::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon SetMenu(&m_Menu); m_vDir1 = m_Dir1.GetControlUnknown(); _ASSERT(m_vDir1 != NULL); m_vPreview1 = m_Preview1.GetControlUnknown(); _ASSERT(m_vPreview1 != NULL); // Connect the directory control to the print preview control m_vPreview1->ContentProvider = m_vDir1->Window; // display directory ShowDirectory(); m_vPreview1->ZoomFactor = 100; Resize(); // resize directory and preview window to fill entire window ShowWindow(SW_MAXIMIZE); return TRUE; // return TRUE unless you set the focus to a control } void CPrintPreviewDlg::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(); } } HCURSOR CPrintPreviewDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CPrintPreviewDlg::Resize() { CRect rect; GetClientRect(&rect); // resize directory and preview window to full size // (only one is actually visible) if (IsWindow(m_Dir1)) m_Dir1.MoveWindow(rect); if (IsWindow(m_Preview1)) m_Preview1.MoveWindow(rect); } void CPrintPreviewDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); Resize(); } void CPrintPreviewDlg::ShowDirectory() { // Disable & hide the print preview control m_Preview1.EnableWindow(FALSE); m_Preview1.ShowWindow(SW_HIDE); // Show the SftDirectory control m_Dir1.EnableWindow(); m_Dir1.ShowWindow(SW_SHOW); m_Dir1.SetFocus(); } void CPrintPreviewDlg::ShowPreview() { // Disable & hide the SftDirectory control m_Dir1.EnableWindow(FALSE); m_Dir1.ShowWindow(SW_HIDE); // Show the print preview control m_Preview1.EnableWindow(); m_Preview1.ShowWindow(SW_SHOW); m_Preview1.SetFocus(); } void CPrintPreviewDlg::OnDirectory() { ShowDirectory(); } void CPrintPreviewDlg::OnPreview() { ShowPreview(); } void CPrintPreviewDlg::OnExit() { OnCancel(); } void CPrintPreviewDlg::OnPageSetupWantedSftPrintPreview1() { m_vPreview1->PageSetup(0); } void CPrintPreviewDlg::OnHelpWantedSftPrintPreview1(LPCTSTR HelpName) { MessageBox(_T("Sorry, this sample doesn't offer a help file")); } void CPrintPreviewDlg::OnCloseWantedSftPrintPreview1() { ShowDirectory(); } BEGIN_EVENTSINK_MAP(CPrintPreviewDlg, CDialog) //{{AFX_EVENTSINK_MAP(CPrintPreviewDlg) ON_EVENT(CPrintPreviewDlg, IDC_SFTPRINTPREVIEW1, 7 /* PageSetupWanted */, OnPageSetupWantedSftPrintPreview1, VTS_NONE) ON_EVENT(CPrintPreviewDlg, IDC_SFTPRINTPREVIEW1, 6 /* HelpWanted */, OnHelpWantedSftPrintPreview1, VTS_BSTR) ON_EVENT(CPrintPreviewDlg, IDC_SFTPRINTPREVIEW1, 8 /* CloseWanted */, OnCloseWantedSftPrintPreview1, VTS_NONE) //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP()