No exported method: END on exit

No exported method: END on exit

Postby PatrickWeisser » Sun Mar 25, 2007 10:28 am

Hello I'm trying to get my first FWH program working. It is based on the testxbrw example, but it uses an RC file for the menu. The only problem I'm having is with the action oWnd:End() which is connected to one of my menu options. It causes a "No exported method: END" error, but the method END was used in the original example. What is the proper way to end a program from a menu Action? Here is the code:


function Main()

local oBmp, oWnd

REQUEST DBFCDX
rddsetdefault( "DBFCDX" )

USE D_Header NEW

DEFINE WINDOW oWnd TITLE "DonorQuest 7.0 For Windows";
MENU RCBuildMenu( oWnd ) MDI;
MENUINFO 3

DEFINE BITMAP oBmp RESOURCE "Background"

SET MESSAGE OF oWnd TO "DonorQuest 7.0, (c) Intrepid Systems, Inc. " CENTERED

oWnd:bPainted = { | hDC | BmpTiled( hDC, oWnd, oBmp ) }

ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//


function RCBuildMenu( oWnd )

local oMenu, oItem

DEFINE MENU oMenu RESOURCE FRAME_MENU

REDEFINE MENUITEM oItem ID FRAME_MENU OF oMenu ACTION MsgInfo( "DonorQuest in 32 bits!" )
REDEFINE MENUITEM oItem ID FMID_FILE_OPEN OF oMenu ACTION AutoEdit( oWnd )

REDEFINE MENUITEM oItem ID FMID_FILE_EXIT OF oMenu ACTION oWnd:End()

return( oMenu )

//----------------------------------------------------------------------------//


Thanks,

-Patrick

[list=][/list]
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Re: No exported method: END on exit

Postby Enrico Maria Giordano » Sun Mar 25, 2007 12:14 pm

Code: Select all  Expand view
#include "Fivewin.ch"


STATIC oWnd


FUNCTION MAIN()

    DEFINE WINDOW oWnd;
           MENU BUILDMENU()

    ACTIVATE WINDOW oWnd

    RETURN NIL


STATIC FUNCTION BUILDMENU()

    LOCAL oMenu

    MENU oMenu
        MENUITEM "Exit";
                 ACTION oWnd:End()
    ENDMENU

    RETURN oMenu


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: No exported method: END on exit

Postby PatrickWeisser » Sun Mar 25, 2007 7:30 pm

Hello Enrico,

Thanks for responding. Making oWnd a global static does allow the exit action to work, but it causes problems with TXBrowse -- makes the browse window unresponsive. There must have been some reason they made oWnd a local variable in the testxbrw.prg example.

-Patrick
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Re: No exported method: END on exit

Postby Enrico Maria Giordano » Sun Mar 25, 2007 8:07 pm

Did you remove the LOCAL oWnd declaration?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: No exported method: END on exit

Postby PatrickWeisser » Sun Mar 25, 2007 10:32 pm

Yes, and the code works fine for exiting now, but the TXBrowse won't work properly.

As a test, I added a TXBrowse to the sample program resmenu.prg (provided with FiveWin). I got exactly the same behavior -- the oWnd:End() works fine, but not the action AutoEdit(). Here is the complete code exactly as I have it. It should compile if you place it in your \FWH\Samples\ folder:

Code: Select all  Expand view
// Using PullDown Menus from resources

#include "FiveWin.ch"
#include "ResMenu.ch"           // Some IDs for this Test
#include "xbrowse.ch"
#include "InKey.ch"


static oWnd

//----------------------------------------------------------------------------//

function Main()

   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )

   USE CUSTOMER NEW

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 75 ;
      TITLE "Using Menus from resources" ;
      MENU  BuildMenu() MDI

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu, oItem

   DEFINE MENU oMenu RESOURCE "Main"

   REDEFINE MENUITEM oItem ID ID_ABOUT OF oMenu ;
      ACTION MsgInfo( "About FiveWin" )

   REDEFINE MENUITEM ID ID_TEST  OF oMenu ACTION AutoEdit()

   REDEFINE MENUITEM ID ID_EXIT OF oMenu ACTION oWnd:End()

   REDEFINE MENUITEM ID ID_DELETE OF oMenu ACTION MsgInfo( "ok: Delete" )

return oMenu



//----------------------------------------------------------------------------//

STATIC FUNCTION AutoEdit()

   local oChild, oBrw, oCol
   local nFor

   DEFINE WINDOW oChild TITLE "Auto edit browse" MDICHILD OF oWnd

   oBrw := TXBrowse():New( oWnd )

   oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLCELL
   oBrw:nColDividerStyle    := LINESTYLE_BLACK
   oBrw:nRowDividerStyle    := LINESTYLE_BLACK
   oBrw:lColDividerComplete := .t.

   oBrw:SetRDD()

   for nFor := 1 to len( oBrw:aCols )
      oCol := oBrw:aCols[ nFor ]
      oCol:nEditType := 1
      oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, FieldPut( o:nCreationOrder, v ), ) }
   next

   oBrw:CreateFromCode()
   oChild:oClient := oBrw

   ACTIVATE WINDOW oChild ON INIT oBrw:SetFocus()

RETURN NIL

[/code]
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Postby Antonio Linares » Sun Mar 25, 2007 10:52 pm

Patrick,

Please change this line:

oBrw := TXBrowse():New( oWnd )

into:

oBrw := TXBrowse():New( oChild )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

No exported method: END on exit

Postby PatrickWeisser » Sun Mar 25, 2007 11:42 pm

That works perfectly!

Thanks very much Antonio and Enrico.

I must say that coming from a Clip4Win background, I'm very impressed with FiveWin so far and how easy it is to create an MDI application -- that required a lot of complicated code in Clip4Win!
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA

Re: No exported method: END on exit

Postby Enrico Maria Giordano » Thu Mar 29, 2007 8:07 am

This is a version using LOCAL variable:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd

    ACTIVATE WINDOW oWnd;
             ON INIT oWnd:SetMenu( BUILDMENU( oWnd ) )

    RETURN NIL


STATIC FUNCTION BUILDMENU( oWnd )

    LOCAL oMenu

    MENU oMenu
        MENUITEM "Exit";
                 ACTION oWnd:End()
    ENDMENU

    RETURN oMenu


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby PatrickWeisser » Fri Mar 30, 2007 2:49 am

Okay thanks Enrico! That will be useful as I add more data grids to the application I'm porting to FiveWin. I will need to make extensive use of data grids showing related tables with TXBrowse(), so I'm going to be delving into custom skip blocks with TXBrowse(). Hopefully there are some good examples in the FiveWin Samples folder!
User avatar
PatrickWeisser
 
Posts: 53
Joined: Fri Mar 23, 2007 4:10 am
Location: Seattle, WA, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: cmsoft, Google [Bot], Natter and 59 guests