-
May 15th, 2020, 04:07 AM
#1
[RESOLVED] How to send an LVN_COLUMNCLICK message?
Hello
I read it on MSDN that it should be sent through WM_NOTIFY.
And that the iSubItem number has to be put in a NMLISTVIEW structure.
But where do I put the NMLISTVIEW structure to tell it to which column to click on?
Code:
NMHDR nmh;
nmh.code = LVN_COLUMNCLICK; // Message type defined by control.
nmh.idFrom = GetDlgCtrlID(hListView);
nmh.hwndFrom = hListView;
NMLISTVIEW nmlv = {0};
nmlv.iItem = -1;
nmlv.iSubItem = 1;
SendMessage(hwnd, WM_NOTIFY, nmh.idFrom,(LPARAM)&nmh);
https://docs.microsoft.com/en-us/win...rols/wm-notify
https://docs.microsoft.com/en-us/win...vn-columnclick
-
May 15th, 2020, 05:12 AM
#2
Re: How to send an LVN_COLUMNCLICK message?
LVN_COLUMNCLICK is not a message, but a notification received via the WM_NOTIFY message when a column header is clicked.
An example of use from some code is:
Code:
LPNMHDR tc;
LPNMLISTVIEW pnmlv;
DWORD subitm;
// g_hwndLV is the window handle to the list view control
case WM_NOTIFY:
tc = (LPNMHDR)lParam;
if ((tc->hwndFrom == g_hwndLV) && (tc->code == LVN_COLUMNCLICK)) {
pnmlv = (LPNMLISTVIEW)lParam;
subitm = pnmlv->iSubItem;
// ...
}
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 15th, 2020, 07:05 AM
#3
Re: How to send an LVN_COLUMNCLICK message?
Try
Code:
NMLISTVIEW nmlv = {0};
nmlv.nmh.code = LVN_COLUMNCLICK; // Message type defined by control.
nmlv.nmh.idFrom = GetDlgCtrlID(hListView);
nmlv.nmh.hwndFrom = hListView;
nmlv.iItem = -1;
nmlv.iSubItem = 1;
SendMessage(hwnd, WM_NOTIFY, nmh.idFrom,(LPARAM)&nmlv);
Victor Nijegorodov
-
May 15th, 2020, 02:09 PM
#4
Re: How to send an LVN_COLUMNCLICK message?
Of course, how could I miss it that NMHDR hdr; was also a member of NMLISTVIEW structure.
Ive learned something and its working, thank you very much Victor!
-
May 15th, 2020, 02:44 PM
#5
Re: How to send an LVN_COLUMNCLICK message?
You are welcome!
Victor Nijegorodov
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
|