|
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)
Switching from my application to Notepad:
the hook procedure don't trap anything at all
What's wrong? Why I get NULL in the first case and I don't trap nothing in the second one?
Thanks
Gaetano Sferra
|
|
|
|
|
In a call to SetWindowsHookEx(), set the last parameter as '0' This would associate hook with all the existing threads.
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Nilesh K. wrote:
In a call to SetWindowsHookEx(), set the last parameter as '0' This would associate hook with all the existing threads.
Looking into the MSDN, in the SetWindowsHookEx explaination I see the following:
lpfn
[in] Pointer to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
If I set the last parameter of the SetWindowsHookEx() (dwThradId) to 0 I cannot provide a pointer to an hook procedure that reside in the my application process as shown in my previous post, I shoud build a DLL.
My questions are:
Can I obtain a handle to the window losing the keyboard focus without use a global hook (a hook procedure in a DLL)?
Why when my application window lose the ketyboard focus the hook procedure isn't called? (It should trap a CBT event with the lParam set to the handle to my application window)
Why when my application window gain the keyboard focus I got NULL as handle to the window losing the keyboard focus? (I should get the correct handle because the CBT event destination is the my application process)
If my interpretation of MSDN or my deductions are wrong, please correct me.
Thanks
Gaetano Sferra
|
|
|
|
|
I doubt it would be possible without global hook procedure.
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Thank you Nilesh,
I will begin a DLL development to handle it.
Gaetano Sferra
|
|
|
|
|
inline float FastCosF(float value)<br />
{<br />
#ifdef Im_In_VisualStudio<br />
<br />
__asm<br />
{<br />
fld value;<br />
fcos;<br />
fstp value;<br />
}<br />
<br />
#else //in GNU compiler<br />
<br />
<br />
#endif<br />
<br />
return value;<br />
}<br />
Through googling i got this: asm ("fsin" : "=t" (value) : "0" (value));
but i don't think it works
|
|
|
|
|
which CPU are you targeting?
i think the author of that bit is assuming anyone using Visual Studio compiler is going to be making EXEs for use on Pentium (and compatible) processors. but since gcc is used on many different architectures, not just Pentiums, you can't make the same assumption - and you'll have to pick a processor(s) to write for.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hmm i didn't consider that...shows how much i know about asm. Looks like for sake of multiplatform im just gonna have to use the built in math functions.
|
|
|
|
|
Please help me in writing a code to know whether a webcam is attached to any USB port or not? This is very urgent
Thanking you
anukampa
|
|
|
|
|
The easiest way would probably be to use the driver for that device to check it's status.
Elaine
The tigress is here
|
|
|
|
|
If the webcam has a valid driver installed you just
need to enumerate connected video devices and look
for a "friendlyname" that matches that of your webcam.
Look at AMCAP source code (in the DirectShow SDK samples)
for details of how to do that. AMCAP enumerates all
connected video devices and lists their "friendlyname"s
in a menu from which the user can select one.
Steve T
|
|
|
|
|
I need to know the Combobox selection that was before the user changed the selection.
If I use
OnChangeCbXXX() {<br />
int selection = m_cbXXX.GetCurSel()<br />
}
then selection holds the new value. How to get the value before the change???
|
|
|
|
|
Just create another member variable that defaults to -1. On the CBN_SELCHANGE handler, do something like:
OnChangeCbXXX()
{
int selection = m_cbXXX.GetCurSel();
TRACE("Previous selection = %d\n", m_prevsel);
TRACE(" Current selection = %d\n", selection);
m_prevsel = selection;
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
How can I find out opened files on LAN ? I would like to use it in my app. I mean this Computer management->System tools->Shared folders->Open files
|
|
|
|
|
See here and here for possibilities.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have a window with a standard title bar (or caption bar) with the standard trio of Minimize, Max/Restore, and Close(SYSMENU) pushbuttons. Specifically, I have this window start maximized by sending myself a WM_SIZE message or by using the WS_MAXIMIZE style on creation. It looks great, but it isn't maximized. It can be moved by dragging the title bar, and I want the maximize button to be the restore button. More generally, I would like to know more about how to interact with a windows default title bar. I am not currently using MFCs in an effort to better understand the effort required to program for windows without MFCs. Any references to better references on the subject of title bar "maintenance" are also helpful.
|
|
|
|
|
Hi all!
How could I stop flickering in a list view control?
|
|
|
|
|
I assume the flickering is happening while items are being added to the control. If so, try calling SetRedraw(FALSE) beforehand.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
No!, it's happening when I resize the window.
|
|
|
|
|
Hello people,
I'm having a very weird problem at the moment and I can't figure it out. Here's the situation;
- I have a normal dialog (CDialog class) with a groupbox on it.
- Inside the groupbox, I create a CPropertySheet like this:
CWnd* pWnd = GetDlgItem(IDC_ST_TAB);
m_propSheet.Create(pWnd, WS_CHILD | WS_VISIBLE);
m_propSheet.SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
where IDC_ST_TAB is the ID of the groupbox and m_propSheet is a CPropertySheet object.
- Before I call create, I add several pages. All pages show fine.
- On one of the pages contains a custom listbox, this listbox has a popup menu on right click. The popup menu shows fine.
- When an item in the popup menu is clicked, it SHOULD pop up another dialog (again a CDialog class). It does seem to load the dialog, but never shows it! It hangs on DoModal().
Now here's the weird thing; when I change the m_propSheet.Create to say WS_POPUP or just nothing instead of WS_CHILD, I get a floating property sheet and then the dialogs DO pop up properly...
What am I missing here? All property sheets are also set as child in the resource (but I don't think it matters).
|
|
|
|
|
I have used a "Forms 2.0 ActiveX control" in my first piece of software created with VC++ 6.0. Unfortunalty my software will not run on a system unless MS Office is installed. What have I done wrong!!!
Can I include the nessesary files in my application to make my software run on a system without MS Office.
Thanxs
|
|
|
|
|
Normally what you should do is supply the ActiveX with your program (but check for license and everything cause that's not my field, I'm just a programmer that don't care about licenses ). Then you will need to register it using regsvr32.
Probably that this ActiveX is used by Office thus it is already installed with Office..
|
|
|
|
|
I thought I had!!!
The component is fm20.dll normally found in Windows\System32. It came from the Registered ActiveX Controls gallery found under "Add to project, Components and controls, ".
How should I supply the control with my program?
Thanxs, for your help. Sorry for the questions but I am new to this!
|
|
|
|
|
avs4 wrote:
How should I supply the control with my program?
You will need to make an installation programm that will check if the ActiveX is already there or not. If not it has to copy it in Window\System32 and register it. For installation program, you can use InstallShield but I don't have a lot of knowledge there. Or of course you can also copy and register it manually but I don't know if this is a good solution
By the way, fm20.dll, is not an ActiveX but a dll. ActiveX have the .ocx extention. So maybe you are looking at the wrong file...
[EDIT] Also, do you say that your application won't run. But what is happening ? Simply nothing when you start your application or do you get an error message ? [\EDIT]
|
|
|
|
|
When I click my icon to start the program, nothing happens, no error message, nothing. If fm20.dll is installed in the system32 directory the program runs.
It is the correct file, the control is in the VC6.0 gallery under registered ActiveX controls. The path to the control indicates "System32\FM20.DLL".
Is there no easy way to include this .DLL in my project?
Thanxs for your help.
|
|
|
|