1. win32lib main window

The documentation furnishes these configurations for ShowWindow.

SW_HIDE = 0, SW_SHOWNORMAL = 1, SW_NORMAL = 1, SW_SHOWMINIMIZED = 2, SW_SHOWMAXIMIZED = 3, SW_MAXIMIZE = 3, SW_SHOWNOACTIVATE = 4, SW_SHOW = 5, SW_MINIMIZE = 6, SW_SHOWMINNOACTIVE = 7, SW_SHOWNA = 8, SW_RESTORE = 9, SW_SHOWDEFAULT = 10, SW_MAX = 10, w32FullScreen = "fullscreen",

However, none of these produce the same result as clicking on the max-min icon of a main window. Any one know how to accomplish the above result by code?

Buzzo

new topic     » topic index » view message » categorize

2. Re: win32lib main window

This works for me...

 
include Win32Lib.ew 
 
constant 
    Main        = create( Window, "Min/Max Testing", 0, Default, Default, 640, 480, 0 ), 
    MinButton   = create( PushButton, "Minimize", Main, 0, 0, 90, 30, 0 ), 
    MaxButton   = create( PushButton, "Maximize", Main, 0, 0, 90, 30, 0 ), 
$ 
 
procedure Main_OnResize( integer self, integer event, sequence params ) 
     
    -- params[1] is the 'style' of the size event. 
    -- See Win32Lib documentation for w32HResize. 
     
    if params[1] = SIZE_RESTORED then 
         
        -- Next action should be SW_MAXIMIZE. 
        setText( MaxButton, "Maximize" ) 
         
    elsif params[1] = SIZE_MAXIMIZED then 
         
        -- Next action should be SW_RESTORE. 
        setText( MaxButton, "Restore" ) 
         
    end if 
     
    -- Center the buttons. 
    setRect( MinButton, {0.5,-45}, {0.5,-35}, 90, 30, w32True ) 
    setRect( MaxButton, {0.5,-45}, {0.5,  5}, 90, 30, w32True ) 
     
end procedure 
setHandler( Main, w32HResize, routine_id("Main_OnResize") ) 
 
procedure MinButton_OnClick( integer self, integer event, sequence params ) 
     
    -- Just minimize the window. 
    showWindow( Main, SW_MINIMIZE ) 
     
end procedure 
setHandler( MinButton, w32HClick, routine_id("MinButton_OnClick") ) 
 
procedure MaxButton_OnClick( integer self, integer event, sequence params ) 
     
    sequence text = getText( MaxButton ) 
     
    -- Update the window state, based on the current button text. The event 
    -- handler for w32HResize the window will update the text accordingly. 
     
    if equal( text, "Maximize" ) then 
         
        showWindow( Main, SW_MAXIMIZE ) 
         
    elsif equal( text, "Restore" ) then 
         
        showWindow( Main, SW_RESTORE ) 
         
    end if 
     
end procedure 
setHandler( MaxButton, w32HClick, routine_id("MaxButton_OnClick") ) 
 
WinMain( Main, Normal ) 

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: win32lib main window

Thanks, again, Greg... I should have mentioned that I want the program to startup maximized...

I found that if I use this,

 
WinMain(win,SW_MAXIMIZE)	--Normal)  
 

I have the desired result..

Your code will be of use for fullscreen progs, when a size change needs to be made.

Buzzo

new topic     » goto parent     » topic index » view message » categorize

4. Re: win32lib main window

Ah yes, the style values for showWindow() are not the same as for WinMain() (bonus: openWindow() actually accepts the styles from either function!)

When in doubt, always check the docs. Win32Lib documentation is quite helpful. smile

Win32Lib docs said...

showWindow ( window, style )

Shows a window according to the style

Category: Attributes

window is either a control id or the name of a Window control.

The style flag is one of those in this list.

  • SW_HIDE = 0
  • SW_SHOWNORMAL = 1
  • SW_NORMAL = 1
  • SW_SHOWMINIMIZED = 2
  • SW_SHOWMAXIMIZED = 3
  • SW_MAXIMIZE = 3
  • SW_SHOWNOACTIVATE = 4
  • SW_SHOW = 5
  • SW_MINIMIZE = 6
  • SW_SHOWMINNOACTIVE = 7
  • SW_SHOWNA = 8
  • SW_RESTORE = 9
  • SW_SHOWDEFAULT = 10
  • w32FullScreen = "fullscreen"

Example:

showWindow(formErrors, SW_HIDE)
showWindow("Message List", SW_RESTORE)

Win32Lib docs said...

WinMain ( window, style )

Run event loop.

Category: System Attributes

This is the main processing loop for Win32Lib. Call WinMain after all the controls and their handlers have been defined for the initial running of the application.

The main window is set to window. When window is closed, the application is shut down. Note that if window is -1 then the first window defined is used as the primary window.

If you wish to have an application that has no window under the control of win32lib, but still wish to use its Windows Message loop, then set window as 0.

The style flag is one of the following:

  • Normal: Original size.
  • Minimized: Minimized into the task bar.
  • Maximized: Fills the client area of the screen.

The WinMain function will open the application's main window.

It it possible to specify the control that will get the initial focus when the window opens. See openWIndow for details.

For example:

-- set MyWindow as main window, open normally
-- with the initial focus on the Login button.
WinMain( {MyWindow, btnLogin}, Normal )

Win32Lib docs said...

openWindow ( window, style )

Opens a window

Category: Attributes

window is either a control id, a two-element sequence containing {control id, focus id}, or the name of a Window control.

If window is a Window then the style flag is one of the following:

  • Normal: Original size.
  • Minimize: Minimized into the task bar.
  • Maximize: Fills screen.
  • Modal: Original size, but no other application window can get focus until this window is closed. Use to emulate modal dialogs.
  • Win32 Flag: For example, SW_SHOWMINNOACTIVE.

The openWindow function will trigger an w32HOpen event before it is opened and a w32HActivate event after it is opened. If the w32HOpen event calls returnValue(-1), the window is not opened.

It it possible to specify the control that will get the initial focus when the window opens. To do this, the window parameter must be specified in the form {window_id, focus_id}. If the focus_id is zero, then the first Edit type control is given focus. If there are no edit boxes, then the first button type control is given focus. If you don't specify the initial focus control, then the control that last had focus in the window is used.

Example:

-- Open the Login window, giving focus to the User ID field.
openWindow({formLogin txtUserId}, Normal)

-- Open the Messages window.
openWindow("Message List", Normal)

-- Open an input form
openWindow(vPromptCust, {"Name","<unknown>"} )

-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu