snap (move) Cursor to Control

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

snap (move) Cursor to Control

Post by AUGE_OHR »

hi,

do you like Mouse Option "snap-to-button" :?:
it does move Cursor to Yes / No Button when appear

this Function do move Cursor and Focus to your Control

Code: Select all

   Snap2Ctrl("Form_1", "oScroll")
SNAP2CTL.ZIP
(806 Bytes) Downloaded 89 times
have fun
! Note : it does NOT move to "highlight" Option. it does move to "center" of Control
have fun
Jimmy
User avatar
salamandra
Posts: 311
Joined: Thu Jul 31, 2008 8:33 pm
DBs Used: DBF, MySQL, SQL
Location: Brazil

Re: snap (move) Cursor to Control

Post by salamandra »

Hi Jimmy,

Thank you Very much for share with us!

Salamandra, Brazil
There is one time in which is crucial awakening. That time is now. ( Buddha )
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: snap (move) Cursor to Control

Post by edk »

I did the same in a different way 8-) :

Code: Select all

PROCEDURE SnapToCtrl ( cForm, cControl )
Local hWnd, nRowCtrl, nColCtrl, nHeightCtrl, nWidthCtrl, nColPointer, nRowPointer 

IF !(IsWindowActive ( &cForm )) .OR. !(IsControlDefined ( &cControl , &cForm ))
	RETURN
ENDIF

hWnd        := GetProperty ( cForm, 'Handle' )

nRowCtrl    := GetProperty ( cForm , cControl, 'Row' )
nColCtrl    := GetProperty ( cForm , cControl, 'Col' )
nHeightCtrl := GetProperty ( cForm , cControl, 'Height' )
nWidthCtrl  := GetProperty ( cForm , cControl, 'Width' )
 
//Center of control
nRowPointer := nRowCtrl + ( nHeightCtrl / 2)
nColPointer := nColCtrl + ( nWidthCtrl / 2)

HMG_SetCursorPos ( hWnd,  nRowPointer,  nColPointer )
DoMethod( cForm, cControl, "Setfocus" )
RETURN

It seems to me that your solution does not work properly in all cases. Try to change the size of the form (height) with the mouse, then call from menu "Test" item "Snap 2 Button" and you will see that the mouse pointer does not always move to the right position:
BUTTON_3.7z
(3.22 KiB) Downloaded 94 times
User avatar
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: snap (move) Cursor to Control

Post by AUGE_OHR »

hi,

i did not know HMG_SetCursorPos()

thx for Advice
have fun
Jimmy
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: snap (move) Cursor to Control

Post by Claudio Ricardo »

i did not know HMG_SetCursorPos()
I did not know that function either (and many others)
Is there any updated documentation that includes the new functions?
I use the one in the IDE help but it is incomplete as of today.

Thanks in advance.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
edk
Posts: 911
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: snap (move) Cursor to Control

Post by edk »

This function is documented in the HMG references available in the IDE.
reference.png
reference.png (147.12 KiB) Viewed 1053 times
Post Reply