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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
nirmalks
Posts: 30
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Sun Aug 02, 2015 10:01 am

MouseMove

Post by nirmalks »

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

DevinL
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: MouseMove

Post by DevinL »

[POST MOVED TO POWERSHELL GUI FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.

jvierra
Posts: 14355
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MouseMove

Post by jvierra »

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

jvierra
Posts: 14355
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MouseMove

Post by jvierra »

Here is a PowerShell Studio demo of moving a control with the mouse;
Attachments
Demo-ControlMover.psf
(20.04 KiB) Downloaded 145 times

jvierra
Posts: 14355
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: MouseMove

Post by jvierra »

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

Locked