: : Can't you simply catch WM_KEYDOWN or similar then?
:
: Unfortunately, according to the info at MSDN, keystrokes are not
: processed within a dialog unless TranslateMessage and all its extra
: support code is included.
:
: However, I have found something that does (almost) work here, but
: will need a little extra code:
:
:
:
: MSG Msg;
:
: while (! PeekMessage(&Msg, hDlg, 0, 0, PM_REMOVE));
:
:
:
: The catch is that it processes ALL events, so a single keystroke
: gives both up and down events, any mouse movement gives events and
: clicks are both up and down. But this might give toddlerasim
: something to build from.
:
: PeekMessage info:
:
:
http://msdn.microsoft.com/en-us/library/ms644943(VS.85).aspx
:
: Take Care,
: Ed
:
: Edit - Post Script:
:
: The easy solution seems to be:
:
:
: MSG Msg;
:
: while (! PeekMessage(&Msg, hDlg, 0, 0, PM_REMOVE));
: while (! PeekMessage(&Msg, hDlg, 0, 0, PM_REMOVE));
:
:
:
: That way a keystroke down trips the first and up trips the second.
:
:Thanks for the help folks and toddlerasim did manage to solve the problem : :). As suggested I used the PeekMessage function and got it to iterate :through the data base. However the code is rough and ugly. I need to work :on it and streamline it. However, the main problem has been solved. I am :sending the code I have used in case someone else faces a similar problem.
:Incidentally, location is a globally declared int variable and :nitialized to zero.
:My sincere thanks to you both for bearing with me.
:
:
: case IDC_READ1:
FILE *p;
p=fopen("d:\\vc6.txt","r");
fread(&teacher, sizeof(teacher),1,p);
SetDlgItemText(hDlg,IDC_EDIT2,teacher.name);
SetDlgItemInt(hDlg,IDC_AGE2,teacher.age,FALSE);
fclose(p);
while(PeekMessage(&msg,hDlg,0,0,PM_REMOVE))
{
switch(msg.message)
{
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
FILE *p;
p=fopen("d:\\vc6.txt","r");
fseek(p,(location)*sizeof(teacher),SEEK_CUR);
fread(&teacher, sizeof(teacher),1,p);
SetDlgItemText(hDlg,IDC_EDIT2,teacher.name);
SetDlgItemInt(hDlg,IDC_AGE2,teacher.age,FALSE);
location++;
fclose(p);
return TRUE;
break;
::