可以WM_NEXTDLGCTL与非对话框窗口中使用吗? [英] Can WM_NEXTDLGCTL be used with non-dialog windows?

查看:162
本文介绍了可以WM_NEXTDLGCTL与非对话框窗口中使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关 WM_NEXTDLGCTL 文档状态,此消息被使用与对话:

The documentation for WM_NEXTDLGCTL states, that this message is to be used with dialogs:

发送到一个对话框过程将键盘焦点设置在对话框中不同的控制。

Sent to a dialog box procedure to set the keyboard focus to a different control in the dialog box.

如果此消息不能与非对话框控件父母可以使用,这将是一个通用的方法非常繁琐的子控件(如的这个问题),因为窗口过程将不得不打电话或者的SetFocus 或发送一个 WM_NEXTDLGCTL 信息的基础上,不是很琐碎,以确定上下文。

If this message cannot be used with non-dialog control parents, it would be very tedious to subclass controls in a generic way (as illustrated in this question), since the window procedure would have to call either SetFocus or send a WM_NEXTDLGCTL message, based on not quite trivial to determine context.

由于其他特定对话框的API可以与非对话框窗口中(如 IsDialogMessage ),它会觉得自然可以使用 WM_NEXTDLGCTL 在此设置也是如此。

Since other dialog-specific APIs can be used with non-dialog windows (e.g. IsDialogMessage), it would feel natural to be able to use WM_NEXTDLGCTL in this setup as well.

问: WM_NEXTDLGCTL 与非对话框控制的父母曾经

Question: Can WM_NEXTDLGCTL be used with non-dialog control parents?

推荐答案

能否WM_NEXTDLGCTL与非对话框控件父母可以使用?

我不认为你可以在非对话框父窗口使用它(至少不改变父窗口),其原因是,它是在 DefDlgProc 实施。所以,你的其他非对话框窗口将不得不调用它,使这个消息的工作。

I dont think you can use it in non dialog parent windows (at least with no changes to parent window), the cause is that it is implemented inside DefDlgProc. So your other non-dialog windows would have to call it to make this message work.

这是我在的旧的新发现报价:实践发展整个的Windows 的演变:?里面DefDlgProc会发生什么

This is the quote I have found in The Old New Thing: Practical Development Throughout the Evolution of Windows: What happens inside DefDlgProc?

对于WM_NEXTDLGCTL消息的言论观察,该DefDlgProc函数通过更新所有的内部对话管理器簿记处理WM_NEXTDLGCTL消息,决定哪些按钮应该是默认的,所有的好东西。

As the remarks for the WM_NEXTDLGCTL message observe, the DefDlgProc function handles the WM_NEXTDLGCTL message by updating all the internal dialog manager bookkeeping, deciding which button should be the default, all that good stuff.

另一个原因则对话框只的消息是,它(从MSDN报价为WM_NEXTDLGCTL):

Another reason why it is dialog only message is the fact that it (quote from msdn for WM_NEXTDLGCTL):

设置默认的控制标识符

要做到这一点,必须发送DM_SETDEFID,其定义为:

to do it it must send DM_SETDEFID, which is defined as:

#define DM_SETDEFID         (WM_USER+1)

所以它是WM_USER,因此它可以用于在非对话框窗口一些其他目的(这一事实在雷蒙德陈氏书中也提及)。有趣的是,根据这本书 IsDialogMessage 也将DM_SETDEFID / DM_GETDEFID到你的窗口。所以,如果你想使用TAB像你内心的导航非对话框窗口(使用对话框code),则必须遵守一定的规则,你可以在里面对他们阅读:<?code>里面IsDialogMessage会发生什么上面的书。这意味着在其他使用如下的消息循环:

so it is WM_USER, and as such it might be used for some other purpose on non dialog window (this fact is also mentioned in Raymond Chens book). The interesting thing is that according to this book IsDialogMessage also sends DM_SETDEFID/DM_GETDEFID to your window. So if you want to use TAB like navigation inside you non dialog window (using dialog code), you must adhere to some rules, you can read on them inside: What happens inside IsDialogMessage? of above book. This means among others to use following message loop:

while (GetMessage(&msg, NULL, 0, 0)) {
    if (IsDialogMessage(hwnd, &msg)) {
        /* Already handled by dialog manager */
    } else {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}

所以,如果你不想做重大改变,你的父窗口code,那么恐怕你的运气了。

so if you dont want to do major changes to your parent windows code, then I am afraid you are out of luck.

这篇关于可以WM_NEXTDLGCTL与非对话框窗口中使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆