This is my first attempt at learning to write a Win 32 program.
It is a slight modification of one in the MASM 32 package.

I looked thru the tuts but I could find out what I need.

I want this to open up fullscreen when I execute it.
There is probably some code that specifies window size.

I am making it to send to my daughter.

Thanks.



.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
IDB_MAIN equ 1

.data
ClassName db "SimpleWin32ASMBitmapClass",0
AppName db "With Love from Dad (His first Windows Program)",0

.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hBitmap dd ?

.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
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,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,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
LOCAL ps:PAINTSTRUCT
LOCAL hdc:HDC
LOCAL hMemDC:HDC
LOCAL rect:RECT
.if uMsg==WM_CREATE
invoke LoadBitmap,hInstance,IDB_MAIN
mov hBitmap,eax
.elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
invoke CreateCompatibleDC,hdc
mov hMemDC,eax
invoke SelectObject,hMemDC,hBitmap
invoke GetClientRect,hWnd,addr rect
invoke BitBlt,hdc,0,0,rect.right,rect.bottom,hMemDC,0,0,SRCCOPY
invoke DeleteDC,hMemDC
invoke EndPaint,hWnd,addr ps
.elseif uMsg==WM_DESTROY
invoke DeleteObject,hBitmap
invoke PostQuitMessage,NULL
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
end start
Posted on 2004-02-17 20:29:09 by skywalker
you specify the window size on the call to CreateWindowEx - look at MSDN, PlatformSDK or win32.hlp for more information.

To create a "fullscreen" window, do GetWindowRect() on the HWND obtained with GetDesktopWindow(), and use the values in the RECT in the call to CreateWindowEx.

I use this myself for DirectX applications, so the transition to a DX fullscreen video mode looks smoother (compared to some games, where you see part of a dummy window for half a sec before the game is completely initialized.)

Ranma, a bit silly to call ShowWindow, when you can add WS_MAXIMIZE to dwStyle on CreateWindowEx - besides this is just maximized, not 'fullscreen' :)
Posted on 2004-02-18 01:31:35 by f0dder

you specify the window size on the call to CreateWindowEx - look at MSDN, PlatformSDK or win32.hlp for more information.

To create a "fullscreen" window, do GetWindowRect() on the HWND obtained with GetDesktopWindow(), and use the values in the RECT in the call to CreateWindowEx.

I use this myself for DirectX applications, so the transition to a DX fullscreen video mode looks smoother (compared to some games, where you see part of a dummy window for half a sec before the game is completely initialized.)

Ranma, a bit silly to call ShowWindow, when you can add WS_MAXIMIZE to dwStyle on CreateWindowEx - besides this is just maximized, not 'fullscreen' :)


Found this on MS, a little slim on the comments though. Just keep in mind that my previous post was a MINOR modification of one of Hutch's example. By reading though the code I realized that the bitmap name is stored
in the .rc file. Not sure why a lone two line file is necessary to store the bitmap. Don't answer that yet.

Thanks.

HWND hwndOwner;
RECT rc, rcDlg, rcOwner;

case WM_INITDIALOG:

// Get the owner window and dialog box rectangles.

if ((hwndOwner = GetParent(hwndDlg)) == NULL)
{
hwndOwner = GetDesktopWindow();
}

GetWindowRect(hwndOwner, &rcOwner);
GetWindowRect(hwndDlg, &rcDlg);
CopyRect(&rc, &rcOwner);

// Offset the owner and dialog box rectangles so that
// right and bottom values represent the width and
// height, and then offset the owner again to discard
// space taken up by the dialog box.

OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
OffsetRect(&rc, -rc.left, -rc.top);
OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);

// The new position is the sum of half the remaining
// space and the owner's original position.

SetWindowPos(hwndDlg,
HWND_TOP,
rcOwner.left + (rc.right / 2),
rcOwner.top + (rc.bottom / 2),
0, 0, // ignores size arguments
SWP_NOSIZE);

if (GetDlgCtrlID((HWND) wParam) != ID_ITEMNAME)
{
SetFocus(GetDlgItem(hwndDlg, ID_ITEMNAME));
return FALSE;
}
return TRUE;
Posted on 2004-02-18 06:23:06 by skywalker