Click to See Complete Forum and Search --> : How to modify BS_PUSHBUTTON WinProc
tacky
September 20th, 2007, 10:47 AM
Hello,
I have a little problem.
I'm programming an on-screen keyboard. It is important that my form with my keyboard doesn’t get focus if I press a button on it.
The buttons are windows with BS_PUSHBUTTON style.
I solved the problem for my main window. There for I set the return value of the message WM_MOUSEACTIVATE to MA_NOACTIVATE. If I now click on my window it doesn’t get the focus.
This doesn’t work for my buttons.
Is there a possibility to cach the messages of the buttons, too, like in the main proc?
Greggle
September 20th, 2007, 08:02 PM
Have you looked into WM_KILLFOCUS and SetFocus(...)?
It's not a perfect solution. Your buttons won't be able to respond to the spacebar, which doesn't seem to be an issue if you only want buttons activated by a mouse message.
tacky
September 21st, 2007, 03:44 AM
It think this will not work as i want it. My own form is not allowed to get any focus. So if i get WM_KILLFOCUS it had a focus for a litte time.
Greggle
September 21st, 2007, 04:09 AM
I think it's impossible to click on some entity and not have it gain focus for some prescribed length of time.
And even if it does have focus 'for a little time' you can set it right back with SetFocus(...)
tacky
September 21st, 2007, 05:05 AM
As you know, I’m writing an On-Screen keyboard.
It sends the keybd_event to the focused window.
At the moment it works fine for only one exception!
If I’m writing in the address bar of the windows explorer and I’m pushing a button on my keyboard it switches the focus to my keyboard, then to the explorer and then it sends the key.
But when it is doing this switching the problem is that windows is marking the hole text in the address bar and the next char I send overwrites the marked text.
You see... just the "little time" my keyboard gets the focus is enough to let this problem appear.
I think there must be a possibility to hook into the button proc to do the same I’ve done with my main proc.
Ali Imran
September 23rd, 2007, 03:45 AM
As far I see yo uare trying to get rid of the focus rectangle that is drawn on the pushbutton when it is in focus. Am I right ? if so then better would be using BS_OWNERDRAW, where you will be able to control the buttondrawing. Secondly am not sure if subclassing a button (defining custom window procuedre for button), will solve the problem.
Besides, if you need appearance of classic stye buttons then you can use statics with WM_NOTIFY style and extended style WS_EX_DLGMODALFRAME, which will produce classic style buttons shape on static controls and when pressed they adopt style WS_EX_CLIENTEDGE, that way you will get rid of focus rectangle. And ya, you will recieve same WM_COMMND message as you are recieveing on pushbuttons. Let me know if this can help, so I provide you little code.
regards
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.