简体   繁体   English

Win 10中的Win Forms VB App-焦点问题

[英]Win Forms VB App in Win 10 - focus issues

I have an app built in VB in Visual Studio 2012 that works absolutely fine on my windows 10 desktop, but as soon as i use it on my windows 10 tablet i see a couple of issues : 我在Visual Studio 2012中使用VB内置了一个应用程序,该应用程序在Windows 10桌面上绝对可以正常运行,但是一旦在Windows 10平板电脑上使用它,我就会看到几个问题:

1) any forms that were intended to be smaller than full screen are shown fullscreen anyway (almost as if you're not allowed any windows less than full screen) i can live with that if need be, but surely theres a way around it? 1)任何打算小于全屏的表格无论如何都将全屏显示(几乎就像您不允许任何小于全屏的窗口一样),如果需要的话,我可以忍受,但是肯定有办法解决吗?

2) - the most important one - for some strange reason, i start my app, and when i click on a button let's say it opens form 6. once i finish what i'm doing the code closes the form 6, but the previous form is now hidden and all you see is the desktop. 2)-最重要的一个-出于某种奇怪的原因,我启动了我的应用程序,当我单击按钮时,可以说它打开了表格6。完成代码后,我将关闭表格6,但是前一个表单现已隐藏,您所看到的只是桌面。 ie it's still running, it just lost its focus and must be selected again. 即它仍在运行,只是失去了焦点,必须再次选择。 I understand i could set the focus to the underlying form before closing form 6, but here's the problem : it can be one of several different forms calling form 6..... so how do i make the app stay aware of what form called form6 so that when done i can return focus there? 我知道我可以在关闭表单6之前将焦点设置到基础表单,但这是问题所在:它可以是调用表单6的几种不同表单之一。...所以我如何使应用程序知道什么叫表单form6,以便完成后我可以在那里集中精力?

this doesnt seem to be a problem on the desktop so i've never encountered it before. 这似乎不是桌面上的问题,所以我以前从未遇到过。 i hope one of you experts has dealt with this before 我希望你们当中的一位专家已经解决了这个问题

I don't have enough points yet to comment. 我的观点还不够。 My guess for #1 is either resolution or DPI differences between the 2 screens, and I don't have experience with the latter. 我对#1的猜测是两个屏幕之间的分辨率或DPI差异,而我对后者没有经验。

As for #2 and keeping the form aware of who called it, this is how I do it, which may not be the best solution, of course. 至于#2,并让表单知道是谁调用的,这就是我的方法,当然,这可能不是最佳解决方案。 ;) ;)

First any form that can have multiple callers has a variable defined like 首先,可以有多个调用方的任何形式的变量都定义为

Dim callingForm As New Form

I typically create an Initialize routine to handle as much as possible before loading a form and this routine is called with the parent form (Me) as a parameter. 我通常创建一个Initialize例程以在加载表单之前尽可能多地处理该例程,并以父表单(Me)作为参数来调用此例程。

Dim frm As New frmClient
frm.Initialize(Me)
frm.Show()
Me.Hide()

In Initialize, callingForm is set to the parent 在Initialize中,callingForm设置为父级

Public Sub Initialize(parent As Form)
    callingForm = parent
    'whatever else you need to do to init...
End Sub

Then when you exit the form... 然后,当您退出表单时...

Private Sub exitForm()
    'whatever other closing stuff you need to do...
    callingForm.Show()
    Me.Close()
End Sub

That should get you started. 那应该让您开始。

fyi for anyone encountering this problem, i solved it myself and it didn't require any coding. 供任何遇到此问题的人参考,我自己解决了它,不需要任何编码。 It was a difference between how vb apps act when the tablet is in "TABLET" mode, and when tablet mode is switched off. 平板电脑处于“平板电脑”模式时和平板电脑模式关闭时,vb应用程序的行为有所不同。 So all that needed doing is switching off enhanced tablet mode in the windows 10 settings 因此,所有需要做的就是在Windows 10设置中关闭增强型平板电脑模式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM