Troubleshooting side by side issues using sxstrace

Side by side errors are troublesome to troubleshoot. You run an MFC/CRT application on customer machine and you run into error dialogs similar to the one shown below… Don’t get overawed by the error. Its quite easy to troubleshoot, hmm well. As the error message suggests let use sxstrace.exe. The usage of sxstrace is pretty […]
Continue reading…

 

[Debugging] How to find length of a CString string in application memory or in a dump

Recently a colleague of mine asked where’s the length of CString string stored in memory. Hmm so lets dig around. Please note I’ve declared the following CString object in my code… CString TestCString = _T(“Nibu is testing CString”); If you dump CString type in the debugger we see following… 0:000> dt TestCStringLocal var @ 0xb4fcd4 […]
Continue reading…

 

[MFC Feature Pack] Select an MDI tab programmatically in a Document View application

A customer recently asked this question, thought I’ll share the solution out here. Its not that obvious FYI. When creating an MFC MDI application we have an option to enable tabbed view of MDI documents. Once this is done here’s how the application will look like… Note that except for the first sample image you […]
Continue reading…

 

[MFC]Application migrated from VS2005 to VS2010 crashes on XP

The crash happens as a result of requesting a non-existent API via GetProcAddress, the API is GetThreadPreferredUILanguages. GetProcAddress returns 0xFFBADD11 (a known issue with windows XP where GetProcAddress returns NON-NULL) which means LDRP_BAD_DLL. To fix this issue override CWinApp::LoadAppLangResourceDLL and prevent loading of the lang dll or set the WINVER macro to target XP builds […]
Continue reading…

 

[MFC] Resize CComboBox drop down list based on contents

I had this post in my draft for a long time. This code snippet resizes a combo box’s drop down list. Please note an application sends the CB_SETDROPPEDWIDTH message to set the minimum allowable width, in pixels, of the list box of a combo box with the CBS_DROPDOWN or CBS_DROPDOWNLIST style. Note: MFC function CComboBox::SetDroppedWidth […]
Continue reading…

 

Using the good old SysLink/CLinkCtrl class

In MFC and in Win32 we have a dedicated control for managing/displaying hyperlinks, the control is pretty old(I guess the MFC feature pack has come up with a new control). In Win32 its called SysLink and in MFC the wrapper class is called CLinkCtrl. Using the control is pretty straight forward but in my opinion […]
Continue reading…

 

Some issues when working with ComboBox

The main reason for posting this issue is to help MFC/Win32 beginners. But anyway it’s a good read ;), so once upon a time… If you’re a beginner with window’s ComboBox controls then you might end up with a bald head thinking and thinking about a weird behavior of combo’s after it’s creation. The combo […]
Continue reading…

 

Add horizontal scrollbar to a combo box

CComboBox has a function called SetHorizontalExtent which doesn’t work. SDK equivalent is CB_SETHORIZONTALEXTENT which also doesn’t work. The reason for this bug is pretty lame, because WS_HSCROLL style for combo box is not set, which in turn the VS dialog editor does not provide :(. So a workaround is to open .rc file in a […]
Continue reading…

 

Where can I find MFC feature pack samples?

People are having trouble finding feature pack samples installed in the samples directory. I too had a similar problem. So what you need to do is to uninstall the previous sample exe that you’ve installed. Then install the samples from here. Good thing about this is that you’ll have an updated samples package. If you’re […]
Continue reading…

 

MFC Feature Pack – CMFCEditBrowseCtrl

CMFCEditBrowseCtrl? It’s a specialized edit control (MFC Feature Pack VS2008) with a browse button attached to it’s right side, when we click on this button we get an open file dialog or an open folder dialog. See this sample screenshot. Also this control allows us to implement our own event handling by overriding OnBrowse function […]
Continue reading…