$$送分,up有分$$

cl0517 2002-09-01 11:07:21
我生成一个dialog,上面的控件都是用代码动态添加的,谁能告诉我怎么能设置这些控件的tab顺序。欢迎up。
...全文
43 44 打赏 收藏 转发到动态 举报
写回复
用AI写文章
44 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiachedan 2002-09-02
  • 打赏
  • 举报
回复
up
txdxun 2002-09-02
  • 打赏
  • 举报
回复
拜托不要老是“Layout->Tab Order”了,人家的是动态创建的
litsnake1 2002-09-02
  • 打赏
  • 举报
回复
应该用SetWindowPos是可以的,具体怎么用不是很记得了,你可以查查msdn,应该可以找到的
galaxyzhang 2002-09-02
  • 打赏
  • 举报
回复
动态生成的控件,他们的TAB ORDER是根据创建的顺序来决定的,在程序中可以通过SetWindowPos来改变他们的TAB ORDER。例如:
创建三个控件:
m_Btn.Create(L"First",WS_CHILD|WS_VISIBLE|WS_TABSTOP,CRect(100,20,200,60),this,102);
m_Lstb.Create(WS_CHILD|WS_VISIBLE|LBS_STANDARD|WS_HSCROLL|WS_TABSTOP,CRect(50,80,190,180),this,101);
m_Edt.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,CRect(100,210,200,240),this,103);

他们的TAB ORDER是m_Btn->m_Lstb->m_Edt;
然后在程序中进行如下修改:
m_Lstb.SetWindowPos(&wndTop,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
m_Edt.SetWindowPos(&m_Lstb,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
m_Btn.SetWindowPos(&m_Edt,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
之后,他们的TAB ORDER是m_Lstb->m_Edt->m_Btn.

:)
Gulang68 2002-09-02
  • 打赏
  • 举报
回复
up
================================================================
我是一个兵,来自老百姓。
笨笨2011 2002-09-02
  • 打赏
  • 举报
回复
up
wxyq 2002-09-02
  • 打赏
  • 举报
回复
还有更好的办法?
================================================================

ok?
wxyq 2002-09-02
  • 打赏
  • 举报
回复
动态建立的控件是按照建立的顺序来的

如要把后来的控件插到前面很麻烦
{
建立控件后
要放到后面的控件。TABSTOP=TRUE
再按顺序--------false

}
================================================================

ok?
wxyq 2002-09-02
  • 打赏
  • 举报
回复
动态建立的控件是按照建立的顺序来的

如要把后来的控件插到前面很麻烦
{
建立控件后
要放到后面的控件。TABSTOP=TRUE
再按顺序--------false

}
================================================================

ok?
longaway 2002-09-02
  • 打赏
  • 举报
回复
Platform SDK: Windows User Interface
SetFocus
The SetFocus function sets the keyboard focus to the specified window. The window must be attached to the calling thread's message queue.

HWND SetFocus(
HWND hWnd // handle to window
);
Parameters
hWnd
[in] Handle to the window that will receive the keyboard input. If this parameter is NULL, keystrokes are ignored.
Return Values
If the function succeeds, the return value is the handle to the window that previously had the keyboard focus. If the hWnd parameter is invalid or the window is not attached to the calling thread's message queue, the return value is NULL. To get extended error information, call GetLastError.

Remarks
The SetFocus function sends a WM_KILLFOCUS message to the window that loses the keyboard focus and a WM_SETFOCUS message to the window that receives the keyboard focus. It also activates either the window that receives the focus or the parent of the window that receives the focus.

If a window is active but does not have the focus, any key pressed will produce the WM_SYSCHAR, WM_SYSKEYDOWN, or WM_SYSKEYUP message. If the VK_MENU key is also pressed, the lParam parameter of the message will have bit 30 set. Otherwise, the messages produced do not have this bit set.

By using the AttachThreadInput function, a thread can attach its input processing to another thread. This allows a thread to call SetFocus to set the keyboard focus to a window attached to another thread's message queue.

Example Code
For an example, see Initializing a Dialog Box.

Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.

See Also
Keyboard Input Overview, Keyboard Input Functions, AttachThreadInput, GetFocus, WM_KILLFOCUS, WM_SETFOCUS, WM_SYSCHAR, WM_SYSKEYDOWN, WM_SYSKEYUP
spwnihao 2002-09-02
  • 打赏
  • 举报
回复
up
ynli2002 2002-09-02
  • 打赏
  • 举报
回复
不好意思,题意弄错了,如果是动态创建的,就不知道了,你不能按顺序创建吗?
查查MSDN把
longaway 2002-09-02
  • 打赏
  • 举报
回复
CWnd::SetFocusSee Also
CWnd Overview | Class Members | Hierarchy Chart | SetFocus | CWnd::GetFocus
Claims the input focus.

CWnd* SetFocus( );
Return Value
A pointer to the window object that previously had the input focus. It is NULL if there is no such window. The returned pointer may be temporary and should not be stored.

Remarks
The input focus directs all subsequent keyboard input to this window. Any window that previously had the input focus loses it.

The SetFocus member function sends a WM_KILLFOCUS message to the window that loses the input focus and a WM_SETFOCUS message to the window that receives the input focus. It also activates either the window or its parent.

If the current window is active but does not have the focus (that is, no window has the focus), any key pressed will produce the messages WM_SYSCHAR, WM_SYSKEYDOWN, or WM_SYSKEYUP.

mouse791020 2002-09-02
  • 打赏
  • 举报
回复
up
ynli2002 2002-09-02
  • 打赏
  • 举报
回复
选择菜单Layout->Tab Order
然后程序就可以按你点击的顺序来安排控件的顺序
都有标号的
longaway 2002-09-02
  • 打赏
  • 举报
回复
不好意思最近比较忙
拿分先

有空帮你找一下
winne_ll 2002-09-02
  • 打赏
  • 举报
回复
up
utada776 2002-09-02
  • 打赏
  • 举报
回复
up
rujor 2002-09-02
  • 打赏
  • 举报
回复
up,抢分啊
lsnhit 2002-09-02
  • 打赏
  • 举报
回复
帮你UP一下
加载更多回复(24)

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧