i' m going crazy....

what's wrong? there is an error, if i try to call CreateWindowEx
(i think:invalid parameter...57h)


;super shit by germax 2002-2008

.686
.mmx
Locals
jumps

.Model Flat ,StdCall
extrn ExitProcess : PROC
extrn MessageBoxA : PROC
extrn LoadBitmapA : PROC
extrn GetModuleHandleA: PROC
extrn RegisterClassA : PROC
extrn MessageBeep : PROC
extrn CreateWindowExA : PROC
extrn TranslateMessage: PROC
extrn DispatchMessageA: PROC
extrn PostQuitMessage : PROC
extrn DefWindowProcA : PROC
extrn LoadCursorA : PROC
extrn LoadIconA : PROC
extrn ShowWindow : PROC
extrn UpdateWindow : PROC
extrn GetMessageA : PROC




.data
newhwnd dd 0
hinstance dd 0
;msgstructur start: 401008
msg dd 0 ;8 mshwnd
dd 0 ;c msmessage
msgwparam dd 0 ;10 mswparam
dd 0 ;14 mslparam
dd 0 ;18 mstime
dd 0 ;1c mspt
;struc wndclass start: 401020
wc:
clsStyle dd 0 ;20
clsLpfnWndProc dd 0 ;24
clsCbClsExtra dd 0 ;28
clsCbWndExtra dd 0 ;2c
clsHInstance dd 0 ;30
clsHIcon dd 0 ;34
clsHCursor dd 0 ;38
clsHbrBackground dd 0 ;3c
clsLpszMenuName dd 0 ;40
clsLpszClassName dd 0 ;44


titlo db 'flat asi usw',0 ;48
class db 'Fasmblabsal ',0 ;69
caption db 'Windowblabla',0 ;73
message db 'Lmb drueckt ',0 ;8a



.code
start:
push 0
call GetModuleHandleA
mov hinstance, eax



push 7f04h
push 0
call LoadIconA
mov clshicon, eax
cmp eax,0
jz end_loop

push 7f00h
push 0
call LoadCursorA
mov clshcursor, eax
cmp eax,0
jz end_loop

mov clsstyle, 4003h
mov clsLpfnWndProc,offset windowproc
mov clsCbClsExtra,0
mov clsCbWndExtra,0
mov eax,hinstance
mov clsHInstance,eax
mov clsHbrBackground,10h
mov clsLpszMenuName,0
mov clsLpszClassName,offset class
push offset wc
call RegisterClassA

cmp eax,0
jz end_loop
;-----------------------------------------------------------------------------
push 0
push hinstance
push 0
push 0
push 160
push 192
push 64h
push 64h
push 0480000h
push offset titlo
push offset class
push 0

:here is an error---------------------------------------------------!!!!
; jmp end_loop
call CreateWindowExA
mov newhwnd, eax

cmp eax,0
je end_loop

push 1
push newhwnd
call ShowWindow
push newhwnd
call UpdateWindow

jmp end_loop


msg_loop:
push 00h
push 00h
push 00h
push msg
call GetMessageA
or ax, ax
jz end_loop
push offset msg
call TranslateMessage
push offset msg
call DispatchMessageA
jmp msg_loop
end_loop:
push msgwparam
call ExitProcess

windowproc:
enter 00h, 00h
push ebx esi edi
cmp dword ptr , 02h
jz wmdestroy
cmp dword ptr , 201h
jz wmlbuttondown
cmp dword ptr , 204h
jz wmrbuttondown
push dword ptr
push dword ptr
push dword ptr
push dword ptr
call DefWindowProcA
jmp finish

wmdestroy:
push 0
call PostQuitMessage
xor eax, eax
jmp finish

wmlbuttondown:
push 40h
push offset caption
push offset message
push dword ptr
call MessageBoxA
jmp finish
wmrbuttondown:
push 0
call MessageBeep
finish:
pop edi esi ebx
; leave
ret
;windowproc endp
end start
Posted on 2002-03-17 12:04:24 by germax
The problem is in your wndProc, consider making use of masm's built-in 'proc' for labels, then you do not need to worry about each parameter's offset.


The problem is that you have no idea what ebp is in the function.


WndProc:
push ebp
mov ebp, esp
...
pop ebp
ret
Posted on 2002-03-17 13:00:53 by bdjames
is this really true?
i tested my prog, seems it 's a problem with this line:

push offset class
push 0



because the newhnd =0!

:here is an error---------------------------------------------------!!!!
; jmp end_loop
call CreateWindowExA
mov newhwnd, eax
Posted on 2002-03-18 13:45:28 by germax
Yup, try it!

""""""""""""""""""""""""""""""""""""""""""""""""

The CreateWindowEx function sends WM_NCCREATE, WM_NCCALCSIZE, and WM_CREATE messages to the window being created.

""""""""""""""""""""""""""""""""""""""""""""""""

Put a break at the top of wndproc
Posted on 2002-03-18 18:12:59 by bdjames
you' re an expert???

have changed it, so it seems to run well.

now it's time to show some bitmaps in my window.
i've loaded these bmps (with a ressource comp.) in my .exe.

1. what's a good way to show my bitmaps (1 with LMB, the other with RMB,(for testing and get more skill))

2. how can i get pointers to my bitmaps (that's absolutely necessary)?

because:
ie .................ie idb_id
347593....... 0123456789.........ie:idb_id1...........ie:idb_id1
var----------->charset----------->buffer------------>showbuffer


hbitmap dd 0
hbitmap1 dd 0

resorce db "IDB_ID",0
resorce1 db "IDB_ID1",0


.code...
.
.
push offset resorce
push hinstance
Call LoadBitmapA
Mov hBitmap, eax

; call allout

push offset resorce1
push hinstance
Call LoadBitmapA
Mov hBitmap1, eax


; call allout



besides i've the masm32 package, looked all the examples but it's to difficult for me to understand, cause the programming-style is quite differnet from mine.:confused:
Posted on 2002-03-19 11:56:54 by germax
Nah, I am pretty good in assembly, but new to windows api.

I have not worked with bitmaps yet, but I see that you are pushing the offset of a string of the ID, try pushing the actual ID number.



IDI_BMP equ 101 ; same number as in the rc file

push IDI_BMP
Posted on 2002-03-21 00:10:00 by bdjames
with my method, i get really back a bmphandle(but i try your version, too).
the problem is, i don`t understand the way to show a bitmap.
i know the APIs GetDC, BeginPaint, BitBlt.....but i don't know how to use them, what order they have to be. i know, that i need hwnd, but i don't know where i can get it(msgstruc?).all i try fails(either i get zeroes back or prog crashes).

my code so far:


msg_loop:
push 00h
push 00h
push 00h
push offset msg
call GetMessageA
or ax, ax
jz end_loop
push offset msg
call TranslateMessage
push offset msg
call DispatchMessageA
jmp msg_loop
end_loop:
;-----------------------------
call GetTickCount
mov ebx,pstart
sub eax,ebx
; call allout
;-----------------------------
xor eax,eax
call ExitProcess

windowproc:
push ebp
mov ebp, esp
cmp dword ptr , 02h
jz wmdestroy
cmp dword ptr , 201h
jz wmlbuttondown
cmp dword ptr , 204h
jz wmrbuttondown
push dword ptr
push dword ptr
push dword ptr
push dword ptr
call DefWindowProcA
jmp finish
wmdestroy:
push 0
call PostQuitMessage
xor eax, eax
jmp finish
wmlbuttondown:

mov eax,
; call GetDC
; mov hdc,eax
call allout


push 40h
push offset caption
push offset message
push dword ptr
call MessageBoxA
jmp finish
wmrbuttondown:
push 40h
push offset caption
push offset message2
push dword ptr
call MessageBoxA
finish:
pop ebp
ret
;windowproc endp



i hope you can do something for me............;)
Posted on 2002-03-21 14:07:20 by germax
push dword ptr
push dword ptr
push dword ptr
push dword ptr <--

aka

push lParam
push wParam
push uMsg
push hWnd <--


Here is how the stack looks:

???
lParam
wParam
uMsg <--ebp+c
hWnd <--ebp+8
IP <--ebp+4
ebp <--ebp,esp
???

What assembler are you using?
Posted on 2002-03-21 14:58:07 by bdjames
i use tasm 5.3.
my problem seems to be, that i am not able to call GetDC
with the right hwnd.
you can see in my prog, i tried to use.
oh i see at this time, that i don't pushed dword ptr
but moved it in eax before call GetDC.....
i have to check this!!!
but don't stop to help me further....:alright:
Posted on 2002-03-22 12:30:38 by germax