Re: Child windows with Win32Lib

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

Heh....   Well, I just learned how to create MDI windows yesterday, and I
had so much FUN learning how to do it *sarcasm*....  Heh.  I don't know how
to do it in Win32Lib, but I know how to do it using the Win32 API...  I'm
using the API wrappers that I made..  If anyone's curious why I'm making my
own set, it's because I find it easier to teach myself the Win32 API this
way..  Well, here's the code..

-- Code starts here --

-- Includes --
include machine.e
include win32.ew
include user32.ew
include abxtra32.ew   -- My "cheater" routines.  Hehehe :) --

-- Constants --
constant

   --
   -- I'm not going to use the structure stuff
   -- that I already defined in win32.ew, just
   -- to let everyone know.
   --
   SIZEOF_MSG = 28,   -- This is usually 40...  Are there extra fields? --
   SIZEOF_CLIENTCREATESTRUCT = 8,
   msg_wParam = 8,
   ccs_hWindowMenu = 0,
   ccs_idFirstChild  = 4

-- Variables --
object junk
atom hWndMain, hWndMDI

-- Initialize variables --
hWndMain = NULL
hWndMDI = NULL

--------
-- WindowProc
--------
function WindowProc(atom hWnd, atom uMsg, atom wParam, atom lParam)
   -- The window procedure --

   -- Check if we're dealing with the MDI frame window --
   if hWnd = hWndMain then

      -- Handle the WM_DESTROY message --
      if uMsg = WM_DESTROY then
         PostQuitMessage(0)
         return 0
      end if

      -- Handle any messages that weren't processed --
      return DefFrameProc(hWnd, hWndMDI, uMsg, wParam, lParam)

   -- Otherwise, we're dealing with child windows --
   else

      -- Handle any messages that weren't processed --
      return DefMDIChildProc(hWnd, uMsg, wParam, lParam)
   end if
end function

--------
-- WinMain
--------
function WinMain(atom hInstance, atom hPrevInstance, atom lpCmdLine, atom
nCmdShow)
   -- The main function --
   atom msg, ccs

   --
   -- Allocate space for the structures.
   --
   -- Let's assume there's no longer a such thing as errors
   -- for the duration of this function... :)
   --
   msg = allocate(SIZEOF_MSG)
   ccs = allocate(SIZEOF_CLIENTCREATESTRUCT)

   -- Register a class using my RegisterEuAppClass "cheater" function..
Hehe :) --
   junk = RegisterEuAppClass(call_back(routine_id("WindowProc")), "MDITest")

   -- Create an MDI frame window --
   hWndMain = CreateWindow("MDITest", "MDI Test", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP,
NULL, hInstance, NULL)

   --
   -- Initialize the data in the CLIENTCREATESTRUCT structure
   --
   -- This data must be passed when creating an MDI client window.
   --
   poke4(ccs + ccs_hWindowMenu, NULL)
   poke4(ccs + ccs_idFirstChild, 1)

   --
   -- Create the MDI client window
   --
   -- MDIClient is a preregistered class name
   -- in Windows.
   --
   hWndMDI = CreateWindow("MDIClient", NULL, {WS_CHILD, WS_VISIBLE}, 0, 0,
0, 0, hWndMain, NULL, hInstance, ccs)

   -- Show the window and update it --
   ShowWindow(hWndMain, nCmdShow)
   UpdateWindow(hWndMain)

   -- The message loop --
   while GetMessage(msg, NULL, 0, 0) do
      TranslateMessage(msg)
      DispatchMessage(msg)
   end while

   -- Get msg.wParam (The value that should be returned to Windows) --
   junk = peek4u(msg, msg_wParam)

   -- Free the structures --
   free(msg)
   free(ccs)

   -- Return to Windows --
   return junk
end function

--
-- Call WinMain()
--
-- Don't worry, ProgHInstance returns the correct instance
-- handle for all versions of Euphoria that support the Win32
-- API..  Heheh.
--
abort(WinMain(ProgHInstance, NULL, ProgCommandLine, SW_SHOWDEFAULT))

-- Code ends here --

*whew*....  Well, I hope that helps explain how to make those things.  If
anyone wants to see what I've did so far with my API wrappers, I'd be more
than happy to share them with y'all...  Heh.  I just hope no one goes crazy
claiming that I stole their code...  The only code that I did steal (or
should I say modify) would be the structure routines in David Cuny's
Win32Lib (He said it was okay for me to use those), and Jacques Deschenes's
screen saver routines (I won't show those because I didn't get Jacques's
permission yet..  I keep forgetting to ask.  Heh)..  A lot of code was
inspired by those two guys right there, but I didn't go stealing code left
and right.  These routines were originally made for me, but, like I said, if
you want to see them, I'll show them to you (if I have the time).  I have a
feeling that I'm going to be constantly flamed when they're shown..
LOL............  Well, I'm gonna go.

   Austin C.  (aka The AfterBeat)

Daniel Berstein wrote:

> At 11:10 PM 27-02-1999 , you wrote:
> >Hello again,
> >
> >Here is another Win32Lib question. I am
> >trying to create a window which will hold
> >several child windows (like the document
> >windows in many text and image editing
> >applications), but I don't know how to do it.
> >I've tried using WS_CHILDWINDOW, but it does
> >not work. Maybe I need to set some attribute
> >in the main window (the one that will hold
> >the others), but I have no idea what it would
> >be. Is there any way to do this in Win32Lib,
> >or is it not supported yet?
>
> The model you are trying to make is called MDI (Multiple Document
> Interface). I think win32lib (and Visual Euphoria 0.02) doesn't support
> such model yet. On MDI you have a main form, a frame window (MDI parent)
> that contains child windows (MDI childs).
>
> Regards,
>          Daniel  Berstein
>          [daber at pair.com]

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

Search



Quick Links

User menu

Not signed in.

Misc Menu