SOS: How to popup a HwndSource on topmost

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不是很熟悉,忘大虾指教:)

posted @ 2009-02-27 10:57  Anders06  阅读(771)  评论(3编辑  收藏  举报