dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Problems with FindWindow

  1. #1
    Guest

    Problems with FindWindow

    [moved from vb.general]

    As for the FindWindow I get an error:

    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
    lpClassName As String, ByVal lpWindowName As String) As Long

    Error: Constants, fixed-length strings, arrays, user-defined types and
    Declare
    statements not allowed as Public members of object modules

    "Phil Weber" <pweber@teleport.com> wrote:
    > > Invalid outside procedure

    >
    >Homer: OK, the problem is that your code is not in a procedure (Sub or
    >Function). Try putting it inside Sub Main:
    >
    > Sub Main
    >
    > Dim hWnd As Long
    >
    > hWnd = FindWindow(vbNullString, "Brood War")
    >
    > End Sub
    >
    >You will also, of course, have to declare the FindWindow function at the
    >top of the module.
    >---
    >Phil Weber
    >
    >P.S. -- If you're new to VB programming, the vb.getting.started newsgroup
    >is the best place to post your questions. Thanks!
    >




  2. #2
    val Guest

    Re: Problems with FindWindow


    where do you have declaration of that api call ?

  3. #3
    123 123 Guest

    Re: Problems with FindWindow


    "val" <pushinks@aol.com> wrote:
    >
    >where do you have declaration of that api call ?


    General declarations
    with the other declares


  4. #4
    Phil Weber Guest

    Re: Problems with FindWindow

    > Error: Constants, fixed-length strings, arrays, user-defined
    > types and Declare statements not allowed as Public members
    > of object modules.


    123: Your code should be in a code module, not a form.
    ---
    Phil Weber



  5. #5
    Rick Rothstein Guest

    Re: Problems with FindWindow

    He should be able to Declare it at the Form level if he uses the Private
    keyword.

    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" _
    (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long


    Rick


    "Phil Weber" <pweber@teleport.com> wrote in message
    news:38ee4b70$1@news.devx.com...
    > > Error: Constants, fixed-length strings, arrays, user-defined
    > > types and Declare statements not allowed as Public members
    > > of object modules.

    >
    > 123: Your code should be in a code module, not a form.
    > ---
    > Phil Weber
    >
    >




  6. #6
    Rick Rothstein Guest

    Re: Problems with FindWindow

    Try putting the keyword Private in front of your declaration or declare it
    in as Public in a Module (Project/AddModule from VB's menu) if it needs a
    wider scope.

    Rick

    <123 123> wrote in message news:38ee40a9$1@news.devx.com...
    >
    > "val" <pushinks@aol.com> wrote:
    > >
    > >where do you have declaration of that api call ?

    >
    > General declarations
    > with the other declares
    >




  7. #7
    Phil Weber Guest

    Re: Problems with FindWindow

    > He should be able to Declare it at the Form level if
    > he uses the Private keyword.


    Rick: True, but I recommended in a previous message that he put his code in
    a Sub Main (he did not have in any procedure). This person is obviously very
    new to VB (which is why I moved the thread here), and I'm trying to give him
    extremely straightforward advice to get his code running with as little
    difficulty as possible.
    ---
    Phil Weber



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center