PDA

Click to See Complete Forum and Search --> : Using API (SetFocus)


bucko
Jan 23rd, 2000, 04:00 PM
Hi, I'm having problems trying to use the SetFocus API function.
What i'm trying to do is set the focus to another application (AutoCAD).
I can get the handle of the AutoCAD window
but when I try to set the focus to this window I keep getting the error message
"Type declaration character does not match declared data type"

where do you think i'm going wrong.

any help or sample code would be of great help

thanks in advance
MICK

Serge
Jan 23rd, 2000, 09:26 PM
Can yo post the code snippet, so we can see what might be wrong with it. Sounds like you're trying to pass parameter for your API with the wrong datatype value.


------------------

Serge

Programmer Analyst
sdymkov@microage.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)




[This message has been edited by Serge (edited 01-24-2000).]

bucko
Jan 23rd, 2000, 09:38 PM
Hi serge, hope this helps

This part of the code is in a module

Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Integer
Global hWnd_Acad As Long


This part of the code is in a function called call_plot

Dim ret As Long
hWnd_Acad = LoadTaskList() 'This returns the correct value
ret = SetFocus%(hWnd_Acad)

thanks
MICK

Clunietp
Jan 23rd, 2000, 10:46 PM
You are returning an INTEGER, when you should be returning a LONG. Here is the API as shown by the API text viewer:

Public Declare Function SetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long

You should change it to something like this:
Public Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long

And call it by SETFOCUSAPI so VB won't confuse it with the intrinsic function SetFocus.

Tom