Enumerating Clipboard formats!

Here is how we do it… [sourcecode language=’cpp’]UINT uFormat = EnumClipboardFormats( 0 ); while( uFormat ) {      // Do something with this format      …      // Get next format      uFormat = EnumClipboardFormats( uFormat ); }// End while[/sourcecode]
Continue reading…

 

Rarely used useful MFC classes

Did you know there exists a class called 1. CCheckListBox 2. CDragListBox 3. CComboBoxEx 4. CHotKeyCtrl 5. CMemoryState 6. CWaitCursor Pretty useful classes, which you should use more for the purpose for which it’s designed instead of wasting time rolling out your own stuff.  😐 I’ve seen people trying to embed a tree in a […]
Continue reading…

 

How to clear screen in MS VC?

One option is to use [sourcecode language=’cpp’]system( “cls” );[/sourcecode] Another option is to to use this function. I copied this from MSDN.  😉 [sourcecode language=’cpp’]void cls( HANDLE hConsole ) { /* here’s where we’ll home the cursor */    COORD coordScreen = { 0, 0 };    BOOL bSuccess = FALSE;    DWORD cCharsWritten = 0; /* […]
Continue reading…

 

How to create SafeArray of BSTR’s?

Here is a sample to create an array of BSTR’s… [sourcecode language=’cpp’]const long lCount = 100; _bstr_t bstrArray[lCount]; COleSafeArray cosaSafeArray; cosaSafeArray.CreateOneDim( VT_BSTR, lCount ) // Fill out this array for( long lIndex = 0; lIndex < lCount; ++lIndex ) { cosaSafeArray.PutElement( &lIndex, static_cast( bstrArray[lIndex] ); } // Now you have a safe array of bstr’s and since […]
Continue reading…