-
November 18th, 2010, 11:21 AM
#1
[RESOLVED] ListView Hotkeys with Checkbox.
How would one go about creating a hotkey that checks/unchecks the checkboxes of a listview and activates an assembly script?
STYLES: ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
Solution and Example code for others:
Code:
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
//Register ListViews
InitListView(hwndDlg, IDC_LIST1);
InitListView1(hwndDlg, IDC_LIST2);
//Register Hotkeys
RegisterHotKey(hwndDlg, IDC_HK1, MOD_SHIFT , VK_F1 );
break;
case WM_HOTKEY: {
//GodMode
switch( wParam ) {
case IDC_HK1: {
GodExit ^= true;
ListView_SetCheckState( GetDlgItem( hwndDlg, IDC_LIST1 ), 0, GodExit );
break;
} default: {
return false;
}
}
return true;
}
Last edited by TodayISawMyHeroFall; November 23rd, 2010 at 08:59 AM.
-
November 20th, 2010, 12:10 PM
#2
Re: ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
How would one go about creating a hotkey that checks/unchecks the checkboxes of a listview
The one seems never need the one. From MSDN
You can obtain the state of the check box for a given item with ListView_GetCheckState. To set the check state, use ListView_SetCheckState. If this style is set, the list-view control automatically toggles the check state when the user clicks the check box or presses the space bar.
Originally Posted by TodayISawMyHeroFall
and activates an assembly script?
Never heard about assembly script.
Last edited by Igor Vartanov; November 20th, 2010 at 12:13 PM.
Best regards,
Igor
-
November 23rd, 2010, 04:38 AM
#3
Re: ListView Hotkeys
Ok so..
ListView_GetCheckState(hWndListView, 0);
ListView_SetCheckState(hWndListView, 0, 0);
Now how do I get a Registered Hotkey to check/uncheck it?
Edit:
case WM_HOTKEY:
//GodMode
if (wParam == IDC_HK1)
{
if (GodExit == FALSE)
{
GodExit = TRUE;
ListView_SetCheckState(hWndListView, 0, 0);
}
else if )GodExit == True)
{
GodExit = FALSE;
ListView_SetCheckState(hWndListView, 0, 1);
Doesn't work..
Last edited by TodayISawMyHeroFall; November 23rd, 2010 at 04:50 AM.
-
November 23rd, 2010, 04:54 AM
#4
Re: ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
Ok so..
ListView_GetCheckState(hWndListView, 0);
ListView_SetCheckState(hWndListView, 0, 0);
Now how do I get a Registered Hotkey to check/uncheck it?
1. ListView_GetCheckState(hWndListView, 0); is not a user action, so why implement any "hot key" for it?
2. You don't need to call
Code:
ListView_SetCheckState(hWndListView, 0, 0);
as a response to "hot key" because List Control will make all needed actions for you after use presses the space bar (and Igor has already pointed it out!).
Victor Nijegorodov
-
November 23rd, 2010, 05:01 AM
#5
Re: ListView Hotkeys
I'm not quite understanding you.. Could you dumb it down for me alittle bit more? Also, Example code would help greatly!
Edit:
What I currently have atm and isn't working..
Code:
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
//Register ListViews
InitListView(hwndDlg, IDC_LIST1);
InitListView1(hwndDlg, IDC_LIST2);
//Register Hotkeys
RegisterHotKey(hwndDlg, IDC_HK1, MOD_SHIFT , VK_F1 );
break;
case WM_HOTKEY:
//GodMode
if (wParam == IDC_HK1)
{
if (GodExit == FALSE)
{
GodExit = TRUE;
ListView_GetCheckState(hwndDlg, 0);
ListView_SetCheckState(hwndDlg, 0, 0);
}
else if (GodExit == TRUE)
{
GodExit = FALSE;
ListView_GetCheckState(hwndDlg, 0);
ListView_SetCheckState(hwndDlg, 0, 1);
}
}
I'm SO confused lol!
Last edited by TodayISawMyHeroFall; November 23rd, 2010 at 05:20 AM.
-
November 23rd, 2010, 05:11 AM
#6
Re: ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
Also, Example code would help greatly!
Again: you don't need any code to check/uncheck list control item. Please, read the post#2 carefully!
Victor Nijegorodov
-
November 23rd, 2010, 05:14 AM
#7
Re: ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
... Edit:
What I currently have atm and isn't working..
I see you have edited your previous posts...
Please, edit them once more to add Code tags around code snippets. Otherwise your code is absolutely unreadable!
Victor Nijegorodov
-
November 23rd, 2010, 05:18 AM
#8
Re: ListView Hotkeys
Originally Posted by VictorN
Again: you don't need any code to check/uncheck list control item. Please, read the post#2 carefully!
I want to add Shift+F1 to activate/de-active the checkbox in row 1 of my listview.
Originally Posted by VictorN
I see you have edited your previous posts...
Please, edit them once more to add Code tags around code snippets. Otherwise your code is absolutely unreadable!
Done.
-
November 23rd, 2010, 05:24 AM
#9
Re: ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
What I currently have atm and isn't working..
What "isn't working"?
Did you debug your code?
Victor Nijegorodov
-
November 23rd, 2010, 07:11 AM
#10
Re: ListView Hotkeys
Compiles but does nothing.
Code:
WM_HOTKEY:
//GodMode
if (wParam == IDC_HK1)
{
if (GodExit == FALSE)
{
GodExit = TRUE;
ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LIST1), 0, 1);
}
else if
(GodExit == TRUE)
{
GodExit = FALSE;
ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LIST1), 0, 1);
}
}
-
November 23rd, 2010, 07:29 AM
#11
Re: ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
Compiles but does nothing.
Code:
WM_HOTKEY:
//GodMode
if (wParam == IDC_HK1)
{
if (GodExit == FALSE)
{
GodExit = TRUE;
ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LIST1), 0, 1);
}
else if
(GodExit == TRUE)
{
GodExit = FALSE;
ListView_SetCheckState(GetDlgItem(hwndDlg, IDC_LIST1), 0, 1);
}
}
Well, again:
Originally Posted by VictorN
Did you debug your code?
Victor Nijegorodov
-
November 23rd, 2010, 08:34 AM
#12
Re: ListView Hotkeys
Originally Posted by VictorN
Well, again:
No. Hold up!
Last edited by TodayISawMyHeroFall; November 23rd, 2010 at 08:38 AM.
-
November 23rd, 2010, 08:45 AM
#13
Re: ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
I want to add Shift+F1 to activate/de-active the checkbox in row 1 of my listview.
BTW, don't you know that Shift+F1 is used in Windows (by default) for Context-Sensitive Help?
Victor Nijegorodov
-
November 23rd, 2010, 08:56 AM
#14
Re: ListView Hotkeys
Fixed. Check my first post edit for the solution.
-
November 23rd, 2010, 09:12 AM
#15
Re: [RESOLVED] ListView Hotkeys
Originally Posted by TodayISawMyHeroFall
Fixed. Check my first post edit for the solution.
OK, I am now trying to check it:
Originally Posted by TodayISawMyHeroFall
How would one go about creating a hotkey that checks/unchecks the checkboxes of a listview and activates an assembly script?
STYLES: ListView_SetExtendedListViewStyle(hWndListView, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
Solution and Example code for others:
Code:
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
//Register ListViews
InitListView(hwndDlg, IDC_LIST1);
InitListView1(hwndDlg, IDC_LIST2);
//Register Hotkeys
RegisterHotKey(hwndDlg, IDC_HK1, MOD_SHIFT , VK_F1 );
break;
case WM_HOTKEY: {
//GodMode
switch( wParam ) {
case IDC_HK1: {
GodExit ^= true;
ListView_SetCheckState( GetDlgItem( hwndDlg, IDC_LIST1 ), 0, GodExit );
break;
} default: {
return false;
}
}
return true;
}
Well, in this example you always check/uncheck the first (and only the first) item.
And, BTW, what does "activates an assembly script" mean?
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
|