none
Converting Visual FoxPro forms to C#.Net Forms

    Pertanyaan

  • I am creating hundreds of C#.NET forms by reading the VFP source and writing the C#.net by hand currently

    The VFP form properties height, width, top, and bottom of all objects are identical to the C#.Net form properties. The font is identical (exception "MS Sans Serif" is changed to "Microsoft Sans Serif" and the font size is the same.

    The spacing and size of the objects are different. Enough to make a mess when the objects(labels, textboxes) are close together on the VFP side.

    I noticed that these lines in the C#.Net Designer help space things around a bit

    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

    Any suggestions on how to make the new .Net form as identical as possible?

    Kamis, 24 Mei 2018 18.08

Semua Balasan

  • Hi,

    >>The spacing and size of the objects are different. Enough to make a mess when the objects(labels, textboxes) are close together on the VFP side.

    What is your real problem about this?

    You can manually adjust the position and size of the controls with mouse, also you can do it with code:

        textBox1.Location = new Point(int, int);
        textBox1.Size = new Size(int, int);
    If you do not want to change them one by one, maybe try to set the AutoScaleMode property of your form to Dpi instead of Font:


    Then change some code in the Program.cs:

    class Program
    {
        [STAThread]
        static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
                SetProcessDPIAware();
    
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        private static extern bool SetProcessDPIAware();
    }
    Best Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Jumat, 25 Mei 2018 02.48
  • @Frankie, why did you move this post to Off-Topic Posts? I believe that it had initially been moved, correctly, to the WinForms forum. The question is *not* about VFP, it's about how to make a Window Form look as close as possible to a VFP form. But it *is* about Windows Forms!!!

    Your reply looked pretty good and I wonder if the OP, @Auios, has tried it?

    At any rate, if you thought it belonged somewhere other than the Windows Forms forum, it should at least been the VFP forum. Which can be found here: https://social.msdn.microsoft.com/Forums/en-US/home?forum=visualfoxprogeneral 

    But, I think that someone should move it back to the Windows Forms forum!

    Just my 2 cents ...


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Selasa, 29 Mei 2018 13.43