24 Sep
Posted by support as Win32/MFC 400 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 [...]
25 Oct
Posted by support as Win32/MFC 2,531 views, 0 Comments
Another title:
How to use a derived CTreeCtrl in a CTreeView?
It is similar with this article: “How to use an derived CListCtrl in CListView” or “How do I subclass the CListCtrl part of a CListView Class?“.
Just like CListView, there is no CTreeCtrl to subclass in CTreeView. The CTreeView is the subclass of the WC_TREEVIEW common control. [...]
Sometime you need to send/post message to CDoumnet, but CDocument is not a window, and it can’t receive message. How do that?
There are 3 solutions:
Solution 1: Send the message to the main window.
Send/Post the message to the main frame or the view, and then call some functions of the document.
But if in a MDI [...]
22 Oct
Posted by support as Win32/MFC 2,844 views, 0 Comments
How to sort the items of a CListCtrl or CListView(CReportView)?
First, when you add items, you need to call SetItemData to attach an data structure(an integer or a pointer) to the item.
Then, define a callback sort function.
int CALLBACK SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
And here, the prarameters lParam1 and lParam2 are the data structure you [...]
18 Oct
Posted by support as General 213 views, 0 Comments
How to set the head backgroud color of CPropertyPage?
In the DrawItem function the TextOut position is pretty half-hearted, and looks a bit better (to my eyes) if you do it something like this instead.
void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
[...]
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, [...]