Announcement

Collapse
No announcement yet.

Use of "Function" In Skeleton Program

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

  • Use of "Function" In Skeleton Program

    Can someone explain the purpose 'Function = 0' in the following code?

    Code:
    'From C:\Program Files\PBDLL60\Samples\Skeleton
        CASE %WM_MENUSELECT
          LoadString hInst, wParam, zText, SIZEOF(zText)
          SendMessage hStatus, %WM_SETTEXT, 0, VARPTR(zText)
          FUNCTION = 0
          EXIT FUNCTION
    
        CASE %WM_MOUSEMOVE
          zText = "Mouse Position:" + STR$(LOWRD(lParam)) + ","+STR$(HIWRD(lParam))
          SendMessage hStatus, %WM_SETTEXT, 0, VARPTR(zText)
          FUNCTION = 0
          EXIT FUNCTION
    'Function' is not declared as a variable and so I'm guessing that it
    is something inherent to either Windows, PBDll, or perhaps even both.

    Thanks For Your Help

    Wesley

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


    [This message has been edited by Wesley Brown (edited March 19, 2001).]

  • #2
    Hi

    in PBCC/PBDLL you can return the result from a function using
    one the following syntax:

    Code:
    FUNCTION ReturnValue (BYVAL AValue AS LONG) AS LONG
    
        ReturnValue = AValue
    
    END FUNCTION
    Or (I prefer this one since I find it more readable):
    Code:
    FUNCTION ReturnValue (BYVAL AValue AS LONG) AS LONG
    
        FUNCTION = AValue
    
    END FUNCTION
    Cheers

    Florent


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

    Comment


    • #3
      It is for preventing the DefWindowProc call at the end of the function
      to process these particular messages. In Winapi32.hlp, each message is
      described with a clause about return value, where it often says,
      "If an application processes this message, it should return zero".

      However, what MS means by "process this message" isn't always clear.
      If you only have code that picks up a value, you don't really process
      anything, so in some cases, one actually shall let them pass and let
      DefWindowProc send them on to the default window procedure.

      One case where this can become obvious is WM_SIZE in MDI applications,
      where child windows must let them pass, but Main WinProc must return
      zero, to avoid strange multiple system menus for each child, etc.


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


      [This message has been edited by Borje Hagsten (edited March 19, 2001).]

      Comment

      Working...
      X