This sample illustrates captions.
All properties are defined at design-time using the Property Dialogs, except the dark mode and high contrast settings.
The source code is located at C:\Program Files (x86)\Softelvdm\SftMask OCX 8.0\Samples\VC++\Sample3\Sample3Dlg.cpp.
// Sample3Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "Sample3.h"
#include "Sample3Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSample3Dlg dialog
CSample3Dlg::CSample3Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CSample3Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSample3Dlg)
// 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);
}
void CSample3Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSample3Dlg)
DDX_Control(pDX, IDC_SFTMASKDATE, m_SftMaskDate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSample3Dlg, CDialog)
//{{AFX_MSG_MAP(CSample3Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSample3Dlg message handlers
BOOL CSample3Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
SftDarkMode_ApplyToDialog(m_hWnd);
for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd != NULL; pWnd = pWnd->GetWindow(GW_HWNDNEXT)) {
ISftMaskPtr pMask(pWnd->GetControlUnknown());
if (pMask != NULL) {
pMask->DarkMode = darkSftMaskAuto; // follow the Windows dark mode setting
pMask->HighContrastMode = highContrastSftMaskAuto; // follow the Windows High Contrast setting
}
}
// 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
m_vSftMaskDate = m_SftMaskDate.GetControlUnknown();
_ASSERT(m_vSftMaskDate != NULL);
m_vSftMaskDate->Contents->DateTime = COleDateTime::GetCurrentTime();;
m_vMask1 = GetDlgItem(IDC_SFTMASK1)->GetControlUnknown();
_ASSERT(m_vMask1 != NULL);
m_vMask2 = GetDlgItem(IDC_SFTMASK2)->GetControlUnknown();
_ASSERT(m_vMask2 != NULL);
m_vMask3 = GetDlgItem(IDC_SFTMASK3)->GetControlUnknown();
_ASSERT(m_vMask3 != NULL);
m_vMask4 = GetDlgItem(IDC_SFTMASK4)->GetControlUnknown();
_ASSERT(m_vMask4 != NULL);
m_vMask5 = GetDlgItem(IDC_SFTMASK5)->GetControlUnknown();
_ASSERT(m_vMask5 != NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CSample3Dlg::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 CSample3Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
BOOL CSample3Dlg::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
INT_PTR dmResult;
if (SftDarkMode_HandleDialogMessage(m_hWnd, message, wParam, lParam, &dmResult)) {
if (pResult) *pResult = dmResult;
return TRUE;
}
return CDialog::OnWndMsg(message, wParam, lParam, pResult);
}