Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #9  
Antiguo 15-04-2016
Noiro Noiro is offline
Registrado
NULL
 
Registrado: abr 2016
Posts: 1
Poder: 0
Noiro Va por buen camino
Puedes utilizar RegisterRawInputDevices.

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  USHORT = Word;
  HRAWINPUT = THandle;
  LPVOID = Pointer;

  tagRAWINPUTDEVICE = record
    usUsagePage: USHORT;
    usUsage: USHORT;
    dwFlags: DWORD;
    hwndTarget: HWND;
  end;
  RAWINPUTDEVICE = tagRAWINPUTDEVICE;
  TRawInputDevice = RAWINPUTDEVICE;
  PRawInputDevice = ^TRawInputDevice;
  LPRAWINPUTDEVICE = PRawInputDevice;
  PCRAWINPUTDEVICE = PRawInputDevice;

  tagRAWINPUTHEADER = record
    dwType: DWORD;
    dwSize: DWORD;
    hDevice: THandle;
    wParam: WPARAM;
  end;
  RAWINPUTHEADER = tagRAWINPUTHEADER;
  TRawInputHeader = RAWINPUTHEADER;
  PRawInputHeader = ^TRawInputHeader;

  tagRAWMOUSE = record
    usFlags: WORD;
    union: record
    case Integer of
      0: (
        ulButtons: ULONG);
      1: (
        usButtonFlags: WORD;
        usButtonData: WORD);
    end;
    ulRawButtons: ULONG;
    lLastX: LongInt;
    lLastY: LongInt;
    ulExtraInformation: ULONG;
  end;
  RAWMOUSE = tagRAWMOUSE;
  TRawMouse = RAWMOUSE;
  PRAWMOUSE = ^RAWMOUSE;
  LPRAWMOUSE = ^RAWMOUSE;

  tagRAWKEYBOARD = record
    MakeCode: USHORT;
    Flags: USHORT;
    Reserved: USHORT;
    VKey: USHORT;
    Message: UINT;
    ExtraInformation: ULONG;
  end;
  RAWKEYBOARD = tagRAWKEYBOARD;
  TRawKeyboard = RAWKEYBOARD;
  PRawKeyboard = ^TRawKeyboard;
  LPRAWKEYBOARD = PRawKeyboard;

  tagRAWHID = record
    dwSizeHid: DWORD;    // byte size of each report
    dwCount: DWORD;      // number of input packed
    bRawData: array [0..0] of BYTE;
  end;
  RAWHID = tagRAWHID;
  TRawHID = RAWHID;
  PRawHID = ^TRawHID;
  LPRAWHID = PRawHID;


  tagRAWINPUT = record
    header: TRawInputHeader;
    case Integer of
      0: (mouse: RAWMOUSE);
      1: (keyboard: RAWKEYBOARD);
      2: (hid: RAWHID);
  end;
  RAWINPUT = tagRAWINPUT;
  TRawInput = RAWINPUT;
  PRawInput = ^TRawInput;
  LPRAWINPUT = PRawInput;

  TForm1 = class(TForm)
  private
  protected
    procedure CreateWindowHandle(const Params: TCreateParams); override;
    procedure WMInput(var Message: TMessage); message WM_INPUT;
    { Private declarations }
  public
    { Public declarations }
    
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

const
  GenericDesktopControls: USHORT = 01;
  Keyboard: USHORT = 06;
  RIDEV_INPUTSINK = $00000100;

  RIM_INPUT = 0;
  RIM_INPUTSINK = 1;
  RID_INPUT = $10000003;

  RIM_TYPEMOUSE      = 0;
  RIM_TYPEKEYBOARD   = 1;
  RIM_TYPEHID        = 2;

  RI_KEY_MAKE = 0;
  RI_KEY_BREAK = 1;


function RegisterRawInputDevices(
  pRawInputDevices: PCRAWINPUTDEVICE;
  uiNumDevices: UINT;
  cbSize: UINT): BOOL; stdcall; external user32;

function GetRawInputData(
  hRawInput: HRAWINPUT;
  uiCommand: UINT;
  pData: LPVOID;
  var pcbSize: UINT;
  cbSizeHeader: UINT): UINT; stdcall; external user32;


{ TForm1 }

procedure TForm1.CreateWindowHandle(const Params: TCreateParams);
var
  RID: TRawInputDevice;
begin
  inherited;

  RID.usUsagePage := GenericDesktopControls;
  RID.usUsage := Keyboard;
  RID.dwFlags := RIDEV_INPUTSINK;
  RID.hwndTarget := Handle;
  Win32Check(RegisterRawInputDevices(@RID, 1, SizeOf(RID)));
end;

procedure TForm1.WMInput(var Message: TMessage);
var
  Size: UINT;
  Data: array of Byte;
  RawKeyboard: TRawKeyboard;
  RawHID: TRawHID;
begin
  if (Message.WParam and $FF) in [RIM_INPUT, RIM_INPUTSINK] then
    inherited;

  if (GetRawInputData(Message.LParam, RID_INPUT, nil, Size,
      SizeOf(TRawInputHeader)) = 0) then begin
    SetLength(Data, Size);
    if (GetRawInputData(Message.LParam, RID_INPUT, Data, Size,
        SizeOf(TRawInputHeader)) <> UINT(-1)) then
    begin
      if (PRawInput(Data)^.header.dwType = RIM_TYPEKEYBOARD) then
      begin
        RawKeyboard := PRawInput(Data)^.keyboard;

        if (RawKeyboard.VKey = VK_CONTROL) then begin
          if RawKeyboard.Flags and RI_KEY_BREAK = RI_KEY_BREAK then
            Cursor := crDefault
          else
            Cursor := crSizeAll; // will call continously until key is released
        end;
        // might opt to reset the cursor regardless of pointer position...


        if (RawKeyboard.VKey = Ord('A')) then
        begin
          // ....
        end;
      end
      else if (PRawInput(Data)^.header.dwType = RIM_TYPEHID) then
      begin
        RawHID := PRawInput(Data).hid;
        // ....
      end;
    end;

  end;
end;

end.

Para poder "escuchar" el HID tendrás que registrarlo en la llamada RegisterRawInputDevices pasando un array con el total de dispositivos.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Deshabilitar Alt-Tab director0407031 API de Windows 2 30-05-2008 20:24:26
Deshabilitar datatimepicker schaka Varios 2 27-04-2008 22:56:55
Deshabilitar el tab un for eldonfsr C++ Builder 4 25-07-2007 10:36:25
Deshabilitar FKs micayael Firebird e Interbase 1 09-03-2007 18:52:53
deshabilitar los iconos superhopi Varios 8 23-12-2006 02:30:21


La franja horaria es GMT +2. Ahora son las 08:04:44.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi