Click here to Skip to main content
15,920,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionGetting a window that uses directdraw? Pin
Programmer_4_L1f33-Jun-05 11:07
Programmer_4_L1f33-Jun-05 11:07 
AnswerRe: Getting a window that uses directdraw? Pin
Azrael.LingChen3-Jun-05 20:23
Azrael.LingChen3-Jun-05 20:23 
GeneralGraying Out Tabs in a Property Page Pin
laiju3-Jun-05 10:38
laiju3-Jun-05 10:38 
GeneralRe: Graying Out Tabs in a Property Page Pin
David Crow3-Jun-05 11:03
David Crow3-Jun-05 11:03 
GeneralNeed help resolving a deadlock Pin
Budric B.3-Jun-05 10:19
Budric B.3-Jun-05 10:19 
GeneralRe: Just found the problem Pin
Budric B.3-Jun-05 11:02
Budric B.3-Jun-05 11:02 
GeneralRe: Just found the problem Pin
Blake Miller3-Jun-05 11:08
Blake Miller3-Jun-05 11:08 
GeneralA question about CBT hook Pin
Gaetano Sferra3-Jun-05 9:10
Gaetano Sferra3-Jun-05 9:10 
I need to develop a little application to send some keystrokes to the active window, something like the On Screen Keyboard. I need to know what is the window that lose the keyboard focus when the user click on a button in my application so I tried to gain a hook (a thread hook, not a global hook) so I wrote the following routine as CBT event handler:

<br />
LRESULT CALLBACK<br />
CMainFrame::CBTProc(int nCode, WPARAM wParam, LPARAM lParam)<br />
{<br />
  LRESULT nResult;<br />
<br />
  if (nCode == HCBT_SETFOCUS)<br />
  {<br />
    m_hGaining = (HWND) wParam;<br />
    m_hLosing = (HWND) lParam;<br />
<br />
    TRACE1("HWND Gaining: %x\n", m_hGainingFocusWnd);<br />
    TRACE1("HWND Losing: %x\n", m_hLosingFocusWnd);<br />
  }<br />
<br />
  nResult = CallNextHookEx(m_hHook, nCode, wParam, lParam);<br />
<br />
  return nResult;<br />
}<br />


The problem is that when I switch (using mouse or Alt+Tab) between my application and another one such as Notepad I got this behaviour:

Switching from Notepad to my application:
HWND Gaining: 0x50558 (the handle of my application window)
HWND Losing: 0 (NULL) Confused | :confused:

Switching from my application to Notepad:
the hook procedure don't trap anything at all Confused | :confused:

What's wrong? Why I get NULL in the first case and I don't trap nothing in the second one?

Thanks

Gaetano Sferra
GeneralRe: A question about CBT hook Pin
Nilesh K.5-Jun-05 23:32
Nilesh K.5-Jun-05 23:32 
GeneralRe: A question about CBT hook Pin
Gaetano Sferra6-Jun-05 0:44
Gaetano Sferra6-Jun-05 0:44 
GeneralRe: A question about CBT hook Pin
Nilesh K.6-Jun-05 16:43
Nilesh K.6-Jun-05 16:43 
GeneralRe: A question about CBT hook Pin
Gaetano Sferra6-Jun-05 21:23
Gaetano Sferra6-Jun-05 21:23 
GeneralNeed help converting this inline asm cosf function for use in a gnu compiler Pin
FocusedWolf3-Jun-05 8:36
FocusedWolf3-Jun-05 8:36 
GeneralRe: Need help converting this inline asm cosf function for use in a gnu compiler Pin
Chris Losinger3-Jun-05 8:54
professionalChris Losinger3-Jun-05 8:54 
GeneralRe: Need help converting this inline asm cosf function for use in a gnu compiler Pin
FocusedWolf3-Jun-05 11:08
FocusedWolf3-Jun-05 11:08 
QuestionHow to know whether a device is connected to my USB port or not Pin
anukampa3-Jun-05 4:58
anukampa3-Jun-05 4:58 
AnswerRe: How to know whether a device is connected to my USB port or not Pin
Trollslayer3-Jun-05 13:14
mentorTrollslayer3-Jun-05 13:14 
AnswerRe: How to know whether a device is connected to my USB port or not Pin
FlyingTinman3-Jun-05 14:36
FlyingTinman3-Jun-05 14:36 
GeneralCComboBox selection state before CBN_SELCHANGE Pin
stevy823-Jun-05 4:24
stevy823-Jun-05 4:24 
GeneralRe: CComboBox selection state before CBN_SELCHANGE Pin
David Crow3-Jun-05 5:28
David Crow3-Jun-05 5:28 
GeneralMonitoring opened files Pin
0908869039@seznam.cz3-Jun-05 3:37
0908869039@seznam.cz3-Jun-05 3:37 
GeneralRe: Monitoring opened files Pin
David Crow3-Jun-05 4:03
David Crow3-Jun-05 4:03 
Generalplatform Win32 title bar Pin
camoguard3-Jun-05 2:51
camoguard3-Jun-05 2:51 
GeneralFlickering Pin
Dennis L3-Jun-05 2:29
Dennis L3-Jun-05 2:29 
GeneralRe: Flickering Pin
David Crow3-Jun-05 2:43
David Crow3-Jun-05 2:43 

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.