Windows Mobile 使用面板自动调整大小
我有一个应用程序可以在两个不同的设备上运行 - 一个屏幕尺寸为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让表单停靠填充,然后使用
Anchor
属性确保表单内的控件按预期调整大小。如果您想要自定义单个控件调整大小的方式,请不要在其上设置锚点属性,而是处理
Resize
事件并在代码中执行自定义调整大小/重新定位。例如
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
我写这个答案是为了那些将来可能遇到类似问题的人。 PaulG 为我指明了正确的方向,但我发现根本原因是其他的。
我的 PDA 项目使用“FormFactor WindowsMobile 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.