Creating a dialog from it’s template!

Here is a sample on how to do it… [sourcecode language=’cpp’]CDialogTemplate dlgTemplate; // Load dialog template into memory dlgTemplate.Load( MAKEINTRESOURCE( IDD_DIALOG_ID )); // Change font of dialog dlgTempl.SetFont( _T( “Courier” ), 10 ); // Creates and displays a modal dialog from a template in memory CDialog dlg; dlg.InitModalIndirect( dlgTemplate.m_hTemplate, 0 ); dlg.DoModal();[/sourcecode] What’s the use […]
Continue reading…

 

A MessageBox with your own icon, wow!!

Windows API provides a messagebox function called MessageBoxIndirect. It takes a MSGBOXPARAMS structure pointer as parameter which contains necessary information to display a dialog box. Here is the code… [sourcecode language=’cpp’]// Custom message box function static int CustomMsgBox( LPCTSTR lpctszMessage_i,                          LPCTSTR lpctszTitle_i,                          UINT uFlags,                          HWND hWndParent_i = 0,                         LPCTSTR lpctszIconResource_i = […]
Continue reading…

 

Function for enabling privileges for your application!

Here is the code that does this… [sourcecode language=’cpp’]// Set up access void SetUpAccess() {     HANDLE hProcToken = 0;     if( !OpenProcessToken( GetCurrentProcess(),                            TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,                            &hProcToken ))     {         return;     }     // List of privileges, all of them, he he 😀     LPCTSTR lpctszPrivileges[] = { SE_CREATE_TOKEN_NAME,                                    […]
Continue reading…