Click here to Skip to main content
15,923,168 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHOOKs again Pin
Mustafa Demirhan10-Sep-00 10:46
Mustafa Demirhan10-Sep-00 10:46 
GeneralRe: HOOKs again Pin
Michael Dunn10-Sep-00 11:44
sitebuilderMichael Dunn10-Sep-00 11:44 
GeneralRe: HOOKs again Pin
Sam Hobbs10-Sep-00 14:55
Sam Hobbs10-Sep-00 14:55 
GeneralRe: HOOKs again Pin
Sam Hobbs10-Sep-00 15:22
Sam Hobbs10-Sep-00 15:22 
GeneralI'm new and i need help with html and all Pin
Alex98065410-Sep-00 10:26
Alex98065410-Sep-00 10:26 
GeneralRe: I'm new and i need help with html and all Pin
Philip Nicoletti10-Sep-00 12:56
Philip Nicoletti10-Sep-00 12:56 
GeneralAbout bitmaps on dialog Pin
Eq9-Sep-00 17:39
Eq9-Sep-00 17:39 
GeneralUsing HOOKs Pin
Mustafa Demirhan9-Sep-00 0:44
Mustafa Demirhan9-Sep-00 0:44 
Hello,
I am trying to use hooks to get all keyboard events but i could not achieve to compile my code. Here is the code:

<br />
LRESULT CALLBACK CWinSchedulerView::KeyboardProc(<br />
	int code,       // hook code<br />
	WPARAM wParam,  // virtual-key code<br />
	LPARAM lParam)  // keystroke-message information<br />
{<br />
	if (code < 0 || code != HC_ACTION)<br />
		return CallNextHookEx(m_hhk, code, wParam, lParam);<br />
	if (wParam == VK_F1)<br />
	{<br />
            MessageBox("F1 is pressed!");<br />
	}<br />
	return CallNextHookEx(m_hhk, code, wParam, lParam);<br />
}<br />
<br />
void CWinSchedulerView::OnDestroy() <br />
{<br />
	CFormView::OnDestroy();<br />
	UnhookWindowsHookEx(m_hhk);	<br />
}<br />

This code is compiled with no errors. However at InitDialog() the following code gives error:

<br />
HOOKPROC lpfn = MakeProcInstance(KeyboardProc, hInst);<br />
m_hhk = SetWindowsHookEx(WH_KEYBOARD,lpfn,NULL, GetCurrentThreadId());<br />


I know that MakeProcInstance is obselete in Win32. So I tried the following:
<br />
m_hhk = SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardProc,NULL, GetCurrentThreadId());<br />

But, this cannot be compiled to. The error is same:
<br />
D:\Visual C++ Projects\WinScheduler\WinSchedulerView.cpp(216) : error C2440: 'initializing' : cannot convert from '' to 'long (__stdcall *)(int,unsigned int,long)'<br />
        None of the functions with this name in scope match the target type<br />


I think i cannot give the function pointer correctly. How can i correct this error?

Thanks in advance for any help.

Mustafa Demirhan
GeneralRe: Using HOOKs Pin
Sam Hobbs9-Sep-00 17:22
Sam Hobbs9-Sep-00 17:22 
GeneralRe: Using HOOKs Pin
Marcelo Guerra26-Dec-00 6:47
Marcelo Guerra26-Dec-00 6:47 
GeneralMoney 2000 Pin
pankaj8-Sep-00 21:07
pankaj8-Sep-00 21:07 
GeneralRe: Money 2000 Pin
David Wulff10-Sep-00 10:58
David Wulff10-Sep-00 10:58 
GeneralSetWindowLong Pin
Jamie Nordmeyer8-Sep-00 14:13
Jamie Nordmeyer8-Sep-00 14:13 
GeneralRe: SetWindowLong Pin
Michael Dunn8-Sep-00 20:57
sitebuilderMichael Dunn8-Sep-00 20:57 
GeneralRe: SetWindowLong Pin
Jamie Nordmeyer11-Sep-00 7:55
Jamie Nordmeyer11-Sep-00 7:55 
GeneralRe: SetWindowLong Pin
Michael Dunn11-Sep-00 8:16
sitebuilderMichael Dunn11-Sep-00 8:16 
GeneralRe: SetWindowLong Pin
Sam Hobbs11-Sep-00 17:50
Sam Hobbs11-Sep-00 17:50 
GeneralRich Edit Question Pin
Mihalcik8-Sep-00 8:25
sussMihalcik8-Sep-00 8:25 
GeneralMDI Child Window Pin
Jamie Nordmeyer8-Sep-00 7:46
Jamie Nordmeyer8-Sep-00 7:46 
GeneralRe: MDI Child Window Pin
Sam Hobbs8-Sep-00 8:34
Sam Hobbs8-Sep-00 8:34 
GeneralRe: MDI Child Window Pin
Jamie Nordmeyer8-Sep-00 8:44
Jamie Nordmeyer8-Sep-00 8:44 
GeneralRe: MDI Child Window Pin
Jamie Nordmeyer8-Sep-00 8:49
Jamie Nordmeyer8-Sep-00 8:49 
GeneralRe: MDI Child Window Pin
Sam Hobbs8-Sep-00 9:01
Sam Hobbs8-Sep-00 9:01 
GeneralDll programming... Linker Error Pin
thedogbear8-Sep-00 5:52
thedogbear8-Sep-00 5:52 
GeneralRe: Dll programming... Linker Error Pin
Chris Meech8-Sep-00 8:09
Chris Meech8-Sep-00 8:09 

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.