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
}
}
}
}
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
Re: Keyboard event handling on List view
Quote:
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?
Re: Keyboard event handling on List view
Quote:
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.
Re: Keyboard event handling on List view
Quote:
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;
}
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?
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
Re: Keyboard event handling on List view
Quote:
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
Re: Keyboard event handling on List view
Quote:
Originally Posted by
manjut19
But FindNext is not giving any notification
Well, now it's time to show your code for "giving a notification". :)