# SftMask/DLL 7.0 — Sample Source Code > Full source code for the SftMask/DLL 7.0 samples, referenced from https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0.txt ## Calculator Sample (C) Source: https://softelvdm.com/Documentation/SftMask%20DLL%207%200/Topic/sample_c_calculator ```c /****************************************************************************/ /* SftMask/DLL 7.0 - Masked Edit Control for C/C++ */ /* Copyright (C) 2026 Softel vdm, Inc. All Rights Reserved. */ /****************************************************************************/ /* SftMask/DLL 7.0 sample. Guide: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0.txt, API reference: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0-reference.txt - see AGENTS.md. */ #include #include "SftMask.h" /* SftMask/DLL Header File */ #define SFTDARKMODE_IMPLEMENTATION #include "SftDarkMode.h" /* Dark mode support */ #include "resource.h" // application resources HINSTANCE g_hInst; // App Instance Handle /**********************************************************************/ /* Currency Amount with Calculator */ /**********************************************************************/ static void InitAmount(HWND hwndDlg) { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_AMOUNT); SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); SftMask_GetControlInfo(hwndEdit, &Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_RIGHT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEntrySelect = SFTMASK_ENTRYSELECTHOMEEND; Ctl.lpszCaption = (LPTSTR) TEXT("&Amount:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszLabel = (LPTSTR) TEXT("|"); // "|" displays the locale currency symbol Ctl.lpszMask = (LPTSTR) TEXT("$C-,8.2"); Ctl.nCalcLines = 6; Ctl.nFracDigits = 2; Ctl.iClipMode = SFTMASK_CLIPEXCLUDE; Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; SftMask_SetControlInfo(hwndEdit, &Ctl); } /**********************************************************************/ /* Center the main dialog */ /**********************************************************************/ static void CenterWindow(HWND hwnd) { RECT rc; RECT rcOwner; int x, y; GetWindowRect(hwnd, &rc); GetWindowRect(GetDesktopWindow(), &rcOwner); x = rcOwner.left + (((rcOwner.right - rcOwner.left) - (rc.right - rc.left)) / 2); y = rcOwner.top + (((rcOwner.bottom - rcOwner.top) - (rc.bottom - rc.top)) / 2); SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } /**********************************************************************/ /* Dialog Proc */ /**********************************************************************/ INT_PTR CALLBACK MainDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_APP))); InitAmount(hwndDlg); SftDarkMode_ApplyToDialog(hwndDlg); CenterWindow(hwndDlg); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, 0); return TRUE; } break; } { INT_PTR dmResult; if (SftDarkMode_HandleDialogMessage(hwndDlg, msg, wParam, lParam, &dmResult)) return dmResult; } return FALSE; } /**********************************************************************/ /* WinMain */ /**********************************************************************/ int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpszCmdLine, int cmdShow) { g_hInst = hinst; SftDarkMode_Init(); /* Dark mode support */ SftMask_RegisterApp(hinst); /* Register with SftMask/DLL */ DialogBox(g_hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDialogProc); SftMask_UnregisterApp(hinst); /* Unregister from SftMask/DLL */ return 0; } ``` ## DateTime Sample (C) Source: https://softelvdm.com/Documentation/SftMask%20DLL%207%200/Topic/sample_c_datetime ```c /****************************************************************************/ /* SftMask/DLL 7.0 - Masked Edit Control for C/C++ */ /* Copyright (C) 2026 Softel vdm, Inc. All Rights Reserved. */ /****************************************************************************/ /* SftMask/DLL 7.0 sample. Guide: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0.txt, API reference: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0-reference.txt - see AGENTS.md. */ #include #include "SftMask.h" /* SftMask/DLL Header File */ #define SFTDARKMODE_IMPLEMENTATION #include "SftDarkMode.h" /* Dark mode support */ #include "resource.h" // application resources HINSTANCE g_hInst; // App Instance Handle /**********************************************************************/ /* Date and Date/Time Input */ /**********************************************************************/ static void InitDate(HWND hwndDlg) { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_DATE); SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); SftMask_GetControlInfo(hwndEdit, &Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITCALENDARDROPDOWN; Ctl.fDDButtonCalendar = TRUE; Ctl.calfDropOnFocus = FALSE; Ctl.lpszCaption = (LPTSTR) TEXT("&Date:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) TEXT("$D"); Ctl.lpszDefaultText = (LPTSTR) TEXT("=Today"); Ctl.iDefaultStyle = SFTMASK_DEFAULT_IMMEDIATE; Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; SftMask_SetControlInfo(hwndEdit, &Ctl); } static void InitDateTime(HWND hwndDlg) { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_DATETIME); SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); SftMask_GetControlInfo(hwndEdit, &Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITUPDOWN; Ctl.fTabAdvance = TRUE; Ctl.lpszCaption = (LPTSTR) TEXT("Date/&Time:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) TEXT("$D $T"); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; SftMask_SetControlInfo(hwndEdit, &Ctl); } /**********************************************************************/ /* Center the main dialog */ /**********************************************************************/ static void CenterWindow(HWND hwnd) { RECT rc; RECT rcOwner; int x, y; GetWindowRect(hwnd, &rc); GetWindowRect(GetDesktopWindow(), &rcOwner); x = rcOwner.left + (((rcOwner.right - rcOwner.left) - (rc.right - rc.left)) / 2); y = rcOwner.top + (((rcOwner.bottom - rcOwner.top) - (rc.bottom - rc.top)) / 2); SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } /**********************************************************************/ /* Dialog Proc */ /**********************************************************************/ INT_PTR CALLBACK MainDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_APP))); InitDate(hwndDlg); InitDateTime(hwndDlg); SftDarkMode_ApplyToDialog(hwndDlg); CenterWindow(hwndDlg); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hwndDlg, 0); return TRUE; } break; } { INT_PTR dmResult; if (SftDarkMode_HandleDialogMessage(hwndDlg, msg, wParam, lParam, &dmResult)) return dmResult; } return FALSE; } /**********************************************************************/ /* WinMain */ /**********************************************************************/ int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpszCmdLine, int cmdShow) { g_hInst = hinst; SftDarkMode_Init(); /* Dark mode support */ SftMask_RegisterApp(hinst); /* Register with SftMask/DLL */ DialogBox(g_hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDialogProc); SftMask_UnregisterApp(hinst); /* Unregister from SftMask/DLL */ return 0; } ``` ## DataEntry Sample (C) Source: https://softelvdm.com/Documentation/SftMask%20DLL%207%200/Topic/sample_c_dataentry ```c /****************************************************************************/ /* SftMask/DLL 7.0 - Masked Edit Control for C/C++ */ /* Copyright (C) 2026 Softel vdm, Inc. All Rights Reserved. */ /****************************************************************************/ /* SftMask/DLL 7.0 sample. Guide: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0.txt, API reference: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0-reference.txt - see AGENTS.md. */ #include #include "SftMask.h" /* SftMask/DLL Header File */ #define SFTDARKMODE_IMPLEMENTATION #include "SftDarkMode.h" /* Dark mode support */ #include "resource.h" // application resources HINSTANCE g_hInst; // App Instance Handle /**********************************************************************/ /* IP Address, Password, Phone Number, Path Autocomplete */ /**********************************************************************/ static void InitIPAddress(HWND hwndDlg) { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_IPADDRESS); SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); SftMask_GetControlInfo(hwndEdit, &Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITUPDOWN; Ctl.fAutoAdvance = TRUE; Ctl.fTabAdvance = TRUE; Ctl.fPromptUnderline = TRUE; Ctl.lpszCaption = (LPTSTR) TEXT("&IP Address:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) TEXT("$I^03(0,255)\\.$I^03(0,255)\\.$I^03(0,255)\\.$I^03(0,255)"); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; SftMask_SetControlInfo(hwndEdit, &Ctl); } static void InitPassword(HWND hwndDlg) { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_PASSWORD); SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); SftMask_GetControlInfo(hwndEdit, &Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.chPswdChar = TEXT('*'); Ctl.nMaxLength = 16; Ctl.lpszCaption = (LPTSTR) TEXT("&Password:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) TEXT(""); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; SftMask_SetControlInfo(hwndEdit, &Ctl); } static void InitPhone(HWND hwndDlg) { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_PHONE); SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); SftMask_GetControlInfo(hwndEdit, &Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.fPromptUnderline = TRUE; Ctl.lpszCaption = (LPTSTR) TEXT("P&hone:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) TEXT("\\([M1-9]##\\) ###\\-####"); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; SftMask_SetControlInfo(hwndEdit, &Ctl); } static void InitPath(HWND hwndDlg) { HWND hwndEdit = GetDlgItem(hwndDlg, IDC_PATH); SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); SftMask_GetControlInfo(hwndEdit, &Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITELLIPSE; Ctl.nMaxLength = 300; Ctl.lpszCaption = (LPTSTR) TEXT("Pa&th:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 20; Ctl.lpszMask = (LPTSTR) TEXT(""); Ctl.auto_iMode = SFTMASK_AUTOCOMPLETE_SUGGESTAPPEND; Ctl.auto_iContents = SFTMASK_AUTOCOMPLETECONTENTS_FILESDIRS; Ctl.auto_fOptimalHeight = TRUE; Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; SftMask_SetControlInfo(hwndEdit, &Ctl); } /**********************************************************************/ /* Center the main dialog */ /**********************************************************************/ static void CenterWindow(HWND hwnd) { RECT rc; RECT rcOwner; int x, y; GetWindowRect(hwnd, &rc); GetWindowRect(GetDesktopWindow(), &rcOwner); x = rcOwner.left + (((rcOwner.right - rcOwner.left) - (rc.right - rc.left)) / 2); y = rcOwner.top + (((rcOwner.bottom - rcOwner.top) - (rc.bottom - rc.top)) / 2); SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } /**********************************************************************/ /* Dialog Proc */ /**********************************************************************/ INT_PTR CALLBACK MainDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_APP))); InitIPAddress(hwndDlg); InitPassword(hwndDlg); InitPhone(hwndDlg); InitPath(hwndDlg); SftDarkMode_ApplyToDialog(hwndDlg); CenterWindow(hwndDlg); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PATH: if (HIWORD(wParam) == SFTMASKN_ELLIPSECLICKED) SftMask_AutoComplete_Refresh((HWND) lParam); // open the suggestion dropdown break; case IDCANCEL: EndDialog(hwndDlg, 0); return TRUE; } break; } { INT_PTR dmResult; if (SftDarkMode_HandleDialogMessage(hwndDlg, msg, wParam, lParam, &dmResult)) return dmResult; } return FALSE; } /**********************************************************************/ /* WinMain */ /**********************************************************************/ int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpszCmdLine, int cmdShow) { g_hInst = hinst; SftDarkMode_Init(); /* Dark mode support */ SftMask_RegisterApp(hinst); /* Register with SftMask/DLL */ DialogBox(g_hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, MainDialogProc); SftMask_UnregisterApp(hinst); /* Unregister from SftMask/DLL */ return 0; } ``` ## Calculator Sample (C++/MFC) Source: https://softelvdm.com/Documentation/SftMask%20DLL%207%200/Topic/sample_mfc_calculator ```cpp /****************************************************************************/ /* SftMask/DLL 7.0 - Masked Edit Control for C/C++ */ /* Copyright (C) 2026 Softel vdm, Inc. All Rights Reserved. */ /****************************************************************************/ /* SftMask/DLL 7.0 sample. Guide: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0.txt, API reference: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0-reference.txt - see AGENTS.md. */ #include "stdafx.h" #include "MainDlg.h" #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainDlg dialog BEGIN_MESSAGE_MAP(CMainDlg, CDialog) END_MESSAGE_MAP() CMainDlg::CMainDlg(CWnd* pParent) : CDialog(CMainDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CMainDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_AMOUNT, m_Amount); } BOOL CMainDlg::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // Currency amount with dropdown calculator SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); m_Amount.GetControlInfo(&Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_RIGHT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEntrySelect = SFTMASK_ENTRYSELECTHOMEEND; Ctl.lpszCaption = (LPTSTR) _T("&Amount:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszLabel = (LPTSTR) _T("|"); // "|" displays the locale currency symbol Ctl.lpszMask = (LPTSTR) _T("$C-,8.2"); Ctl.nCalcLines = 6; Ctl.nFracDigits = 2; Ctl.iClipMode = SFTMASK_CLIPEXCLUDE; Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; m_Amount.SetControlInfo(&Ctl); // Dark mode SftDarkMode_ApplyToDialog(m_hWnd); return TRUE; } void CMainDlg::OnOK() { // Enter must not close the sample } ``` ## DateTime Sample (C++/MFC) Source: https://softelvdm.com/Documentation/SftMask%20DLL%207%200/Topic/sample_mfc_datetime ```cpp /****************************************************************************/ /* SftMask/DLL 7.0 - Masked Edit Control for C/C++ */ /* Copyright (C) 2026 Softel vdm, Inc. All Rights Reserved. */ /****************************************************************************/ /* SftMask/DLL 7.0 sample. Guide: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0.txt, API reference: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0-reference.txt - see AGENTS.md. */ #include "stdafx.h" #include "MainDlg.h" #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainDlg dialog BEGIN_MESSAGE_MAP(CMainDlg, CDialog) END_MESSAGE_MAP() CMainDlg::CMainDlg(CWnd* pParent) : CDialog(CMainDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CMainDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_DATE, m_Date); DDX_Control(pDX, IDC_DATETIME, m_DateTime); } BOOL CMainDlg::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // Date with dropdown calendar; an empty field defaults to today { SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); m_Date.GetControlInfo(&Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITCALENDARDROPDOWN; Ctl.fDDButtonCalendar = TRUE; Ctl.calfDropOnFocus = FALSE; Ctl.lpszCaption = (LPTSTR) _T("&Date:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) _T("$D"); Ctl.lpszDefaultText = (LPTSTR) _T("=Today"); Ctl.iDefaultStyle = SFTMASK_DEFAULT_IMMEDIATE; Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; m_Date.SetControlInfo(&Ctl); } // Date/time with up-down buttons { SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); m_DateTime.GetControlInfo(&Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITUPDOWN; Ctl.fTabAdvance = TRUE; Ctl.lpszCaption = (LPTSTR) _T("Date/&Time:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) _T("$D $T"); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; m_DateTime.SetControlInfo(&Ctl); } // Dark mode SftDarkMode_ApplyToDialog(m_hWnd); return TRUE; } void CMainDlg::OnOK() { // Enter must not close the sample } ``` ## DataEntry Sample (C++/MFC) Source: https://softelvdm.com/Documentation/SftMask%20DLL%207%200/Topic/sample_mfc_dataentry ```cpp /****************************************************************************/ /* SftMask/DLL 7.0 - Masked Edit Control for C/C++ */ /* Copyright (C) 2026 Softel vdm, Inc. All Rights Reserved. */ /****************************************************************************/ /* SftMask/DLL 7.0 sample. Guide: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0.txt, API reference: https://softelvdm.com/Vault/Softelvdm.com/llms/SftMask-DLL-7.0-reference.txt - see AGENTS.md. */ #include "stdafx.h" #include "MainDlg.h" #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainDlg dialog BEGIN_MESSAGE_MAP(CMainDlg, CDialog) ON_CONTROL(SFTMASKN_ELLIPSECLICKED, IDC_PATH, OnPathEllipse) END_MESSAGE_MAP() CMainDlg::CMainDlg(CWnd* pParent) : CDialog(CMainDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CMainDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_IPADDRESS, m_IPAddress); DDX_Control(pDX, IDC_PASSWORD, m_Password); DDX_Control(pDX, IDC_PHONE, m_Phone); DDX_Control(pDX, IDC_PATH, m_Path); } BOOL CMainDlg::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // IP address with up-down buttons { SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); m_IPAddress.GetControlInfo(&Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITUPDOWN; Ctl.fAutoAdvance = TRUE; Ctl.fTabAdvance = TRUE; Ctl.fPromptUnderline = TRUE; Ctl.lpszCaption = (LPTSTR) _T("&IP Address:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) _T("$I^03(0,255)\\.$I^03(0,255)\\.$I^03(0,255)\\.$I^03(0,255)"); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; m_IPAddress.SetControlInfo(&Ctl); } // Password input (hidden characters) { SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); m_Password.GetControlInfo(&Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.chPswdChar = _T('*'); Ctl.nMaxLength = 16; Ctl.lpszCaption = (LPTSTR) _T("&Password:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) _T(""); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; m_Password.SetControlInfo(&Ctl); } // US phone number { SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); m_Phone.GetControlInfo(&Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.fPromptUnderline = TRUE; Ctl.lpszCaption = (LPTSTR) _T("P&hone:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 40; Ctl.lpszMask = (LPTSTR) _T("\\([M1-9]##\\) ###\\-####"); Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; m_Phone.SetControlInfo(&Ctl); } // Path with file/folder autocomplete { SFTMASK_CONTROL Ctl; Ctl.cbSize = sizeof(SFTMASK_CONTROL); m_Path.GetControlInfo(&Ctl); Ctl.fAutoSize = TRUE; Ctl.iAlignment = ES_LEFT; Ctl.iBorderStyle = SFTMASK_BORDER_THIN; Ctl.iEditStyle = SFTMASK_EDITELLIPSE; Ctl.nMaxLength = 300; Ctl.lpszCaption = (LPTSTR) _T("Pa&th:"); Ctl.captionfTransparent = TRUE; Ctl.captioniPosition = SFTMASK_POSITIONLEFT; Ctl.captioniAlignment = ES_LEFT; Ctl.captioniVerticalAlignment = SFTMASK_VERTALIGNBASELINE; Ctl.captionnSizePercent = 20; Ctl.lpszMask = (LPTSTR) _T(""); Ctl.auto_iMode = SFTMASK_AUTOCOMPLETE_SUGGESTAPPEND; Ctl.auto_iContents = SFTMASK_AUTOCOMPLETECONTENTS_FILESDIRS; Ctl.auto_fOptimalHeight = TRUE; Ctl.nDarkMode = SFTMASK_DARKMODE_AUTO; m_Path.SetControlInfo(&Ctl); } // Dark mode SftDarkMode_ApplyToDialog(m_hWnd); return TRUE; } void CMainDlg::OnPathEllipse() { m_Path.AutoCompleteRefresh(); // open the suggestion dropdown } void CMainDlg::OnOK() { // Enter must not close the sample } ```