windows mobile 2003 SE and net cf v2
I moved from using visual studio 2003 to develope an application for a windows mobile 2003 SE PDA to vs2005. After some problems this now works.
However when I upgrade to using .net cf v2 and download to the PDA the forms in the application become compressed to appox. a quarter of their origial size. The menus are still in the correct place its just the size oif the forms.
Has anyone else had this problem, does anybody know of a solution?
I already haveNETCFv2 SP1 installed.
Thanks
Rob
Please set form's AutoScaleMode to Dpi in form's properties or in code:
Me.AutoScaleMode = Windows.Forms.AutoScaleMode.Dpi
Ilya,
Just got round to trying this, unfortunately it makes no difference. Is there anything else it could be?
Thanks
In addition to setting the form's AutoScaleMode property to DPI, You will also need to set it's AutoScaleDimensions property to a new SizeF(96.0, 96.0) (or whatever the equivalent is in VB).
Hi,
Thanks for your reply.
I found that suggestion elsewhere and tried it with limited success.
Adding the two statements initially did nt work, but then changing something on the form appeared to correct the problem on a very simple application I was using. However when I did the same on the actual application I'm trying to update I encountered problems.
If a form contains a picturebox adding the 2 statements alone makes no difference. Changing anything on the form generates an error msg "object reference not set to an instance of the object", saving the form causes the images in the picturebox to be lost and the picture boxes to be moved to the top left of the form and the same error msg to be displayed. Despite this, build returns no errors.
If nothing is changed in 'design view' then the object reference error does not occur. But there's the size problem.
I tried creating a new project and adding the forms to it but got the same problem.
I when back and tried the Visual Studio 2005 .net 1 version of the project, just changing something on a form with a picturebox and again got the object reference error.
Initially the project had been imported from vs2003 with .net 1 where it had no such problems.
I'd greatly appreciate any assistance as this has been going on for the past couple of months.
Thanks
It sounds like you are having design-time problems. I am moving this thread to the appropriate forum.
Tim,
Did you move the thread, if so where to?
Thanks
I'm not quite sure what you're asking. Your thread is right here, you can post to it, right?
As to initial issue, please make sure you've added code above for all forms in correct places. If you not sure how it should be used, create fresh NETCF V2 project and examine form's code.
Thanks for replying.
The post from Tim indicated the thread would be moved but I was n't sure what he meant and the thread appeared to remain in the smart devices C# and vb forum hence the question.
As to the initial problem.
On doing the conversion and upgrading the project to .net cf 2 when the application ran on a pda the forms were compressed to approx 1/4 of the size the should be. Your suggestion of setting the form's AutoScaleMode property to DPI and AutoScaleDimensions sizef to 96 had limited sucess.
ie
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
in InitializeComponent()
Initailly it did nothing but when I changed someother command on the form and redeployed the application to the pda that form would display correctly.
However if the form included a picture box any change to the form in design view would cause the error message "object reference not set to an instance of the object" " to be displayed. The contents of the picture box would be lost and the picture boxes size and lication would change, reduced in size and moved to the top left of the screen, this occurred in design view.
I have created a new project and tried to import existing forms but encounter the same problem.
Comparing the code in the imported form and a newly created form its the same other than InitializeComponent() is seperate in a .designer.cs file for the new form.
When the error message "object reference not set to an instance of the object" is displayed the code is changed, picture boxes remain part of the form
this.Controls.Add(this.pictureBox1);
but they have no properties ie the following disappear
this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
this.pictureBox4.Location = new System.Drawing.Point(21, 26);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(198, 148);
this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
So I'm stuck.
I really do n't want to have to go through each form and add the picture boxes as theres a lot of them.
Any suggestions?
Thanks