2010-01-06 54 views
0

我有一个winforms自定义用户界面控件库,其中包含一个显示模式对话框画中画的控件。松散地耦合模式对话框 - 这可能吗?

此自定义控件接收作为参数的指针,该指针指向启动其显示的控件。所以他们被绑在一起。这允许控制器模式地显示在启动它的窗口上。

Dim f As New PiPCustomDialog  'this form wraps another form PictureInPicture style 
    f.FormToLoad = New PrintOptions() 'this is the form the user will interact with 
    f.Owner = Me      'used to determine the size of PiPCustomDialog 
    Dim dr As DialogResult = f.ShowDialog(Me) 'shows PiPCustonDialog coating, f's OnLoad event initiates display of FormToLoad centered within. 

这个控件需要f.Owner被设置的事实是什么臭。 User32.dll有一个函数Ge​​tActiveWindow(),这可能会让控件更加自给自足。

谁在那里谁想教这个老狗一个新的诡计?我想学习更好的方法。

+0

我不明白。如果您只是删除f.Owner作业,它会更好吗?不需要,将我传给ShowDialog()也是一样。或者这实际上是一种控制而不是一种形式?什么是“f”? – 2010-01-06 18:00:50

+0

好吧,你说的对不清楚。 f是自定义控件的一个实例。我会添加更多信息。 – bperreault 2010-01-06 19:05:45

回答

0

我将使用这个解决方案现在:

  • 删除要求 所有者显示模态的 形式之前设置任何验证。
  • 如果所有者没有设置透明覆盖类 (第一种形式) - 执行系统调用
    GetActiveWindow获取所有者以便窗口大小可以设置。