March 29, 2024, 07:10:12 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Move a control

Started by Andy, May 09, 2021, 12:29:28 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Andy

May 09, 2021, 12:29:28 AM Last Edit: May 09, 2021, 04:45:14 AM by Andy
Hi,

I was determined to post some code that would enable us all to move a control easily without us having to do calculations.

It came about when LarryMc mentioned that he might find it hard to drag a control to a specific location and that arrow keys would help.

So here are the functions and in this example I am detecting the keyboard arrow keys being pressed e.g. up / down etc and moving a control a specific amount in this case 20.

The functions are:

MoveControlUp
MoveControlDown
MoveControlLeft
MoveControlRight


Parameters (three):

Window, ControlId, Amount of movement.

This works for a window with / without the @SIZE style.

The code is designed so that the control does not disappear from the window.

You could of course move the local variables / constants and make them global ones etc, but this way the code is portable and you should be able to use it in any of your programs.

I'm sure this will come in handy from time to time so I would suggest you grab yourself a copy!

Useful?


Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.