Thursday, October 25, 2007

Remove the WS_BORDER style for a CEdit control programmatically?

void CMyEdit::RemoveBorder()

{

DWORD dwStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);

If (dwStyle & WS_EX_CLIENTEDGE)

{

ModifyStyleEx(WS_EX_CLIENTEDGE,0);

SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER );

}

}

Common Class Declaration Mistake

class CComboCellTypeArgs : public HotListCtrlCellTypeArgs
{

public:
CComboCellTypeArgs(void);
virtual ~CComboCellTypeArgs(void);

public:
CStringArray m_arrString;
}

If u just missed to write a semicolon after class declaration, u will be get some horrible compilation error like the following:

error C2533: 'HotListCtrlCellTypeArgs::{ctor}' : constructors not allowed a return type

So don’t miss to write the semicolon after class declaration!!!

Some Constants doesn’t work at VC++ 6.0.

Solution:

// For Visual C++ 6.0 Compatible and also Upper Version

#ifndef VK_OEM_MINUS

#define VK_OEM_MINUS 0xBD // '-' any country

#endif

#ifndef VK_OEM_PERIOD

#define VK_OEM_PERIOD 0xBE // '.' any country

#endif

#ifndef IDC_HAND

#define IDC_HAND MAKEINTRESOURCE(32649)

#endif

ON_WM_TIMER() message map probelm at Win64 Build

At VC++ 6.0 ON_WM_TIMER() Function prototype is

afx_msg void OnTimer (UINT nIDEvent);

Which get a compilation error when u builds it at Windows 64-bit. So use the new function prototype is

afx_msg void OnTimer (UINT_PTR nIDEvent);

Set Default Font to any MFC Control

// Set the Default font to the Window

::SendMessage(this->m_hWnd, WM_SETFONT, WPARAM(GetStockObject(DEFAULT_GUI_FONT)), LPARAM(TRUE));