Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages
Started by Jonathan Dumaresq
Fri, 09 Feb 2007 22:42
RegisterRawInputDevices WM_INPUT ????
Author: Jonathan Dumaresq
Date: Fri, 09 Feb 2007 22:42
Date: Fri, 09 Feb 2007 22:42
51 lines
2059 bytes
2059 bytes
hi all ,
I try to find a simple application that register a hid to get his raw data.
I have try this code, but i not receive the wm_input message:
HEADER
class TForm5 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm5(TComponent* Owner);
void WindowProc(TMessage &msg);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_INPUT,TMessage,WindowProc);
END_MESSAGE_MAP(TForm)
};
CPP file
void __fastcall TForm5::Button1Click(TObject *Sender)
{
RAWINPUTDEVICE Rid;
Rid.usUsagePage = 0x01;
Rid.usUsage = 0x04;
Rid.dwFlags = 0; // adds joystick
Rid.hwndTarget = NULL;
if (RegisterRawInputDevices(&Rid, 1, sizeof(Rid)) == FALSE)
{
//registration failed. Call GetLastError for the cause of the error.
ShowMessage("error");
}
}
//---------------------------------------------------------------------------
void TForm5::WindowProc(TMessage &msg)
{
ShowMessage("WM_INPUT");
}
this is for a joystick device.
regards
Jonathan
Re: RegisterRawInputDevices WM_INPUT ????
Author: Remy Lebeau (TeamB)
Date: Fri, 09 Feb 2007 23:14
Date: Fri, 09 Feb 2007 23:14
45 lines
1992 bytes
1992 bytes
"Jonathan Dumaresq" <jdumaresq@cimeq.qc.ca_nospam> wrote in message
news:45ccf77e$1@newsgroups.borland.com...
> void WindowProc(TMessage &msg);
TForm inherits a WindowProc property from TControl. You cannot
declare a method with the same name. You should override the virtual
WndProc() method instead.
> RAWINPUTDEVICE Rid;
You should always zero out API structures before using them:
RAWINPUTDEVICE Rid = {0};
Or
RAWINPUTDEVICE Rid;
memset(&Rid, 0, sizeof(Rid));
Or:
RAWINPUTDEVICE Rid;
::ZeroMemory(&Rid, sizeof(Rid));
> Rid.usUsagePage = 0x01;
> Rid.usUsage = 0x04;
> Rid.dwFlags = 0; // adds joystick
> Rid.hwndTarget = NULL;
Why are you not setting the TForm's Handle as the target? That is
where you are trying to catch the WM_INPUT messages, afterall.
> if (RegisterRawInputDevices(&Rid, 1, sizeof(Rid)) == FALSE)
> {
> //registration failed. Call GetLastError for the cause of the
error.
> ShowMessage("error");
> }
You did not say which error is actually being reported.
Gambit
Re: RegisterRawInputDevices WM_INPUT ????
Author: Jonathan Dumaresq
Date: Mon, 12 Feb 2007 15:18
Date: Mon, 12 Feb 2007 15:18
40 lines
1917 bytes
1917 bytes
>
>> void WindowProc(TMessage &msg);
>
> TForm inherits a WindowProc property from TControl. You cannot
> declare a method with the same name. You should override the virtual
> WndProc() method instead.
good. I have found it after posting it.
>
>> RAWINPUTDEVICE Rid;
>
> You should always zero out API structures before using them:
I have do it also.
>> Rid.hwndTarget = NULL;
i think this was my error. The first time i try it i put 'this' instead of
Handle.
>> if (RegisterRawInputDevices(&Rid, 1, sizeof(Rid)) == FALSE)
>> {
>> //registration failed. Call GetLastError for the cause of the
> error.
>> ShowMessage("error");
>> }
>
> You did not say which error is actually being reported.
I have not put it because i have no error.
BUT THANKS AGAIN GAMBIT. this is now working. I got my event :)
do i have to put something at the end of the wndproc to redispatch the
messages ?
regards
Jonathan
Re: RegisterRawInputDevices WM_INPUT ????
Author: Jonathan Dumaresq
Date: Mon, 12 Feb 2007 15:23
Date: Mon, 12 Feb 2007 15:23
13 lines
1235 bytes
1235 bytes
Hi again, Is it possible to use BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_INPUT TMessage, WMInput) END_MESSAGE_MAP(TComponent) to get only the WM__INPUT ? if yes, what i should put for parameter to END_MESSAGE_MAP ? Jonathan
Re: RegisterRawInputDevices WM_INPUT ????
Author: Jonathan Dumaresq
Date: Mon, 12 Feb 2007 15:51
Date: Mon, 12 Feb 2007 15:51
14 lines
1348 bytes
1348 bytes
> BEGIN_MESSAGE_MAP > MESSAGE_HANDLER(WM_INPUT TMessage, WMInput) > END_MESSAGE_MAP(TComponent) > > to get only the WM__INPUT ? > > if yes, what i should put for parameter to END_MESSAGE_MAP ? > > Jonathan forget it. I try it and it's work. I put TForm as the parametrer. Jonathan
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads