News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MessageBox changes the focus from edit control to main window

Started by jj2007, December 06, 2022, 09:42:22 AM

Previous topic - Next topic

jj2007

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.

hutch--


      .case WM_SETFOCUS
        invoke SetFocus,hEdit

jj2007

Quote from: hutch-- on December 06, 2022, 04:28:34 PM

      .case WM_SETFOCUS
        invoke SetFocus,hEdit

That works fine :thumbsup:

(as long as you have only one edit control)

hutch--

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.

HSE

You can subclass all edits, and store the handle in a global variable (lastEdit) when they receive WM_SETFOCUS.  :thumbsup:
Equations in Assembly: SmplMath

TimoVJL

May the source be with you

jj2007

Quote from: HSE on December 06, 2022, 11:04:17 PM
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 :winking:


HSE

Quote from: jj2007 on December 06, 2022, 11:50:17 PM
I've already implemented a more straightforward mechanism

:thumbsup: but that can return focus in other controls.
Equations in Assembly: SmplMath




jj2007

Quote from: HSE on December 07, 2022, 12:05:51 AM
:thumbsup: but that can return focus in other controls.
Quote from: HSE on December 07, 2022, 01:50:55 AM
      :biggrin: :biggrin: :biggrin:

Quote from: jj2007 on December 07, 2022, 12:06:57 AM
How that?

Quote from: jj2007 on December 06, 2022, 11:23:31 AM
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.

hutch--

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 !

jj2007

Quote from: hutch-- on December 07, 2022, 08:47:50 AM
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.

HSE

Quote from: jj2007 on December 07, 2022, 03:56:00 AM
You love criticising,

I'm a professional  :thumbsup:

Quote from: jj2007 on December 07, 2022, 03:56:00 AM
but you rarely prove your points.

Some times is better that who receive the critic find the way, and I know You can  :biggrin:

Quote from: jj2007 on December 07, 2022, 03:56:00 AM
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):
Equations in Assembly: SmplMath