-
August 22nd, 2013, 02:14 AM
#1
Keyboard event handling on List view
Hi all,
In my win 32 application,I have adilaog box and inside that one list view control to display some records.I want to use Find dialogue box for this List view.
1.How can i identify Cntrl+f event under LVN_KEYDOWN
2.I registered the FINDMESSAGESTRING in Win main function.and written the handler for FR_FINDNXT on default case of DialogProc.But control is not going to this handler.
Code:
//Dialog procedure
extern UINT uFindReplaceMsg; // message identifier FINDMSGSTRING decared and registerd in main file
HWND HdlgFindOrReplce = NULL; // handle to Find dialog box
LRESULT CALLBACK DlgtProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG://setting the items & subitem values
break;
case WM_NOTIFY:
switch(LOWORD(wParam))
{
case IDC_LISTVIEW:
switch(((LPNMHDR)lParam)->code)
{
case LVN_KEYDOWN:
//wat condition i have to write for Cntrl+F??
//creating the find dialog box
break;
}
break;
}
break;
default:
{
LPFINDREPLACE lpfr;
if ( uMsg == uFindReplaceMsg)
{
// Get pointer to FINDREPLACE structure from lParam.
lpfr = (LPFINDREPLACE)lParam;
// If the FR_DIALOGTERM flag is set,
// invalidate the handle identifying the dialog box.
if (lpfr->Flags & FR_DIALOGTERM)
{
HdlgFindOrReplce = NULL;
return 0;
}
// If the FR_FINDNEXT flag is set,
// call the application-defined search routine
// to search for the requested string.
if ((lpfr->Flags & FR_FINDNEXT))
{//Handler of find next
}
}
}
}
-
August 22nd, 2013, 03:02 AM
#2
Re: Keyboard event handling on List view
1) See Victor's response here from your other thread
http://forums.codeguru.com/showthrea...dal-dialog-box
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)
-
August 22nd, 2013, 03:53 AM
#3
Re: Keyboard event handling on List view
Originally Posted by 2kaud
K.i got answer for my first question in another way.by using the structure NMLVKEYDOWN.What about my second problem?
-
August 22nd, 2013, 04:05 AM
#4
Re: Keyboard event handling on List view
Originally Posted by manjut19
2.I registered the FINDMESSAGESTRING in Win main function.and written the handler for FR_FINDNXT on default case of DialogProc.But control is not going to this handler.
Where and how did you register the FINDMESSAGESTRING? Show your code.
Victor Nijegorodov
-
August 22nd, 2013, 04:46 AM
#5
Re: Keyboard event handling on List view
Originally Posted by VictorN
Where and how did you register the FINDMESSAGESTRING? Show your code.
Code:
Main.cpp//Another file
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
//InitCommonControls();
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = (HICON) LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,32,32,0);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+11);
wcex.lpszMenuName = MAKEINTRESOURCE (IDR_MENU1);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = (HICON) LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON2),IMAGE_ICON,32,32,0);
if (!RegisterClassEx(&wcex))
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("ladder editor"),
NULL);
return 1;
}
if(!SetUpMDIChildWindowClass(hInstance))
return 0;
hInst = hInstance; // Store instance handle in our global variable
HWND hWnd = CreateWindow(
szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd)
{
MessageBox(NULL,
_T("Call to RegisterClassEx failed!"),
_T("ladder editor"),
NULL);
return 1;
}
g_hMainWindow = hWnd;
ShowWindow(hWnd,SW_MAXIMIZE);
UpdateWindow(hWnd);
//Regestered FINDMSGSTRING
uFindReplaceMsg = RegisterWindowMessage(FINDMSGSTRING);
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
Last edited by manjut19; August 22nd, 2013 at 04:48 AM.
-
August 22nd, 2013, 04:59 AM
#6
Re: Keyboard event handling on List view
OK!
Did you debug your code to be sure uFindReplaceMsg is a valid message ID?
Are you sure your find/replace dialog sends messages to your main dialog?
Victor Nijegorodov
-
August 22nd, 2013, 05:27 AM
#7
Re: Keyboard event handling on List view
"When the dialog box is open, your main message loop must include a call to the IsDialogMessage function. Pass a handle to the dialog box as a parameter in the IsDialogMessage call. This ensures that the dialog box correctly processes keyboard messages."
http://msdn.microsoft.com/en-us/libr...x#finding_text
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)
-
August 22nd, 2013, 06:29 AM
#8
Re: Keyboard event handling on List view
Originally Posted by VictorN
OK!
Did you debug your code to be sure uFindReplaceMsg is a valid message ID?
Are you sure your find/replace dialog sends messages to your main dialog?
Yes I debugged the code uFindReplaceMsg getting a valid message id.There are only 2 buttons on my Find dialog box,FinNext and Cancel,Cancel is closing the dailog box(Find),But FindNext is not giving any notification
Last edited by manjut19; August 22nd, 2013 at 06:40 AM.
-
August 26th, 2013, 05:20 AM
#9
Re: Keyboard event handling on List view
Originally Posted by manjut19
But FindNext is not giving any notification
Well, now it's time to show your code for "giving a notification".
Best regards,
Igor
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
|