Inside EnableWindow, IsWindowEnabled and how to use WM_ENABLE?

Recently a friend of mine was asking why is WM_ENABLE not working, control is grayed out but it remains enabled. So what should be done first do is modify style of control and add WS_DISABLED style and then call SendMessage with event set as WM_ENABLE and wParam value set as FALSE in order to disable […]
Continue reading…

 

When to use OnDrawItem, DrawItem and OnPaint?

Note: This post assumes that owner draw flag for controls is set. OnDrawItem is mainly provided to facilitate owner drawing child controls in a parent window class without sub classing them. An e.g. can be a tab/button/listbox/combobox/menu control, we can ownerdraw these without sub classing using this function. Note that OnDrawItem is called as result […]
Continue reading…

 

explicit c++ keyword explained

A friend of mine was asking this question so quickly thought of explaining it to other doubtees. 😉 In one sentence, it prevents automagic/implicit conversions. Let me explain with an example… First compile this sample using the explicit keyword, compile again with explicit keyword removed. First time you will get error, second time with the […]
Continue reading…

 

Choosing between a function and a macro definition

This is a common and a funny problem. So what is this all about? Let me put it like this… We have a standard “c” function called _toupper and an equivalent macro is also available called _toupper. So my question is how to call function version of _toupper explicitly, if we write _toupper, macro version  […]
Continue reading…

 

Tokenizing strings using _tcstok_s

So what is Tokenizing, eh? Well it’s the process of splitting a string into smaller strings (called tokens) based on a given delimiter string. For e.g. If we have to split a string called “Nibu Babu Thomas” 😉 and the delimiter string is ” ” (space). So our tokens will be Nibu Babu Thomas So […]
Continue reading…

 

A TCHAR version of std stream and string classes

Quite simple… [sourcecode language=’cpp’]// A TCHAR based std::string typedef std::basic_string tstring; // A TCHAR based std::ifstream; typedef std::basic_ifstream tstream; // A TCHAR based std::stringstream typedef std::basic_stringstream tstringstream;[/sourcecode] So now no need to worry about UNICODE and ANSI, should work as CString, since TCHAR becomes char/wchar_t based on _UNICODE macro definition. Also note that stl has […]
Continue reading…

 

Restricting window size

Easy! Handle WM_GETMINMAXINFO, LPARAM of this message points to a MINMAXINFO structure. Fill out necessary information into this structure like minimum and maximum tracking size, maximum position, maximum size. If you’ve handled and filled out necessary information then return FALSE to so that the changes get’s applied. If you are using MFC then add a […]
Continue reading…