I've often wondered why M$ didn't make creating a window a simple as registering a class in that only one 32 bit value need be passed to calling routine. Although this is not ground breaking code design it does facilitate calling code only set EBX to point to all values required by CreateWindowEx.

; 				    *** CREATE_WND ***

;	ENTRY:	EBX = Pointer to structure CreateWindowEx structure

;	LEAVE:	EAX = Handle to window, or null if failed
;		 CY = 0 Successful, 1 otherwise.

; ============================================================================================

  Create_Wnd	mov	ecx, 48
		sub	esp, ecx		; Create stack frame for CreateWindowEx
		mov	edx, esp		; Need this pointer in EDI
		push	esi
		push	edi			; Save registers
		mov	edi, edx
		mov	esi, ebx		; Setup for movsd
		shr	ecx, 2			; Number of dwords to move
		rep	movsd			; Copy parameters into stack area
		pop	edi
		pop	esi			; Restore index registers and create
		call	_CreateWindowExA@48	; window
		and	eax, eax
		jnz	.Done + 1		; If non zero, then was successful

	; Error handling code will eventually go here

  .Done		stc				; Set error flag

12 Years
Discussion Span
Last Post by vegaseat

I've never done anything in assembly for console, although the concept is very simple. This series I'm doing now will only have another couple of posts and it will be complete as far as displaying a window on the monitor. What I can do and what I think might be fairly informative is displaying "Hello World" in the default GUI font only while the left mouse button is being pressed at the cursor position at that time. This will be a little more consitent with my objective of this series of snippets. At that time I will post the entire source in thread18331. The complete source encorporates all the snippets I'm posting here.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.