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

Re: turnkey w/ no window

From: Anil Rodrigues <arodrix_at_weld.com>
Date: Mon, 21 Mar 2005 13:33:05 -0500

Thank you very much, I think I can complete it now.

Yes I follow STARTER, and the BYE was just for STARTER.
The key I think I was missing and suspected so, you addressed
by using the Desktop. I thought I was lacking the MAIN program=20
to call the actions from.

I had to move the line [OBJECT ....OBJECT] from WINMAIN to=20
MY-PROGRAM in your listing.

This way is preferable to z-get for opening files; I have to learn=20
a bit about objects and SWOOP. The double-colon left me clueless.

Hopefully now I can finish this stage. Thanks again.

Anil

-----Original Message-----
From: Mike Ghan [mailto:MikeGhan_at_logix-controls.com]
Sent: Sunday, March 20, 2005 11:40 AM
To: sftalk_at_forth.com
Subject: [sftalk] Re: turnkey w/ no window

A couple of gotchas:

STARTER expects the SwiftForth console. Standalone programs should use
MAIN as the startup vector.

Similarly, BYE is closely associated with the SwiftForth development
environment. Instead of BYE, use the following phrase

   'ONSYSEXIT CALLS \ Execute System Exit Chain
   0 ExitProcess=3D20

The following example uses SwiftForth's file open objects. You could
also use z-get. Note that during initialization I am altering HWND to
return the desktop window handle. This is a bit of a hack but works
fine for windowless apps such as this.

Hope this helps,
Mike

-------------------------------------

CREATE MY-FILES
   ,Z" Text (*.TXT)" ,Z" *.TXT"
   ,Z" Widget (*.WIG)" ,Z" *.WIG"
   ,Z" All files (*.*)" ,Z" *.*"
   0 ,

PACKAGE OFN-DIALOGS ( Re-open Package )

FILENAME-DIALOG SUBCLASS MY-OFN-DIALOG

   : ACTION ( addr -- bool ) :: GetOpenFileName ;

END-CLASS

PUBLIC

MY-OFN-DIALOG SUBCLASS MY-FILE-DIALOG

   : CUSTOM ( -- title filter flags )
      Z" Open My File" MY-FILES
      DEFAULT-OPEN-FLAGS OFN_FILEMUSTEXIST OR ;

END-CLASS

END-PACKAGE

: MY-PRINT ( zStr -- )
   ZCOUNT TYPE CR ;

PRINTING +ORDER

: MY-PROGRAM ( -- ) =3D20
   MY-FD CHOOSE
   IF MY-FD FILENAME ( zStr )
      WINPRINT OPEN-PERSONALITY
      ( zStr ) ['] MY-PRINT CATCH DROP \ Catch in case of error
      CLOSE-PERSONALITY
   THEN ;

PRINTING -ORDER

: WINMAIN ( -- )=3D20
   [OBJECTS MY-FILE-DIALOG MAKES MY-FD OBJECTS]
   GetDesktopWindow 'WF @ ! ( Trickery - Set HWND to Desktop )
   ['] MY-PROGRAM CATCH \ Catch in case of error
   IF GetDesktopWindow Z" Error running application" Z" Error!"
      MB_ICONSTOP MessageBox DROP
   THEN
   'ONSYSEXIT CALLS \ Execute System Exit Chain
   0 ExitProcess ;

\ Save App
' WINMAIN 'MAIN !
-1 THRESHOLD \ No Xref file

PROGRAM MyProgram MyIcon.ico
BYE

-----------------------------------------

-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com] On Behalf
Of Anil Rodrigues
Sent: Friday, March 18, 2005 8:22 AM
To: sftalk_at_forth.com
Subject: [sftalk] Re: turnkey w/ no window
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Mar 21 2005 - 10:35:12 PST

This archive was generated by hypermail 2.2.0 : Thu Dec 04 2008 - 03:04:19 PST