|
-
Feb 1st, 2002, 05:45 AM
#1
Thread Starter
New Member
-
Feb 1st, 2002, 08:39 AM
#2
ummmm....I don't know the answer to your question, but could
you post the code you use to trap the keystroke from any
focused window? This is a part of a project that I was just
beginning to approach.
I think I might have found it:
Code:
Declare Function GetActiveWindow Lib "user32.dll" () As Long
Platforms: Win 32s, Win 95/98, Win NT
"GetActiveWindow returns a handle to your program's currently
active window. This only works with windows created by your
application -- in other words, it won't find the active window of
other programs. If your program is in the background, the
function will get the window that would be active if the program
were active. If an error occurs, or if there is no active window to
your program, the function instead returns 0. "
http://www.vbapi.com/ref/g/getactivewindow.html
Thanks.
-
Feb 1st, 2002, 09:22 AM
#3
Thread Starter
New Member
Ok, Don't think that API will help since it will return a handle to one of my forms, even though my app is not active....
thx, here is the code you asked for....
Module :
Declare Function GetAsyncKeyState Lib _
"user32" (ByVal vKey As Long) As Integer
Public Function Showhelp(hdInForHandle As Long)
Dim X As Long, SW_SHOW As Long
Dim sOp As String, sFile As String, sParam As String, sDir As String
SW_SHOW = 5
sOp = "open"
sFile = C_AppPath & "Myhelp.pdf"
sDir = Left$(C_AppPath, Len(C_AppPath) - 1)
sParam = ""
X = ShellExecute(ByVal hdInForHandle, ByVal sOp, ByVal sFile, ByVal sParam, ByVal sDir, ByVal SW_SHOW)
Select Case X
Case 0: MsgBox "Insufficient system memory or corrupt program file."
Case 2: MsgBox "File not found."
Case 3: MsgBox "Invalid path."
Case 5: MsgBox "Sharing or protection error."
Case 6: MsgBox "Separate data segments are required for each task."
Case 8: MsgBox "Insufficient memory to run the program."
Case 10: MsgBox "Incorrect Windows version."
Case 11: MsgBox "Invalid program file."
Case 12: MsgBox "Program file requires a different operating system."
Case 13: MsgBox "Program requires MS-DOS 4.0"
Case Is < 33: MsgBox "Could not start Acrobat."
End Select
End Function
Form :
Sub Timer1.timer()
Dim keystate As Long ' receives key state
keystate = GetAsyncKeyState(112) ' read the F1 key's status
If keystate = 1 Then Showhelp (Me.hwnd)
end sub
-
Feb 1st, 2002, 09:36 AM
#4
You're right, it doesn't. On first reading, I thought that it would
return a 0 if you are not the active window, but instead it returns
what the active window would be IF it were active.
Try this one:
Code:
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Platforms: Win 95/98, Win NT
"GetForegroundWindow finds which window is currently the
foreground window. The foreground window is the window,
usually at the top of the Z-order, with which the user is currently
working with -- i.e., the window with the focus. The function
returns 0 if an error occured, or the handle of the foreground
window if successful. "
BTW, thanks for the code, JUST what I needed!!!
Good Luck
-
Feb 4th, 2002, 10:10 AM
#5
Thread Starter
New Member
bugger.... :(
anyone else can help me with this ??? please.....
-
Feb 5th, 2002, 02:48 AM
#6
Thread Starter
New Member
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
|