Results 1 to 4 of 4

Thread: Using API (SetFocus)

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 1999
    Posts
    34

    Post

    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

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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




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

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 1999
    Posts
    34

    Post

    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

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width