[win32] - how can i call the WM_DRAWITEM message?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: [win32] - how can i call the WM_DRAWITEM message?

  1. #1
    Join Date
    Apr 2009
    Posts
    636

    [win32] - how can i call the WM_DRAWITEM message?

    i'm trying call the wm_drawitem message without sucess

    Code:
    if(KeyPressed(VK_MENU)==true) SendMessage(hButton,WM_DRAWITEM,NULL,NULL);
    what i'm doing wrong?

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,362

    Re: [win32] - how can i call the WM_DRAWITEM message?

    See http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    wParam Specifies the identifier of the control that sent the WM_DRAWITEM message. If the message was sent by a menu, this parameter is zero.

    lParam Pointer to a DRAWITEMSTRUCT structure containing information about the item to be drawn and the type of drawing required.

    You need to pass a pointer to a DRAWITEMSTRUCT structure that contains the required info.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Apr 2009
    Posts
    636

    Re: [win32] - how can i call the WM_DRAWITEM message?

    "wParam Specifies the identifier of the control that sent the WM_DRAWITEM message. If the message was sent by a menu, this parameter is zero."
    i belive you mean the ID... but how i get the ID?

    "lParam Pointer to a DRAWITEMSTRUCT structure containing information about the item to be drawn and the type of drawing required.


    You need to pass a pointer to a DRAWITEMSTRUCT structure that contains the required info."
    how can i get the DRAWITEMSTRUCT from actual state?

  4. #4
    Join Date
    Apr 2009
    Posts
    636

    Re: [win32] - how can i call the WM_DRAWITEM message?

    heres what i did:

    Code:
    if(KeyPressed(VK_MENU)==true) SendMessage(hButton,WM_DRAWITEM,GetDlgCtrlID(hButton),MAKEWPARAM(GetDlgCtrlID(hButton),BN_PUSHED));
    but isn't working
    please tell me more

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,381

    Re: [win32] - how can i call the WM_DRAWITEM message?

    Quote Originally Posted by Cambalinho View Post
    heres what i did:

    Code:
    if(KeyPressed(VK_MENU)==true) SendMessage(hButton,WM_DRAWITEM,GetDlgCtrlID(hButton),MAKEWPARAM(GetDlgCtrlID(hButton),BN_PUSHED));
    but isn't working
    please tell me more
    First do NOT place more than one statement in one line. Do it like
    Code:
    if(KeyPressed(VK_MENU))
         SendMessage(hButton,WM_DRAWITEM,GetDlgCtrlID(hButton),MAKEWPARAM(GetDlgCtrlID(hButton),BN_PUSHED));
    Second, never compare something returning BOOL with TRUE nor with true. The return value of the Win API may be either 0 (FALSE) or any other non-zero integer that is interpreted as TRUE.
    After that you could debug your code and what goes wrong and why...
    Victor Nijegorodov

  6. #6
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,362

    Re: [win32] - how can i call the WM_DRAWITEM message?

    The lparam needs to be a pointer to a DRAWITEMSTRUCT as I indicated in my post #2. What you have shown in post #4 isn't a pointer for the lparam parameter. You need to initialise a struct and then pass its memory address. The format of the structure is here http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    So you need something like this
    Code:
    DRAWITEMSTRUCT dis = {0};
    //Initialise the fields for dis
    if (KeyPressed(VK_MENU))
        SendMessage(hButton, WM_DRAWITEM, (WPARAM)GetDlgCtrlID(hButton), (LPARAM)&dis);
    Are you sure you need to send this message? What are you trying to accomplish? There may be better ways of achieving it.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  7. #7
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

    Re: [win32] - how can i call the WM_DRAWITEM message?

    WM_DRAWITEM message is...
    [ MSDN ]
    ...sent to the parent window of an owner-drawn button, combo box, list box, or menu when a visual aspect of the button, combo box, list box, or menu has changed.
    It is sent by the system when needed, and it has no sense to be directly sent from your application.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center