Announcement

Collapse
No announcement yet.

FindWindow and Null String

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    It's a little more complex than what Semen suggests, and it is really beyond the scope of this topic.

    However the CALL statement is irrelevent. PB does not do things differently whether the CALL statement is used or omitted - that would not make any sense.

    The important aspect is the parameter class the receiving function is expecting.

    If it is ASCIIZ, then PB passes a null-pointer (0) when passing "".

    If it expects a dynamic string, and you pass "", PB passes a pointer to a string handle.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Eric Pearson
    replied
    In this context, "" would mean "find a window with class aClass and a blank title" and BYVAL 0 would mean "find a window with class aClass and any title".

    There is a subtle but important difference between "nothing" and "null value". The one you use will depend on what you are trying to accomplish...

    -- Eric

    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    If you use "" in call statements, PB transfers exactly 0, not a pointer to an empty nul-terminated string.




    ------------------
    E-MAIL: [email protected]

    Leave a comment:


  • Lance Edmonds
    replied
    It's usual to pass BYVAL %NULL (the value zero, a null-pointer) rather than "" ( a pointer to an empty nul-terminated string) in that circumstance.

    With some API functions, passing a pointer has a different effect or result than passing a null-pointer.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Should have fiddled a bit more before posting.

    I knew the answer was simple but "" is a bit too simple.

    ------------------
    Patrick White

    Leave a comment:


  • Guest's Avatar
    Guest started a topic FindWindow and Null String

    FindWindow and Null String

    I'm trying to get the right call to get FindWindow to work with a null parameter as the Window Name.

    Dim hw&, aClass as ASCIIZ *256, aWindowName as ASCIIZ*256

    aClass = "SOME_CLASS_NAME"

    hw = FindWindow(aClass, aWindowName)

    I seem to be getting a zero window handle even though my class name is valid and an actively loaded app at the time. How do you pass a null string to the FindWindows API from PowerBasic?

    From MSDN:
    lpWindowName
    [in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.



    ------------------
    Patrick White
Working...
X