Re: multi-window Windows app?

new topic     » topic index » view thread      » older message » newer message

Hi George,

> The docs say, "The main window is set to <i>window</i>. When
> <i>window</i>
> is closed, the application is shut down."
>
> That seems pretty limiting. Suppose I want to (and I think I
> do) create a
> multiple-window application. Sounds like I can't do it, using
> this version
> of Win32lib. Am I correct, or is there a way to overcome that
> limitation?

multi-window apps are very possible - look at the IDE that Judith is working
on.

The "main window" is defined as the window supplied in the WinMain() call.
If this window is closed then the app closes down. It is not the first, last
or any other window created in your application. For example...

  -------------------------------------
  include win32lib.ew
  if compare(Win32LibVersion, {0,54,5}) < 0
  then
     abortErr("Needs Win32lib.ew version 0.54.5 or later")
  end if

  without warning
  integer cPrimary, cSecondary, cApp
  integer cCloseBox

  -- Define an invisible "app" window
  cApp = create(Window, "", 0, 0, 0, 0, 0, {WS_POPUP})

  procedure Close_Primary()
    -- Only close the app if the checkbox is checked.
    if isChecked(cCloseBox) then
      -- closing the "main" window closes the app.
      closeWindow(cApp)
    else
      -- return -1 to stop this window closing.
      returnValue(-1)
    end if
  end procedure

  procedure Open_App()
    -- Create the "real" windows.
    cPrimary   = create(Window, "My Wonderful Application", 0, 0, 0, 300,
300, 0)
    cCloseBox  = create(CheckBox, "Close App?", cPrimary, 5, 5, 80, 25, 0)

    cSecondary = create(Window, "Message Log", 0, 0, 300, 400, 100, 0)

    onClose[cPrimary] = routine_id("Close_Primary")

    -- Show the windows I'll actually be using.
    -- Notice that the order of opening is not important here.
    openWindow(cSecondary, Normal)
    openWindow(cPrimary, Normal)

    -- Make sure this gets focus. (Ooops! This only works v0.55 onwards)
    setFocus(cPrimary)
  end procedure

  -- Start the app running.
  onOpen[cApp] = routine_id("Open_App")
  WinMain(cApp, Normal)
  -------------------------------------


> I am trying to rapidly develop a prototype here. I'm willing
> to *eventually*
> learn as much detail of Windows programming as I need to get
> the job done,
> but would like to do things easily and quickly in the short term.

If using win32lib is still too hard, please let us know what can be done to
improve it.

----
cheers,
Derek Parnell

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu