Click here to Skip to main content
15,911,531 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can I make the pop-up dialog resizable ? Pin
cagespear24-Apr-08 0:12
cagespear24-Apr-08 0:12 
QuestionHow do I create a propeties file Pin
pl_kode23-Apr-08 23:46
pl_kode23-Apr-08 23:46 
GeneralRe: How do I create a propeties file Pin
Saurabh.Garg24-Apr-08 2:17
Saurabh.Garg24-Apr-08 2:17 
Generalwin32 openssl based client socket application [modified] Pin
amit_pansuria23-Apr-08 23:25
amit_pansuria23-Apr-08 23:25 
GeneralRe: win32 openssl based client socket application Pin
Mark Salsbery24-Apr-08 6:26
Mark Salsbery24-Apr-08 6:26 
GeneralRe: win32 openssl based client socket application Pin
amit_pansuria25-Apr-08 19:35
amit_pansuria25-Apr-08 19:35 
GeneralRe: win32 openssl based client socket application Pin
Mark Salsbery26-Apr-08 6:22
Mark Salsbery26-Apr-08 6:22 
Questionhow to create a hook which monitors foreground windows using WinCE for Pocket PC Pin
Shashi.Shinde23-Apr-08 23:04
Shashi.Shinde23-Apr-08 23:04 
Hello,
I am new in WinCE development.
I have to create a hook which monitors foreground windows. If internet explorer window come to foreground then I have to invoke a dialog box.
For that I tried to create hook using SetWinEventHook API which is not supported directly by WinCE.
So we have to update some declarations using winuser.h (general Windows XP, Vista, etc) and have to load coredll.dll

I had tried and getting following errors –

Generating Code...
Compiling resources...
Linking...
MainFrm.obj : error LNK2019: unresolved external symbol "struct HWINEVENTHOOK__ * __cdecl SetWinEventHook(unsigned long,unsigned long,struct HINSTANCE__ *,void (__cdecl*)(struct HWINEVENTHOOK__ *,unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long),unsigned long,unsigned long,unsigned long)" (?SetWinEventHook@@YAPAUHWINEVENTHOOK__@@KKPAUHINSTANCE__@@P6AXPAU1@KPAUHWND__@@JJKK@ZKKK@Z) referenced in function "protected: int __cdecl CMainFrame::OnCreate(struct tagCREATESTRUCTW *)" (?OnCreate@CMainFrame@@IAAHPAUtagCREATESTRUCTW@@@Z)
Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\Release/ScureApp.exe : fatal error LNK1120: 1 unresolved externals

Please have a quick look on my code as follows -
my MainFrm :: OnCreate() contains

g_hHkApiDLL = LoadLibrary(_T("user32.dll"));
g_hHkApiDLLBox = LoadLibrary(_T("coredll.dll"));

if((g_hHkApiDLLBox && g_hHkApiDLL) == NULL)
{
AfxMessageBox(_T("Error to load coredll.dll"));
//something is awfully wrong
//the dll has to be present
return false;
}
else
{
//load the SetWindowsHookEx API call
//the SetWindowsHookEx function installs an application-defined hook procedure into a hook chain.
//You would install a hook procedure to monitor the system for certain types of events.
//here we use use the hook to monitor kyeboard events
LPTSTR pSetWinEventHook;
pSetWinEventHook = (LPTSTR)GetProcAddress(g_hHkApiDLLBox, _T("SetWinEventHook"));
if(pSetWinEventHook == NULL)
{
AfxMessageBox(_T("Error to install hook procedure"));
//this means that MS has really stopped supporting this API in WinCE
return false;
}
else
{
//SetWindowRetProcHook (TRUE);
// hEvtHook = SetWinEventHook (EVENT_MIN, EVENT_MAX,
hEvtHook = SetWinEventHook (EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND,
NULL, ForegroundProc, 0, 0,
WINEVENT_OUTOFCONTEXT);
}
}

My ForgroundProc as follows -

VOID CALLBACK ForegroundProc( HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd,LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime )
{
AfxMessageBox(_T("Inside ForegroundProc"));
TCHAR buf[MAX_PATH];

HWND hWndForeGroundWin = GetForegroundWindow();
if (GetClassName(hWndForeGroundWin, buf, MAX_PATH))
{
if (!_tcsicmp (buf, TEXT("IEFRAME")) ||
_tcsstr (buf, TEXT("Internet Explorer")) ||
!_tcsicmp (buf, TEXT("MozillaUIWindowClass")))
{
AfxMessageBox(TEXT("Found Internet Explorer"));
}
}
}

Also we have declared in header .h file -
HINSTANCE g_hHookApiDLL = NULL; //handle to coredll.dll, where all the hook related APIs are present
HHOOK g_hInstalledLLKBDhook = NULL; //g_hInstalledLLKBDhook represents handle to the installed KB hook
#define EVENT_SYSTEM_FOREGROUND 0x0003
#define WINEVENT_OUTOFCONTEXT 0x0000 // Events are ASYNC


typedef VOID (CALLBACK* WINEVENTPROC)(
HWINEVENTHOOK hWinEventHook,
DWORD event,
HWND hwnd,
LONG idObject,
LONG idChild,
DWORD idEventThread,
DWORD dwmsEventTime);

//typedef HWINEVENTHOOK (WINAPI *SetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);


//extern "C"
WINUSERAPI
HWINEVENTHOOK
WINAPI
SetWinEventHook(
__in DWORD eventMin,
__in DWORD eventMax,
__in_opt HMODULE hmodWinEventProc,
__in WINEVENTPROC pfnWinEventProc,
__in DWORD idProcess,
__in DWORD idThread,
__in DWORD dwFlags);

Now request you, please look into the code, and suggest me where I am getting wrong.

Thanks.

Regards,

Shashikant
AnswerRe: how to create a hook which monitors foreground windows using WinCE for Pocket PC Pin
Cedric Moonen23-Apr-08 23:13
Cedric Moonen23-Apr-08 23:13 
GeneralRe: how to create a hook which monitors foreground windows using WinCE for Pocket PC Pin
Shashi.Shinde23-Apr-08 23:41
Shashi.Shinde23-Apr-08 23:41 
GeneralRe: how to create a hook which monitors foreground windows using WinCE for Pocket PC Pin
Cedric Moonen23-Apr-08 23:50
Cedric Moonen23-Apr-08 23:50 
AnswerRe: how to create a hook which monitors foreground windows using WinCE for Pocket PC Pin
Naveen23-Apr-08 23:44
Naveen23-Apr-08 23:44 
GeneralRe: how to create a hook which monitors foreground windows using WinCE for Pocket PC Pin
Shashi.Shinde24-Apr-08 1:50
Shashi.Shinde24-Apr-08 1:50 
GeneralUsing Wuapi at visual c++ Pin
monsieur_jj23-Apr-08 22:42
monsieur_jj23-Apr-08 22:42 
GeneralFile operation Pin
Chandrasekharan P23-Apr-08 22:33
Chandrasekharan P23-Apr-08 22:33 
QuestionRe: File operation Pin
CPallini23-Apr-08 22:49
mveCPallini23-Apr-08 22:49 
GeneralRe: File operation Pin
Chandrasekharan P23-Apr-08 22:51
Chandrasekharan P23-Apr-08 22:51 
GeneralRe: File operation Pin
CPallini23-Apr-08 23:17
mveCPallini23-Apr-08 23:17 
GeneralRe: File operation Pin
David Crow24-Apr-08 3:59
David Crow24-Apr-08 3:59 
Generalpassing a value from one exe to another Pin
Le@rner23-Apr-08 22:20
Le@rner23-Apr-08 22:20 
GeneralRe: passing a value from one exe to another Pin
CPallini23-Apr-08 22:30
mveCPallini23-Apr-08 22:30 
AnswerRe: passing a value from one exe to another Pin
prasad_som24-Apr-08 2:05
prasad_som24-Apr-08 2:05 
QuestionUsername & password!! Pin
Ajay L D23-Apr-08 22:19
Ajay L D23-Apr-08 22:19 
JokeRe: Username & password!! Pin
CPallini23-Apr-08 22:24
mveCPallini23-Apr-08 22:24 
GeneralRe: Username & password!! Pin
tina->newcoder23-Apr-08 22:55
tina->newcoder23-Apr-08 22:55 

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.