Click here to Skip to main content
16,013,082 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralProblem converting a CComBSTR to LPCTSTR with CW2CT Pin
JC Gauthier29-May-02 10:24
JC Gauthier29-May-02 10:24 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
soptest29-May-02 12:25
soptest29-May-02 12:25 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
JC Gauthier30-May-02 4:27
JC Gauthier30-May-02 4:27 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
soptest30-May-02 8:36
soptest30-May-02 8:36 
General_popen issue Pin
Stew29-May-02 9:41
Stew29-May-02 9:41 
GeneralRe: _popen issue Pin
Joaquín M López Muñoz29-May-02 9:46
Joaquín M López Muñoz29-May-02 9:46 
GeneralRe: _popen issue Pin
soptest29-May-02 9:56
soptest29-May-02 9:56 
GeneralWeird Keyboard Hooking Issue Pin
John Aldrich29-May-02 9:02
John Aldrich29-May-02 9:02 
I've got a really strange keyboard hooking issue that is causing problems between the debug and release versions of the test code, namely the debug version is working globally while the release version seems to only work within the context of the test app window. Below is the source code for the test app. Any insight into this would be greatly apprecaited.

----------------------------------------------

#include "stdafx.h"

static HHOOK KeyboardHookHandle = NULL;

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

LRESULT CALLBACK KeyboardHookProc(int code, WPARAM wParam, LPARAM lParam)
{
MessageBox(NULL, "Keystroke Detected", "Memorex", MB_OK);
return CallNextHookEx(KeyboardHookHandle, code, wParam, lParam);
}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;

wndclass.cbSize = sizeof (wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, IDI_WINLOGO);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);

wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "KeyboardHookTest";
wndclass.hIconSm = LoadIcon (NULL, IDI_WINLOGO);

RegisterClassEx (&wndclass);

hwnd = CreateWindow ("KeyboardHookTest",
"KeyboardHookingTest",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);

ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);

while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}

return msg.wParam ;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
case WM_CREATE:

KeyboardHookHandle = SetWindowsHookEx(WH_KEYBOARD, KeyboardHookProc, 0, 0);

break;

case WM_SIZE:

break;

case WM_PAINT:

break;

case WM_DESTROY:

if (KeyboardHookHandle)
UnhookWindowsHookEx(KeyboardHookHandle);
PostQuitMessage(0);

break;
}

return DefWindowProc (hwnd, iMsg, wParam, lParam);

}

----------------------------------------------
I can't seem to isolate what is causing such anomalous behavior and I also apologize for the 'messiness' of my code. Again, any help would be apprecaited.


Can you imagine Darth Maul on speed?
GeneralRe: Weird Keyboard Hooking Issue Pin
Joaquín M López Muñoz29-May-02 9:34
Joaquín M López Muñoz29-May-02 9:34 
GeneralI think I got it now Pin
Joaquín M López Muñoz29-May-02 9:40
Joaquín M López Muñoz29-May-02 9:40 
GeneralMeasureItem doesn't get called. Pin
29-May-02 9:07
suss29-May-02 9:07 
GeneralRe: MeasureItem doesn't get called. Pin
Paul M Watt29-May-02 9:22
mentorPaul M Watt29-May-02 9:22 
GeneralRe: MeasureItem doesn't get called. Pin
29-May-02 9:46
suss29-May-02 9:46 
GeneralQuestion Pin
Steve L.29-May-02 9:04
Steve L.29-May-02 9:04 
GeneralRe: Question Pin
Mauricio Ritter29-May-02 9:20
Mauricio Ritter29-May-02 9:20 
GeneralMaximum value of unsigned long Pin
Hoang Le29-May-02 8:54
Hoang Le29-May-02 8:54 
GeneralRe: Maximum value of unsigned long Pin
Joaquín M López Muñoz29-May-02 8:50
Joaquín M López Muñoz29-May-02 8:50 
GeneralRe: Maximum value of unsigned long Pin
Christopher Lord29-May-02 12:49
Christopher Lord29-May-02 12:49 
GeneralRe: Maximum value of unsigned long Pin
Michael Dunn29-May-02 17:52
sitebuilderMichael Dunn29-May-02 17:52 
GeneralRe: Maximum value of unsigned long Pin
Joaquín M López Muñoz29-May-02 19:59
Joaquín M López Muñoz29-May-02 19:59 
GeneralRe: Maximum value of unsigned long Pin
Michael Dunn29-May-02 20:24
sitebuilderMichael Dunn29-May-02 20:24 
GeneralRe: Maximum value of unsigned long Pin
Joaquín M López Muñoz29-May-02 21:52
Joaquín M López Muñoz29-May-02 21:52 
GeneralRe: Maximum value of unsigned long Pin
Mike Nordell1-Jun-02 0:54
Mike Nordell1-Jun-02 0:54 
GeneralRe: Maximum value of unsigned long Pin
Michael Dunn1-Jun-02 6:22
sitebuilderMichael Dunn1-Jun-02 6:22 
GeneralRe: Maximum value of unsigned long Pin
Mike Nordell1-Jun-02 7:57
Mike Nordell1-Jun-02 7:57 

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.