News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Cancel Button (X)

Started by herge, October 01, 2008, 07:05:19 AM

Previous topic - Next topic

herge


Hi There:

I am trying to get the X button to work.
So I don't have to press ok a hundred
times.



      invoke MessageBox, NULL, addr dtbuf, addr AppName, MB_OK
      cmp  dword ptr [esp+2*4],  MB_OK
      jz    Exit
Skip:     
      pop   esi
      add   esi, 4
      pop   ecx
      jmp   Next

Exit:



Any suggestions please.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

donkey

You can use MB_OKCANCEL and create a messagebox with a cancel button on it, then test the return value for either IDOK or IDCANCEL(1 and 2 respectively). The close button [X] returns 1 so it is the same as IDOK when only an OK button is used, when a Cancel button is added the return value from the close button is 2 (Cancel)
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

herge


Hi donkey:

Thanks.

Houston We Have Lift Off!


      invoke MessageBox, NULL, addr dtbuf, addr AppName, MB_OKCANCEL
      cmp  eax, 2
      jz    Exit



I was getting tired of hitting ok a hundred times or
rearranging the data. This will save my fingers.
I will have to make a proper window but I think
we will leave that for another day.

Regards herge
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

kero

donkey:
>The close button [X] returns 1 so it is the same as IDOK when only an OK button is used, when a Cancel button is added the return value from the close button is 2 (Cancel)

Info from WinXP-pro-sp2:
1) close button [X] returns 2 (IDCANCEL) always,
2) "when only an OK button is used" => id(OK button)=IDCANCEL

donkey

Quote from: kero on October 01, 2008, 11:09:47 AM
donkey:
>The close button [X] returns 1 so it is the same as IDOK when only an OK button is used, when a Cancel button is added the return value from the close button is 2 (Cancel)

Info from WinXP-pro-sp2:
1) close button [X] returns 2 (IDCANCEL) always,
2) "when only an OK button is used" => id(OK button)=IDCANCEL

Could possibly be, I wasn't aware that it would change from version to version but in XPSP3 it is definitely as I stated above, I just tested it.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

kero

>I wasn't aware that it would change from version to version but in XPSP3 it is definitely as I stated above, I just tested it.

Yes, strange MessageBox feature... Then - please, 2 questions more about Message Boxes on XPSP3:

1) GetWindowLong(hWndMsgBox,GWL_USERDATA) == 0 or not ? (sp2 => !=0)

2) PostMessage(hWndMsgBox,WM_TIMER,0,0) == PostMessage(hWndMsgBox,WM_CLOSE,0,0) or not ?  (sp2 => ==)
  (see http://www.masm32.com/board/index.php?topic=9864.0)

donkey

Hi Kero,

Since Messageboxes are modal by nature I would have to set up a threaded test application in order to send it messages, something I don't have the time for this morning but may take a look at after work, or I might just create one and send the messages from a seperate process or WinSpy, should work as well.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable