Announcement

Collapse
No announcement yet.

Is message forwarding good enough ?

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

  • Is message forwarding good enough ?

    Hi there,

    just had a look on some C code generated by winCFront from CPP
    sources. Most interesting is the implementation of message mapping.

    I guess with a procedural lang. like PB most users will reflect msgs
    by forwarding them to the windows it belongs.

    iE. %WM_CTLCOLOREDIT handeld by MainWndProc like this :
    Code:
    CALLBACK FUNCTION MainWndProc
          SELECT CASE CBMSG
             CASE %WM_COMMAND
             CASE %WM_CTLCOLOREDIT  : FUNCTION = sendmessage ( CBLPARAM, %WM_CTLCOLOR_REFLECT, CBWPARAM, 0 )
          END SELECT
    END FUNCTION
    refelected by control's wndProc
    Code:
    FUNCTION SuperEditProc( BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG ) AS LONG
          SELECT CASE wMsg
             CASE %WM_CREATE  : edit_create  hWnd, OffsetWndExtra
             CASE %WM_DESTROY : edit_destroy hWnd, OffsetWndExtra
             CASE %WM_CTLCOLOR_REFLECT
                  SetBkColor   WPARAM, GetSysColor( %COLOR_HIGHLIGHT )
                  SetTextColor WPARAM, %CYAN
                  FUNCTION = gETsTOCKoBJECT(%GRAY_BRUSH)
                  EXIT FUNCTION
          END SELECT
          FUNCTION = CallWindowProc(BaseWndProc, hWnd, wMsg, WPARAM, LPARAM)
    END FUNCTION
    The c code doesn't use sendmessage. It call's SuperEditProc direct,
    after retrieiving the wndProc CodePtr via GetWindowLong.

    Do you see any benefits calling the child wndProc directly ?

    Ralph


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

  • #2
    From one side, C-code is more clever - one API call less.
    But when I see that typically my CPU is busy 2-3%, I don't think that it's very actual.
    Anyway, typically, processing each message includes some API calls -
    GetMessage - Is DialogMessage - TranslateMessage - DispatchMessage - DefWindowProc and so on.



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

    Comment


    • #3
      Semen;

      i think you're right. Looking a the c code preparsed from C++ is
      like a view under the hood. Ensures me that procedural compilers
      like PB will be alive for a long time.

      Ralph

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

      Comment

      Working...
      X