How to open at startup the window maximized

Started by stapper, January 01, 2009, 03:24:00 PM

Previous topic - Next topic

stapper

Hi,

Iam new in Assembly.
How do i in a proper way open the application with the window en richedit maximized .

.Const

.Data?

.Data

.Code

WinMainProcedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM

   .If uMsg == WM_COMMAND
      Mov Eax, wParam
      .If Ax == IDM_WINMAIN_IDC_NEW                  ;Request for a new file

      .ElseIf Ax == IDM_WINMAIN_IDC_EXIT               ;Exit application from Menu
         Invoke SendMessage, hWnd, WM_CLOSE, 0, 0
         Return TRUE

      .ElseIf Ax == IDM_WINMAIN_IDC_OPEN            ;Open a file

      .EndIf
   .EndIf
   .If uMsg == WM_CREATE

      Return TRUE

   .ElseIf uMsg == WM_CLOSE
      Invoke IsModal, hWnd
      .If Eax
         Invoke EndModal, hWnd, IDCANCEL
         Return TRUE
      .EndIf
   .EndIf
   Return FALSE
WinMainProcedure EndP


WinMainRichEdit1 Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM

   Invoke ShowWindow, hWnd, SW_MAXIMIZE
   Return FALSE
WinMainRichEdit1 EndP

Ramon Sala

Hi stapper,

Welcome to assembly and thanks for using Easy Code.

The best you can do is deleting the WinMainRichEdit1 procedure and control all the messages through its parent, the main window. So, in the WM_CREATE message of the WinMainProcedure procedure, get the handle to the richedit control and save it in a global variable (let's say hWndEdit). Then resize the RichEdit control to fit its parent client area. Here is the code:


.Const

.Data?

.Data

hWndEdit   HWND   NULL


.Code

WinMainProcedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
   .If uMsg == WM_CREATE

      Invoke GetWindowItem, hWnd, IDC_WINMAIN_RICHEDIT1
      Mov hWndEdit, Eax


      Return TRUE

   .ElseIf uMsg == WM_SIZE
      ;Get the width of client
      ;area and save it to Edx
      LoWord wParam
      Mov Edx, Eax


      ;Get the height of client area
      HiWord wParam

      ;Resize the rich edit control to
      ;fit the whole parent's client area
      Invoke MoveWindow, hWndEdit, 0, 0, Edx, Eax, TRUE
      
   .ElseIf uMsg == WM_COMMAND
      ...
      ...
      ...
   .ElseIf uMsg == WM_CLOSE
      Invoke IsModal, hWnd
      .If Eax
         Invoke EndModal, hWnd, IDCANCEL
         Return TRUE
      .EndIf
   .EndIf
   Return FALSE
WinMainProcedure EndP


Finally, if you want the application to appear maximized when starting, just change the main window ShowWindow property to Maxmized.

Regards and happy new year,

Ramon



Greetings from Catalonia

stapper

Thanks for reply Ramon and also happy new year for you

I found alot of examples and iam starting to study them.

Kind regards

Patrick


Ramon Sala

Greetings from Catalonia