Announcement

Collapse
No announcement yet.

SendMessage vs. CALL of Window Procedure

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

  • SendMessage vs. CALL of Window Procedure

    I thought SendMessage, when used as a FUNCTION, returns the return value of the associated window procedure.

    But, when I did this...

    Code:
    FUNCTION TabMainDialogProc (BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                      BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
    
       SELECT CASE wMSg
    
        CASE %PWM_QUERY_MARKED           ' private message; wparam = claim_seq_no
                                         ' returns true or false, claim is marked
              ' need to search every item of the listview, query its lparam
              ' until I find the target sequence number
              ' get the item data from the listview, in which the lparam is its pClaim
              'MSGBOX "RECEIVED PWM_QUERY MARKED in TabMain"
              hWndLV = GetDlgItem (hWndTab(%SUB_TAB_CLAIMLIST),%ID_LISTVIEW_CLAIMS)
              lvi.iSubItem = 0
              lvi.mask = %LVIF_PARAM OR %LVIF_STATE
              lvi.Statemask = %LVIS_STATEIMAGEMASK    ' bits 12-15
              K = %FALSE
              FOR I = 0 TO @pOSVP.RFI.nClaim - 1
                  lvi.iitem = I
                  J = SendMessage (hWndLV, %LVM_GETITEM, 0&, BYVAL VARPTR (lvi))
                  pCLaim = lvi.lparam
                  IF @pclaim.claim_seq_no = wparam THEN   ' this is the one we want
                    ' working OK now      MSGBOX "Found requested claim, seq#=" & STR$(wParam)
                     'MSGBOX "lvi State of target=" & HEX$(lvi.state, 4) ' returns correwct
                     IF lvi.state = %LV_CHECKBOX_SELECTED THEN
                       ' MSGBOX "CHECKBOX SELECTED, SETTING FUNCTION = TRUE"
                        K = %TRUE
                     END IF
                     EXIT FOR
                     ' FUNCTION = ISTRUE (lvi.state AND %LV_CHECKBOX_SELECTED) = %LV_CHECKBOX_SELECTED
                   END IF
               NEXT I
              ' MSGBOX "Exiting funtion with K = " & STR$(K)
               FUNCTION = K
               EXIT FUNCTION
    And called it like this...
    Code:
             I = SendMessage (GetParent(GetParent(hwnd)), %PWM_QUERY_MARKED, Claim_seq_no, 0&)
             ' MSGBOX "PWM QUERY FUNCTION RETURNS:" & STR$(I)
    ... It always returned zero, even why my "debug" code told me the function was being set to %TRUE..

    So, I thought I'd just call the function this way:
    Code:
           I = TabMainDialogProc (GetParent(GetParent(hwnd)), %PWM_QUERY_MARKED, Claim_seq_no, 0&)
    This way returned the value assigned to the FUNCTION.

    Using SendMessage, I know the message was getting to the right place; but the return value was always zero.

    Using the explicit call works, so I am going to do that with a couple of other private messages I need to process.

    But I was wondering if I misunderstand how "sendmessage" works. MSDN enlightens (?) us with,
    "Return Values.
    The return value specifies the result of the message processing; it depends on the message sent. "
    Comments appreciated...

    MCM

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

  • #2
    Micheal;
    The name of your window procedure implies that it is for a dialog.
    If it is, then what you are trying to do will not work. That will
    only work for standard windows. To return a result from a dialog
    procedure do the following-

    SetWindowLong hWndDlg, %DWL_MSGRESULT, lResult
    FUNCTION = %TRUE

    ------------------
    Dominic Mitchell
    Dominic Mitchell
    Phoenix Visual Designer
    http://www.phnxthunder.com

    Comment


    • #3
      Thank you, that's exactly what I needed to know. (Works, too).

      Your tip led me to check MSDN under the generic "DialogProc" entry, and I noticed there a couple of other "Window" functions which behave differently when the windowproc is a dialog procedure. I guess now I know where to look next time I want to do something like this.

      MCM


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

      Comment

      Working...
      X