Solved

VB code translated to C#.

Posted on 2011-09-20
3
198 Views
Last Modified: 2013-12-17
Hi,

I have found code to resize a borderless form.
But the code is in VB! So I use this site:
http://www.developerfusion.com/tools/convert/vb-to-csharp
to convert the code to C#.

After testing it there is one little problem ( i hope i explain this right):

After I have resized the form and let go of the mouse-button
the edge of the form is still attached to the mouse-cursor. So
even do I let go of the mouse-button I still can resize the form.
I have to click it twice before it actually let go.

I have tested the VB-version and that works great.

Does someone knows the anser and is willing to help me?

Greetings,

Peter Kiers
VisualBasic.txt
CSharp.txt
0
Comment
Question by:peterkiers
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
x77 earned 500 total points
ID: 36569512
Vb uses WithEvent Clause when Declare Buttons and Panel.
This Generates some internal properties to set EventHandlers.

You need add Handlers to Buttons and Panel as converter do´nt make it.

You omit also methods from buttons
public StickyNotes()
        {
            InitializeComponent();
            MouseMove += StickyNotes_MouseMove;
            MouseDown += StickyNotes_MouseDown;

            this.btnClose.Click += btnClose_Click;
            this.btnMaximize.Click += btnMaximize_Click;
            this.btnMinimize.Click += this.btnMinimize_Click;
            this.pnlCaption.MouseMove += pnlCaption_MouseMove;
            this.pnlCaption.MouseDown += pnlCaption_MouseDown;
        
        }
        private void pnlCaption_MouseDown(object sender, MouseEventArgs e)
        {
            if ((e.Button == MouseButtons.Left) & (this.WindowState != FormWindowState.Maximized))
            {
                this.MoveForm();
            }
        }
        private void pnlCaption_MouseMove(object sender, MouseEventArgs e)
        {
            this.resizeDir = ResizeDirection.None;
        }
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void btnMinimize_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }
        private void btnMaximize_Click(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Maximized)
            {
                this.WindowState = FormWindowState.Normal;
                this.btnMaximize.Text = "Maximize";
            }
            else
            {
                this.WindowState = FormWindowState.Maximized;
                this.btnMaximize.Text = "Restore";
            }
        }

Open in new window

0
 
LVL 1

Author Comment

by:peterkiers
ID: 36571632
Thanks for the answer I will look at it tonignt.

Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36572055
Hi,

After implementing your code and testing it
I still have the problem.

Your solution did not help?

Peter Kiers
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question