App does not run with VS 2008 SP1 DLLs, previous version works with RTM versions

I have battled this problem myself last week and consider myself somewhat of an expert now 😉 I’m 99% sure that not all dlls and static libraries were recompiled with the SP1 version. You need to put #define _BIND_TO_CURRENT_MFC_VERSION 1 #define _BIND_TO_CURRENT_CRT_VERSION 1 into every project you’re using. For every project of a real-world size, … Read more

Disallowing creation of the temporary objects

Edit: As j_random_hacker notes, it is possible to force the user to declare a named object in order to take out a lock. However, even if creation of temporaries was somehow banned for your class, then the user could make a similar mistake: // take out a lock: if (m_multiThreaded) { CSingleLock c(&m_criticalSection, TRUE); } … Read more

How do you convert CString and std::string std::wstring to each other?

According to CodeGuru: CString to std::string: CString cs(“Hello”); std::string s((LPCTSTR)cs); BUT: std::string cannot always construct from a LPCTSTR. i.e. the code will fail for UNICODE builds. As std::string can construct only from LPSTR / LPCSTR, a programmer who uses VC++ 7.x or better can utilize conversion classes such as CT2CA as an intermediary. CString cs … Read more

LPCSTR, LPCTSTR and LPTSTR

To answer the first part of your question: LPCSTR is a pointer to a const string (LP means Long Pointer) LPCTSTR is a pointer to a const TCHAR string, (TCHAR being either a wide char or char depending on whether UNICODE is defined in your project) LPTSTR is a pointer to a (non-const) TCHAR string … Read more

How to create a resizable CDialog in MFC?

In the RC resource file if the dialog has this style similar to this it will be fixed size: IDD_DIALOG_DIALOG DIALOGEX 0, 0, 320, 201 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU If the dialog has this style it will be sizeable: IDD_DIALOG_DIALOG DIALOGEX 0, 0, 320, 201 STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION … Read more