Announcement

Collapse
No announcement yet.

Wm_measureitem

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

  • Wm_measureitem

    Working on a superclassed Listbox control.

    I tried to trap this message in the parent window and send a user message on to the child control so that it could provide the MEASUREITEMSTRUCT.ItemHeight value:
    Code:
            CASE %WM_MEASUREITEM
                ' pass the message on to the superclassed LB control
                sendmessage (hlist, %WM_USER + %our_MEASUREITEM, wparam, lparam)
    Of course, it didn't work:
    MSDN says: The system sends the WM_MEASUREITEM message to the owner window of combo boxes and list boxes created with the OWNERDRAWFIXED style before sending the WM_INITDIALOG message. As a result, when the owner receives this message, the system has not yet determined the height and width of the font used in the control; function calls and calculations requiring these values should occur in the main function of the application or library.
    Is there ANY OTHER WAY of telling windows what this value should be,
    1. based upon the font actually used in the Listbox control
    2. which can be done by the Listbox control itself?

  • #2
    When sending messages, always read the API docs to see if a return value is needed.

    ie.

    Code:
    FUNCTION=SendMessage (hlist, %WM_USER + %our_MEASUREITEM, wparam, lparam)
    EXIT FUNCTION
    The return value is important, since it may flag a specific state or situation (or at minimum tell windows the message was processed).
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      Originally posted by Chris Boss View Post
      When sending messages..
      Quite so, but the problem here is that the message is not picked up in the Listbox control, presumably for the reason given in MSDN as shown above if we can read WM_CREATE for WM_INITDIALOG in this context.

      Comment


      • #4
        You aren't providing enough surrounding code to make it possible to find the problem.

        SendMessage will send any message to the control, so if the control isn't getting the message it is likely one of two problems.

        - hList is not being defined with the correct handle to the listbox control.
        - your subclassing code for the listbox, isn't processing the message correctly.

        ie.

        If you use:

        CASE %our_MEASUREITEM

        instead of

        CASE %WM_USER + %our_MEASUREITEM

        in the subclass routine, then you will miss the message.

        The %WM_USER constant should be used only when you define your custom message constant and not elsewhere.

        ie.

        %our_MEASUREITEM = %WM_USER+100

        Then use:

        SendMessage hCtrl%, %our_MEASUREITEM

        and in the subclass code select case use:

        CASE %our_MEASUREITEM

        A good way to test to see if a custom message is getting through to your subclass routine, use the BEEP command in the message processing code.

        No BEEP, then message never occurs.
        Chris Boss
        Computer Workshop
        Developer of "EZGUI"
        http://cwsof.com
        http://twitter.com/EZGUIProGuy

        Comment


        • #5
          Why not just handle WM_MEASUREITEM in the owner window procedure?
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Originally posted by Michael Mattias View Post
            ...handle WM_MEASUREITEM in the owner window procedure?
            That's what I'm doing. It would have been nice to set it as a function of the font, which itself is passed in from the owner. Just trying to simplify the developer interface.

            Comment


            • #7
              I meant not sending a message to the control in question. If you can get a handle to the control (which of course you can), you know everything there is to know about that control.
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Originally posted by Michael Mattias View Post
                I meant not sending a message to the control in question.
                How I fixed it temporarily was to send a LB_SETITEMHEIGHT message to the listbox. What I would prefer to do now that I have discovered LB_SETITEMHEIGHT is to derive the height from the font sent to the Listbox control and have it send the message to itself, one less thing for the poor overworked developer to worry about. Have to work out how. Don't go acronymic on me.
                Last edited by Chris Holbrook; 7 Feb 2008, 11:24 AM.

                Comment

                Working...
                X