exemple simple pour ajouter un splash screen à vos application
Source / Exemple :
.386
.model flat,stdcall
option casemap:none
include c:\masm32\include\windows.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\gdi32.inc
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\gdi32.lib
.CODE
include splash.hex
PROGRAMME:
;////////////////////////////////
;----------- CREE THREAD -------
;////////////////////////////////
push 0
push 0
push 0
push offset WINSPLASH
push 0
push 0
call CreateThread
;////////////////////////////////////////////
;---------- FENETRE PRINCIPAL ---------------
;////////////////////////////////////////////
push 200h
push GPTR
call GlobalAlloc
push eax ;arg GlobalFree
mov dword ptr [eax],WS_CAPTION or WS_SYSMENU or DS_CENTER
mov word ptr [eax+14],290
mov word ptr [eax+16],100
push 0
push offset DialogProc
push 0
push eax
push 400000h ;hinst
call DialogBoxIndirectParam
call GlobalFree
push 0
call ExitProcess
;//////////////////////////////////////////////////
;----------- PROC FENETRE PRINCIPAL --------------
;//////////////////////////////////////////////////
DialogProc proc
mov eax,[esp+8]
cmp eax,WM_CLOSE
je WMCLOSE
jmp DLG
WMCLOSE: push 0
push [esp+8]
call EndDialog
DLG: xor eax,eax
ret 16
DialogProc endp
;///////////////////////////////////////////
;------------- FENETRE SPLASH --------------
;///////////////////////////////////////////
WINSPLASH proc
push 512
push GPTR
call GlobalAlloc
push eax ;arg GlobalFree
mov dword ptr [eax],WS_POPUP or DS_CENTER
mov dword ptr [eax+4],WS_EX_TOPMOST or WS_EX_TOOLWINDOW
mov word ptr [eax+14],160
mov word ptr [eax+16],120
push 0
push offset DlgSplashProc
push 0
push eax
push 400000h ;hinst
call DialogBoxIndirectParam
call GlobalFree
ret
WINSPLASH endp
;///////////////////////////////////////
;--------- PROC FENETRE SPLASH --------
;///////////////////////////////////////
DlgSplashProc proc
mov eax,[esp+8]
cmp eax,WM_ACTIVATEAPP
je WMACTIVAPP
cmp eax,WM_CLOSE
je WMCLOSE
push [esp+4]
call GetDC
mov edi,eax
lea esi,image
mov eax,esi
add eax,14
mov edx,esi
add edx,[esi+10]
push 00CC0020h ;copy
push 0 ;DIB_RGB_COLORS=0
push eax;bmp_header
push edx;bmp_pixels
push [esi+22] ;bmp height DIB source
push [esi+18] ;bmp width DIB source
push 0 ;y of source rectangle
push 0 ;x of source rectangle
push 240 ;bmp height rect destination
push 320 ;bmp width rect destination
push 0 ;y of destination rectangle
push 0 ;x of destination rectangle
push edi ;DC of da window
call StretchDIBits
jmp DLG
WMACTIVAPP: push 0
push 0
push [esp+12]
push offset TIMER
push 0
push 0
call CreateThread
jmp DLG
WMCLOSE: push 0
push [esp+8]
call EndDialog
DLG: xor eax,eax
ret 16
DlgSplashProc endp
;/////////////////////////////////
;-------------- TIMER ------------
;/////////////////////////////////
TIMER proc
push 5000
call Sleep
push 0
push 0
push WM_CLOSE
push [esp+16]
call SendMessage
ret 4
TIMER endp
end PROGRAMME
Conclusion :
Très simple on cree un thread qui cree la fenetre splash
et dans sa proc on cree un thread qui sert de timer
propre simple efficace comparer avec l'example dans masm.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.