Hi!
In the past, I used MASM, but when I tried several compilers (C,C++,ASM,VB,Python,etc), I found that FASM fits best my programming needs, because it's simple, fast, and flat :-)
Now I'm trying to step to next level (I coded only msgboxes and some other dummy little nothing).
With hard guesses through days I found how to code in macro mode :-)
Now I want a little text mode splash screen: only a plain little topmost window without caption and some text in it.
I read a few win32asm tutorials, ckecked a lot of asm sample code (MASM :( ), but after a few wasted days with a lot of tries I'm now confused, because my asm code goes worse and worse... PLEASE HELP ME. Here is the source:



include '%include%\win32ax.inc'

.data

_mainhwnd dd 0
_hinstance dd 0
msg MSG
wc WNDCLASSEX
lb LOGBRUSH
_brsh dd 0
_title db 'Splashscreen',0
_class db 'Splash',0
_wtx dd 0
_wty dd 0
_hDC dd 0
_paintstruct PAINTSTRUCT
_rect RECT

.code

start:
invoke GetModuleHandle,0
mov [_hinstance],eax

mov [lb.lbStyle],BS_SOLID
mov [lb.lbColor],00CCCCCCh ; direct COLORREF nember
mov [lb.lbHatch],0

invoke CreateBrushIndirect,lb
mov [_brsh],eax

; mov [wc.cbSize],sizeof WNDCLASSEX ;;I don't know how to translate from MASM this SIZEOF operand
mov [wc.style],CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov [wc.lpfnWndProc],SplashProc
mov [wc.cbClsExtra],0
mov [wc.cbWndExtra],0
mov eax,[_hinstance]
mov [wc.hInstance],eax
mov eax,[_brsh] ; the brush in the required colour
mov [wc.hbrBackground],eax
mov [wc.lpszMenuName],0
mov [wc.lpszClassName],_class
mov [wc.hIcon],0
mov [wc.hCursor],0
mov [wc.hIconSm],0
invoke RegisterClass,wc

invoke GetSystemMetrics,SM_CXSCREEN
stdcall TopXY,240,eax
mov [_wtx], eax

invoke GetSystemMetrics,SM_CYSCREEN
stdcall TopXY,160,eax
mov [_wty], eax

invoke CreateWindowEx,WS_EX_TOPMOST,_class,_title,WS_POPUP,_wtx,_wty,240,160,0,0,[_hinstance],0
mov [_mainhwnd],eax
invoke ShowWindow,[_mainhwnd],SW_SHOWNORMAL
invoke UpdateWindow,[_mainhwnd]

invoke Sleep, 2000
invoke ExitProcess, 0

proc TopXY, wDim, sDim
enter
shr [sDim],1 ; divide screen dimension by 2
shr [wDim],1 ; divide window dimension by 2
mov eax, [wDim] ; copy window dimension into eax
sub [sDim], eax ; sub half win dimension from half screen dimension
return

proc SplashProc, hWin, wMsg, wParam, lParam
enter
cmp [wMsg],WM_PAINT
jne txtnoneyet
invoke DefWindowProc,[hWin],[wMsg],[wParam],[lParam]
invoke BeginPaint,[hWin],_paintstruct
mov [_hDC], eax

invoke SetBkMode,[_hDC],TRANSPARENT
invoke GetClientRect,[hWin],_rect
invoke DrawText,[_hDC],_title,13,_rect,DT_CENTER

; invoke TextOut,[_hDC],0,0,_title,13

invoke EndPaint,[hWin],_paintstruct
return
txtnoneyet:
invoke DefWindowProc,[hWin],[wMsg],[wParam],[lParam]
return

.end start
Posted on 2003-06-10 04:39:04 by MACi
When I compile this, the .exe crashes, drwatson (XP) investigates.
I changed the
invoke RegisterClass,wc
to
invoke RegisterClassEx,wc
now don't crashes, but doesn't shows up anything
Posted on 2003-06-10 04:51:58 by MACi
Hi MACi,

CreateWindowEx needs RegisterClassEx. And,

sizeof.WNDCLASSEX

and beside,

.code

use this one,

section '.code' code readable executable

also you need a message loop,

msg_loop:
invoke GetMessage,msg,NULL,0,0
or eax,eax
jz end_loop
invoke TranslateMessage,msg
invoke DispatchMessage,msg
jmp msg_loop
end_loop:
invoke ExitProcess,

after this line,

invoke UpdateWindow,[_mainhwnd]

as I saw yet. And look at examples, documents, which comes with your zip package(fasmw.zip). Also here there are more examples about translation of iczelion tuts. Like
this link

Regards
Posted on 2003-06-10 12:22:27 by cakmak
No, you can still use RegisterClass and CreateWindowEx together.
Posted on 2003-06-10 13:18:32 by comrade
yes but except don't need small icon. In this case WNDCLASS is OK.
Posted on 2003-06-10 13:39:21 by cakmak
If you used WNDCLASSEX, also i assume you have,

import user,\
RegisterClassEx,'RegisterClassExA',\
CreateWindowEx,'CreateWindowExA',\
.
.
Posted on 2003-06-10 15:36:52 by cakmak
Sorry guys, but these infos are mostly useless, anyway thanks for your help.

cakmak:
You wrote:
"CreateWindowEx needs RegisterClassEx."
I wrote before this:
"I changed the
invoke RegisterClass,wc
to
invoke RegisterClassEx,wc
now don't crashes, but doesn't shows up anything"

You wrote:
"and beside,
.code
use this one,
section '.code' code readable executable"
I wrote before this:
"I found how to code in macro mode"
so I want to use macro mode furthermore, this means:
.data
.code
etc.
Did you see the include file at the beginning? include '%include%\win32ax.inc'
This allows macro mode, and I added an .rsrc macro to this include file also.

Do you think I need that message loop when I want only a splashscreen?
I tried few days ago to compile with those kind of message loop, but then I have to kill manually the window (living only in memory and it didn't had a visible window!), before the prg steps to the Sleep code.

You wrote:
"If you used WNDCLASSEX, also i assume you have,
import user,RegisterClassEx,'RegisterClassExA',CreateWindowEx,'CreateWindowExA' "...
I used include '%include%\win32ax.inc' that includes '%include%/apia/user32.inc'

Anyway, thanks for the dot :) in sizeof.WNDCLASSEX, it works.
...but I don't get yet any window :(
Posted on 2003-06-11 02:04:15 by MACi

No, you can still use RegisterClass and CreateWindowEx together.


No I can't.
Because my original code was:
invokeRegisterClass,wc
and I wrote:
"When I compile this, the .exe crashes, drwatson (XP) investigates.
I changed the
invoke RegisterClass,wc
to
invoke RegisterClassEx,wc
now don't crashes, but doesn't shows up anything"
So, with RegisterClass it crashes.
Posted on 2003-06-11 02:10:46 by MACi
RegisterClass requires WNDCLASS structure.
RegisterClassEx requires WNDCLASSEX structure.
CreateWindowEx doesn't care about WNDCLASS or WNDCLASSEX.
Posted on 2003-06-11 02:46:36 by tenkey
Thanks tenkey!
...but where is my window??? :confused:
Posted on 2003-06-11 02:49:58 by MACi
I digged thorough the FASM forum, and I saw many people have problems like I had when I started with FASM in the past.
I think these problems are not about asm tutorials, but about FASM SYNTAX!!!
Like I had that kind of problem nowadays with sizeof operand:
TASM (perhaps MASM syntax)
sizeof WNDCLASSEX
in FASM:
sizeof.WNDCLASSEX
When I don't know about that little dot, I cannot compile my code, so I cannot do my next step.
So people want FASM syntax tutorial!
(I've been searching for it, but nothing found)
Posted on 2003-06-11 03:20:40 by MACi
All of the code was good to do a splash, except:
invokeCreateWindowEx,WS_EX_TOPMOST,_class,_title ,WS_POPUP,_wtx,_wty,240,160,0,0,[_hinstance],0
So simple bug :(
What a hunt was! :)
the corrected code:
invokeCreateWindowEx,WS_EX_TOPMOST,_class,_title ,WS_POPUP,[_wtx],[_wty],240,160,0,0,[_hinstance],0
and finally it works!
Thanks guys to participate and the greatest thanks to MACi :) who resolved the whole problem :)
Posted on 2003-06-11 05:02:07 by MACi