Click here to Skip to main content
15,914,225 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Toolbar capture Pin
subir talukder10-Jan-01 22:02
subir talukder10-Jan-01 22:02 
GeneralRe: Toolbar capture Pin
11-Jan-01 10:12
suss11-Jan-01 10:12 
GeneralRe: Toolbar capture Pin
subir talukder11-Jan-01 21:34
subir talukder11-Jan-01 21:34 
GeneralRe: Toolbar capture Pin
11-Jan-01 23:49
suss11-Jan-01 23:49 
QuestionIs there a program to convert Borland C++ Builder components to VB 6 or MSVS 6? Pin
Chris Bunting10-Jan-01 4:02
Chris Bunting10-Jan-01 4:02 
AnswerRe: Is there a program to convert Borland C++ Builder components to VB 6 or MSVS 6? Pin
Anders Molin10-Jan-01 6:52
professionalAnders Molin10-Jan-01 6:52 
AnswerRe: Is there a program to convert Borland C++ Builder components to VB 6 or MSVS 6? Pin
Erik Funkenbusch10-Jan-01 9:35
Erik Funkenbusch10-Jan-01 9:35 
GeneralWhat's up? My hook works but my program doesn't work Pin
raul10-Jan-01 2:36
raul10-Jan-01 2:36 
Hello. It's the first time i've made a program about hooks. So The program is very simple. I use a DLL. The keys pressed buy the user will be saved in a small Buffer till the user press ESC. Then the program should show the Buffer and stop.


Here is the DLL
_______________




#include <windows.h>
#include "Definiciones.h"

#pragma data_seg(".DATOS_COMPARTIDOS_DE_LA_DLL")
HHOOK hHookDLL = NULL;//

#pragma data_seg()

char Buffer[100] ="";
BOOL Bandera = FALSE;

BOOL WINAPI DllMain (HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
{

switch(fdwReason)

{

case DLL_PROCESS_ATTACH:




if (lpReserved)
{

if ( hHookDLL ) // Si ya se consigió el handle, salir
return FALSE;

hHookDLL = SetWindowsHookEx( WH_KEYBOARD, (HOOKPROC)KeyboardProc, hInstDLL, GetWindowThreadProcessId(GetActiveWindow(),NULL));
}


return TRUE;

case DLL_THREAD_ATTACH:

return TRUE;

case DLL_THREAD_DETACH:

return TRUE;

case DLL_PROCESS_DETACH:

if ( hHookDLL )
{
UnhookWindowsHookEx( hHookDLL );
hHookDLL = NULL;

}


}

return TRUE;

}



LRESULT CALLBACK KeyboardProc(
int idHook, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{


if (idHook < 0)
{
return (CallNextHookEx(hHookDLL, idHook, wParam, lParam));
}



else
{



LRESULT r =CallNextHookEx(hHookDLL, idHook, wParam, lParam);

if ((wParam >= 48) && (GetKeyState(wParam) &0xF0))//
{
Bandera = TRUE;
if (strlen(Buffer) < 100)
{

Buffer[strlen(Buffer)]= (char) wParam;
Buffer[strlen(Buffer)+1] = 0;
}
}



if (wParam == VK_ESCAPE)
{
Bandera = TRUE;//<-----------THE PROGRAM SEEMS NOT TO
//<----------- CHECK THE NEW STATE
MessageBox(NULL,Buffer,"Pressed ESC",MB_OK);


}

return(r);
}
}

int RetornaBandera(void)//returns true or false that's all
{
return Bandera;
}





Here is the program which loads statically the DLL
__________________________________________________

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
while(!RetornaBandera())//An exported function from the DLL which SHOULD
//return ESC was pressed

return 0;
}



Raúl
GeneralPlay one video file in several windows simultaneously Pin
10-Jan-01 2:32
suss10-Jan-01 2:32 
GeneralUrgent Exception in GetString of ADODB.Recordsset Pin
Alpesh10-Jan-01 1:24
Alpesh10-Jan-01 1:24 
GeneralSound Pin
10-Jan-01 0:58
suss10-Jan-01 0:58 
QuestionCListCtrl and noresize columns ???? Pin
10-Jan-01 0:33
suss10-Jan-01 0:33 
AnswerRe: CListCtrl and noresize columns ???? Pin
10-Jan-01 21:50
suss10-Jan-01 21:50 
QuestionActiveX controls belong in Doc or View? Pin
Brendan Tregear9-Jan-01 11:01
Brendan Tregear9-Jan-01 11:01 
AnswerRe: ActiveX controls belong in Doc or View? Pin
Erik Funkenbusch9-Jan-01 12:20
Erik Funkenbusch9-Jan-01 12:20 
Generalstd::string and unicode Pin
Anders Molin9-Jan-01 8:52
professionalAnders Molin9-Jan-01 8:52 
GeneralRe: std::string and unicode Pin
Chad Plautz9-Jan-01 9:32
Chad Plautz9-Jan-01 9:32 
GeneralRe: std::string and unicode Pin
Chad Plautz9-Jan-01 9:38
Chad Plautz9-Jan-01 9:38 
GeneralRe: std::string and unicode Pin
Anders Molin9-Jan-01 21:02
professionalAnders Molin9-Jan-01 21:02 
QuestionHow do I force my program to check the message queue? Pin
Paul Auger9-Jan-01 6:35
Paul Auger9-Jan-01 6:35 
AnswerRe: How do I force my program to check the message queue? Pin
9-Jan-01 7:10
suss9-Jan-01 7:10 
GeneralCWnd - HWnd Map Related problem Pin
9-Jan-01 2:54
suss9-Jan-01 2:54 
GeneralHICON to .ico File Pin
8-Jan-01 23:17
suss8-Jan-01 23:17 
Questionhow to display a GIF image by programming? Pin
8-Jan-01 20:02
suss8-Jan-01 20:02 
AnswerRe: how to display a GIF image by programming? Pin
Jim Howard9-Jan-01 7:52
Jim Howard9-Jan-01 7:52 

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.