News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Windows sizing revisited

Started by shankle, June 22, 2005, 03:04:23 PM

Previous topic - Next topic

shankle

To get a window with this code you have to maximize it.
In other words the only thing that appears on the screen is the minimize/maximize/X box.
I have tried all kinds of combinations of settings to make the window appear maximized. No Luck.
Also read the manuals on CreateWindowEx,  SystemParametersInfo, WinMain - no luck.

Now if I hit the maximize button the window will appear and it is correct.   


;--------------------------------------------------
;   Hello Windows Resolution Testing Program
; -------------------------------------------------
.486
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
WinMain           PROTO :DWORD,:DWORD,:DWORD,:DWORD
.data               
AppName          db   'The Hello Program',0
Windowsmsg       db   'Hello, Windows 95!',0
szDisplayName    db   'Hello Windows',0
.data?
CommandLine   LPSTR     ?
hInstance     dd        ?
rect          RECT      {?}
.code
start:
invoke GetModuleHandle, NULL
mov    hInstance,eax
invoke GetCommandLine
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWNORMAL
invoke ExitProcess,eax
WinMain PROC hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:DWORD
LOCAL wc:WNDCLASSEX, msg: MSG, hwnd: HWND, hBrush: DWORD, hdc: HDC, rr: RECT
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  hInst
pop   wc.hInstance
invoke LoadIcon, NULL, IDI_APPLICATION
mov   wc.hIcon, eax
      invoke LoadCursor, NULL,IDC_ARROW
mov   wc.hCursor, eax
      invoke GetStockObject, (WHITE_BRUSH)
      mov   hBrush, eax
mov   wc.hbrBackground, eax
mov   wc.lpszMenuName, NULL
mov   wc.lpszClassName, OFFSET szDisplayName
mov   wc.hIconSm, 0
invoke RegisterClassEx, addr wc
      invoke SystemParametersInfo, SPI_GETWORKAREA, 0, RECT, 0       
INVOKE CreateWindowEx, NULL, ADDR szDisplayName, ADDR AppName,\
           WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rr.right,\
           rr.bottom, NULL, NULL, hInst, NULL           
      mov   hwnd, eax
INVOKE ShowWindow, hwnd, SW_SHOWNORMAL
INVOKE UpdateWindow, hwnd
      StartLoop:
          INVOKE GetMessage, ADDR msg, NULL, 0, 0
          cmp eax, 0
          je ExitLoop
          INVOKE TranslateMessage, ADDR msg
          INVOKE DispatchMessage, ADDR msg
          jmp StartLoop
       ExitLoop:
          mov eax, msg.wParam
          ret           
WinMain ENDP
WndProc PROC  hWnd:HWND, iMsg:UINT, wParam:WPARAM, lParam:LPARAM
        LOCAL hdc: HDC, hInst: HINSTANCE, ps:PAINTSTRUCT, rr: RECT         
       .if iMsg==WM_PAINT
         invoke BeginPaint, hWnd, ADDR ps
         mov hdc, eax         
         invoke DrawText, hdc, addr Windowsmsg, -1, addr rect,\
               DT_SINGLELINE or DT_CENTER or DT_VCENTER
        invoke EndPaint, hWnd, ADDR ps         
   GetOut:     
      .ELSEIF iMsg==WM_DESTROY
         invoke PostQuitMessage,NULL
         ret 0
.ENDIF
      invoke DefWindowProc, hWnd, iMsg, wParam, lParam
ret 
WndProc ENDP             
end start


Thanks for any help.
Very Puzzled,
JPS
The greatest crime in my country is our Congress

Maelstrom

You have two seperate issues with the program the way it is stated.

First is the local RECT "rr".  It is never properly initialized after creation so, I believe, it is defaulted to all zeros.  So on main window creation the window size is being defined as (X:0, Y:0, Width:0, Height:0) so in this case it is making the window as small as possible.  You should probably lose the local RECT and fill in some constants.

Besides from that in the main window callback you will have the same problem with the API DrawText call.  Since the RECT is not being initialized its going to clip the text output to nothing...

:toothy

shankle

Thank you so much.
Your suggestions pointed me in the right direction.

The program is now working.

JPS
The greatest crime in my country is our Congress