flat assembler
Message board for the users of flat assembler.

Index > Windows > can't create maximized window

Author
Thread Post new topic Reply to topic
sobrien



Joined: 25 Jun 2006
Posts: 2
sobrien
hello,

I'm a total newb so please be gentle with me Smile
I was messing about with template.asm from the examples folder of fasm and can't figure how to create a maximized window. I can maximize it after creation but according to win32hlp, if I create it with the WS_MAXIMIZE it should be maximized upon creation. Here's the code anyway Confused

Code:
; Template for program using standard Win32 headers

format PE GUI 4.0
entry start

include '%fasminc%\win32a.inc'

section '.data' data readable writeable

  _title db 'Win32 program template',0
  _class db 'FASMWIN32',0

  wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,_class

  msg MSG

section '.code' code readable executable

  start:

        invoke  GetModuleHandle,0
        mov     [wc.hInstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],eax
        invoke  RegisterClass,wc

        invoke  CreateWindowEx,0,_class,_title,\
                WS_VISIBLE+WS_OVERLAPPEDWINDOW+WS_MAXIMIZE,\    ;Shouldn't this load a maximized window?
                128,128,192,192,\
                NULL,NULL,[wc.hInstance],NULL

;From win32hlp :-

;       If an application specifies the WS_MAXIMIZE or WS_MINIMIZE style in the CreateWindowEx function,
;       the window is initially maximized or minimized.


  msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        or      eax,eax
        jz      end_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  end_loop:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc hwnd,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_DESTROY
        je      wmdestroy
  defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     finish
  wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax
  finish:
        pop     edi esi ebx
        ret
endp

section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
        user32,  'USER32.DLL'

include '%fasminc%\apia\Kernel32.inc'
include '%fasminc%\apia\User32.inc'
    
Post 25 Jun 2006, 12:36
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Your program opens a maximized window on my WinXP.

[edit]Sorry, it only works if I run it from FASMW, but if I just do double click over the exe file on the desktop it opens a very small window :S

This code fix the problem:
Code:
        invoke  CreateWindowEx,0,_class,_title,\ 
                WS_OVERLAPPEDWINDOW,\    ;Shouldn't this load a maximized window?
                128,128,192,192,\ 
                NULL,NULL,[wc.hInstance],NULL
        invoke ShowWindow, eax, SW_SHOWMAXIMIZED    
Post 25 Jun 2006, 14:15
View user's profile Send private message Reply with quote
sobrien



Joined: 25 Jun 2006
Posts: 2
sobrien
Thx for the reply locode, but let me reiterate my OP

Quote:
...how to create a maximized window

Quote:
I can maximize it after creation... (Which is what you are doing in your code)

and from the code...
Quote:
From win32hlp :-

If an application specifies the WS_MAXIMIZE or WS_MINIMIZE style
in the CreateWindowEx function, the window is initially maximized or minimized.

and the window style I used in CreatWindowEx was
Quote:
WS_VISIBLE+WS_OVERLAPPEDWINDOW+WS_MAXIMIZE

but this isn't creating a maximized window.
Post 25 Jun 2006, 16:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.