环境
- Windows XP SP3 x32
- Visual Studio 2005 标准
- Windows Mobile/Pocket PC 2003
- .NET Compact Framework 1.0 SP3 和 .NET Framework 1.1
- Honeywell Dolphin 9500 手持式条码扫描仪
目标
我有一个三表单应用程序和一个外部类 (Program.cs),它具有应用程序入口点 Main()
。主窗体首先加载,然后从 MainForm_Load(...)
内部实例化/显示一个类似于启动屏幕的新窗体。我希望所有三种形式都最大化。所有三个窗体都设置了以下属性:
-
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
>
-
this.ControlBox = false;
问题
“闪屏”表单显示全屏,没有任何问题。然后我处理它并显示主屏幕(首先加载和 Application.Run();
的参数。在主屏幕上,一旦检测到列表框 SelectedIndexChanged 事件,就会出现第三种形式显示(将主窗体留在第三个窗体后面)。第三个窗体在窗体的顶部显示任务栏:
关闭此窗体后,主窗体现在也覆盖了任务栏。
码
友粘贴链接。让我知道我是否应该在此处发布代码。 WorkOrderView 有一千多行,所以我认为这会更容易。
不相关的建议
我是一个相当新手的程序员,而且我特别缺乏在这种环境中的经验。因此,如果您对我做某些事情的方式有任何建议/批评,请随时向我提出。最好只对帖子发表评论,而不是针对这些类型的回复发布答案。
谢谢!
Environment
- Windows XP SP3 x32
- Visual Studio 2005 Standard
- Windows Mobile/Pocket PC 2003
- .NET Compact Framework 1.0 SP3 and .NET Framework 1.1
- Honeywell Dolphin 9500 Handheld Barcode Scanner
Goal
I have a three form application and an external class (Program.cs) that has the application entry point, Main()
. The main form loads first and then, from within MainForm_Load(...)
, instantiates/shows a new form kind of like a splash screen. I want all three forms to be maximized. All three forms have the following properties set:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ControlBox = false;
Problem
The "splash screen" form shows up full screen without any issue. I then dispose of it and show the main screen (first to load and the param for Application.Run();
. From the main screen, once a list box SelectedIndexChanged event is detected, a third form is shown (leaving the main form behind said third form). That third form shows the task bar over the top portion of my form:
Upon closing this form, the main form now has the task bar overlayed as well.
Code
Friend paste links. Let me know if I should just post the code here. WorkOrderView is over a thousand lines so I figured this would be easier.
Unrelated Suggestions
I am quite a green programmer and I especially lack experience in this environment. So, if you have any suggestions/criticisms on the way I'm doing some things, don't hesitate to hit me with them. Probably best to just comment on the post instead of posting an answer for those types of replies.
Thanks!
发布评论
评论(2)
首先,我这些天只运行 Windows Mobile 5 (WM5)。 (几年前我从 PocketPC 2003 升级到了。哈哈)
我发现定义表单的窗口大小在移动设备上效果不佳,并且显示/隐藏多个表单很尴尬,并且行为方式永远不会像您那样想。
不过,请确保您的主窗体的
WindowState
设置为最大化。我还将
ControlBox
和MinimizeBox
设置为 False,如果有帮助的话。与其使用多个表单,不如直接使用面板作为表单,将主表单作为某种 MDI 容器(用词不好,但这就是我正在做的事情),它看起来会好得多。
在我的设计器视图中,每个面板只是一个充满控件的小盒子。
Dock
设置为Fill。pnl1_button1
和pnl2_button1
这样的名称在代码中比 VS 默认的button1
和button2
更容易理解。Dock
属性并将其设置回 None。我发现它也有助于维护面板的小草图及其名称和控件的名称。
在主窗体的
Load
事件中,将每个Panel
的Dock
属性设置为 DockStyle.Fill。然后,当您想要显示一种表单时,只需调用Panel1.BringToFront()
而不是dialog.Show()
即可。移动开发并不难,但又有所不同。 :)
编辑:
在项目的 Program.cs 文件中,我保留了以下静态工具,可用于打开和关闭“开始”菜单(不起作用,因此在 WM5 中很好,但我仍然在我的 PocketPC 版本的代码中得到它)。
我已经有一年左右的时间没有打开这个项目了,但它应该都是有效的。尝试一下。如果我遗漏了什么,请告诉我。
将其粘贴到项目的 Program.cs 文件中后,只需在程序启动时调用
Program.ShowWindowsMenu(false);
和Program.ShowWindowsMenu(true); 即可。
当你的程序退出时。编辑2:
声明主窗体的私有静态实例,然后将其包装在项目的
Program.cs
文件中的try...catch例程中,如下所示:First off, I only run Windows Mobile 5 (WM5) these days. (I got to move up from PocketPC 2003 a couple of years ago. LOL)
I've found that defining a Form's Window Size does not work well on mobile devices, and that showing/hiding multiple forms is awkward and never behaves the way you want.
Still, make sure your Main Form has it's
WindowState
set to Maximized.I also set
ControlBox
andMinimizeBox
to False, if that helps.Instead of using multiple forms, it will look much nicer if you simply use Panels as your forms with the Main Form as some kind of MDI container (bad choice of words, but that is what I'm doing).
In my Designer View, each panel is just a small box full of controls.
Dock
to Fill.pnl1_button1
andpnl2_button1
are easier to understand in your code than the VS defaultbutton1
andbutton2
.Dock
properties and set it back to None.I have found it also helps to maintain a small sketch of your panels with their names and the names of their controls.
In the
Load
event of your main form, set everyPanel
'sDock
property to DockStyle.Fill. Then, as you want to show one form, simply callPanel1.BringToFront()
instead ofdialog.Show()
.Mobile development isn't hard, but it is different. :)
EDIT:
In the project's Program.cs file, I keep the following static tools that I can use to turn ON and OFF the Start Menu (doesn't work so well in WM5, but I've still got it in my code from my PocketPC version).
I have not had to open this project in a year or so, but it should all be valid. Give them a try. If I've left something out, just let me know.
Once this is pasted into your project's Program.cs file, just call
Program.ShowWindowsMenu(false);
when your program starts andProgram.ShowWindowsMenu(true);
when your program exits.EDIT2:
Declare a private static instance of your main form, then wrap that in a try....catch routine inside your project's
Program.cs
file like so:您所追求的通常称为“信息亭模式”(这可能有助于您的搜索引擎结果)。
根本问题是开始栏不是您的应用程序的一部分 - 它是 Shell 应用程序的一部分,并且您正在与它竞争所需的行为。您想要的是平台试图阻止您做的事情,因此您必须准备好将您的开发人员引导到平台的脖子上以使其正常运行。
此博客条目是解决此问题的一个非常好的起点,并且可能会给您带来帮助您需要什么,但请随意使用搜索引擎来查找更多/备用建议。实际上,网络上有很多这方面的材料 - 超出了这个答案的范围。
What you're after is usually referred to as "kiosk mode" (which may help your search engine results).
The underlying issue is that the start bar is not part of your app - it's part of the Shell app and you're competing with it for desired behavior. What you want is something the Platform is trying to prevent you from doing, so you have to be prepared to put your developer boot on the platform's neck to get it to behave.
This blog entry is a really good starting point for this issue and will probably give you what you need, but feel free to use a search engine to find more/aternate proposals. There's actually a lot of material on the web for this - more than would belong in this answer.