zoukankan      html  css  js  c++  java
  • 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不是很熟悉,忘大虾指教:)

  • 相关阅读:
    课堂练习-电梯调度
    团队开发项目———来用————用户调研报告
    购书思想课堂作业4.14
    针对《来用》的NABC分析
    《梦断代码》读书笔记3
    《梦断代码》读书笔记2
    《大道至简》阅读笔记2
    《大道至简》阅读笔记1
    课堂练习之找出所有的“1”
    典型用户与场景分析
  • 原文地址:https://www.cnblogs.com/anders06/p/1399334.html
Copyright © 2011-2022 走看看