Windows Mobile 使用面板自动调整大小

发布于 2024-11-19 13:05:38 字数 635 浏览 1 评论 0原文

我有一个应用程序可以在两个不同的设备上运行 - 一个屏幕尺寸为 240x320,另一个屏幕尺寸为 480x640。

对于除其中一种以外的所有表单,VS 生成的代码都很好:

this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;

对于一种表单,我正在捕获签名。我通过带有图形处理程序的面板来完成此操作;捕获鼠标按下和移动事件;这会生成一个向量点列表,我可以用它来画线。

在较小分辨率的屏幕上,这很好。在高分辨率下,我无法显示我的线条..我认为这是因为面板超出了窗口窗体大小。

创建的表单尺寸为 240 x 268;我认为是标准尺寸 - 我没有手动设置它,VS 为我做了这个。

为了使面板位于高分辨率设备上的正确位置,坐标为 3, 290;即,290 超过 268。面板的宽度也是 448,比 240 稍大。

我正在使用 .net 2.0(以后不能使用)。我认为我需要调整表单大小以使其更大,但我确实想保留表单上其他控件的现有调整大小。

我不知道该怎么做。

I've got an app which will run on two different devices - one with a screen size of 240x320, the other 480x640.

For all forms bar one the VS generated code is fine:

this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;

For one form i'm capturing a signature. I'm doing this by a panel with a graphics handler; capturing mouse down and move events; this generates a list of vector points which I can draw lines with.

On the smaller res screen this is fine. On the higher res, I can't display my lines.. and I think this is because the panel is beyond the windows form size.

The form is created with a size of 240 x 268; a standard size I think - i've not manually set it, VS does this for me.

In order to get the panel in the right spot on the high res device, the co-ordinates are 3, 290; ie, 290 is past 268. Also the width of the panel is 448 which is somewhat larger than 240.

I'm using .net 2.0 (can't use later). I think I need to resize the form to make it larger but I do want to keep the existing re-sizing for the other controls on the form.

I'm not sure how to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别靠近我心 2024-11-26 13:05:38

让表单停靠填充,然后使用 Anchor 属性确保表单内的控件按预期调整大小。

如果您想要自定义单个控件调整大小的方式,请不要在其上设置锚点属性,而是处理 Resize 事件并在代码中执行自定义调整大小/重新定位。

例如

private void form_Resize(object sender, EventArgs e)
{
    // Center the control without changing width. Other controls are anchored.
    this.control.Left = (this.Width - this.control.Width) / 2;
}

Make the form dock to fill, then use the Anchor properties to ensure controls inside the form resize as expected.

If you want the option of customizing how an individual control resizes, then DONT set the anchor properties on it, and instead handle the Resize event and perform custom resizing/repositioning within code there.

eg

private void form_Resize(object sender, EventArgs e)
{
    // Center the control without changing width. Other controls are anchored.
    this.control.Left = (this.Width - this.control.Width) / 2;
}
兲鉂ぱ嘚淚 2024-11-26 13:05:38

我写这个答案是为了那些将来可能遇到类似问题的人。 PaulG 为我指明了正确的方向,但我发现根本原因是其他的。

我的 PDA 项目使用“FormFactor WindowsMo​​bile 6 Classic”,其默认尺寸为 240 x 268。

将其更改为“Windows Mobile 6 Professional VGA”会创建更大的表单尺寸。

这使我能够正确定位较大尺寸的物品;然后将 AutoScaleMode 更改为 DPI;并手动调整面板大小使其变小,一切正常。

IE,从大变小很容易;我的工作并没有从小到大。

I'm writing this answer for the benefit of those who may have a similar problem in the future. PaulG pointed me in the right direction but I found the root cause to be something else.

The PDA project i've got uses "FormFactor WindowsMobile 6 Classic" which has a default size of 240 x 268.

Changing this to "Windows Mobile 6 Professional VGA" created a much larger form size.

This allowed me to get things positioned correctly for the larger size; then AutoScaleMode to DPI; and manually resizing the panel smaller made it all work.

IE, going from larger to smaller was easy; I didn't get smaller to larger working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文