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

Quote from: HSE on December 07, 2022, 09:30:32 AMJust 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.

HSE

Quote from: jj2007 on December 07, 2022, 09:36:27 AM
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:
Quote from: hutch-- on December 07, 2022, 08:47:50 AM
Set a GLOBAL variable.
Equations in Assembly: SmplMath

jj2007

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.

It's more complicated than you think.

Quote from: jj2007 on December 07, 2022, 09:05:19 AM
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, 10:04:28 AM
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.

It's more complicated than you think.

I don't see the problem:
Equations in Assembly: SmplMath

jj2007

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

HSE

If you have more than one edit, you must use hEdit to store the active edit handle.
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on December 07, 2022, 10:14:55 PM
If you have more than one edit, you must use hEdit to store the active edit handle.

You are moving closer now :thumbsup: