20070606 smartphone vs2005 tree-view controls
http://www.yippeesoft.com
create an MFC app using VS2005 for Smartphone. A CTreeCtrl (sitting on a CFormView) is not processing any keyboard input. For example, pressing the arrow keys or Action key does not expand/contract nodes. Am I missing something simple?
By default, CTreeCtrl on Smartphone has limited navigation:
Expand/Collapse node = Action Key
Move focus = Up/Down
Check/Uncheck box = <nothing>
A sugeestion is to override this for Smartphone so that:
Expand/Collapse node = Left/Right key
Move focus = Up/Down
Check/Uncheck box = Action key
Hope that helps.
smartphone开发中遇到的问题,TreeView为什么不响应键盘消息? 按确定不能展开,按上下键不能在节点之间移动..
楼主jun_01(无名小卒)2005-07-03 16:49:52 在 硬件/嵌入开发 / 嵌入开发(WinCE) 提问
总之一句话, treeView不响应任何键盘消息.
替换了它的wndProc,能发现有消息发给它,但它就是没有任何效果 …
4 楼nbcool(载舟之水)回复于 2005-07-07 21:42:57 得分 80
不好意思,下载才有空回答,不过很高兴你找到了正确的方法。
这个问题原因有2个。
1.当前treeview没有获得焦点,或者在当前窗口开了其他窗口后忘记把焦点交回treeview。
这个解决办法很简单了,每次SetFocus就行了。或者在
DialogBox(…); or MessageBox(…);
SetFocus(hTreeView);
这样就能保证焦点回来。
2.在DialogBox里建立的TreeView,由于DialogBox会屏蔽一些键盘传送的消息,导致消息无法传给treeview,这种情况有两个办法
a.不用DialogBox,而改用窗口。
b.就是做子类化了,替换TreeView控件的消息处理过程,我猜你用了这个。但是记得别忽视了焦点的问题,这在SP下比较重要,而PPC显得次要些。
LRESULT CALLBACK TreeViewProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
&leftsign;
switch (uMsg)
&leftsign;
case WM_GETDLGCODE:
return DLGC_WANTMESSAGE;
&rightsign;
return CallWindowProc(OldTreeViewProc, hwnd, uMsg, wParam, lParam);
&rightsign;
HTML 控件也有这个问题。希望你满意这个答案。
to nbcool(载舟之水) ,没想到你是一个很负责的人,呵呵。
我就是自己替换treeview的windowProc,然后拦截键盘的上下左右和确定键来完成的。
但遇到了很多问题,首先是key_down有的键竟然拦截不到,然后用了key_up,又发现和xbar有冲突。
每次按键都会连续收到2次消息,实在没办法,又判断了2次消息之间的时间间隔,总算勉强完成了想要的功能,真的是不爽。
而且我后来用到了listview控件,又发现了一些问题,好在有treeview的经验,也用类似的办法勉强搞了出来,实在是怕了。。。
看到你的WM_GETDLGCODE,我发现应该有用,准备试一下。真是感谢!
我还遇到了其它一些关于菜单的键盘消息的问题,也在困惑中,真是郁闷呀。
How to: Subclass a TreeView by Using Native Callbacks
This example shows how to subclass a TreeView control to create a NodeMouseClick event, which is not available in the .NET Compact Framework.
The form displays the subclassed TreeView control and information about a clicked node. It shows the a node\’s text and the x and y coordinates of where the TreeView control was clicked, which changes as you click in different places on a node.
This example program is described in detail in Subclassing Controls with a Managed Window Procedure.
To subclass a TreeView control to create a NodeMouseClick event
1.
In Microsoft Visual Studio 2005, create a Smart Device Pocket PC project.
2.
Add the Win32 helper class to your project. This code is available in How to: Use a Helper Class for Platform Invokes.
3.
Add the WinProcHooker class to your project. This code is available in How to: Use a Class for Hooking Windows Procedures.
4.
Add the TreeViewBonus class to your project.
历史博文
- 开发Android NetBeans - 2010
- 20080618 多难兴邦 外协 - 2009
- 0901 Asynchronous Pluggable Protocol demo 4 - 2007
- 0109 SKIN 异型 窗体 SetWindowRgn - 2006