Click here to Skip to main content
16,004,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using MSXML APIs in C++ program Pin
jhwurmbach22-Aug-07 7:44
jhwurmbach22-Aug-07 7:44 
QuestionHow to pass dynamic array from SDI Document to Dialog ComboBox? Pin
penny black22-Aug-07 7:21
penny black22-Aug-07 7:21 
AnswerRe: How to pass dynamic array from SDI Document to Dialog ComboBox? Pin
David Crow22-Aug-07 7:33
David Crow22-Aug-07 7:33 
AnswerRe: How to pass dynamic array from SDI Document to Dialog ComboBox? Pin
Maximilien22-Aug-07 7:37
Maximilien22-Aug-07 7:37 
AnswerRe: How to pass dynamic array from SDI Document to Dialog ComboBox? Pin
jhwurmbach22-Aug-07 7:38
jhwurmbach22-Aug-07 7:38 
AnswerRe: How to pass dynamic array from SDI Document to Dialog ComboBox? Pin
penny black22-Aug-07 7:51
penny black22-Aug-07 7:51 
GeneralRe: How to pass dynamic array from SDI Document to Dialog ComboBox? Pin
Iain Clarke, Warrior Programmer22-Aug-07 12:24
Iain Clarke, Warrior Programmer22-Aug-07 12:24 
QuestionHelp with Hook Pin
act_x22-Aug-07 7:04
act_x22-Aug-07 7:04 
I am trying to create a System Wide hook to listen to Window Creation events in the system .

For this purpose , I set up a new Project - > an regular MFC DLL

I have created SHARED regions where I Store the hook id created , the module and the HOOKPROC values .

The problem is that I am still not able to intercept any Window Creation Events .

Clearly am missing something

Help is appreciated.

Below is the main code of my DLL

<br />
// HookEg.cpp : Defines the initialization routines for the DLL.<br />
//<br />
<br />
#include "stdafx.h"<br />
#include "HookEg.h"<br />
#include "HookCommon.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
<br />
<br />
#pragma data_seg(".SHARED")<br />
<br />
HHOOK hookid = 0; // id of the created Hook <br />
HINSTANCE mod =NULL; // DLL module <br />
HOOKPROC proc =NULL; // Function pointer to Hook Procedure <br />
<br />
#pragma data_seg()<br />
#pragma comment(linker, "/section:.SHARED,rws")<br />
<br />
<br />
	 static LRESULT CALLBACK ShellProc(int nCode,WPARAM wParam,LPARAM lParam)<br />
	{		<br />
		TRACE("Shell message rcvd nCode = %d wParam = %d lParam=%d \n",nCode,wParam,lParam);<br />
		if(nCode == HSHELL_WINDOWCREATED )<br />
		{<br />
			TRACE("new window created \n");<br />
		<br />
		}<br />
		else if(nCode == HSHELL_WINDOWDESTROYED)<br />
		{			<br />
		<br />
		}<br />
		<br />
		return CallNextHookEx(hookid, nCode, wParam, lParam); <br />
	}<br />
<br />
<br />
//<br />
//	Note!<br />
//<br />
//		If this DLL is dynamically linked against the MFC<br />
//		DLLs, any functions exported from this DLL which<br />
//		call into MFC must have the AFX_MANAGE_STATE macro<br />
//		added at the very beginning of the function.<br />
//<br />
//		For example:<br />
//<br />
//		extern "C" BOOL PASCAL EXPORT ExportedFunction()<br />
//		{<br />
//			AFX_MANAGE_STATE(AfxGetStaticModuleState());<br />
//			// normal function body here<br />
//		}<br />
//<br />
//		It is very important that this macro appear in each<br />
//		function, prior to any calls into MFC.  This means that<br />
//		it must appear as the first statement within the <br />
//		function, even before any object variable declarations<br />
//		as their constructors may generate calls into the MFC<br />
//		DLL.<br />
//<br />
//		Please see MFC Technical Notes 33 and 58 for additional<br />
//		details.<br />
//<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
// CHookEgApp<br />
<br />
BEGIN_MESSAGE_MAP(CHookEgApp, CWinApp)<br />
	//{{AFX_MSG_MAP(CHookEgApp)<br />
		// NOTE - the ClassWizard will add and remove mapping macros here.<br />
		//    DO NOT EDIT what you see in these blocks of generated code!<br />
	//}}AFX_MSG_MAP<br />
END_MESSAGE_MAP()<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
// CHookEgApp construction<br />
<br />
CHookEgApp::CHookEgApp()<br />
{<br />
	// TODO: add construction code here,<br />
	// Place all significant initialization in InitInstance<br />
}<br />
<br />
/////////////////////////////////////////////////////////////////////////////<br />
// The one and only CHookEgApp object<br />
<br />
CHookEgApp theApp;<br />
<br />
BOOL CHookEgApp::InitInstance() <br />
{<br />
<br />
	<br />
	return CWinApp::InitInstance();<br />
}<br />
<br />
int CHookEgApp::ExitInstance() <br />
{<br />
	// TODO: Add your specialized code here and/or call the base class<br />
	if(hookid)<br />
	{<br />
		if(UnhookWindowsHookEx(hookid))<br />
			hookid = 0; <br />
		else<br />
			TRACE("Error = %d\n",GetLastError());<br />
		//return (hookid ==0);<br />
	}<br />
	<br />
	return CWinApp::ExitInstance();<br />
}<br />
<br />
<br />
HOOKEG_API void  HookegInit() <br />
{<br />
<br />
		// TODO: Add your specialized code here and/or call the base class<br />
	hookid = 0;<br />
	<br />
	mod = GetModuleHandle("HookEg.dll"/*strDLLPath*/);<br />
	//delete [] strDLLPath ; <br />
	//strDLLPath = NULL ; <br />
	<br />
	proc = ShellProc;<br />
	<br />
	hookid = SetWindowsHookEx(WH_SHELL , proc , mod , NULL);<br />
	<br />
<br />
}<br />
<br />

AnswerRe: Help with Hook Pin
PJ Arends22-Aug-07 9:10
professionalPJ Arends22-Aug-07 9:10 
GeneralRe: Help with Hook Pin
act_x22-Aug-07 13:45
act_x22-Aug-07 13:45 
Question[VC8] Picture Control always above OK/CANCEL buttons. Need buttons above picture control Pin
abiemann22-Aug-07 6:59
abiemann22-Aug-07 6:59 
AnswerRe: [VC8] Picture Control always above OK/CANCEL buttons. Need buttons above picture control Pin
Mark Salsbery22-Aug-07 7:18
Mark Salsbery22-Aug-07 7:18 
GeneralRe: [VC8] Picture Control always above OK/CANCEL buttons. Need buttons above picture control Pin
abiemann22-Aug-07 8:00
abiemann22-Aug-07 8:00 
GeneralRe: [VC8] Picture Control always above OK/CANCEL buttons. Need buttons above picture control Pin
Mark Salsbery22-Aug-07 8:05
Mark Salsbery22-Aug-07 8:05 
GeneralRe: [VC8] Picture Control always above OK/CANCEL buttons. Need buttons above picture control Pin
abiemann22-Aug-07 10:08
abiemann22-Aug-07 10:08 
GeneralRe: [VC8] Picture Control always above OK/CANCEL buttons. Need buttons above picture control Pin
Mark Salsbery22-Aug-07 10:21
Mark Salsbery22-Aug-07 10:21 
GeneralRe: [VC8] Picture Control always above OK/CANCEL buttons. Need buttons above picture control Pin
Mark Salsbery22-Aug-07 10:50
Mark Salsbery22-Aug-07 10:50 
QuestionHow to Display the Value of a member varible in message box Pin
saravana00122-Aug-07 5:49
saravana00122-Aug-07 5:49 
AnswerRe: How to Display the Value of a member varible in message box Pin
Iain Clarke, Warrior Programmer22-Aug-07 6:12
Iain Clarke, Warrior Programmer22-Aug-07 6:12 
AnswerRe: How to Display the Value of a member varible in message box Pin
ThatsAlok22-Aug-07 21:24
ThatsAlok22-Aug-07 21:24 
QuestionCMyMenu::DrawItem() - how change background color? Pin
Cris22-Aug-07 4:58
Cris22-Aug-07 4:58 
AnswerRe: CMyMenu::DrawItem() - how change background color? Pin
Cris23-Aug-07 2:16
Cris23-Aug-07 2:16 
QuestionCapture yahoo mail Pin
karthipollachi@gmail.com22-Aug-07 4:54
karthipollachi@gmail.com22-Aug-07 4:54 
AnswerRe: Capture yahoo mail Pin
led mike22-Aug-07 5:06
led mike22-Aug-07 5:06 
QuestionRe: Capture yahoo mail Pin
David Crow22-Aug-07 6:33
David Crow22-Aug-07 6:33 

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.