; <<
; File name: fullscr. ASM
; Author: Purple endurer (purpleendurer@163.com)
Function: the demo program switches between window mode and full screen mode.
; Date log
;-------------------------------------------------
The Code was optimized from
; Use settimer () and getasynckeystate () to add the ESC key
; As a hotkey for switching from full screen to window mode!
; In full screen mode, the window cannot receive the wm_keydown message
; Create! Switch between full screen and window mode!
On a foreign masm32 forum, I saw some netizens discussing how to use it.
; Masm32: write a full-screen window program. Therefore
Use VC 6.0 to write the Flash Player-5. Full Screen playback
; (Http://blog.csdn.net/purpleendurer/archive/2005/12/07/545717.aspx)
.
; <<
. 386
. Model flat, stdcall
Option Casemap: None
Include/masm32/include/Windows. inc
Include/masm32/include/user32.inc
Include/masm32/include/gdi32.inc
Include/masm32/include/kernel32.inc
Include/masm32/include/shell32.inc
Includelib/masm32/lib/user32.lib
Includelib/masm32/lib/gdi32.lib
Includelib/masm32/lib/kernel32.lib
Includelib/masm32/lib/shell32.lib
Winmain proto: DWORD,: DWORD
Setfullscr proto: hwnd
Setwinmode proto: hwnd
Switchmode proto: hwnd
M_m2m macro D1, D2
Push D2
Pop d1
Endm
;. Const
C_buttonid equ 1
C_timerid equ 1
. Data
G_szwinclsname DB "demowinclass", 0
G_szappname DB "Full Screen Display demo by purpleendurer", 0
G_szbtnclsname DB "button", 0
G_szfullscr DB "full screen display! ", 0
G_szsetwinmode DB "window display! Press ESC to return! ", 0
G_szfailwinmode DB "failed to set to window mode! ", 0
G_szfailfullscrmode DB "failed to be set to full screen mode! ", 0
G_bisfull DWORD false
. Data?
G_hinstance hinstance?
G_hwndbutton handle?
G_storiginpos windowplacement <>
. Code
Start:
Invoke getmodulehandle, null
MoV g_hinstance, eax
Invoke winmain, g_hinstance, null, null, sw_showdefault
Invoke exitprocess, eax
Winmain proc hinst: hinstance, hprevinst: hinstance, using line: lpstr, cmdshow: DWORD
Local WC: wndclassex
Local MSG: msg
Local hwnd: hwnd
M_m2m WC. cbsize, sizeof wndclassex
M_m2m WC. style, cs_hredraw or cs_vredraw
M_m2m WC. lpfnwndproc, offset wndproc
M_m2m WC. cbclsextra, null
M_m2m WC. cbwndextra, null
M_m2m WC. hinstance, g_hinstance
M_m2m WC. hbrbackground, color_window + 1
M_m2m WC. lpszmenuname, null
M_m2m WC. lpszclassname, offset g_szwinclsname
Invoke loadicon, null, idi_application
MoV WC. hicon, eax
MoV WC. hiconsm, eax
Invoke loadcursor, null, idc_arrow
MoV WC. hcursor, eax
Invoke registerclassex, ADDR WC
Invoke createappswex, null, ADDR g_szwinclsname, ADDR g_szappname ,/
Ws_overlappedwindow, cw_usedefault ,/
Cw_usedefault, null, null ,/
Hinst, null
MoV hwnd, eax
Invoke showwindow, hwnd, sw_shownormal
Invoke updatewindow, hwnd
. 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
Winmain endp
Wndproc proc hwnd: hwnd, umsg: uint, wparam: wparam, lparam: lparam
. If umsg = wm_destroy
Invoke postquitmessage, null
. Elseif umsg = wm_create
; Create button
Invoke createjavaswex, null, ADDR g_szbtnclsname, ADDR g_szfullscr ,/
Ws_child or ws_visible or bs_defpushbutton ,/
25, 25,560, 50, hwnd, c_buttonid, g_hinstance, null
MoV g_hwndbutton, eax
. Elseif umsg = wm_command
MoV eax, wparam
. If lparam! = 0
. If AX = c_buttonid
SHR eax, 16
. If AX = bn_clicked
Invoke switchmode, hwnd
. Endif
. Endif
. Endif
. Elseif umsg = wm_timer
Invoke getasynckeystate, vk_escape; ESC key
Test eax, 08000 H
JZ @ F
Invoke switchmode, hwnd
@@:
. Else
Invoke defwindowproc, hwnd, umsg, wparam, lparam
RET
. Endif
XOR eax, eax
RET
Wndproc endp
Switchmode proc hwnd: hwnd
. If g_bisfull = true
Invoke killtimer, hwnd, c_timerid; clear Timer
Invoke setwinmode, hwnd; set to window mode
. If eax = 0
Invoke MessageBox, hwnd, ADDR g_szfailwinmode, ADDR g_szappname, mb_iconerror
RET
. Endif
M_m2m g_bisfull, false
Invoke setwindowtext, g_hwndbutton, ADDR g_szfullscr; modify the text of the button
. Else
Invoke setfullscr, hwnd; set to full screen mode
. If eax = 0
Invoke MessageBox, hwnd, ADDR g_szfailfullscrmode, ADDR g_szappname, mb_iconerror
RET
. Endif
M_m2m g_bisfull, true
Invoke settimer, hwnd, c_timerid, 100, null; start the timer to capture the ESC key
Invoke setwindowtext, g_hwndbutton, ADDR g_szsetwinmode; modify the text of the button
. Endif
RET
Switchmode endp
; //////////////////////////////////////// ////////////////////////////////////
; Return Value: If failed, eax = 0; if successful, eax! = 0
; //////////////////////////////////////// ////////////////////////////////////
Setfullscr proc hwnd: hwnd
Local HDC: hwnd
Local dwhorzres, dwvertres: DWORD
Invoke getwindowplacement, hwnd, ADDR g_storiginpos
Invoke getwindowlong, hwnd, gwl_style
XOR eax, ws_caption; push EDI
; MoV EDI, ws_caption
; Not EDI
; And eax, EDI
; Push EDI
Invoke setwindowlong, hwnd, gwl_style, eax; // remove the title bar.
Invoke getdc, hwnd
MoV HDC, eax
Invoke getdevicecaps, HDC, horzres
MoV dwhorzres, eax
Invoke getdevicecaps, HDC, vertres
MoV dwvertres, eax
XOR eax, eax
Invoke movewindow, hwnd, eax, eax, dwhorzres, dwvertres, true
XOR eax, eax
Invoke setwindowpos, hwnd, hwnd_topmost, eax, eax, dwhorzres, dwvertres, swp_showwindow; Full Screen Display
RET
Setfullscr endp
; //////////////////////////////////////// ////////////////////////////////////
; Return Value: If failed, eax = 0; if successful, eax! = 0
; //////////////////////////////////////// ////////////////////////////////////
Setwinmode proc hwnd: hwnd
Invoke getwindowlong, hwnd, gwl_style
Or eax, ws_caption
Invoke setwindowlong, hwnd, gwl_style, eax; // restore the title bar
Invoke showwindow, hwnd, sw_hide
Invoke setwindowplacement, hwnd, ADDR g_storiginpos
RET
Setwinmode endp
End start