Click here to Skip to main content
15,914,419 members
Home / Discussions / C#
   

C#

 
GeneralRe: REGULAR_EXP Pin
Christian Graus23-Jan-05 11:07
protectorChristian Graus23-Jan-05 11:07 
GeneralSearching for words in a string Pin
Azel Low22-Jan-05 21:14
Azel Low22-Jan-05 21:14 
GeneralRe: Searching for words in a string Pin
V|ktor22-Jan-05 21:54
V|ktor22-Jan-05 21:54 
GeneralRe: Searching for words in a string Pin
Azel Low22-Jan-05 22:54
Azel Low22-Jan-05 22:54 
GeneralRe: Searching for words in a string Pin
mav.northwind22-Jan-05 23:07
mav.northwind22-Jan-05 23:07 
GeneralRe: Searching for words in a string Pin
Azel Low23-Jan-05 0:50
Azel Low23-Jan-05 0:50 
GeneralDatagrid, dataset, update, scroll Pin
Bedevian22-Jan-05 19:53
Bedevian22-Jan-05 19:53 
GeneralHooks CallWndProc to get my mouse Pin
c121hains22-Jan-05 15:43
c121hains22-Jan-05 15:43 
I noticed that my HOOK function isn't capturing mouse related messages. But others like WM_ACTIVEAPP is fine. I'm using the CallWndProc method instead of a mouse hook procedure.

I want to be able to peek at ALL mouse and keyboard related windows messages across the desktop and other applications. The mouse hook seemed to only capture what was being delivered to my app. When i was experimenting with the mouse hook proc, i did this:
hHook = SetWindowsHookEx(WH_MOUSE,MouseHookProcedure,
(IntPtr)0,0);

.. to specify all threads across the desktop (last param). But it crashed here. Doesn't like the last two parameters 0 and 0. So this is why i'm not trying CallWndProc.

Any ideas of how to do this?

private void button8_Click(object sender, System.EventArgs e)
{
if(hHook == 0)
{

CWPHookProcedure = new HookProcDT(Form1.CWPHookProc);
hHook = SetWindowsHookEx
(WH_CALLWNDPROC,
CWPHookProcedure,
IntPtr.Zero,
User32.GetWindowThreadProcessId(this.Handle.ToInt32(),
0));
.. etc


.. and then in my CallWndProc hook method:
public static int CWPHookProc(int code, IntPtr wparam, IntPtr lParam)
{
if (code < 0)
return User32.CallNextHookEx(hHook, code, wparam, lParam);

CWPSTRUCT cwp = (CWPSTRUCT) Marshal.PtrToStructure(
lParam,
typeof(CWPSTRUCT));

if (code == 0) //this means that the hook procedure should process the
//message contained in CWPSTRUCT
{
switch(cwp.message)
{
case WM_ACTIVATEAPP: //GET'S HERE
MessageBox.Show("Is here in CWPHookProc");
break;
case WM_MOUSEMOVE: //BUT NOT HERE
MessageBox.Show("Is here in CWPHookProc");
break;

}
}
return User32.CallNextHookEx(hHook, code, wparam, lParam);
}

//Declare wrapper managed CWPStruct class.
[StructLayout(LayoutKind.Sequential)]
public class CWPSTRUCT
{
public IntPtr lparam;
public IntPtr wparam;
public int message;
public IntPtr hwnd;
}
GeneralRe: Hooks CallWndProc to get my mouse Pin
Dennis C. Dietrich22-Jan-05 16:28
Dennis C. Dietrich22-Jan-05 16:28 
GeneralRe: Hooks CallWndProc to get my mouse Pin
c121hains24-Jan-05 16:57
c121hains24-Jan-05 16:57 
GeneralRe: Hooks CallWndProc to get my mouse Pin
Richard Schneider26-Jan-05 1:35
Richard Schneider26-Jan-05 1:35 
Generaledit,update,insert data on datagrid Pin
koochinh22-Jan-05 14:09
koochinh22-Jan-05 14:09 
GeneralChecking a string is a number Pin
Andy *M*22-Jan-05 14:03
Andy *M*22-Jan-05 14:03 
GeneralRe: Checking a string is a number Pin
Colin Angus Mackay22-Jan-05 14:38
Colin Angus Mackay22-Jan-05 14:38 
GeneralRe: Checking a string is a number Pin
Tom John24-Jan-05 0:26
Tom John24-Jan-05 0:26 
GeneralTotal Memory Usage Pin
Alex Leshinsky22-Jan-05 13:39
Alex Leshinsky22-Jan-05 13:39 
GeneralRe: Total Memory Usage Pin
Alex Leshinsky23-Jan-05 10:37
Alex Leshinsky23-Jan-05 10:37 
GeneralRe: Total Memory Usage Pin
Dennis C. Dietrich23-Jan-05 17:22
Dennis C. Dietrich23-Jan-05 17:22 
Generallocalized dateTimepicker Pin
Jassim Rahma22-Jan-05 10:19
Jassim Rahma22-Jan-05 10:19 
Generaldesign changes in runtime!!! Pin
Jassim Rahma22-Jan-05 10:17
Jassim Rahma22-Jan-05 10:17 
GeneralRe: design changes in runtime!!! Pin
spif200123-Jan-05 20:34
spif200123-Jan-05 20:34 
GeneralRe: design changes in runtime!!! Pin
Jassim Rahma25-Jan-05 1:30
Jassim Rahma25-Jan-05 1:30 
QuestionHow to scroll a windows form? Pin
E6AD22-Jan-05 10:06
E6AD22-Jan-05 10:06 
AnswerRe: How to scroll a windows form? Pin
Stefan Troschuetz23-Jan-05 0:06
Stefan Troschuetz23-Jan-05 0:06 
Generalneed beginner's treeView help Pin
SuperStruct22-Jan-05 9:03
SuperStruct22-Jan-05 9:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.