Tag: window

MonoMac窗口关闭没有错误

我刚开始使用Xamarin Studio中的MonoMac,我遇到了一个最奇怪的问题: 我是一个带有NSButton和NSTextField的窗口。 到目前为止,我已经删除了按钮上的事件处理程序,因此它不做任何事情,除非我点击它时突出显示。 按钮创建代码如下所示: nsButton = new NSButton(new System.Drawing.RectangleF(0, 0, 100, 100)); nsButton.BezelStyle = NSBezelStyle.RoundRect; nsButton.Font = NSFont.SystemFontOfSize( NSFont.SystemFontSizeForControlSize(NSControlSize.Regular)); nsButton.StringValue = text; …然后它会像这样添加到窗口中: nsView.AddSubview(control.Handle as NSView); (因为在这部分代码中,control.Handle被输入为对象,而nsView是窗口上的主视图)。 所有的运行和工作正常。 但是,如果我反复点击该按钮,最终窗口就会关闭。 没有错误,没有例外,应用程序本身也不会退出; 当我使用菜单时,菜单会继续响应并愉快地记录消息。 但窗户很简单 – 走了。 这是非常可重复的:它发生在21次点击之后。 如果我添加一个更新NSTextField的事件处理程序(例如hello.Caption =“Foo”;),那么它会在19次点击后发生。 无论是快点还是慢点都没关系; 它始终是相同的点击次数。 请注意,项目中没有关闭窗口的代码,窗口甚至没有关闭框; 我知道没有合法的方法来关闭它而不是退出应用程序。 我在这里感到困惑,不知道如何进一步调试。 在这么多活动之后,Xamarin是否有某种评估限制可以关闭你的窗户? 这是一个框架错误吗? 任何见解将不胜感激。

只有在创建Window并显示为对话框后才能设置DialogResult

我有一个主WPF窗口,mywindow.showDialog,当在窗口上单击一个按钮时,执行一个命令让我们说命令是SendToTableCommand protected virtual void SendToTableExecute(object o) { UIThread.BeginInvoke(new Action(SendToTableExecuteUI),o); } private void SendToTableExecuteUI(object o) { if (o is Control) { m_OwningWindow = UIHelper.FindVisualParent((Control)o); } do sth… if (m_OwningWindow != null) { //only set DialogResult when window is ShowDialog before if(System.Windows.Interop.ComponentDispatcher.IsThreadModal) m_OwningWindow.DialogResult = true; } } 前一段时间, m_OwningWindow.DialogResult = true抛出exception。 所以我添加了一个使用IsThreadModal的if检查。 它已经工作了一段时间,但现在m_OwningWindow不会因为IsThreadModal是假的而关闭。 我不知道解决问题的正确方法是什么,并认为我没有正确处理它。 请帮忙。 提前致谢

新的WPF窗口仅显示在原始窗口下方

在我的WPF应用程序中,我在主窗体上有一个ListView,它显示来自DataSet的绑定数据。 当用户双击ListView中的行时,它会打开一个详细信息窗口。 在我的XAML中,我使用样式在listview上创建双击处理程序: … 在代码隐藏中,我有一个跟踪打开的详细信息窗口的字典(多个可以一次打开),这样如果一个细节窗口已经打开,它就会被带到前面。 我像这样处理双击: private void HandleDoubleClick(object sender, MouseEventArgs e) { DataRowView clickedRow = ((ListViewItem)sender).Content as DataRowView; int row = (int)clickedRow.Row[“ID”]; if (!displayedCards.ContainsKey(row)) { DetailWindow window = new DetailWindow(RetrieveData(row)); //window.Owner = this; displayedCards.Add(row, window); window.Show(); } else { displayedCards[row].Activate(); } } 我的问题是,使用上面的代码,详细信息窗口在主窗体后面打开。 如果我设置了所有者信息( window.Owner = this ),则会在主窗体的顶部打开详细信息窗口,但主窗体永远不会出现在详细信息窗口的前面。 displayedCards[row].Activate()按预期工作,将该细节窗口带到所有其他细节窗口的前面,但它成为上述相同问题的受害者 – 它不会出现在主窗口的前面。 我想要完成的是将细节窗口放在与主窗口相同的层/层(/ z顺序?)上,这样两者都可以显示在彼此的顶部,并使细节窗口显示在打开时的主要forms。 编辑:如果重要,则详细信息窗口没有WindowStyle并且AllowsTransparency设置为true。 […]

.NET(C#)窗口最小化事件

嘿,我真的在这里坚持我的项目…我需要知道什么时候最小化/恢复任何打开的窗口,并在我自己的应用程序中处理事件。 有任何想法吗? 编辑:Musigenesis是正确的,我想知道其他应用程序何时被最小化/恢复

如何使用C#最小化IE浏览器?

如何使用C#最小化IE浏览器? 我尝试下面提到的代码不起作用: var processes = Process.GetProcessesByName(“*iexplorer.*”); if (processes.Any()) { var handle = processes.First().MainWindowHandle; ShowWindow(handle, SW_SHOWMINIMIZED); } 有没有其他方法可以实现IE浏览器的最小化?

WPF窗口在启动时抛出TypeInitializationException

我有一个带有几个色带的Excel AddIn,一个色带是设置窗口。 单击它时,将显示自定义窗口。 但是,单击时没有任何内容显示。 我在日志文件中看到以下exception。 是什么导致这种情况以及如何解决? 非常感谢 2012-04-09 09:59:50,161 [1] ERROR Helper [(null)] – Name:TypeInitializationException消息:’System.Windows.Window’的类型初始值设定项引发exception。 目标:Void .ctor()Stack:位于MyAddIn.Connect.BtnClick(IRibbonControl控件)MyAddIn.Connect.GetSettings()的MyShared.View.ConnectionSetup..ctor()处的System.Windows.Window..ctor()处。 :TypeInitializationException消息:’System.Windows.FrameworkElement’的类型初始值设定项引发exception。 目标:Void .cctor()Stack:at System.Windows.Window..cctor()Name:TypeInitializationException消息:’System.Windows.Documents.TextElement’的类型初始值设定项引发exception。 目标:Void .cctor()Stack:at System.Windows.FrameworkElement..cctor()Name:TypeInitializationException消息:’MS.Internal.FontCache.Util’的类型初始值设定项引发exception。 目标:Int32 get_Dpi()Stack:在System.Windows.Dindows.TextElement..cctor()处的System.Windows.SystemFonts.ConvertFontHeight(Int32 height)处的MS.Internal.FontCache.Util.get_Dpi()处。名称:UriFormatException消息:无效的URI:无法确定URI的格式。 目标:Void CreateThis(System.String,Boolean,System.UriKind)Stack:位于MS的System.Uri..ctor(String uriString,UriKind uriKind)的System.Uri.CreateThis(String uri,Boolean dontEscape,UriKind uriKind)。 Internal.FontCache.Util..cctor() 编辑,这是xaml代码 Historical <!—-> Add Remove Username: Password: Forgot Password? Save username and password OK Historical Real Time Username: Password: Forgot […]

在自定义窗口上启动窗口的系统菜单

当您单击应用程序的图标或在应用程序的标题栏上单击鼠标右键时,我想调用ContextMenu 。 这是ContextMenu我的意思是: 我需要它,因为我做了像窗口一样的自定义控件。 我需要这种行为来完成我的控制。 编辑: Leo Lorenzo Luis问我代码: https://skydrive.live.com/?cid=c3392940f5cf5f74&id=C3392940F5CF5F74%21107&authkey=!APd2X3tDxWRfpL4 要么: 我的MainWindow.xaml: <!– –> 我的MainWindow.cs(代码隐藏): using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Interop; using System.Windows.Forms; namespace WpfApplication16 { /// /// Interaction logic for […]

我怎样才能获得前景窗口的exe路径

我想获取活动前台窗口的可执行文件路径。 我已经拥有前台窗口的处理程序: [DllImport(“user32.dll”)] static extern IntPtr GetForegroundWindow(); IntPtr handlerAppActual = GetForegroundWindow(); 我想得到它的可执行文件的路径,就像一个快捷方式。 (例如:C:\ application \ application.exe) 我为什么需要这个? 稍后使用它来通过调用其进程来自动执行应用程序,如下所示: Process process = new Process(); process.StartInfo.FileName = @parametros[0]; process.Start(); 其中“parametros [0]”是文件的路径。 我要求前景窗口的应用程序的路径,但如果你知道任何其他方式来做我需要的(获得前台应用程序的主要进程以后执行它),我会很高兴听到它。 谢谢,致敬!

在我的文档中获取特定于语言环境的目录

我有我的自定义应用程序在我的文档路径中生成一个目录,安装后应用程序使用该目录,但我在中文Windows操作系统中遇到问题,我的应用程序文件夹名称以中文显示,所以有什么方法我可以得到文件名正确地在“en”或某些词语中,以便我可以在运行时使用该目录名称。

WPF窗口设置焦点

我有一个WPF窗口,我只创建一次,然后多次Show()和Hide()。 现在我正在寻找一种方法来将焦点设置在每个Show()上的元素上。 我在哪里以及如何做到这一点?