home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Hutch / DOWNLOAD / Example2.exe / SPLASH / SPLASH.ASM < prev    next >
Encoding:
Assembly Source File  |  1999-06-09  |  12.5 KB  |  419 lines

  1. ; #########################################################################
  2. ;
  3. ;   This demo creates a window for the splash screen and displays it
  4. ;   with the WS_EX_TOPMOST attribute. It then creates the main window
  5. ;   under it and waits until the programmed time delay is up before
  6. ;   closing the Splash screen. The splash screen window creation code
  7. ;   is in the WinMain proc, the message handling is in the SplashProc
  8. ;   proc at the end of the file.
  9. ;
  10. ; #########################################################################
  11.  
  12.       .386
  13.       .model flat, stdcall  ; 32 bit memory model
  14.       option casemap :none  ; case sensitive
  15.  
  16.       include Splash.inc    ; local includes for this file
  17.  
  18. ; #########################################################################
  19.  
  20. .code
  21.  
  22. start:
  23.       invoke GetModuleHandle, NULL
  24.       mov hInstance, eax
  25.  
  26.       invoke GetCommandLine
  27.       mov CommandLine, eax
  28.  
  29.       invoke InitCommonControls
  30.  
  31.       invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
  32.       invoke ExitProcess,eax
  33.  
  34. ; #########################################################################
  35.  
  36. WinMain proc hInst     :DWORD,
  37.              hPrevInst :DWORD,
  38.              CmdLine   :DWORD,
  39.              CmdShow   :DWORD
  40.  
  41.       ;====================
  42.       ; Put LOCALs on stack
  43.       ;====================
  44.  
  45.       LOCAL wc   :WNDCLASSEX
  46.       LOCAL spl  :WNDCLASSEX
  47.       LOCAL msg  :MSG
  48.       LOCAL Wwd  :DWORD
  49.       LOCAL Wht  :DWORD
  50.       LOCAL Wtx  :DWORD
  51.       LOCAL Wty  :DWORD
  52.       LOCAL tc   :DWORD
  53.       LOCAL lb   :LOGBRUSH
  54.       LOCAL brsh :DWORD
  55.  
  56.     ; -------------------------
  57.     ; fill a LOGBRUSH structure
  58.     ; -------------------------
  59.       mov lb.lbStyle,BS_SOLID
  60.       mov lb.lbColor,000000FFh  ; direct COLORREF nember
  61.       mov lb.lbHatch,NULL
  62.  
  63.       invoke CreateBrushIndirect,ADDR lb
  64.       mov brsh, eax
  65.  
  66.       szText szSplashName,"Splash_Class"
  67.  
  68.       mov spl.cbSize,         sizeof WNDCLASSEX
  69.       mov spl.style,          CS_HREDRAW or CS_VREDRAW \
  70.                                 or CS_BYTEALIGNWINDOW
  71.       mov spl.lpfnWndProc,    offset SplashProc
  72.       mov spl.cbClsExtra,     NULL
  73.       mov spl.cbWndExtra,     NULL
  74.       m2m spl.hInstance,      hInst
  75.       m2m spl.hbrBackground,  brsh  ; the brush in the required colour
  76.       mov spl.lpszMenuName,   NULL
  77.       mov spl.lpszClassName,  offset szSplashName
  78.       mov spl.hIcon,          NULL
  79.       mov spl.hCursor,        NULL
  80.       mov spl.hIconSm,        NULL
  81.  
  82.       invoke RegisterClassEx, ADDR spl
  83.  
  84.       mov Wwd, 350
  85.       mov Wht, 200
  86.  
  87.       invoke GetSystemMetrics,SM_CXSCREEN
  88.       invoke TopXY,Wwd,eax
  89.       mov Wtx, eax
  90.  
  91.       invoke GetSystemMetrics,SM_CYSCREEN
  92.       invoke TopXY,Wht,eax
  93.       mov Wty, eax
  94.  
  95.     ; ------------------------------------------------------------
  96.     ; Create the Splash Screen window with WS_EX_TOPMOST attribute
  97.     ; ------------------------------------------------------------
  98.       invoke CreateWindowEx,WS_EX_TOPMOST,
  99.                             ADDR szSplashName,
  100.                             ADDR szDisplayName,
  101.                             WS_POPUP or WS_BORDER,
  102.                             Wtx,Wty,Wwd,Wht,
  103.                             NULL,NULL,
  104.                             hInst,NULL
  105.       mov   hSplash,eax
  106.  
  107.       invoke ShowWindow,hSplash,SW_SHOWNORMAL
  108.       invoke UpdateWindow,hSplash
  109.  
  110.       invoke GetTickCount   ; get a time reference
  111.       mov tc, eax
  112.  
  113.     ; -------------------------------------------
  114.     ; the following WNDCLASSEX structure and
  115.     ; CreateWindowEx call are for the main window
  116.     ; -------------------------------------------
  117.       invoke LoadIcon,hInst,500    ; icon ID
  118.       mov hIcon, eax
  119.  
  120.       szText szClassName,"Project_Class"
  121.  
  122.       mov wc.cbSize,         sizeof WNDCLASSEX
  123.       mov wc.style,          CS_HREDRAW or CS_VREDRAW \
  124.                              or CS_BYTEALIGNWINDOW
  125.       mov wc.lpfnWndProc,    offset WndProc
  126.       mov wc.cbClsExtra,     NULL
  127.       mov wc.cbWndExtra,     NULL
  128.       m2m wc.hInstance,      hInst
  129.       mov wc.hbrBackground,  COLOR_BTNFACE+1
  130.       mov wc.lpszMenuName,   NULL
  131.       mov wc.lpszClassName,  offset szClassName
  132.       m2m wc.hIcon,          hIcon
  133.         invoke LoadCursor,NULL,IDC_ARROW
  134.       mov wc.hCursor,        eax
  135.       m2m wc.hIconSm,        hIcon
  136.  
  137.       invoke RegisterClassEx, ADDR wc
  138.  
  139.     ;--------------------------------
  140.     ; Centre window at following size
  141.     ;--------------------------------
  142.       mov Wwd, 500
  143.       mov Wht, 350
  144.  
  145.       invoke GetSystemMetrics,SM_CXSCREEN
  146.       invoke TopXY,Wwd,eax
  147.       mov Wtx, eax
  148.  
  149.       invoke GetSystemMetrics,SM_CYSCREEN
  150.       invoke TopXY,Wht,eax
  151.       mov Wty, eax
  152.  
  153.       invoke CreateWindowEx,WS_EX_LEFT,
  154.                             ADDR szClassName,
  155.                             ADDR szDisplayName,
  156.                             WS_OVERLAPPEDWINDOW,
  157.                             Wtx,Wty,Wwd,Wht,
  158.                             NULL,NULL,
  159.                             hInst,NULL
  160.       mov   hWnd,eax
  161.  
  162.       invoke LoadMenu,hInst,600  ; menu ID
  163.       invoke SetMenu,hWnd,eax
  164.  
  165.       invoke ShowWindow,hWnd,SW_SHOWNORMAL
  166.       invoke UpdateWindow,hWnd
  167.  
  168.       add tc, 2000  ; add 2 seconds to the time reference
  169.  
  170.     ; ------------------------------------------------
  171.     ; loop until Tick count catches up with added time
  172.     ; ------------------------------------------------
  173.     @@:
  174.       invoke GetTickCount
  175.         .if tc > eax
  176.           jmp @B
  177.         .endif
  178.     ; -------------------
  179.     ; Close Splash screen
  180.     ; -------------------
  181.       invoke SendMessage,hSplash,WM_SYSCOMMAND,SC_CLOSE,NULL
  182.  
  183.     ;-----------------------------------
  184.     ; Loop until PostQuitMessage is sent
  185.     ;-----------------------------------
  186.     StartLoop:
  187.       invoke GetMessage,ADDR msg,NULL,0,0
  188.       cmp eax, 0
  189.       je ExitLoop
  190.       invoke TranslateMessage, ADDR msg
  191.       invoke DispatchMessage,  ADDR msg
  192.       jmp StartLoop
  193.     ExitLoop:
  194.  
  195.       return msg.wParam
  196.  
  197. WinMain endp
  198.  
  199. ; #########################################################################
  200.  
  201. WndProc proc hWin   :DWORD,
  202.              uMsg   :DWORD,
  203.              wParam :DWORD,
  204.              lParam :DWORD
  205.  
  206.     LOCAL var    :DWORD
  207.     LOCAL caW    :DWORD
  208.     LOCAL caH    :DWORD
  209.     LOCAL Rct    :RECT
  210.     LOCAL hDC    :DWORD
  211.     LOCAL Ps     :PAINTSTRUCT
  212.     LOCAL tbab   :TBADDBITMAP
  213.     LOCAL tbb    :TBBUTTON
  214.     LOCAL buffer1[128]:BYTE  ; these are two spare buffers
  215.     LOCAL buffer2[128]:BYTE  ; for text manipulation etc..
  216.  
  217.     .if uMsg == WM_COMMAND
  218.     ;======== toolbar commands ========
  219.  
  220.         .if wParam == 50
  221.             szText tbMsg0,"WM_COMMAND ID 50"
  222.             invoke MessageBox,hWin,ADDR tbMsg0,
  223.                               ADDR szDisplayName,MB_OK
  224.  
  225.         .elseif wParam == 51
  226.             szText tbMsg1,"WM_COMMAND ID 51"
  227.             invoke MessageBox,hWin,ADDR tbMsg1,
  228.                               ADDR szDisplayName,MB_OK
  229.  
  230.         .elseif wParam == 52
  231.             szText tbMsg2,"WM_COMMAND ID 52"
  232.             invoke MessageBox,hWin,ADDR tbMsg2,
  233.                               ADDR szDisplayName,MB_OK
  234.  
  235.         .elseif wParam == 53
  236.             szText tbMsg3,"WM_COMMAND ID 53"
  237.             invoke MessageBox,hWin,ADDR tbMsg3,
  238.                               ADDR szDisplayName,MB_OK
  239.  
  240.         .elseif wParam == 54
  241.             szText tbMsg4,"WM_COMMAND ID 54"
  242.             invoke MessageBox,hWin,ADDR tbMsg4,
  243.                               ADDR szDisplayName,MB_OK
  244.  
  245.         .elseif wParam == 55
  246.             szText tbMsg5,"WM_COMMAND ID 55"
  247.             invoke MessageBox,hWin,ADDR tbMsg5,
  248.                               ADDR szDisplayName,MB_OK
  249.  
  250.         .elseif wParam == 56
  251.             szText tbMsg6,"WM_COMMAND ID 56"
  252.             invoke MessageBox,hWin,ADDR tbMsg6,
  253.                               ADDR szDisplayName,MB_OK
  254.  
  255.         .elseif wParam == 57
  256.             szText tbMsg7,"WM_COMMAND ID 57"
  257.             invoke MessageBox,hWin,ADDR tbMsg7,
  258.                               ADDR szDisplayName,MB_OK
  259.  
  260.         .elseif wParam == 58
  261.             szText tbMsg8,"WM_COMMAND ID 58"
  262.             invoke MessageBox,hWin,ADDR tbMsg8,
  263.                               ADDR szDisplayName,MB_OK
  264.  
  265.         .endif
  266.  
  267.     ;======== menu commands ========
  268.         .if wParam == 1000
  269.            jmp @F
  270.              szTitleO   db "Open A File",0
  271.              szFilterO  db "All files",0,"*.*",0,
  272.                            "Text files",0,"*.TEXT",0,0
  273.            @@:
  274.     
  275.            invoke FillBuffer,ADDR szFileName,length szFileName,0
  276.            invoke GetFileName,hWin,ADDR szTitleO,ADDR szFilterO
  277.     
  278.            cmp szFileName[0],0   ;<< zero if cancel pressed in dlgbox
  279.            je @F
  280.            ; file name returned in szFileName
  281.            invoke MessageBox,hWin,ADDR szFileName,
  282.                              ADDR szDisplayName,MB_OK
  283.            @@:
  284.  
  285.         .elseif wParam == 1001
  286.            jmp @F
  287.              szTitleS   db "Save file as",0
  288.              szFilterS  db "All files",0,"*.*",0,
  289.                            "Text files",0,"*.TEXT",0,0
  290.            @@:
  291.     
  292.            invoke FillBuffer,ADDR szFileName,length szFileName,0
  293.            invoke SaveFileName,hWin,ADDR szTitleS,ADDR szFilterS
  294.     
  295.            cmp szFileName[0],0   ;<< zero if cancel pressed in dlgbox
  296.            je @F
  297.            ; file name returned in szFileName
  298.            invoke MessageBox,hWin,ADDR szFileName,
  299.                              ADDR szDisplayName,MB_OK
  300.            @@:
  301.  
  302.         .endif
  303.         .if wParam == 1010
  304.             invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
  305.         .elseif wParam == 1900
  306.             szText AboutMsg,"Prostart Pure Assembler Template",13,10,\
  307.             "Copyright ⌐ Prostart 1999"
  308.             invoke ShellAbout,hWin,ADDR szDisplayName,ADDR AboutMsg,hIcon
  309.         .endif
  310.     ;====== end menu commands ======
  311.  
  312.     .elseif uMsg == WM_SYSCOLORCHANGE
  313.         invoke Do_ToolBar,hWin
  314.  
  315.     .elseif uMsg == WM_CREATE
  316.         invoke Do_ToolBar,hWin
  317.  
  318.         invoke Do_Status,hWin
  319.  
  320.     .elseif uMsg == WM_SIZE
  321.         invoke SendMessage,hToolBar,TB_AUTOSIZE,0,0
  322.         invoke MoveWindow,hStatus,0,0,0,0,TRUE
  323.  
  324.     .elseif uMsg == WM_PAINT
  325.         invoke BeginPaint,hWin,ADDR Ps
  326.           mov hDC, eax
  327.           invoke Paint_Proc,hWin,hDC
  328.         invoke EndPaint,hWin,ADDR Ps
  329.         return 0
  330.  
  331.     .elseif uMsg == WM_CLOSE
  332.  
  333.     .elseif uMsg == WM_DESTROY
  334.         invoke PostQuitMessage,NULL
  335.         return 0 
  336.     .endif
  337.  
  338.     invoke DefWindowProc,hWin,uMsg,wParam,lParam
  339.  
  340.     ret
  341.  
  342. WndProc endp
  343.  
  344. ; ########################################################################
  345.  
  346. TopXY proc wDim:DWORD, sDim:DWORD
  347.  
  348.     shr sDim, 1      ; divide screen dimension by 2
  349.     shr wDim, 1      ; divide window dimension by 2
  350.     mov eax, wDim    ; copy window dimension into eax
  351.     sub sDim, eax    ; sub half win dimension from half screen dimension
  352.  
  353.     return sDim
  354.  
  355. TopXY endp
  356.  
  357. ; #########################################################################
  358.  
  359. Paint_Proc proc hWin:DWORD, hDC:DWORD
  360.  
  361.     LOCAL btn_hi   :DWORD
  362.     LOCAL btn_lo   :DWORD
  363.     LOCAL Rct      :RECT
  364.  
  365.     invoke GetSysColor,COLOR_BTNHIGHLIGHT
  366.     mov btn_hi, eax
  367.  
  368.     invoke GetSysColor,COLOR_BTNSHADOW
  369.     mov btn_lo, eax
  370.  
  371.     return 0
  372.  
  373. Paint_Proc endp
  374.  
  375. ; ########################################################################
  376.  
  377. SplashProc proc hWin   :DWORD,
  378.                 uMsg   :DWORD,
  379.                 wParam :DWORD,
  380.                 lParam :DWORD
  381.  
  382.     LOCAL hDC :DWORD
  383.     LOCAL Rct :RECT
  384.     LOCAL Ps  :PAINTSTRUCT
  385.  
  386.     .if uMsg == WM_PAINT
  387.         invoke BeginPaint,hWin,ADDR Ps
  388.         mov hDC, eax
  389.  
  390.       ; ----------------------------------------------------------
  391.       ; This area is where you control what is put on the splash
  392.       ; screen, text, BitBlt() bitmaps or GDI based graphics
  393.       ; drawing functions.
  394.       ; ----------------------------------------------------------
  395.  
  396.         invoke SetBkMode,hDC,TRANSPARENT
  397.         invoke GetClientRect,hWin,ADDR Rct
  398.  
  399.         szText splashMsg,"Splash Screen"
  400.         invoke DrawText,hDC,ADDR splashMsg,13,ADDR Rct,
  401.                         DT_SINGLELINE or DT_VCENTER or DT_CENTER
  402.  
  403.       ; ----------------------------------------------------------
  404.  
  405.         invoke EndPaint,hWin,ADDR Ps
  406.         return 0
  407.  
  408.     .endif
  409.  
  410.     invoke DefWindowProc,hWin,uMsg,wParam,lParam
  411.  
  412.     ret
  413.  
  414. SplashProc endp
  415.  
  416. ; ########################################################################
  417.  
  418. end start
  419.