24 Sep
Posted by support as Win32/MFC 401 views, 0 Comments
Question:
In some app like WinSpy/Spy++ to make adjustments to list controls. It can correctly set an app’s list control’s modes, alignments, sorting, styles, and extended styles. It can also get the widths of the columns and count of items.
The problem is that you cannot seem to get the columns’ names or [...]
Sometime you need some CEdit Validation, for example, restricting the data number only.
The simple implemetion is to handle the EN_UPDATE notification message. The EN_UPDATE message is useful to handle as it caters for both normal entry and clipboard paste. You can do that in the Dialog or subclass the CEdit class.
Here is an example of [...]
22 Jun
Posted by support as General 584 views, 0 Comments
In MFC program, you’d better try to avoid using std::string. There is no compelling reason to use it in MFC, and it leads to confusion.
There are some standard method to translate among Cstring ,string and char[].
// Suppose
CString str;
std::string s;
char buf[SIZE];
// from CString to std::string
s = str;
// from std::string to CString
str = s.c_str();
// to char[]
_tcscpy(buf, [...]
21 Mar
Posted by support as Win32/MFC 201 views, 0 Comments
CWnd::IsIconic
BOOL IsIconic( ) const;
Return Value
Nonzero if CWnd is minimized; otherwise 0.
Remarks
Specifies whether CWnd is minimized (iconic).
Example
// This code, normally emitted by the AppWizard for a dialog-based
// project for the dialog’s WM_PAINT handler, runs only if the
// window is iconic. The window erase the icon’s area, then
// paints the icon referenced by m_hIcon.
if (IsIconic())
{
[...]
Problem:
In the C time, we used to use sscanf to read data from string as following:
char strUserName[20], strPassword[20];
// if the content of m_recvBuff is “Microsoft Bill”.
sscanf((const char *)m_recvBuff, “%s %s”, strUserName, strPassword);
And when you first get CString in sight, you may write the similar code:
CString strUserName, strPassword;
// if the content of m_recvBuff is “Microsoft Bill”.
sscanf((const char [...]
How to load a bitmap from bmp file and draw it in DC?
There are two main steps:
Load the bitmap from the file to a memory DC.
Paint the content of the memory DC to the one which display the bitmap.
In MFC, there is no API to load a bitmap directly from a file, but you can [...]