题记:不知道为什么在学校登CSDN登不上去,真是有急需解决的问题,所以花了20分钟从寝室走到网吧来问,求知之心,望各位达人帮小弟解决一下。孙鑫VC++6.0深入讲解 第261页 例7-35  GetFocus()->GetNextWindow()->SetFocus();
这里的GetNextWindow()是按照什么顺序来求下一个控件的?我知道前几个函数如:平台SDK的GetNextWindow,GetWindow和GetNextTabItem等函数都是按照控件Tab值的大小排序来找下一个控件的,不知道这里的CWnd成员函数是按照什么顺序来来找下一个的?
我在执行例7-35的时候,执行顺序是这样的,先Edit1,再Cancel,再Add,再 收缩按钮,再按几下回车就出现错误(见p262图7.46) 按照这种结果好像就是调用CWnd成员函数GetNextWindow后Edit1的下一个寻找到的控件是Cancel而不是Edit2,我怎么改Tab值的顺序都不能解决这个问题,所以我想这个函数应该不是按照Tab值的顺序来找下一个的,昨天都被它折磨一天了希望各位能告诉我怎么解决这个问题?

解决方案 »

  1.   

    没看过视频,但GetNextWindow的顺序是:
    The GetNextWindow function retrieves a handle to the next or previous window in the Z-Order. The next window is below the specified window; the previous window is above. If the specified window is a topmost window, the function retrieves a handle to the next (or previous) topmost window. If the specified window is a top-level window, the function retrieves a handle to the next (or previous) top-level window. If the specified window is a child window, the function searches for a handle to the next (or previous) child window. 
      

  2.   

    1。获得窗口函数:GetNextWindow();注意编辑框需将多行设置真属性;
    2。获取窗口句柄函数:GetWindow()可找窗口,子窗口等。
    3。GetNextTabItem,具Tab Stop属性函数。
    焦点依次传递,基缺省按钮默认函数相应。GetNextDlgItem(GetFocus())->SetFocus();
    即使OK按钮被删除,On_OK依然被响应,特别注意:ID号ID_OK应缺省ON_OK响应。
      

  3.   

    是按照Z-Order顺序,与Tab顺序不同,以下是MSDN中Z-Order的说明:The z-order of a window indicates the window's position in a stack of overlapping windows. This window stack is oriented along an imaginary axis, the z-axis, extending outward from the screen. The window at the top of the z-order overlaps all other windows. The window at the bottom of the z-order is overlapped by all other windows.The system maintains the z-order in a single list. It adds windows to the z-order based on whether they are topmost windows, top-level windows, or child windows. A topmost window overlaps all other non-topmost windows, regardless of whether it is the active or foreground window. A topmost window has the WS_EX_TOPMOST style. All topmost windows appear in the z-order before any non-topmost windows. A child window is grouped with its parent in z-order.When an application creates a window, the system puts it at the top of the z-order for windows of the same type. You can use the BringWindowToTop function to bring a window to the top of the z-order for windows of the same type. You can rearrange the z-order by using the SetWindowPos and DeferWindowPos functions.The user changes the z-order by activating a different window. The system positions the active window at the top of the z-order for windows of the same type. When a window comes to the top of z-order, so do its child windows. You can use the GetTopWindow function to search all child windows of a parent window and return a handle to the child window that is highest in z-order. The GetNextWindow function retrieves a handle to the next or previous window in z-order.