News:

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

How does the simplest Windows program work?

Started by bf2, October 24, 2011, 07:31:22 PM

Previous topic - Next topic

bf2

Consider a simple program like below,


INCLUDE \masm32\include\masm32rt.inc

.DATA
caption DB "Caption", 0
text DB "Message", 0

.CODE
start:

INVOKE MessageBox, NULL, ADDR text, ADDR caption, MB_OK
INVOKE ExitProcess, NULL

END start


It's a Windows program, but we don't have to create the window, register the class, or process messages. Why?

qWord

Quote from: bf2 on October 24, 2011, 07:31:22 PMIt's a Windows program, but we don't have to create the window, register the class, or process messages. Why?
Because this is done by the function MessageBox  :U
FPU in a trice: SmplMath
It's that simple!

Vortex

Hi bf2,

You can consider the MessageBox function as a code template built to display a predefined dialog box needing only the four parameters you pass.

dedndave

MessageBox does have a registered class, WndProc, and message loop - just like any other window
the operating system provides them all for you   :U
the same is true for all dialogs, buttons, and other controls
sometimes, even text or icons have a window if they are in a "static" control
even the desktop is a window

it may seem like a lot of resources for just a button   :P
but - the OS has to take care of all apples - no oranges

MichaelW

This is probably in the "needless detail" category, but it's possible to use a private class for a dialog, instead of the standard system-defined class, and for a modeless dialog the application must provide a message loop.
eschew obfuscation