Get key names as a string!

Well how do you get key names, for eg: when you type “A” you should get a string like “A ” or when you press page down you get a string like “Page Down”! It’s easy, there is a windows API for this purpose called GetKeyNameText. [sourcecode language=’cpp’]LRESULT CMyDlg::WindowProc(UINT Message, WPARAM wParam, LPARAM lParam) { […]
Continue reading…

 

Blocking cut, copy, paste and context menu for an edit control!

Sometimes you may have to prevent cut, copy, and paste, sometimes context menu too, on an edit control. So how to do this! Well it’s easy to do this… Override WindowProc and provide empty case statements for these events, WM_COPY, WM_CUT, WM_PASTE, WM_CONTEXTMENU. [sourcecode language=’cpp’]LRESULT CMyEdit::WindowProc(UINT Message, WPARAM wParam, LPARAM lParam) {    switch( Message ) […]
Continue reading…

 

How to rotate text using WinAPI?

Simple way to rotate a piece of text is to use a font object… Here is a sample which does this… [sourcecode language=’cpp’]void CSomeDlg::OnPaint() {     CPaintDC dc(this);  // Get existing dlg font     CFont NewFont;      LOGFONT lgFnt = { 0 };      GetFont()->GetLogFont(&lgFnt);  // Modify this existing font // // Face name is […]
Continue reading…

 

AfxTrace trick!

Ever felt the need for a simple thing like, you print something to developer studio output window and when you double click on that line it takes us to the place from where this was output. For eg: You have an unknown exception and you put a trace statement which prints the file name and […]
Continue reading…

 

Something about a Toolbar!

Did you know that you can have a toolbar for any window? Have you seen nice little toolbars just above a combo box with buttons to sort ascending or descending and some other stuffs. Development studio has such controls. You can also do the same, just do some digging with respect to toolbars and I […]
Continue reading…

 

Using SearchPath!

If you want to search for file in a given path use SearchPath API. Read MSDN documentation on this function. If no path is given while calling SearchPath API, it searches in the following order(as per MSDN). The directory from which the application loaded. The current directory. The Windows system directory. Use the GetSystemDirectory function […]
Continue reading…