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.
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
nirmalks
Posts: 38
Last visit: Tue Mar 26, 2024 5:02 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
Posts: 1098
Last visit: Tue Jun 06, 2017 9:15 am

Re: MouseMove

Post by DevinL »

[POST MOVED TO POWERSHELL GUI FORUM BY MODERATOR]
DevinL
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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 221 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: MouseMove

Post by jvierra »

Demo of movable controls a circular button.
Attachments
Demo-ControlTricks.psf
(20.73 KiB) Downloaded 206 times
This topic is 8 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked