Convert colors from RGB to hue-luminance-saturation (HLS) format.

Use ColorRGBToHLS. Function signature is as follows: [sourcecode language=’cpp’]VOID ColorRGBToHLS( COLORREF clrRGB, WORD *pwHue, WORD *pwLuminance, WORD *pwSaturation );[/sourcecode] Now you should be knowing how to use it. Link to shlwapi.lib, include shlwapi.h. You must have IE version 5 and above.
Continue reading…

 

Convert colors from hue-luminance-saturation (HLS) to RGB format

Use ColorHLSToRGB. Function signature is as follows… [sourcecode language=’cpp’]COLORREF ColorHLSToRGB( WORD wHue,    WORD wLuminance,     WORD wSaturation );[/sourcecode] Returns RGB value. Link to shlwapi.lib. Include file shlwapi.h. You must have atleast internet explorer version 5.
Continue reading…

 

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…

 

Forward declaring a template class!

This is how we forward declare a template class… [sourcecode language=’cpp’]// Forward declare CArray template class template< class TYPE, class ARG_TYPE> class CArray; class SomeClass { public: // No need for “afxtempl.h”       CArray* m_pFloatArray; };[/sourcecode]
Continue reading…