ATL 9.0 displayed in the middle of an Activex control

Recently a customer of mine faced this issue. So he had an ActiveX control and when displaying the ActiveX control in browser a string is displayed right in the middle of the control: “ATL 9.0”. So this issue happens because you didn’t override CComControlBase::OnDraw  function. The default code for CComControlBase::OnDraw looks like the following… [sourcecode language=”cpp”]HRESULT CComControlBase::YourClassName::OnDraw(_In_ ATL_DRAWINFO& […]
Continue reading…

 

How to debug a dll?

Why? Well debugging exe is quite easy, but ever wondered how to debug a dll. Well why? Simple, you write a dll and you wanna debug a bug just like you would do with an executable. Can you give us some examples? Well so what is a dll? I think of it as a parasite because […]
Continue reading…

 

How to create a GUID programmatically?

Do the following… [sourcecode language=’cpp’]GUID guId = { 0 }; CoCreateGuid( &guId ); // or UUID uid = { 0 }; UuidCreate( &uid );[/sourcecode] For converting to string use… [sourcecode language=’cpp’]PUCHAR pChar = 0; // Convert to string UuidToString( &uid, &pChar ); MessageBox( NULL, (char*)pChar, NULL, MB_OK ); //Don’t forget to free allocated string RpcStringFree( […]
Continue reading…

 

Freeing unused libraries while using COM!

It’s a good practice to free unused COM dlls if it’s not used anymore. So is there a function call which does this? Yes, it’s called CoFreeUnusedLibraries or CoFreeUnusedLibrariesEx! Are the libraries immediately removed from the internal COM dll list, no there is a time delay of 10 minutes for MTAs and neutral apartment models, […]
Continue reading…

 

How to resolve a shortcut!

Ever wondered how to resolve a shortcut! There is a hidden helper function if you are using MFC, it’s called AfxResolveShortcut. I customized it a bit, so that we can use it independently without MFC, and here is the finished product. 😉 [sourcecode language=’cpp’]BOOL ResolveShortcut( HWND hWnd_i,                       LPCTSTR lpctszFileIn_i,                       LPTSTR  lptszFileOut_o,                       const int nPathLength_i […]
Continue reading…

 

Easy way to display Gif’s, Ico’s, JPEG’s and BMP’s on your window

Here is a function that does this! You only have to call this function with an image file, (gif, jpeg, jpg, bmp, ico) and a window handle onto which picture is to be painted. This is originally from MSDN but I modified it slightly to make it into one function… 😉 [sourcecode language=’cpp’]// This function loads […]
Continue reading…