Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32 Assembly, Program Runs, Window does not show

Status
Not open for further replies.

bnice2137

Programmer
Dec 10, 2003
1
US
Yes i did call ShowWindow

%include "win32n.inc"

GLOBAL start

extern GetModuleHandleA
extern ExitProcess
extern LoadCursorA
extern LoadIconA
extern RegisterClassExA
extern CreateWindowExA
extern ShowWindow
extern GetMessageA
extern TranslateMessage
extern DispatchMessageA
extern PostQuitMessage
extern DefWindowProcA
extern UpdateWindow

import GetModuleHandleA kernel32.dll
import ExitProcess kernel32.dll
import LoadCursorA user32.dll
import LoadIconA user32.dll
import RegisterClassExA user32.dll
import CreateWindowExA user32.dll
import ShowWindow user32.dll
import GetMessageA user32.dll
import TranslateMessage user32.dll
import DispatchMessageA user32.dll
import PostQuitMessage user32.dll
import DefWindowProcA user32.dll
import UpdateWindow user32.dll

%define PARAM1 [ebp + 4]
%define PARAM2 [ebp + 8]
%define PARAM3 [ebp + 12]
%define PARAM4 [ebp + 16]

section .data
BITS 32

AppName db 'My First Window',0
ClassName db 'Simple WindowClass',0

wc:
istruc WNDCLASSEX
at WNDCLASSEX.cbSize, dd 0
at WNDCLASSEX.style, dd 0
at WNDCLASSEX.lpfnWndProc, dd 0
at WNDCLASSEX.cbClsExtra, dd 0
at WNDCLASSEX.cbWndExtra, dd 0
at WNDCLASSEX.hInstance, dd 0
at WNDCLASSEX.hIcon, dd 0
at WNDCLASSEX.hCursor, dd 0
at WNDCLASSEX.hbrBackground, dd 0
at WNDCLASSEX.lpszMenuName, dd 0
at WNDCLASSEX.lpszClassName, dd 0
at WNDCLASSEX.hIconSm, dd 0
iend
endwc:

msg: dd 0, 0, 0, 0, 0, 0



section .rdata
BITS 32

hInstance resd 1
CommandLine resd 1
hParentWnd resd 1

section .code
BITS 32

start:

push dword 0
call [GetModuleHandleA]
mov dword [hInstance], eax

call WinMain
push eax
call [ExitProcess]

WinMain:
mov dword [wc + WNDCLASSEX.cbSize], endwc - wc
mov dword [wc + WNDCLASSEX.style], CS_HREDRAW | CS_VREDRAW
mov dword [wc + WNDCLASSEX.lpfnWndProc], WndProc
mov dword [wc + WNDCLASSEX.cbClsExtra], 0
mov dword [wc + WNDCLASSEX.cbWndExtra], 0
mov dword eax, [hInstance]
mov dword [wc + WNDCLASSEX.hInstance], eax
mov dword [wc + WNDCLASSEX.hbrBackground], COLOR_WINDOW + 1
mov dword [wc + WNDCLASSEX.lpszMenuName], 0
mov dword [wc + WNDCLASSEX.lpszClassName], ClassName
mov dword [wc + WNDCLASSEX.hIconSm], 0


push dword IDC_ARROW
push dword [hInstance]
call [LoadCursorA]
mov dword [wc + WNDCLASSEX.hCursor], eax

push dword IDI_APPLICATION
push dword [hInstance]
call [LoadIconA]
mov dword [wc + WNDCLASSEX.hIcon], eax

push dword wc
call [RegisterClassExA]

push dword 0
push dword [hInstance]
push dword 0
push dword 0
push dword CW_USEDEFAULT
push dword CW_USEDEFAULT
push dword CW_USEDEFAULT
push dword CW_USEDEFAULT
push dword WS_CAPTION + WS_MAXIMIZEBOX + WS_MINIMIZEBOX + WS_SIZEBOX + WS_SYSMENU + WS_VISIBLE
push dword AppName
push dword ClassName
push dword WS_EX_CLIENTEDGE + WS_EX_WINDOWEDGE
call [CreateWindowExA]
mov dword [hParentWnd], eax

push dword SW_SHOWDEFAULT
push dword [hParentWnd]
call [ShowWindow]

push dword [hParentWnd]
call [UpdateWindow]

MsgLoop:
push dword 0
push dword 0
push dword [hParentWnd]
push dword msg
call [GetMessageA]

or eax, eax
jz ProgramQuit

push dword msg
call [DispatchMessageA]
jmp MsgLoop

ProgramQuit:
push dword 0
call [ExitProcess]

WndProc:
enter 0,0

cmp dword PARAM2, WM_DESTROY
je GotWmDestroy
jne DisreguardMessageA

xor eax, eax
leave
ret

GotWmDestroy:
push dword 0
call [PostQuitMessage]

DisreguardMessageA:
push dword PARAM4
push dword PARAM3
push dword PARAM2
push dword [hParentWnd]
call [DefWindowProcA]
leave
ret
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top