Software Archive
Read-only legacy content
17061 討論

Peekcharqq in DLL

bdrichards
初學者
618 檢視
I am using a call to PEEKCHARQQ in a DLL function (that's called from Delphi) inside of a DO WHILE loop to, hopefully, trap a keystroke such as ESC to end the loop, yet the call ALWAYS returns false, as if nothing is ever in the keyboard buffer. Should PEEKCHARQQ not be used inside of a DLL?
Bill
0 積分
2 回應
Jugoslav_Dujic
傑出貢獻者 II
618 檢視
According to docs, PEEKCHARQQ Checks the keystroke buffer for a recent console keystroke . My reading is that it will work only for applications with console (either real or "overloaded" as in QuickWin). A better way would be to use PeekMessage(...WM_KEYDOWN), or, still better, to use synchronization objects and let the caller decide how to interrupt the calculation if necessary. See ThreadDlg sample for an illustration of the technique.

HTH
Jugoslav
bdrichards
初學者
618 檢視
Right! thanks. PeekMessage is the answer. As a Fortran "old timer" I can't get used to there not being a console all the time.
BILL
回覆