;EasyCodeName=Splash
;
.Const
;
.Data?
;---------------------------------------
hInstance   DD  ?
;
.Data
;---------------------------------------
BitmapName  DB  "MySplashBMP",0
ClassName   DB  "SplashWndClass",0
hBitMap     DD  0
TimerID     DD  0
;
.Code
DllEntry Proc hInst:DWord, reason:DWord, reserved1:DWord
;---------------------------------------;
        .If reason==DLL_PROCESS_ATTACH  ; When the dll is loaded
          Push hInst
          Pop hInstance
          Call ShowBitMap
        .EndIf
        Mov Eax,TRUE
        Ret
;---------------------------------------
DllEntry EndP
;
;
ShowBitMap Proc
;---------------------------------------
        Local   wc:WNDCLASSEX
        Local   msg:MSG
        Local   hwnd:HWND
;
        Mov     wc.cbSize, SizeOf WNDCLASSEX
        Mov     wc.style, CS_HREDRAW Or CS_VREDRAW
        Mov     wc.lpfnWndProc, Offset WndProc
        Mov     wc.cbClsExtra, NULL
        Mov     wc.cbWndExtra, NULL
        Push    hInstance
        Pop     wc.hInstance
        Mov     wc.hbrBackground, COLOR_WINDOW+1
        Mov     wc.lpszMenuName, NULL
        Mov     wc.lpszClassName, Offset ClassName
        Invoke  LoadIcon, NULL, IDI_APPLICATION
        Mov     wc.hIcon, Eax
        Mov     wc.hIconSm, 0
        Invoke  LoadCursor, NULL, IDC_ARROW
        Mov     wc.hCursor, Eax
        Invoke  RegisterClassEx, Addr wc
        Invoke  CreateWindowEx, NULL, Addr ClassName, NULL,\
                WS_POPUP, CW_USEDEFAULT,\
                CW_USEDEFAULT, 400, 300, NULL, NULL,\
                hInstance, NULL
        Mov     hwnd, Eax
        Invoke  ShowWindow, hwnd, SW_SHOWNORMAL
        .While TRUE
          Invoke  GetMessage, Addr msg, NULL, 0, 0
          .Break .If (!Eax)
          Invoke TranslateMessage, Addr msg
          Invoke DispatchMessage, Addr msg
        .EndW
        Mov     Eax, msg.wParam        
        Ret
;---------------------------------------
ShowBitMap EndP
;
;
WndProc Proc hWnd:DWord,uMsg:DWord,wParam:DWord,lParam:DWord
;---------------------------------------
        Local ps:PAINTSTRUCT
        Local hdc:HDC
        Local hMemoryDC:HDC
        Local hOldBmp:DWord
        Local bitmap:BITMAP
        Local DlgHeight:DWord
        Local DlgWidth:DWord
        Local DlgRect:RECT
        Local DesktopRect:RECT

        .If uMsg==WM_DESTROY
          .If hBitMap!=0
            Invoke  DeleteObject, hBitMap
          .EndIf
          Invoke  PostQuitMessage, NULL
        .ElseIf uMsg==WM_CREATE
          Invoke  GetWindowRect, hWnd, Addr DlgRect
          Invoke  GetDesktopWindow
          Mov     Ecx, Eax
          Invoke  GetWindowRect, Ecx, Addr DesktopRect
          Push    0                     ; Part of the later call to MoveWindow (no repaint)
          Mov     Eax, DlgRect.bottom   ; Get the bottom of our dialogs window
          Sub     Eax, DlgRect.top      ; Subtract the y value at the top of our window
          Mov     DlgHeight, Eax        ; And store it as the dialog's height
          Push    Eax                   ; Push it for the call to MoveWindow
          Mov     Eax, DlgRect.right    ; The X coordinate of the right side of our dialog
          Sub     Eax, DlgRect.left     ; Minus that of the left side
          Mov     DlgWidth, Eax         ; Gives us the width
          Push    Eax                   ; Push it for the call to MoveWindow
          Mov     Eax, DesktopRect.bottom   ; Get the bottom of the desktop window
          Sub     Eax, DlgHeight        ; Subtract the height of our dialog
          Shr     Eax, 1                ; And divide by 2...this gives the middle of the screen
          Push    Eax                   ; Push for the movewindow call
          Mov     Eax, DesktopRect.right    ; Get the right side of the desktop
          Sub     Eax, DlgWidth         ; Minus the width of our dialog
          Shr     Eax, 1                ; Divide by 2
          Push    Eax                   ; Push it
          Push    hWnd                  ; Push the window handle
          Call    MoveWindow            ; Move the window                
          Invoke  LoadBitmap, hInstance, Addr BitmapName
          Mov     hBitMap, Eax
          Invoke  SetTimer, hWnd, 1, 2000, NULL
          Mov     TimerID,Eax
        .ElseIf uMsg==WM_TIMER
          Invoke  SendMessage, hWnd, WM_LBUTTONDOWN, NULL, NULL
          Invoke  KillTimer, hWnd, TimerID
        .ElseIf uMsg==WM_PAINT
          Invoke  BeginPaint, hWnd, Addr ps
          Mov     hdc, Eax
          Invoke  CreateCompatibleDC, hdc
          Mov     hMemoryDC, Eax
          Invoke  SelectObject, Eax, hBitMap
          Mov     hOldBmp, Eax
          Invoke  GetObject, hBitMap, SizeOf BITMAP, Addr bitmap
          Invoke  StretchBlt, hdc, 0, 0, 400, 300,\
                  hMemoryDC, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY
          Invoke  SelectObject, hMemoryDC, hOldBmp
          Invoke  DeleteDC, hMemoryDC
          Invoke  EndPaint, hWnd, Addr ps
        .ElseIf uMsg==WM_LBUTTONDOWN               
          Invoke  DestroyWindow, hWnd
        .Else
          Invoke  DefWindowProc, hWnd, uMsg, wParam, lParam
          Ret
        .EndIf
        Xor     Eax, Eax
        Ret
;---------------------------------------
WndProc EndP
;
;
        End     DllEntry
