-
May 31st, 2014, 09:35 AM
#1
[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?
-
May 31st, 2014, 09:48 AM
#2
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 31st, 2014, 09:52 AM
#3
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?
-
May 31st, 2014, 11:01 AM
#4
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
-
May 31st, 2014, 02:59 PM
#5
Re: [win32] - how can i call the WM_DRAWITEM message?
Originally Posted by Cambalinho
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
-
May 31st, 2014, 03:00 PM
#6
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
June 1st, 2014, 07:37 AM
#7
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|