The MASM Forum
General => The Workshop => Topic started by: jj2007 on December 06, 2022, 09:42:22 AM
-
I can't remember having seen that documented anywhere, but on Win7-64 at least, it's true. And it's a major nuisance :sad:
Testbed attached, pure Masm32 SDK code.
-
.case WM_SETFOCUS
invoke SetFocus,hEdit
-
.case WM_SETFOCUS
invoke SetFocus,hEdit
That works fine :thumbsup:
(as long as you have only one edit control)
-
At least you can pick which one via the handle. If you have multiple edit windows, you would need a mechanism to switch the handles to the one you are using at the time.
-
You can subclass all edits, and store the handle in a global variable (lastEdit) when they receive WM_SETFOCUS. :thumbsup:
-
WM_KILLFOCUS message
https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-killfocus
-
You can subclass all edits, and store the handle in a global variable (lastEdit) when they receive WM_SETFOCUS. :thumbsup:
Interesting idea, thanks, but I've already implemented a more straightforward mechanism in the Santa Claus edition (http://masm32.com/board/index.php?topic=94.0) :winking:
(http://www.jj2007.eu/pics/MsgBoxKeepFocus.png)
-
I've already implemented a more straightforward mechanism
:thumbsup: but that can return focus in other controls.
-
:thumbsup: but that can return focus in other controls.
How that?
-
:biggrin: :biggrin: :biggrin:
How that?
Your lack of imagination is deplorable :biggrin:
-
:biggrin: :biggrin: :biggrin:
:greensml: I knew I read that somewhere else.
-
:thumbsup: but that can return focus in other controls.
:biggrin: :biggrin: :biggrin:
How that?
Your lack of imagination is deplorable :biggrin:
Your lack of arguments, too :tongue:
Show me how the MsgBox macro could "return focus in other controls". You love criticising, but you rarely prove your points. Make an effort, demonstrate that you are decent coder.
-
The problem is so easily solved.
Set a GLOBAL variable.
As each edit control gets the focus, set its handle to that GLOBAL.
Easy, peasy, sleazy, greasy !
-
The problem is so easily solved.
Set a GLOBAL variable.
As each edit control gets the focus, set its handle to that GLOBAL.
Easy, peasy, sleazy, greasy !
That requires a handler - an overkill. My solution is short and foolproof.
-
You love criticising,
I'm a professional :thumbsup:
but you rarely prove your points.
Some times is better that who receive the critic find the way, and I know You can :biggrin:
Make an effort, demonstrate that you are decent coder.
How that?
Just in case. If you make a real program with a real interface, you can find that GetFocus don't return the Edit handle :biggrin:
Like in this little program (and is not so complex):
-
Just in case. If you make a real program with a real interface, you can find that GetFocus don't return the Edit handle :biggrin:
Like in this little program (and is not so complex):
If you don't post code, I will consider you a troll, Hector.
-
If you don't post code
Sorry, it's unplublished yet (and advance is very slow :eusa_boohoo:).
But the trick, apparently, is not a secret :biggrin:
Set a GLOBAL variable.
-
The "trick" is an overkill. Besides, I am looking forward to see a working example. I invite you to modify the simple template at the beginning of this thread - plain Masm32. Btw I do use a global variable, see here (http://www.jj2007.eu/pics/MsgBoxKeepFocus.png).
It's more complicated than you think.
The problem is so easily solved.
Set a GLOBAL variable.
As each edit control gets the focus, set its handle to that GLOBAL.
Easy, peasy, sleazy, greasy !
That requires a handler - an overkill. My solution is short and foolproof.
-
I am looking forward to see a working example. I invite you to modify the simple template at the beginning of this thread - plain Masm32. Btw I do use a global variable, see here (http://www.jj2007.eu/pics/MsgBoxKeepFocus.png).
It's more complicated than you think.
I don't see the problem:
-
Yep, you don't see the problem :thumbsup:
mov ebx, rv(GetFocus)
invoke MessageBox, 0, chr$("Focus will change"), chr$("Title"), MB_OK
push eax
invoke SetFocus, hEdit
pop eax
pop ebx
-
If you have more than one edit, you must use hEdit to store the active edit handle.
-
If you have more than one edit, you must use hEdit to store the active edit handle.
You are moving closer now :thumbsup: