Window Creation

Tight_Coder_Ex 0 Tallied Votes 178 Views Share

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
		cld
		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
		ret
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Nice idea!
We have a little thread going on DaniWeb under: http://www.daniweb.com/techtalkforums/thread18331.html
Would be nice to get the asm Hello World! from you.

Tight_Coder_Ex 17 Posting Whiz in Training

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.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The thread is not limited to console only. Please go ahead and give us a good one! Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.