Support Forums

MouseMove

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.
User avatar
nirmalks
Posts: 30
Joined: Sun Aug 02, 2015 10:01 am

MouseMove

Postby nirmalks » Fri Feb 12, 2016 11:36 am

Hello,

Need a little help on this code:

IF ($_.Button -eq 'Left')
{

$CurTopNow = $panel259.Top
$CurLeftNow = $panel259.Left

$panel259.Top = [System.Windows.Forms.Cursor]::Position.X + $CurTopNow
$panel259.Left = [System.Windows.Forms.Cursor]::Position.Y + $CurLeftNow

}

I have a panel on a form that I'd like to move. So far I've tried above code, but can't determine as to what to add in MouseMove event so it moves smoothly.

Thanks heaps!
Nirmal
User avatar
DevinL
Site Admin
Posts: 738
Joined: Mon Aug 17, 2015 2:25 pm

Re: MouseMove

Postby DevinL » Fri Feb 12, 2016 11:39 am

[POST MOVED TO POWERSHELL GUI FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.
User avatar
jvierra
Posts: 10043
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MouseMove

Postby jvierra » Fri Feb 12, 2016 12:01 pm

Here is an example of how to use the event. You need to establish capture and dragging states.
http://www.codeproject.com/Articles/318 ... at-runtime
User avatar
jvierra
Posts: 10043
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MouseMove

Postby jvierra » Fri Feb 12, 2016 4:01 pm

Here is a PowerShell Studio demo of moving a control with the mouse;
Attachments
Demo-ControlMover.psf
(20.04 KiB) Downloaded 91 times
User avatar
jvierra
Posts: 10043
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MouseMove

Postby jvierra » Fri Feb 12, 2016 4:16 pm

Demo of movable controls a circular button.
Attachments
Demo-ControlTricks.psf
(20.73 KiB) Downloaded 85 times

Return to “PowerShell GUIs”

Who is online

Users browsing this forum: No registered users and 6 guests