MFC CTreeCtrl instructions
when I build a demo project on CTreeCtrl, I added treectrl.h file into .rc resource file. it caused compilation errors:
Error RC2188 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\atlmfc\include\afxcmn3.inl(502) : warning RC4011: identifier truncated to '_CSTRING_DISABLE_NARROW_WIDE_CO' TreeControl C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\atlmfc\include\atlalloc.h 665
ErrorRC2188 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\atlmfc\include\atlalloc.h(609) : error RC2188: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\atlmfc\include\atlalloc.h(640) : warning RC4011: identifier truncated to '_ATL_USE_WINAPI_FAMILY_DESKTOP_' TreeControl C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\atlmfc\include\atlconv.h 22
then I googled and find this post. it gives me a clue:
- Warning RC4011 and error RC2188
- VS Preview 2019 vcruntime.h causes RC4011 warning
- What is this error: invalid preprocessor command 'include_next' ?
I told you in my first reply, you have to check all the headers included by the resource file, some of them cannot be parsed by the resource compiler and the need to be excluded by using #ifndef RC_INVOKED.
You have 2 headers that may cause this problem in your resource file: resacz99.h and widgets.h. One of them must somehow include ATL headers.
Thanks for your hint.
I found an include on one resource file that made use of stdio.h . Removing that dependence, the warning vanished.
then I compiled this project again and ran into another error:
Error RC1004 unexpected end of file found TreeControl C:\Demo\TreeControl\TreeControl\ids.h 21
then I googled and find another wonderful link. tested the solution and it works well. amazing internet!
Full Error Name: Resource Compiler Fatal Error RC1004 unexpected end of file found
To Fix: Be sure to hit enter at the end of the last line in both the resource.h and the resource.rc files.
good research on CTreeCtrl.
- CDeviceTree
- Using CTreeCtrl:: gateway to articles
- Using Tree Controls:: detailed steps
- Tree Control Styles
- Tree-View Control Window Styles
- Tree Control Notification Messages::Mcirosodt Official Message List
- TN061: ON_NOTIFY and WM_NOTIFY Messages
- Module 5b: The Modal Dialog and Windows Common Controls 3
- Thread: CTreeCtrl and DeleteItem notification
- MFC Controls: The Tree Control
- CTreeCtrl Notification Message
- CTreeCtrl, TrackPopupMenu and CCmdTarget
- MFC-- manually call message response function CTreeCtrl
- CTreeCtrl使用演示
- CTreeCtrl使用演示
it lists all notification message designed for this CTreeCtrl control.
it has detailed instructions on mapping message handlers.
the bottom section touched on CTreeCtrl and Notification Message. needs to take a look:
The Tree Control
The list control and the tree control have some things in common: they can both use the same image list, and they share some of the same notification messages. Their methods of identifying items are different, however. The tree control uses an HTREEITEM handle instead of an integer index. To insert an item, you call the InsertItem() member function, but first you must build up a TV_INSERTSTRUCT structure that identifies (among other things) the string, the image list index, and the handle of the parent item (which is null for top-level items). As with list controls, infinite customization possibilities are available for the tree control. For example, you can allow the user to edit items and to insert and delete items.
The WM_NOTIFY Message
The original Windows controls sent their notifications in WM_COMMAND messages. The standard 32-bit wParam and lParam message parameters are not sufficient, however, for the information that a common control needs to send to its parent. Microsoft solved this "bandwidth" problem by defining a new message, WM_NOTIFY. With the WM_NOTIFY message, wParam is the control ID and lParam is a pointer to an NMHDR structure, which is managed by the control. This C structure is defined by the following code:
typedef struct tagNMHDR { HWND hwndFrom; // handle to control sending the message UINT idFrom; // ID of control sending the message UINT code; // control-specific notification code } NMHDR;
Many controls, however, send WM_NOTIFY messages with pointers to structures larger than NMHDR. Those structures contain the three members above plus appended control-specific members. Many tree control notifications, for example, pass a pointer to an NM_TREEVIEW structure that contains TV_ITEM structures, a drag point, and so forth. When ClassWizard maps a WM_NOTIFY message, it generates a pointer to the appropriate structure.
No comments:
Post a Comment