Announcement

Collapse
No announcement yet.

Using MessageBox API

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

  • Using MessageBox API

    Code:
    ' MessageBox app
    #INCLUDE "WIN32API.INC" 'include Windows API calls
    FUNCTION PBMAIN
    DIM retval AS LONG, hWnd AS LONG
    hWnd = GetDesktopWindow()
    retval = MessageBox hWnd, "Sprinkles on that?", _
    "The Sundae Shoppe", %MB_YESNOCANCEL+%MB_ICONQUESTION
    PRINT retval
    WAITKEY$
    END FUNCTION
    As is, this gives me a 480 error "parameter mismatches definition." If I remove the retval = part, it works fine, but I don't get the return value.

    I'm sure it's something simple, but I'm new to Windows programming.
    The boy just ain't right.

  • #2
    >retval = MessageBox hWnd, "Sprinkles on that?", _
    > "The Sundae Shoppe", %MB_YESNOCANCEL+%MB_ICONQUESTION

    That's a syntax error. When using a procedure as a function (returning a value), any procedure parameters must be enclosed by parentheses. (In 6x and 8x. In 7x there was a bug in the compiler which allowed you to get away with no parens).

    Crap error message, but that IS your problem (assuming you are using 6x or 8x, version not shown).

    BTW you should combine styles with the OR operator, not the '+' (addition) operator. You will 'get away with this' some of the time, but that will be plain old dumb luck.



    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      That did it. Thanks.

      I fool so feelish... When I teach Java at work, I always point out "somename(" tells you right away it's a function/method. Now I just need to remember that for PB too. (Using PBCC 4.04)
      The boy just ain't right.

      Comment

      Working...
      X