|
-
Mar 4th, 2001, 02:16 PM
#1
Thread Starter
Junior Member
Hello to all of you,
I want to know whether i can restict the mouse movement in an particular are or not if yes how.
Also how can i get which key has been pressed in any window ,even if i get any key has been pressed (not which )will also be sufficient.Thanks for reading & repling
my question.
-
Mar 4th, 2001, 04:53 PM
#2
Lively Member
Well, I can't think of anything for the Mouse question, but for the Keyboard just use the KeyPress event and put it into all the forms your program uses.
-AndySoft
[email protected]
[email protected] (Use the other one first!)
I use: NASM, HTML, Perl, PHP, JavaScript, Batch, TI-Basic (TI-83+), QBasic 1.1, QuickBASIC 4.5, QuickBASIC Extended 7.1, VB-WIN 6 Ent., and the rest of Visual Studio 6 Ent.  And who knows what else!
-
Mar 4th, 2001, 07:07 PM
#3
To restrict the mouse to a specific area, use the ClipCursor function.
Code:
Private Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Sub RestrictMouse()
Dim RC As RECT
GetWindowRect hwnd, RC
ClipCursor RC
End Sub
Sub UnRestrictMouse()
Dim RC As RECT
GetWindowRect GetDesktopWindow, RC
ClipCursor RC
End Sub
Private Sub Command1_Click()
RestrictMouse
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnRestrictMouse
End Sub
-
Mar 6th, 2001, 05:06 AM
#4
Thread Starter
Junior Member
Thank you Megatron for your code but their is some more problem,that code works fine when the program is runned through vb itself but it fails by giving the message that "The program has done some illegal operation",when an exe is made of the program, so please tell me where is the fault in my code or in my windows.
-
Mar 6th, 2001, 05:17 AM
#5
Thread Starter
Junior Member
Thank you for replying andysoft but my problem was something else i.e. i wanted to check key press event for all the other softwares which are working at this time which may be any one of notepad wordpad etc.so please reply for it.
-
Mar 6th, 2001, 03:34 PM
#6
I'm not sure why you'd be getting an illegal operation. Do you have any other code in your Form? It's possible that it might be that code that is causing the conflicts.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|