Click here to Skip to main content
15,915,509 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: The Boss and the Worker Pin
Rozis22-Jan-10 12:05
Rozis22-Jan-10 12:05 
Questionc++ integration subroutine. Pin
mrby12321-Jan-10 12:50
mrby12321-Jan-10 12:50 
AnswerRe: c++ integration subroutine. Pin
Mattias G21-Jan-10 12:55
Mattias G21-Jan-10 12:55 
GeneralRe: c++ integration subroutine. Pin
mrby12321-Jan-10 13:05
mrby12321-Jan-10 13:05 
GeneralRe: c++ integration subroutine. Pin
Mattias G21-Jan-10 13:21
Mattias G21-Jan-10 13:21 
QuestionCompiling an assembly file with Visual Studio Pin
Jim Crafton21-Jan-10 8:44
Jim Crafton21-Jan-10 8:44 
AnswerRe: Compiling an assembly file with Visual Studio Pin
Jim Crafton21-Jan-10 8:47
Jim Crafton21-Jan-10 8:47 
QuestionDialog hang Pin
Member 686483921-Jan-10 8:22
Member 686483921-Jan-10 8:22 
Hi all

i am get guide from codeproject and codeguru for create dll WH_KEYBOARD. Code is here
// Testdll.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "Testdll.h"

#pragma data_seg(".HOOKDATA")//Shared data among all instances.
HHOOK hook = NULL;
HWND hwnd = NULL;
#pragma data_seg()

#pragma comment(linker, "/SECTION:.HOOKDATA,RWS")//linker directive

HINSTANCE hinstance = NULL;

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }

	hinstance = (HINSTANCE)hModule;
	hook = NULL;

    return TRUE;
}

Testdll_API void installhook(HWND h)
{
	hook = NULL;
	hwnd = h;
	hook = SetWindowsHookEx(WH_KEYBOARD,hookproc,hinstance,NULL);
	if(hook==NULL)
		MessageBox(NULL,"Unable to install hook","Error!",MB_OK);
}
Testdll_API void removehook()
{
	UnhookWindowsHookEx(hook);
}


Testdll_API LRESULT CALLBACK hookproc(int ncode,WPARAM wparam,LPARAM lparam)
{
	if(ncode>=0)
	{
		if((lparam & 0x80000000) == 0x00000000)//Check whether key was pressed(not released).
		{
			hwnd = FindWindow("#32770","TestDialog");//Find application window handle
			PostMessage(hwnd,WM_USER+755,wparam,lparam);//Send info to app Window.
		}
	}
	return ( CallNextHookEx(hook,ncode,wparam,lparam) );//pass control to next hook in the hook chain.
}

// Testdll.h : Defines the entry point for the DLL application.
//

#ifdef TESTDLL_EXPORTS
#define TESTDLL_API __declspec(dllexport)
#else
#define TESTDLL_API __declspec(dllimport)
#endif

TESTDLL_API void installhook(HWND h);//This function installs the Keyboard hook.
TESTDLL_API void removehook();//This function removes the previously installed hook.
TESTDLL_API LRESULT CALLBACK hookproc(int ncode,WPARAM wparam,LPARAM lparam);//This function is called when the keyboard is operated.


It is compile successful.
Now i am using this dll in testdlg.Then dialog hang.
installhook(this->GetSafeHwnd());

Can any one tell me where i am wromg.
Plz help me
AnswerRe: Dialog hang Pin
Mattias G21-Jan-10 12:39
Mattias G21-Jan-10 12:39 
GeneralRe: Dialog hang Pin
Member 686483922-Jan-10 6:38
Member 686483922-Jan-10 6:38 
GeneralRe: Dialog hang Pin
Mattias G22-Jan-10 11:13
Mattias G22-Jan-10 11:13 
QuestionDisabling Entire MFC ActiveX Control Pin
wgoodwater21-Jan-10 7:47
wgoodwater21-Jan-10 7:47 
AnswerRe: Disabling Entire MFC ActiveX Control Pin
LunaticFringe21-Jan-10 8:31
LunaticFringe21-Jan-10 8:31 
GeneralRe: Disabling Entire MFC ActiveX Control Pin
wgoodwater21-Jan-10 8:33
wgoodwater21-Jan-10 8:33 
GeneralRe: Disabling Entire MFC ActiveX Control Pin
LunaticFringe21-Jan-10 8:40
LunaticFringe21-Jan-10 8:40 
QuestionCannot remove popup from CVSListbox - Help????? [modified] Pin
gamejunk21-Jan-10 7:20
gamejunk21-Jan-10 7:20 
QuestionCMFCStatusBar in ActiveX control without Title Bar Pin
wgoodwater21-Jan-10 5:33
wgoodwater21-Jan-10 5:33 
Questionmy list error! Pin
wbgxx21-Jan-10 4:54
wbgxx21-Jan-10 4:54 
AnswerRe: my list error! Pin
Cedric Moonen21-Jan-10 5:00
Cedric Moonen21-Jan-10 5:00 
QuestionRe: my list error! Pin
Maximilien21-Jan-10 5:04
Maximilien21-Jan-10 5:04 
AnswerRe: my list error! Pin
LunaticFringe21-Jan-10 5:06
LunaticFringe21-Jan-10 5:06 
AnswerRe: my list error! Pin
Richard MacCutchan21-Jan-10 5:09
mveRichard MacCutchan21-Jan-10 5:09 
AnswerRe: my list error! Pin
David Crow21-Jan-10 9:04
David Crow21-Jan-10 9:04 
Questionwhat is the difference between ..? Pin
krish_kumar21-Jan-10 4:06
krish_kumar21-Jan-10 4:06 
AnswerRe: what is the difference between ..? Pin
Cedric Moonen21-Jan-10 4:17
Cedric Moonen21-Jan-10 4:17 

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.