Hi @all...
I'm developing a simple SplashScreen Library that I'll release here (hoping that someone will be interested in it :)), but I ha ve a few problems:
1) I use GetBitmapDimensionEx to get Height and Width of the bitmap used for the SplashScreen, but even though the function returns a nonzero value (correct), the size is always (0,0). The bitmap used is really (400,300). The function requires a SIZE structure not defined in WINDOWS.INC and I use a POINT structure (it has the same fields: 2 DWORDs). May it be this the problem? If so, how can I fix it?
2) The SplashScreen windows has the Titlebar: which style should I use not to have it? I tried no style at all, but I still get the Titlebar.

I'm attaching the lib code, hoping that someone can give me a little help. Thanx to anyone in advance.

Sincerely,
Daniel


.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive

include \masm32\include\windows.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

SplashScreenProc PROTO :HWND, :UINT, :WPARAM, :LPARAM

.data?
SShBmp HBITMAP ?
SSTime dd ?
SShWnd HWND ?

.data
SSClassName db 'SplashScreen',0

.code
SplashScreen PROC hInst: HINSTANCE, hParWnd: HWND, resBitmap: DWORD, Time: DWORD

LOCAL wc: WNDCLASSEX
LOCAL rect: RECT
LOCAL x: DWORD, y: DWORD
LOCAL dim: POINT

push Time
pop SSTime

; Register the SplashScreen window class
mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET SplashScreenProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInst
pop wc.hInstance
invoke LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
mov wc.hbrBackground, COLOR_BTNFACE + 1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, OFFSET SSClassName
invoke RegisterClassEx, ADDR wc

; Get Bitmap dimensions -> Splash Window dimensions
invoke LoadBitmap, hInst, resBitmap
mov SShBmp, eax
invoke GetBitmapDimensionEx, SShBmp, ADDR dim

; Computes SplashScreen position
invoke GetWindowRect, hParWnd, ADDR rect
mov eax, rect.right
sub eax, rect.left
sub eax, dim.x
shr eax, 1
add eax, rect.left
mov x, eax
mov eax, rect.bottom
sub eax, rect.top
sub eax, dim.y
shr eax, 1
add eax, rect.top
mov y, eax

; Create the SplashScreen
; invoke CreateWindowEx, WS_EX_CLIENTEDGE + WS_EX_DLGMODALFRAME + WS_EX_TOPMOST + WS_EX_WINDOWEDGE, ADDR SSClassName, ADDR SSClassName,WS_VISIBLE, x, y, dim.x, dim.y, hParWnd, NULL, hInst, NULL
invoke CreateWindowEx, NULL, ADDR SSClassName, ADDR SSClassName, NULL, x, y, dim.x, dim.y, hParWnd, NULL, hInst, NULL
mov SShWnd, eax
invoke ShowWindow, SShWnd, SW_SHOWNORMAL
invoke UpdateWindow, SShWnd
ret
SplashScreen endp

SplashScreenProc proc hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

LOCAL hDcWnd: HDC, hDcMem: HDC, dim: POINT

.if uMsg==WM_CREATE
invoke SetTimer, hWin, 1, SSTime, NULL
.elseif uMsg == WM_PAINT
invoke GetDC, hWin
mov hDcWnd, eax
invoke CreateCompatibleDC, eax
mov hDcMem, eax
invoke SelectObject, hDcMem, SShBmp
invoke GetMapMode, hDcWnd
invoke SetMapMode, hDcMem, eax
invoke GetBitmapDimensionEx, SShBmp, ADDR dim
invoke BitBlt, hDcWnd, dim.x, dim.y, 400, 300, hDcMem, 0, 0, SRCCOPY
invoke DeleteDC, hDcMem
.elseif uMsg == WM_TIMER
invoke KillTimer, hWin, 1
invoke DeleteObject, SShBmp
invoke PostQuitMessage, TRUE
.else
invoke DefWindowProc, hWin, uMsg, wParam, lParam
ret
.endif
xor eax,eax
ret
SplashScreenProc endp
Posted on 2001-12-16 12:50:49 by dguzz
i think that this isn't difficult. use GetObject to get the bitmap dimensions. use WS_POPUP style for your window....

hope that helps
nop
Posted on 2001-12-16 13:18:52 by NOP-erator
The SplashScreen windows has the Titlebar: which style should I use not to have it?

WS_POPUP should do the trick.
Posted on 2001-12-16 13:20:55 by Tola
Hi @ all again...
thanx for the help you gave me, but I'm very sorry in telling you that you wasted your time: I already fixed my problems a few hours ago, but I cannot warn you about this because I couldn't connect to Internet in the past few hours. Please excuse me.
Now I have another problem.
My target for this LIB is to make it work this way: in the WM_CREATE code section of the MAIN application I would call the SplashScreen proc and then forget it. Infact I'm passing any parameter needed, even the number of milliseconds the SplashScreen should stay visible. Alas, even if the SetTimer in the WM_CREATE of the SplashScreenProc returns a value <> 0, the WM_TIMER message is never dispatched. And because in the WM_TIMER code section I would kill the timer and close the SplashScreen, really the SplashScreen is actually not closed at all!!!
Have anyone an idea (and perhaps a fix) why the WM_TIMER is not sent to the SplashScreenProc, even though the SetTimer is correctly invoked? I also tried passing a TimerProc instead of NULL, deleting the WM_TIMER from the SplashScreenProc and using the TimerProc, but even this way it is never called. The Number of milliseconds used is 3000 (so 3 seconds), but... alas... it doesn't work.

This time I think I cannot fix the code by myself and I would greatly appreciate any sort of help.

Thanx in advance!

Sincerely,
Daniel


.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive

include \masm32\include\windows.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

SplashScreenProc PROTO :HWND, :UINT, :WPARAM, :LPARAM

.data?
SShBmp HBITMAP ?
SSTime dd ?
SShWnd HWND ?

.data
SSClassName db 'SplashScreen',0

.code
SplashScreen PROC hInst: HINSTANCE, hParWnd: HWND, resBitmap: DWORD, Time: DWORD

LOCAL wc: WNDCLASSEX
LOCAL rect: RECT
LOCAL x: DWORD, y: DWORD
LOCAL hdBmp: BITMAP
LOCAL msg:MSG

push Time
pop SSTime

; Register the SplashScreen window class
mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET SplashScreenProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInst
pop wc.hInstance
invoke LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
mov wc.hbrBackground, COLOR_BTNFACE + 1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, OFFSET SSClassName
invoke RegisterClassEx, ADDR wc

; Get Bitmap dimensions -> Splash Window dimensions
...
CORRECT CODE HERE
...
; Computes SplashScreen position
...
CORRECT CODE HERE
...
; Create the SplashScreen
invoke CreateWindowEx, WS_EX_TRANSPARENT, ADDR SSClassName, ADDR SSClassName, WS_CHILD, x, y, eax, ebx, hParWnd, NULL, hInst, NULL
mov SShWnd, eax
invoke ShowWindow, SShWnd, SW_SHOWNORMAL
invoke UpdateWindow, SShWnd
ret
SplashScreen endp

SplashScreenProc proc hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

LOCAL hDcWnd: HDC, hDcMem: HDC, hdBmp: BITMAP, rect: RECT

.if uMsg == WM_CREATE
invoke SetTimer, hWin, 1, SSTime, NULL
.elseif uMsg == WM_PAINT
...
CORRECT CODE HERE
...
.elseif uMsg == WM_TIMER
invoke KillTimer, hWin, 1
invoke DeleteObject, SShBmp
invoke PostQuitMessage, TRUE
.else
invoke DefWindowProc, hWin, uMsg, wParam, lParam
ret
.endif
xor eax,eax
ret
SplashScreenProc endp

end


The attached image is an example of the SplashScreen working but not closing!
Posted on 2001-12-17 11:40:00 by dguzz
You don't show a message loop.

WM_TIMER requires a message loop.
Posted on 2001-12-17 16:33:07 by tank
OK... thanx...
I'll try to make the SplashCreation in a new thread so that the MAIN app can continue initializing and loading while the SplashProc receives the WM_TIMER

Thanx again (I hope it'll work :))

Sincerely,
Daniel
Posted on 2001-12-18 11:48:38 by dguzz