FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Difference xBrowse ::KeyDown and ::KeyChar
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Difference xBrowse ::KeyDown and ::KeyChar
Posted: Mon Jul 02, 2012 01:37 PM

Hi friends,

as subject, what is the difference between these methods. Some keys are trapped in ::Keydown() some in ::KeyChar().

In what case I have to to use ::bKeyDown, in what case ::bKeyChar ? What is the best method to create a new keyhandler ?

kind regards

Stefan
Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Re: Difference xBrowse ::KeyDown and ::KeyChar
Posted: Mon Jul 02, 2012 01:52 PM
oApp():bKeyDown := {|nKey| Stephan_Tecla(nKey,oApp():oGrid,oCont,oApp():oDlg) }


function Stephan_Tecla(nKey,oGrid,oCont,oDlg)
Do case
case nKey==VK_RETURN
Function for edit record
case nKey==VK_INSERT
function for add record
case nKey==VK_DELETE
function for delete a record
case nKey==VK_ESCAPE
oDlg:End()
otherwise
if nKey >= 96 .AND. nKey <= 105
function for search a record
elseif HB_ISSTRING(CHR(nKey))
function for search a record
endif
EndCase

return nil
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Difference xBrowse ::KeyDown and ::KeyChar
Posted: Mon Jul 02, 2012 06:13 PM
Stefan,

Method KeyDown() is FiveWin implementation for Windows WM_KEYDOWN message:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646280(v=vs.85).aspx

and Method KeyChar() is FiveWin implementation for Windows WM_CHAR message:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646276(v=vs.85).aspx

As you can review, the difference is not very clear, so sometimes it is better to check both to find what we may be looking for:

WM_KEYDOWN:
Posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the ALT key is not pressed.


WM_CHAR:
Posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Difference xBrowse ::KeyDown and ::KeyChar
Posted: Wed Jul 04, 2012 07:14 AM

Antonio,

it seems, bKeyDown() traps the most keys I need, bKeyChar does not recognize if two keys are pressed (e.g. ctrl p), it traps only the first key.

Thanks

kind regards

Stefan

Continue the discussion