-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加和其他程序交互的机制 #895
Merged
添加和其他程序交互的机制 #895
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
把 MessageBox 的 hWnd 参数设为主窗口即可,弹窗会被主窗口“拥有”。如果希望弹窗期间主窗口可以交互,可以用 TaskDialogIndirect 代替。 TASKDIALOGCONFIG tdc{
.cbSize = sizeof(TASKDIALOGCONFIG),
.dwFlags = TDF_SIZE_TO_CONTENT,
.pszWindowTitle = L"test",
.pszContent = L"test",
.cButtons = 0,
.pButtons = nullptr,
.pfCallback = [](HWND hWnd, UINT msg, WPARAM /*wParam*/, LPARAM /*lParam*/, LONG_PTR /*lpRefData*/) -> HRESULT {
if (msg == TDN_CREATED) {
SetProp(hWnd, L"Magpie.ToolWindow", (HANDLE)TRUE);
}
return S_OK;
}
};
TaskDialogIndirect(&tdc, nullptr, nullptr, nullptr); |
消息窗口和文件选择窗口一般都是模态的,不需要特殊处理。原本这个机制只用于简单的场景,你的场景比较复杂的话就必须自己处理复杂的情况了。 从窗口属性读取进程 ID 不大可行。
|
以管理员身份运行 Magpie 问题还存在吗? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #447
我创建了 MagpieWatcher 来演示这些机制。
如何在缩放状态改变时得到通知
监听 MagpieScalingChanged 消息。
UINT WM_MAGPIE_SCALINGCHANGED = RegisterWindowMessage(L"MagpieScalingChanged");
参数
wParam
为事件 ID,对于不同的事件lParam
有不同的含义。目前支持两个事件:lParam
。lParam
为缩放窗口句柄。注意事项
如果你的进程完整性级别 (Integration level) 比 Magpie 更高,由于用户界面特权隔离 (UIPI),你将无法收到 Magpie 广播的消息。这种情况下请调用 ChangeWindowMessageFilter 允许接收 MagpieScalingChanged 消息。
ChangeWindowMessageFilter(WM_MAGPIE_SCALINGCHANGED, MSGFLT_ADD);
如何获取缩放窗口句柄
你可以监听 MagpieScalingChanged 消息来获取缩放窗口句柄,也可以查找类名为
Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22
的窗口以在缩放中途获取该句柄。Magpie 将确保此类名不会改变,且不会同时存在多个缩放窗口。如何将你的窗口置于缩放窗口上方
你的窗口必须是置顶的。你还应该监听 MagpieScalingChanged 消息,当收到该消息时缩放窗口已经显示,然后你可以使用
BringWindowToTop
函数将自己的窗口置于缩放窗口上方。缩放窗口在存在期间不会尝试调整自己在 Z 轴的位置。如何获取缩放信息
缩放窗口的窗口属性中存储着缩放信息。目前支持以下属性:
Magpie.SrcHWND
: 源窗口句柄Magpie.SrcLeft
、Magpie.SrcTop
、Magpie.SrcRight
、Magpie.SrcBottom
: 被缩放区域的边界Magpie.DestLeft
、Magpie.DestTop
、Magpie.DestRight
、Magpie.DestBottom
: 缩放后区域矩形边界如何使 Magpie 在你的窗口位于前台时保持缩放
前台窗口改变时 Magpie 会停止缩放,只对某些系统窗口例外。你可以通过设置属性
Magpie.ToolWindow
将自己的窗口添加入例外,这对由该窗口拥有 (owned) 的窗口也有效。