![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

Ok, using the code from the fourth example, I am still
not able to see the result of adding a MENU. Here is
code for running the APP-Menu
: MAKE-MENU ( -- )
HWND APP-MENU LoadMenuIndirect SetMenu DROP ;
: APP-EXIT ( -- )
HWND WM_CLOSE 0 0 PostMessage DROP ;
[SWITCH AppCommands DROP ( cmd -- )
M_EXIT RUNS APP-EXIT
M_ABOUT RUNS AboutApp
SWITCH]
[+SWITCH AppMessages ( -- res )
WM_SIZE RUN: SizeStatus SizeToolbar 0 ;
WM_COMMAND RUN: WPARAM LOWORD AppCommands 0 ;
WM_CREATE RUN: MakeMenu MakeStatus MakeToolbar CreateMore 0 ;
WM_CLOSE RUN: HWND GetMenu DestroyMenu DROP
HWND DestroyWindow DROP 0 ;
SWITCH]
Even when I INCLUDE the file that the MENU is in, the example code is not
noticing it. I had tried to called MAKE-MENU from the STARTUP, even put
it into the GO. I got no errors. The windows started and ran, but there is
no
sign of the MENU or MAKE-MENU being compiled. What is the order that I
need to compile and what is the missing link?
Jodell
>
> ftp.forth.com/pub/SwiftForth/samples/four
>
> Thanks,
>
> Rick
>
>
>
> **********************************************************************
> **********************************************************************
> **********************************************************************
> main.f
> **********************************************************************
> **********************************************************************
> **********************************************************************
>
> { ====================================================================
> Window skeletons to hang applications on
>
> Copyright (C) 2002 FORTH, Inc. <br> Rick VanNorman rvn_at_forth.com
>
> This file implements the simplest complete Windows application written
> in SwiftForth utilizing the Swoop class framework. The window itself
> does nothing. Literally, nothing.
> ==================================================================== }
>
> INCLUDE GLOBALS \ global variables and resources
> INCLUDE STATUSBAR \ a multipane status bar
> INCLUDE DATAVIEW \ the data container
> INCLUDE APPPANE \ the application window
> INCLUDE APPWIN \ the main window, simply a container
> INCLUDE STARTUP \ startup code
>
> .(
>
> Type "GO" to run the application from SwiftForth.
> Type "PROGRAM filename" to save the application as an executable file.
>
> )
>
> **********************************************************************
> **********************************************************************
> **********************************************************************
> globals.f
> **********************************************************************
> **********************************************************************
> **********************************************************************
>
> { ====================================================================
> globals.f
>
> Copyright (C) 2001 FORTH, Inc. <br> Rick VanNorman rvn_at_forth.com
> ==================================================================== }
>
> 1 VALUE TMODE
>
>
>
> **********************************************************************
> **********************************************************************
> **********************************************************************
> dataview.f
> **********************************************************************
> **********************************************************************
> **********************************************************************
>
> { ====================================================================
> dataview.f
>
> Copyright (C) 2002 FORTH, Inc. <br> Rick VanNorman rvn_at_forth.com
> ==================================================================== }
>
> CHILDWINDOW SUBCLASS DATAVIEW
>
> : MyClass_ClassName ( -- zname ) Z" DATAVIEW" ;
>
> : MyClass_hbrBackground ( -- hbrush ) BLACK_BRUSH :: GetStockObject ;
>
> \ here we incorporate the ONPAINT hander discussed recently
>
> : OnPaint ( -- res)
> [OBJECTS PAINTCANVAS MAKES p
> RECT MAKES r OBJECTS]
> mHWND p ATTACH
> p HDC WHITE :: SetTextColor DROP
> p HDC BLACK :: SetBkColor DROP
> mHWND r ADDR :: GetClientRect DROP
> r right @ (.) PAD PLACE
> S" x " PAD APPEND
> r bottom @ (.) PAD APPEND
> 5 5 PAD COUNT p TEXT
> p DETACH 0 ;
>
> \ but we also include an INVALIDATERECT in the resize handler
> \ so that the window gets repainted while being resized
>
> : RESIZE ( x y x y -- ) RESIZE mHWND 0 1 :: InvalidateRect DROP ;
>
> END-CLASS
>
>
> **********************************************************************
> **********************************************************************
> **********************************************************************
> apppane.f
> **********************************************************************
> **********************************************************************
> **********************************************************************
>
> { ====================================================================
> apppane.f
> An application frame to hang menus and such on
>
> Copyright (C) 2002 FORTH, Inc. <br> Rick VanNorman rvn_at_forth.com
> ==================================================================== }
>
> { --------------------------------------------------------------------
> This is the major window pane. It doesn't need a name, as it has no
> title bar to display it on. This is the bare minimum needed to be
> a contained window.
> -------------------------------------------------------------------- }
>
> CHILDWINDOW SUBCLASS PANEWINDOW
>
> : MyClass_ClassName ( -- zname ) Z" APPPANE" ;
>
> : MyClass_hbrBackground ( -- hbrush )
> WHITE_BRUSH :: GetStockObject ;
>
> \ two dataview containers
>
> DATAVIEW BUILDS LEFT
> DATAVIEW BUILDS RIGHT
>
> \ a structure for holding the PANEWINDOW boundaries
>
> RECT BUILDS PANE
>
> \ the point at which to divide the window
>
> SINGLE DIVIDER
>
> \ given N the width of PANE, and DIV the place at which to
> \ divide PANE, return the x origin and x width of each of
> \ the two containers, leaving a 4-pixel border between them
> \ where the background of PANE will show.
>
> : HSPLIT ( n div -- 0 n/3 n/3 n-n/3 ) ( n -- x cx x2 xc2 )
> >R 0 SWAP R@ 2- R> 2+ ROT OVER - ;
>
> \ we resize the children by first measuring the width of PANE.
> \ then we divide this width with HSPLIT and resize each of the
> \ children accordingly.
>
> : RESIZE-CHILDREN ( -- )
> mHWND PANE ADDR :: GetClientRect DROP
> PANE right @ DIVIDER HSPLIT 2>R
> 0 SWAP PANE bottom @ LEFT RESIZE
> 2R> 0 SWAP PANE bottom @ RIGHT RESIZE ;
>
> \ any time PANE is resized, resize the main window.
>
> : RESIZE ( x y x y -- )
> SUPER RESIZE RESIZE-CHILDREN ;
>
> \ initialize the divider to a reasonable value
>
> : OnCreate ( -- res )
> 100 TO DIVIDER mHWND LEFT ATTACH mHWND RIGHT ATTACH 0 ;
>
> \ the only time that PANE will get WM_MOUSEMOVE messages is when
> \ the cursor is hovering over the boundary between the containers.
> \ when there, if the cursor is moved, we will adjust the location
> \ of the divider.
>
> : SPLIT-RESIZE ( -- )
> WPARAM MK_LBUTTON AND IF
> LPARAM LOWORD TO DIVIDER RESIZE-CHILDREN
> THEN ;
>
> \ set the cursor style to the SIZEWE (size-west-east) cursor
> \ for adjusting the relative widths of the two panes
>
> : CURSED ( -- )
> 0 IDC_SIZEWE :: LoadCursor :: SetCursor DROP ;
>
> WM_LBUTTONDOWN MESSAGE: mHWND :: SetCapture DROP CURSED 0 ;
> WM_LBUTTONUP MESSAGE: :: ReleaseCapture DROP 0 ;
> WM_MOUSEMOVE MESSAGE: CURSED SPLIT-RESIZE 0 ;
>
> END-CLASS
>
>
> **********************************************************************
> **********************************************************************
> **********************************************************************
> appwin.f
> **********************************************************************
> **********************************************************************
> **********************************************************************
>
> { ====================================================================
> appwin.f
>
> Copyright (C) 2002 FORTH, Inc. <br> Rick VanNorman rvn_at_forth.com
> ==================================================================== }
>
> { --------------------------------------------------------------------
> APPWINDOW is the main application window class. It is built from the
> base class GENERICWINDOW with a few appropriate over-rides
> specified. Note that MyClass_ClassName and MyWindow_WindowName _must_ be
> specified in any user-defined class -- leaving these as defaults will
> work in this simple example but will bite you hard in the butt later.
>
> This version of APPWINDOW will be used as a container to hold other
> windows (PANE and STATUSBAR). It is done this way so that the size
> issues can be dealt with in one place, and the two component windows
> don't even have to know about each other.
>
> I chose to render the background color of the PANE differently from
> the APPWINDOW to demonstrate that it really exists.
> -------------------------------------------------------------------- }
>
> GENERICWINDOW SUBCLASS AppWindow
>
> \ Over-ride base defaults
>
> : MyClass_ClassName ( -- zname ) Z" Skeleton" ;
> : MyWindow_WindowName Z" Skeleton" ;
>
> : MyWindow_Shape ( -- x y cx cy ) 10 10 600 350 ;
>
> : MyClass_hbrBackground ( -- hbrush )
> GRAY_BRUSH :: GetStockObject ;
>
> \ the contained windows
>
> PANEWINDOW BUILDS PANE
> MULTISTAT BUILDS STAT
>
> \ contain the size of the client area of APPWINDOW
>
> RECT BUILDS CLIENT
>
> \ contain the pixel distances from the edges of APPWINDOW
> \ to PANE -- used to adjust for toolbars and status lines.
> \ we will initialize left, top, and right to zero. bottom
> \ will contain the height of the status bar.
>
> SINGLE LEFT
> SINGLE TOP
> SINGLE RIGHT
> SINGLE BOTTOM
>
> : /BORDERS ( -- )
> 0 TO LEFT 0 TO RIGHT 0 TO TOP
> STAT HIGH TO BOTTOM ;
>
> : RESIZE-PANE ( -- )
> CLIENT left @ LEFT +
> CLIENT top @ TOP +
> CLIENT right @ RIGHT - LEFT -
> CLIENT bottom @ BOTTOM - TOP -
> PANE RESIZE ;
>
> : RESIZE-STATUS ( -- )
> 0 CLIENT bottom @ BOTTOM -
> CLIENT right @ CLIENT bottom @ STAT RESIZE ;
>
> \ resize contained windows based on our client size
>
> : RESIZED ( -- )
> mHWND CLIENT ADDR :: GetClientRect DROP
> RESIZE-PANE RESIZE-STATUS ;
>
> : OnClose ( -- res )
> mHWND :: DestroyWindow 0 ;
>
> \ init borders, attach PANE, adjust size of PANE.
>
> : OnCreate ( -- res )
> mHWND PANE ATTACH mHWND STAT ATTACH
> mHWND 99 500 0 :: SetTimer DROP
> /BORDERS RESIZED 0 ;
>
> \ ----------------------------------------------------------------
> \ Message handlers
>
> WM_TIMER MESSAGE: ( --res)
> TMODE IF @TIME (TIME) ELSE COUNTER (.) THEN
> 0 PANE-TYPE 0 ;
>
> \ adjust size of contained windows when APPWINDOW is resized
>
> WM_SIZE MESSAGE: ( -- res )
> RESIZED 1 ;
>
> \ immediately pass focus to PANE -- we don't need it!
>
> WM_SETFOCUS MESSAGE: ( -- res )
> PANE mHWND :: SetFocus DROP 1 ;
>
> END-CLASS
>
>
>
> **********************************************************************
> **********************************************************************
> **********************************************************************
> startup.f
> **********************************************************************
> **********************************************************************
> **********************************************************************
>
> { ====================================================================
> startup.f
>
> Copyright (C) 2002 FORTH, Inc. <br> Rick VanNorman rvn_at_forth.com
> ==================================================================== }
>
> { ----------------------------------------------------------------------
> Build a static instance of the application class for debugging purposes.
> This can be omitted in a production version, but will be harmless.
> ---------------------------------------------------------------------- }
>
> AppWindow BUILDS APP
>
> : GO ( -- ) APP CONSTRUCT ;
>
> \ DEBUG THE TIMER CODE
>
> : xxx TMODE 0= TO TMODE ;
>
>
> { ----------------------------------------------------------------------
> MAIN is the entry point for all stand-alone Windows applications.
> Setting 'MAIN to zero will trigger the OnDestroy method to execute
> PostQuitMessage (see the source for GENERICWINDOW) and terminate the
> DISPATCHER loop. Under normal circumstances, 'MAIN is non-zero and
> the OnDestroy method will not call PostQuitMessage.
>
> The instantiation of the object APP in the [OBJECTS .. OBJECTS] phrase
> acutally triggers its construction and causes the window to be
> created. DISPATCHER handles all windows messages directed to it until
> PostQuitMessage, then ExitProcess terminates the whole shebang. Simple,
> huh?
> ---------------------------------------------------------------------- }
>
> : MAIN ( -- ) 0 'MAIN !
> [OBJECTS AppWindow MAKES APP OBJECTS]
> DISPATCHER 0 ExitProcess ;
>
> ' MAIN 'MAIN !
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/2002 ---------------------------------------------------------------------- sftalk_at_forth.com The SwiftForth programming discussion email list To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com For help with listar commands, send subject "help" to listar_at_forth.com Archives are located at http://www.forth.com/sftalk -- check them out! Search the archives! Visit http://www.forth.com/search for details.Received on Thu Aug 08 2002 - 15:41:04 PDT
This archive was generated by hypermail 2.2.0 : Fri Nov 21 2008 - 03:04:24 PST