programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: (No Date: Thu, 18 Jul 2002 15:37:58 -0700

From: Azedia of DOLFINA <dolfina_at_dolfina.org>
Date: Fri, 19 Jul 2002 14:15:54 -0700

Rick,

I have a skeletal Front End that is not filled out yet. I am still figuring
out what the Win API Constants do,
so this is very crude. I had commented out the DEFERS because I was trying
to figure out what it does or
not do. I kept the template to figure out what I should be doing.

{ ====================================================================
PSIAPP.F

Copyright (C) DOLFINA of AIWP <br> Jodell Bumatai azedia_at_dolfina.org
written using Swiftforth 2.2.2.9 May 7 2001 build

So far: PSIAPP runs a Parent Window with a Menu working

Progress Reports:

jULY 18, 2002 Menu needs to run all of the Menu's AppCommands which all
need code to run.

Bugs List: Doesn't display when Console Window open on executable

==================================================================== }

OPTIONAL WINAPP A skeletal Windows application to build from. The source
contains deferred words which you vector to suit your application.

{ --------------------------------------------------------------------
All defers contain reasonable defaults and may be used (at least
initially) as defined.

Defers for the application to set:

ClassName ( -- zstr )
AppTitle ( -- zstr )
MakeStatus ( -- )
SizeStatus ( -- )
MakeToolbar ( -- )
SizeToolbar ( -- )
MakeMenu ( -- )
CreateMore ( -- )
AboutApp ( -- )

Exports

AppMessages ( msg -- res ) a switch to process windows messages
AppCommands ( cmd -- ) a switch to process WM_COMMAND messages
PSIAPP ( -- hwnd )
M_USED ( -- n ) integer VALUE to begin menu item definitions
-------------------------------------------------------------------- }

{ --------------------------------------------------------------------
The base class
-------------------------------------------------------------------- }

0 VALUE hApp

DEFER ClassName :NONAME Z" PSI CAT" ; IS ClassName
DEFER AppTitle :NONAME Z" PSI CAT" ; IS AppTitle

: ENDAPP ( -- res )
   'MAIN @ [ HERE CODE> ] LITERAL < IF ( not an application yet)
      0 TO hApp
   ELSE ( is an application)
      0 PostQuitMessage DROP
   THEN 0 ;

[SWITCH AppMessages DEFWINPROC ( msg -- res )
   WM_DESTROY RUNS ENDAPP
SWITCH]

:NONAME ( -- res )
   MSG LOWORD AppMessages ; 4 CB: APP-WNDPROC

: /APP-CLASS ( -- )
      0 CS_OWNDC OR
         CS_HREDRAW OR
         CS_VREDRAW OR \ class style
      APP-WNDPROC \ wndproc
      0 \ class extra
      0 \ window extra
      HINST \ hinstance
      HINST 101 LoadIcon
      NULL IDC_ARROW LoadCursor \
      WHITE_BRUSH GetStockObject \
      0 \ no menu
      ClassName \ class name
   DefineClass DROP ;

: /APP-WINDOW ( -- hwnd )
   0 TO hApp
      0 \ extended style
      ClassName \ window class name
      AppTitle \ window caption
      WS_OVERLAPPEDWINDOW
      40 40 500 350 \ position and size
      0 \ parent window handle
      0 \ window menu handle
      HINST \ program instance handle
      0 \ creation parameter
   CreateWindowEx DUP -EXIT
   DUP TO hApp
   DUP SW_SHOW ShowWindow DROP
   DUP UpdateWindow DROP ;

:PRUNE ?PRUNE -EXIT
   hApp IF hApp WM_CLOSE 0 0 SendMessage DROP THEN
   ClassName HINST UnregisterClass DROP ;

: PSIAPP ( -- hwnd )
   hApp ?EXIT /APP-CLASS /APP-WINDOW ;

{ --------------------------------------------------------------------
Define CONSTANTS with ENUM
-------------------------------------------------------------------- }

100 ENUM M_EXIT
    ENUM M_ABOUT
    ENUM M_FILE
    ENUM M_OPEN
    ENUM M_OPEN-RECENT
    ENUM M_SAVE
    ENUM M_SAVE-AS
    ENUM M_PRINT
    ENUM M_PRINT-VIEW
    ENUM M_UNDO
    ENUM M_COPY
    ENUM M_PASTE
    ENUM M_CLEAR
    ENUM M_SELLECT-ALL
    ENUM M_CARD
    ENUM M_CARDS
    ENUM M_CARD1
    ENUM M_CARD2
    ENUM M_CARD3
    ENUM M_CARD4
    ENUM M_DICE
    ENUM M_DIE1
    ENUM M_DIE2
    ENUM M_DIE3
    ENUM M_DIE4
    ENUM M_DIE5
    ENUM M_DIE6
    ENUM M_EVT
    ENUM M_SOUND
    ENUM M_JOURNAL
    ENUM M_DREAMS
    ENUM M_VISIONS
    ENUM M_PATTERNS
    ENUM M_STATS
    ENUM M_SCAN-DEVICE
    ENUM M_SCAN-IMAGE
    ENUM M_TEMPLATES
    ENUM M_CODE-CHECKERS
    ENUM M_FAX
    ENUM M_EMAIL
    ENUM M_FTP
    ENUM M_TELNET
    ENUM M_MSNGR
    ENUM M_LOGIN
    ENUM M_PWORD
    ENUM M_TUTORIALS
    ENUM M_WEBLINKS
    ENUM M_HELP
    ENUM M_SPELL
    ENUM M_LANG
    ENUM M_DICT
    ENUM M_OPTIONS

VALUE M_USED
{ --------------------------------------------------------------------
Define a menu with the button classes, exit, and about
-------------------------------------------------------------------- }
MENU APP-MENU

   POPUP "&File"

      M_OPEN MENUITEM "O&pen"
      M_OPEN-RECENT MENUITEM "Open R&ecent"
      M_SAVE MENUITEM "&Save"
      M_SAVE-AS MENUITEM "Save A&s"
      M_EXIT MENUITEM "E&xit"

   END-POPUP

   POPUP "&Edit"
      M_UNDO MENUITEM "&Undo"
      M_COPY MENUITEM "C&opy"
      M_PASTE MENUITEM "P&aste"
      M_CLEAR MENUITEM "C&lear"
      M_SELLECT-ALL MENUITEM "Select &All"
   END-POPUP

   POPUP "&Options"

                 POPUP "&Cards"
                       M_CARDS MENUITEM "&Cards"
                       SEPARATOR
                       M_CARD1 MENUITEM "CARD&1"
                       M_CARD2 MENUITEM "CARD&2"
                       M_CARD3 MENUITEM "CARD&3"
                       M_CARD4 MENUITEM "CARD&4"
                       M_SCAN-DEVICE MENUITEM "Scan &Device"
                 END-POPUP

                 POPUP "&Dice"
                      M_DICE MENUITEM "&Dice"
                      SEPARATOR
                      M_DIE1 MENUITEM "Die&1"
                      M_DIE2 MENUITEM "Die&2"
                      M_DIE3 MENUITEM "Die&3"
                      M_DIE4 MENUITEM "Die&4"
                      M_DIE5 MENUITEM "Die&5
                      M_DIE6 MENUITEM "Die&6"
                 END-POPUP

                 POPUP "&EVT"
                      M_EVT MENUITEM "&Electronic Voice Transmission"
                      SEPARATOR
                 END-POPUP

   END-POPUP

   POPUP "&Journals"
     M_JOURNAL MENUITEM "&Journal"
     M_DREAMS MENUITEM "&Dreams"
     M_VISIONS MENUITEM "&Visions"
     M_PATTERNS MENUITEM "&Patterns"
     M_STATS MENUITEM "&Statistics"

   END-POPUP

   POPUP "&Internet
     M_FAX MENUITEM "F&AX"
     M_FTP MENUITEM "&FTP"
     M_EMAIL MENUITEM "&Email"
     M_TELNET MENUITEM "&Telnet"
     M_MSNGR MENUITEM "&Messenger"
     M_LOGIN MENUITEM "&Login"
     M_PWORD MENUITEM "&Password"
   END-POPUP

   POPUP "&Help"
      M_HELP MENUITEM "H&elp"
      M_TUTORIALS MENUITEM "&Tutorials"
      M_WEBLINKS MENUITEM "Web&links"
      M_ABOUT MENUITEM "&About PSI CAT"
   END-POPUP

END-MENU

{ --------------------------------------------------------------------
{ --------------------------------------------------------------------
ABOUT box seems to be working
-------------------------------------------------------------------- }

OPTIONAL ABOUT1 A simple about box dialog template.

DIALOG (ABOUT) [MODAL " About GOEdit" 180 150 200 100
   (FONT 8, comic sans ms) ]

[DEFPUSHBUTTON " OK" IDOK 132 2 32 14 ]
[ICON 101 RESOURCE -1 3 2 18 20 ]
[LTEXT " PSI CAT" -1 30 10 50 8 ]
[LTEXT " PSI Core Aptitude Trainer" -1 30 20 150 8 ]
[LTEXT " Version .10" -1 30 30 150 8 ]
[LTEXT " (C)2001 DOLFINA of AIWP" -1 30 40 150 8 ]
[LTEXT " All Rights Reserved" -1 30 50 150 8 ]
[LTEXT " Design and Development by Jodell Bumatai " -1 30
60 150 8 ]
[LTEXT " Support email azedia_at_dolfina.org " -1 30
70 150 8 ]
[LTEXT " Visit our Website at www.dolfina.org " -1 30
80 150 8 ]
[LTEXT " P.O.B. 594,Santa Cruz, CA 95061-0594 " -1 30
90 150 8 ]

END-DIALOG

:NONAME ( -- res )
   MSG LOWORD WM_COMMAND = IF
      WPARAM LOWORD DUP IDOK = SWAP IDCANCEL = OR IF
         HWND 1 EndDialog -1 EXIT
      THEN
   THEN
   0 ;

( xt) 4 CB: RUNABOUT

: ABOUT ( -- )
   HINST (ABOUT) HWND RUNABOUT 0 DialogBoxIndirectParam DROP ;

: MAKE-MENU ( -- )
   HWND APP-MENU LoadMenuIndirect SetMenu DROP ;
{ --------------------------------------------------------------------
DEFERS
-------------------------------------------------------------------- }

DEFER MakeStatus ' NOOP IS MakeStatus
DEFER SizeStatus ' NOOP IS SizeStatus
DEFER MakeToolbar ' NOOP IS MakeToolbar
DEFER SizeToolbar ' NOOP IS SizeToolbar
DEFER MakeMenu ' MAKE-MENU IS MakeMenu
DEFER CreateMore ' NOOP IS CreateMore
DEFER AboutApp ' ABOUT IS AboutApp

{ --------------------------------------------------------------------
-------------------------------------------------------------------- }

: APP-EXIT ( -- )
   HWND WM_CLOSE 0 0 PostMessage DROP ;

[SWITCH AppCommands DROP ( cmd -- )
   M_EXIT RUNS APP-EXIT
   M_ABOUT RUNS AboutApp
\ M_CARD4 RUNS PSIGUESS-CONSOLE does not work unless PSIGUESS-CONSOLE
\ M_FILE is in the same file PSIAPP.F
\ M_OPEN
\ M_OPEN-RECENT
\ M_SAVE
\ M_SAVE-AS
\ M_PRINT
\ M_PRINT-VIEW
\ M_UNDO
\ M_COPY
\ M_PASTE
\ M_CLEAR
\ M_SELLECT-ALL
\ M_CARD
\ M_CARDS
\ M_CARD1
\ M_CARD2
\ M_CARD3
\ M_CARD4
\ M_DICE
\ M_DIE1
\ M_DIE2
\ M_DIE3
\ M_DIE4
\ M_DIE5
\ M_DIE6
\ ENUM M_EVT
\ ENUM M_SOUND
\ ENUM M_JOURNAL
\ ENUM M_DREAMS
\ ENUM M_VISIONS
\ ENUM M_PATTERNS
\ ENUM M_STATS
\ ENUM M_SCAN-DEVICE
\ ENUM M_SCAN-IMAGE
\ ENUM M_TEMPLATES
\ ENUM M_CODE-CHECKERS
\ ENUM M_FAX
\ ENUM M_EMAIL
\ ENUM M_FTP
\ ENUM M_TELNET
\ ENUM M_MSNGR
\ ENUM M_LOGIN
\ ENUM M_PWORD
\ ENUM M_TUTORIALS
\ ENUM M_WEBLINKS
\ ENUM M_HELP
\ ENUM M_SPELL
\ ENUM M_LANG
\ ENUM M_DICT
\ ENUM M_OPTIONS
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]

{ --------------------------------------------------------------------
Testing
-------------------------------------------------------------------- }

EXISTS RELEASE-TESTING [IF] VERBOSE

PSIAPP

KEY DROP BYE [THEN]

>
> Thursday, July 18, 2002, 11:06:23 PM, you wrote:
>
> > MYAPP runs fine only when run from the SF Console and it works ok,
> > but when running the exe CORETEST, only the Console Window displays.
>
> > REQUIRES DOSBOX
> > REQUIRES FORK
> > REQUIRES MYAPP / main window app file
> > REQUIRES CORE01 / console window app file
>
> Without knowing what was in MYAPP, and without an explicit knowledge
> of how you are directing SwiftForth to start, I can't hazard a guess
> on anything here.
>
> Rick
>
> ----------------------------------------------------------------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.377 / Virus Database: 211 - Release Date: 7/15/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 Fri Jul 19 2002 - 15:04:28 PDT

This archive was generated by hypermail 2.2.0 : Fri Nov 21 2008 - 03:04:23 PST