The next few posts will be what's required to get a window to display on the monitor. The code between Main & Pump will probably change as time goes on, but for now this is all that is required. I choose this method or placement because only 28 bytes of stack are used at this point. Nesting pump deeper in application might unnecessarily retain unused stack space.


; This is where application begins after OS has done its thing.  I use the space before
; ShowMainWnd for anything that is not particularly related to displaying main window or is
; coded into a message handler such as WM_CREATE.
; ____________________________________________________________________________________________

  Main		enter	28, 0			; MSG structure in proceedure frame.
		call	InitFrame		; Set elements of MSG to zero's

	; In the event there is a failure creating main window, MSG.wParam has already been
	; established.  If a different value is required, set it where ever required.

		lea	ebx, [ebp - 28]		; EBX points to MSG
		dec	dword [ebx + 8]		; Msg.wParam = -1, default error condition.

		call	ShowMainWnd		; Execute main body of application
		jc	.Exit			; NC = 1, Proeedure failed.  

		xor	eax, eax		; EAX = NULL

  	; Applications message pump, continually scan for messages until WM_QUIT is returned.
  .Pump		push	eax			; Save zero value in EAX
		push	eax			; wMsgFilterMax
		push	eax			; wMsgFilterMin
		push	eax			; hWnd = 0, Desktop
		push	ebx			; Pointer to MSG
		call	_GetMessageA@16
		and	eax, eax		; Evaluate returned value
		jz	.Exit	
	; If main window is a dialog box, IsDialog would be evaluated here.

		push	ebx
		call	_TranslateMessage@4
		push	ebx
		call	_DispatchMessageA@4

		pop	eax			; Restore NULL
		jmp	short .Pump
	; Application has terminated, either because ShowMainWnd failed or message que
	; encountered WM_QUIT.  Other fatal errors usually kill app at the point they
	; were encountered as ExitProcess will do appropriate cleanup anywhere.

  .Exit		leave
		push	dword [ebx + 8]		; MSG.wParam
		call	_ExitProcess@4		; Cleanup
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.