惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
Martin Fowler
Martin Fowler
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
U
Unit 42
Y
Y Combinator Blog
月光博客
月光博客
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
GbyAI
GbyAI
H
Help Net Security
量子位
Last Week in AI
Last Week in AI
博客园_首页
腾讯CDC
小众软件
小众软件

博客园 - Anders06

A memory leak issue with WPF Command Binding 我也谈面试 附赠一份题目 败给了IEqualityComparer 标注随测量物体旋转问题 How to detect memory leak issue 图纸中角度标注算法 认真的程序员最可爱 Clean Code反案例:什么是不好的API 避免陷阱,重写Equals方法您需要注意的其中2个原则 What’s the problems with the following code 对象池 关于设计和设计文档的2个补充 SelectMany ConverAll & Exists SOS:利用WPF RichTextBox 提取RTF, 莫名丢掉了Underline样式信息 想探讨两个关于设计文档问题 Don‘t Cry for Me, Argentina 拒绝高姿态 Please avoid implement C# Destruction
SOS: How to popup a HwndSource on topmost
Anders06 · 2009-02-27 · via 博客园 - Anders06

I have create a HwndSource who will host a WPF TextBox control and set it on topmost, then popup it when user double clicks on the node.  Please refer to the following code:

 1 //attach textbox to client window
 2            HwndSourceParameters parameters = new HwndSourceParameters(/*MSG0*/"Parameters", rec.Width, rec.Height);
 3            parameters.ParentWindow = parentIntPtr;
 4            parameters.SetPosition(rec.Location.X, rec.Location.Y);
 5            parameters.WindowClassStyle = 0;
 6            parameters.WindowStyle = (int)(WindowStyles.WS_CHILD | WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_MAXIMIZEBOX);
 7            parameters.ExtendedWindowStyle = (int)(WindowExStyles.WS_EX_TOPMOST);
 8
 9            mHwndSource = new HwndSource(parameters);
10            if (mHwndSource == null)
11                return;
12
13            mHwndSource.RootVisual = mTextBox;

But the popup window’s behavior is very strange, it is not always on topmost.

For example:

· Double click a node text, the node begins to edit, then the text box appears:

clip_image002

· But when I move mouse out of the editing node or move mouse entry other node in order to interact with other node, the text box disappear:

clip_image004

· But I can still interact with the text box, it can response to mouse click, select and so on:

clip_image006

· It seems the text box has been covered by tree node.  The more strange thing is that even I did not draw the node text when its name is editing, the above cover problem still exists as the figures in the step 2&3.

clip_image008

· Then I set the background with red color, I found it looks like that it is covered by background, I guess perhaps this is caused by some redrawing?

clip_image010

有谁知道究竟是什么原因造成TextBox被遮盖吗?

(PS. 我们程序的主窗口是个MFC的form,而上面的内容都是用DirectX渲染的,不知道这个会不会跟WPF的控件有冲突哦)

目前我们的需求就是能够编辑Text, 并非一定要用HwndSource,是不是直接可以popup一个WPF的popup窗口也能实现这个效果呢?本人对WPF不是很熟悉,忘大虾指教:)