Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > set mouse cursor position quick question


Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2003, 10:36 PM
Sphinx Sphinx is offline
Newcomer
 
Join Date: Jul 2003
Posts: 20
Default set mouse cursor position quick question


ok, i know how to set the mouse cursor , but only ON AN OBJECT. I know how to set the position relative t per se , a form. BUT, how can I set it relative to the screen. If I am getting the cursor position from a screen, I want to be able to set that same position relative to the entire screen, not an object like a form, unless i maximized it or something? but i dont really want to do that.

PLEASE, HELP, appreciate it thanx!
Reply With Quote
  #2  
Old 08-16-2003, 10:43 PM
Deadalus Deadalus is offline
Promising Talent

Retired Moderator
* Guru *
 
Join Date: May 2002
Location: Brussels
Posts: 3,601
Default

How are you getting and setting it then? With GetCursorPos and SetCursorPos you always use screen coordinates.
Reply With Quote
  #3  
Old 08-16-2003, 10:48 PM
Sphinx Sphinx is offline
Newcomer
 
Join Date: Jul 2003
Posts: 20
Default

this is how i set the cursor position....
look where it says "window as object' under the public function setcursorpostion. I have to set that to a form! I dont want that, I want it to set the position no matter if there is a form or not.


declarations...
Option Explicit

Private Type POINTAPI
x As Long
y As Long
End Type

Private Declare Function ClientToScreen Lib "user32" _
(ByVal hwnd As Long, lpPoint As POINTAPI) As Long

Private Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long


code...

Public Function SetCursorPosition(Window As Object, xPos As _
Long, yPos As Long) As Boolean

'AUTHOR: FreeVBCode.com (http://www.freevbcode.com)

'Usage: Window = window for which you want
'to set the cursof for (form or control)

'window must support hwnd property; function will
'return false if it doesn't (e.g., won't work
'with labels)

'x = xPosition in twips
'y = yPosition in twips

'if you are not using twips as your scale mode
'you must convert the value to pixels from your
'metric. There is a function on FreeVBCode.com
'that does this, under the System/API
'category

On Error GoTo errorhandler

Dim x As Long, y As Long
Dim lRet As Long
Dim lHandle As Long
Dim typPoint As POINTAPI

lHandle = Window.hwnd
With Screen
x = CLng(xPos / .TwipsPerPixelX)
y = CLng(yPos / .TwipsPerPixelY)
End With

typPoint.x = x
typPoint.y = y

lRet = ClientToScreen(lHandle, typPoint)
lRet = SetCursorPos(typPoint.x, typPoint.y)


SetCursorPosition = (lRet <> 0)

Exit Function

errorhandler:

SetCursorPosition = False
Exit Function


End Function
Reply With Quote
  #4  
Old 08-16-2003, 11:45 PM
Deadalus Deadalus is offline
Promising Talent

Retired Moderator
* Guru *
 
Join Date: May 2002
Location: Brussels
Posts: 3,601
Default

What you don't want is exactly what that function is meant for. So don't use it and look at the SetCursorPos and GetCursorPos on www.allapi.net or search for them here and try to understand how they work.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Question Becca General 5 06-19-2003 12:47 AM
Quick newbie question Xee Word, PowerPoint, Outlook, and Other Office Products 1 04-06-2003 07:08 PM
quick network installation question MKoslof Installation / Documentation 8 01-17-2003 10:22 AM
mouse down / mouse up xmen64 Interface and Graphics 5 10-09-2002 10:36 AM
Quick Question Lancer010 General 4 08-25-2002 02:37 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->