Difference xBrowse ::KeyDown and ::KeyChar

Difference xBrowse ::KeyDown and ::KeyChar

Postby StefanHaupt » Mon Jul 02, 2012 1: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Difference xBrowse ::KeyDown and ::KeyChar

Postby Eoeo » Mon Jul 02, 2012 1:52 pm

oApp():oGrid: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
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Difference xBrowse ::KeyDown and ::KeyChar

Postby Antonio Linares » Mon Jul 02, 2012 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Difference xBrowse ::KeyDown and ::KeyChar

Postby StefanHaupt » Wed Jul 04, 2012 7: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 52 guests