|
do you have child controls on your main window??
Regards,
Sandip.
|
|
|
|
|
I have child controls on the main window.
danginkgo
|
|
|
|
|
then probably WM_KILLFOCUS is for one of the child window which was having focus earlier.
Check the vlaue of wParam in WM_KILLFOCUS. It is a handle to new window which will get the focus.
You can verify that WM_KILLFOCUS was not for your main window by comparing wParam with your main window handle.
And to find which window lost the focus check value of wParam in WM_SETFOCUS.
Regards,
Sandip.
|
|
|
|
|
OK, but if the main window loses focus, doesn't it get the WM_KILLFOCUS message? I just have to unregister some hotkeys if the window loses focus. How can I do that?
danginkgo
|
|
|
|
|
How can I know when the main window loses focus?
danginkgo
|
|
|
|
|
I dont have much idea about SDK, but Try this I hope it works,
WM_SETFOCUS: if the wParam is handle to your main window then it means that your window has lost the focus. (Unregister ur hot keys)
WM_KILLFOCUS: if wParam is handle to your main window then it means that your window is going to get the focus (register your hot keys).
If this doesnt work may be some one can correct as i am really not sure.
Ohh I forgot about HWND parameter of WindowProc.
I guess It will point to your main window whenever whenever WM_KILLFOCUS will be generated for it and similarly for SetFocus.
Regards,
Sandip.
modified on Tuesday, June 24, 2008 5:07 AM
|
|
|
|
|
I tried but it doesn't work.
For WM_SETFOCUS and WM_KILLFOCUS , the wParam is not the main window HWND.
Ex.
wParam = 0x000209fc
This->hwndView = 0x000209ee
hWnd = 0x000209ee (HWND parameter of WindowProc)
So, I can't register and unregister if I get those messages.
danginkgo
|
|
|
|
|
did you manage to get it working it or not can you paste some code snippets for the same.
Regards,
Sandip.
|
|
|
|
|
This is the callback function for the main (view) window:
<br />
<br />
LRESULT CALLBACK FldViewWndProc (HWND hWnd,<br />
UINT wMessage,<br />
WPARAM wParam,<br />
LPARAM lParam){<br />
PluginInstance* This;<br />
................................................<br />
case WM_KILLFOCUS:<br />
This = (PluginInstance*) GetWindowLong(hWnd, 0);<br />
if((HWND)wParam==This->hwndView)<br />
register hotkeys<br />
break;<br />
<br />
<br />
case WM_SETFOCUS:<br />
This = (PluginInstance*) GetWindowLong(hWnd, 0);<br />
if((HWND)wParam==This->hwndView)<br />
unregister hotkeys<br />
break;<br />
..................................................<br />
}<br />
danginkgo
|
|
|
|
|
are you getting the same values in both cases you mentioned in your previous reply.
Regards,
Sandip.
|
|
|
|
|
yes, the same values
danginkgo
|
|
|
|
|
In the documentation I found that the wParam for WM_KILLFOCUS is the window handler for the window that receive focus, so I'll get this message in the WindowProc function if I click on the main window.
So, I can't use this message, because I want to unregister the hotkeys when the main window loses focus, not immediately before it gains focus.
Is it wright what I wrote?
danginkgo
modified on Tuesday, June 24, 2008 7:31 AM
|
|
|
|
|
The problem is I don't get any message in WindowProc if the window loses focus.
danginkgo
|
|
|
|
|
Hi
I tried it in a sample application
1> Main window with two edit controls.
2> In WM_LBUTTONDOWN i called SetFocus(hWnd);
I noticed is that if i dont call setfocus explicitly i dont get the WM_SETFOCUS notification.
and moreover when i switch between the two edit control i dont get any notification.
may be you can try something like following. i dont see any need of using GetWindowLong.
case WM_LBUTTONDOWN:
SetFocus(hWnd);
break;
case WM_KILLFOCUS:
unregisterkeys;
break;
case WM_SETFOCUS:
registerkeys;
break;
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
My code is exactly like what you wrote.
The problem is I don't get the WM_KILLFOCUS message only when I return to the app window. If the focus is on the app window and I go to other window then I don't get any message.
danginkgo
|
|
|
|
|
No when i go from app window to edit control i get the WM_KILLFOCUS notifiction.
also when i call SetFocus() i do get WM_SETFOCUS notification.
Regards,
Sandip.
|
|
|
|
|
It works now. It seems that the problem was that I called MessageBox() function in my code with wrong HWND. That massed up the messages.
I took it out of the code and it works fine.
Thank you very much for your help.
danginkgo
|
|
|
|
|
Good its working now You are welcome .
Regards,
Sandip.
|
|
|
|
|
Check from which window you get these messages.
Greetings from Germany
|
|
|
|
|
danginkgo wrote: I want to register some values when the window has keyboard focus and unregister the values when the window looses focus.
It sounds like you need to use WM_ACTIVATEAPP instead.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I tried using WM_ACTIVATEAPP message, but I don't get it in the main WindowProc function.
Do you have any suggestions?
danginkgo
|
|
|
|
|
I have a pointer to video image buffer as follows in BYTE pointer;
BYTE *pdata
now I want to overlay text on that video image .how can I achieved that task.
Ashish
|
|
|
|
|
|
It's hard to say why since you don't provide enough information, but there are many reasone that you might see the UAC prompt.
First, if your manifest file has
<requestedExecutionLevel level="requireAdministrator" /> this will force the UAC to appear for any user running the program. You can use
<requestedExecutionLevel level="asInvoker"> which allows the program to run without admin rights, and won't prompt with the UAC...
UNLESS
If your program attempts to perform a Vista restricted function (for instance, writing to a file in anywhere in the Program Files directory) then the UAC prompt will still appear.
Other causes can be the name of your executable file, contents of the VERSIONINFO resource in your .rc file and others.
Check out this thread[^] for more info - especially post #15.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
What is the priority of MFC application's GUI thread?
Regards,
Suman
--
"Programming is an art that fights back!"
|
|
|
|