FW 2.4 to compile with FWH & VC98

FW 2.4 to compile with FWH & VC98

Postby paulrhanson » Thu Dec 11, 2008 5:43 am

I am new to FW and FWH. I have purchased the source code for a large project that I can compile with FW, clipper, and link with Blinker 7.0. That all works well.

I have managed to get to the point of the application starting when compiled with FWH and VC98. I have several MsgInfo() calls in the code so I can see something happening.

I can even get to the point where my main application screen appears, but then I get errors. But in order to get to that point, I've de-activated many lines of code in my main program just to get to the activated window. I'm just de-activating code that gives an error.

You can see the de-activated code which is still included with #ifndef __HARBOUR__ compile time directive. If I compile with the normal FW, clipper, and blinker the code is included and all is good.

I suppose that these deactivated lines are causing trouble when the window actually activates.

The following error info happens before it reaches the line:
MsgInfo( "After Activate" )
Error description: Error BASE/1004 No exported method: APPLY
Args:
[ 1] = U
[ 2] = O Object

Stack Calls
===========
Called from APPLY@0
Called from ONINIT@202
Called from (b)WINMAIN@80
Called from CPCREG:ACTIVATE@0
Called from WINMAIN@126


Is there some basic requirement I'm missing that is keeping me from just compiling with FWH and vc98? Thanks for your help, Paul

Code: Select all  Expand view
#include "FiveWin.ch"
#include "commport.ch"
#include "GETKEY.CH"
// include "pcreg.ch"
#include "fileio.ch"
#include "inkey.ch"
#include "bitmap.ch"
#include "xfivewin.ch"
#include "showwin.ch"
#include "aprinter.ch"
#include "aobject.ch"
#include "igroup.ch"
#include "default.ch"

#define CLR_LIGHTBLUE    16744448
#define GWL_STYLE         -16
//#xtranslate mdichild =>
//#xtranslate :oWndClient =>

MemVar cTecInfo

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

static aObject:=;
{;
  {,,,,,};                                   // Totals
,{,{,}};                                    // Entry
,{,{,,,,}};                                 // Customer
,{,};                                       // Journal
,;                                          // BigNum
,{,,};                                      // Fonts
,{{,0,.f.,},{,0,.f.,},{,0,.f.,},{,0,.f.,}}; // Button bars
,;                                          // Service Timer
,;                                          // ECR
,;                                          // Menu
,{,,,};                                     // Option
,;                                          // bInkey
,{};                                        // Queue
,;                                          // Show help
,-1;                                        // Crypkey
,2;                                         // Auto delay
,{{,}};                                     // Color
,.f.;                                       // Design
,;                                          // IsWinNT
}

static nRes:=0.8

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

function WinMain()
   local cIniFile := GetWinDir()+"\FiveWin.ini"
   local oWnd

   Splash('bitmap\splash.bmp',{|| Starting() })
#ifdef __HARBOUR__
   MsgInfo( "start, cIniFile = " + cIniFile )
#endif
   oWnd := CPcreg():New()
#ifdef __HARBOUR__
   MsgInfo( "after CPcreg" )
#endif
   // Add event handlers
   oWnd:bKeyChar := {|nKey,nFlags| OnKeyChar(nKey,nFlags)}
   oWnd:bKeyDown := {|nKey,nFlags| OnKeyDown(nKey,nFlags)}
   oWnd:bInit    := {|| OnInit() }
   oWnd:bValid   := {|| Exit(,.t.) }

   if lSkin()
      // OnPaint
      oWnd:oWndClient:bPainted := {|hDC,cPS| OnPaint(hDC,cPS)}
      #ifdef __HARBOUR__
         MsgInfo( "PCREGW: OnPaint" )
      #endif
   endif

   // Add message bar with date
   // Don't need two clocks on the screen, so only
   // add the clock to message bar when maximized - alOption(3)
#ifndef __HARBOUR__
   oWnd:oMsgBar := TMsgBar():New(oWnd,cProgTitle(),,alOption(3),.t.,.f.,,,,.f.)
#endif
   // Don't change applicaton caption to resources usage when the bottom status bar is double clicked 10/24/2003 02:53PM GJH
#ifndef __HARBOUR__
   oWnd:oMsgBar:lInfoRes := .f.
#endif
   // Require manager security level to set date or time
#ifndef __HARBOUR__
   oWnd:oMsgBar:aItem[1]:bAction := {|| if(nSecLvl()>=MemVar->nMgrLvl,WinExec("Control date/time"),)}
#endif
   if alOption(3)
#ifndef __HARBOUR__
      oWnd:oMsgBar:aItem[2]:bAction := oWnd:oMsgBar:aItem[1]:bAction
#endif
   endif
   // Set the help file
   if file('pcreg.chm')
      setHelpFile('pcreg.chm')
   else
      setHelpFile('pcreg.hlp')
   endif

   // Set the timer for SERVER.REQ for every 2 seconds
   aObject[AO_SERVERTIMER] := TTimer():New(2000,{|| aObject[AO_SERVERTIMER]:Deactivate(),memory(-1),AutoScript(),aObject[AO_SERVERTIMER]:Activate()},oWnd)

   // Show the window
   // oWnd:Activate(if(alOption(3),"MAXIMIZE","NORMAL"))
   // Let CRect:Apply handle the size and maximize, don't maximize here
#ifdef __HARBOUR__
   MsgInfo( "Ready to Activate" )
#endif
   oWnd:Activate("NORMAL")
#ifdef __HARBOUR__
   MsgInfo( "After Activate" )
#endif
return NIL
-Paul
paulrhanson
 
Posts: 13
Joined: Fri Sep 12, 2008 2:40 am

Postby Antonio Linares » Thu Dec 11, 2008 8:42 am

Paul,

Please show the source code for function OnInit(), thanks
regards, saludos

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

FW 2.4 to compile with FWH & VC98

Postby paulrhanson » Thu Dec 11, 2008 11:24 am

Antonio Linares wrote:Paul,

Please show the source code for function OnInit(), thanks


Antonio,

I followed the OnInit() which is:
Code: Select all  Expand view
static function OnInit()

   local oFrame
#ifdef __HARBOUR__
   MsgInfo( "In OnInit" )
#endif

   oFrame := GetWndFrame()

#ifndef __HARBOUR__
   // Re-apply windows postion because Fivewin 2.4 will shrink window each time application is loaded.
   oFrame:oRect:Apply( oFrame )
#endif

   if empty(cSerialNum()) .or. (!lSuperpro() .and. aObject[AO_CRYPKEY]!=0)

      oFrame:End()

   else

      StartPcr()
      aObject[AO_SERVERTIMER]:Activate()

   endif

   CursorArrow()
#ifdef __HARBOUR__
   MsgInfo( "End OnInit" )
#endif

return NIL


Notice that I added some compile time lines that eliminate the error you saw to deactivate the oFrame:oRect:Apply( oFrame ) line. That is the line that was causing the first error. But now I just get a new error that is deeper into the code.

I have noticed a very big difference that might be causing all these errors. Like I mentioned, This code compiles perfectly with FW 2.4 with just clipper. It's very mature code that has been very stable. Too bad I'm not the author.

Below is an example of some other "fixing" I've done to get it to work this far. It's starting to be a pattern. Hopefully I can explain clearly. My terms of reference might not be correct.

The main() code makes this call:
oWnd := CPcreg():New()

CPcreg():New()
Code: Select all  Expand view
METHOD New() CLASS CPcreg
   // local cClrText, cClrPane
   // local nClrText, nClrPane
   local err

   Try()
#ifdef __HARBOUR__
   MsgInfo( "In CPcreg" )
#endif

   ::oRect := CRect():New( GetWorkRect(), 'Options',,, .t. ) // SPI_GETWORKAREA
#ifdef __HARBOUR__
   MsgInfo( "CPCreg-::oRect:nBottom: " + cValToChar( ::oRect:nBottom ) )
   MsgInfo( "CPCreg-::oRect:nRight: " + cValToChar( ::oRect:nRight ) )
   MsgInfo( "Still in CPCReg" )
#endif
...


Notice the two lines in the #ifdef section at the end of the code above. When these lines are executed, I get an error that states: Error BASE/1004 No exported method: NBOTTOM.

But, when I complile with clipper FW and Blinker, it's fine. This seems pretty radical to the way my code is written.

What do you think?

Thanks Antonio,
Paul
-Paul
paulrhanson
 
Posts: 13
Joined: Fri Sep 12, 2008 2:40 am

FW 2.4 to compile with FWH & VC98

Postby paulrhanson » Thu Dec 11, 2008 4:12 pm

Antonio,

I've made it a bit further. I discovered that my CRect:New() method needs RETURN Self rather than RETURN NIL which works for FW 2.4 & clipper.

In any case, this is moving me forward leaps.

Now I'm stuck on this code:
Code: Select all  Expand view
function WinMain()
   local cIniFile := GetWinDir()+"\FiveWin.ini"
   local oWnd

   Splash('bitmap\splash.bmp',{|| Starting() })
   oWnd := CPcreg():New()
   // Add event handlers
   oWnd:bKeyChar := {|nKey,nFlags| OnKeyChar(nKey,nFlags)}
   oWnd:bKeyDown := {|nKey,nFlags| OnKeyDown(nKey,nFlags)}
   oWnd:bInit    := {|| OnInit() }
   oWnd:bValid   := {|| Exit(,.t.) }

   if lSkin()
      // OnPaint
      oWnd:oWndClient:bPainted := {|hDC,cPS| OnPaint(hDC,cPS)}
   endif

   // Add message bar with date
   // Don't need two clocks on the screen, so only
   // add the clock to message bar when maximized - alOption(3)
#ifndef __HARBOUR__
   // Try this simple version for FWH
   oWnd:oMsgBar := TMsgBar():New(oWnd,cProgTitle())
#else
   oWnd:oMsgBar := TMsgBar():New(oWnd,cProgTitle(),,alOption(3),.t.,.f.,,,,.f.)
#endif


When it hits this line of code:
oWnd:oMsgBar := TMsgBar():New(oWnd,cProgTitle())
The following error results:
Code: Select all  Expand view
   Error description: Error BASE/1004  No exported method: ACTIVATE
   Args:
     [   1] = U   

Stack Calls
===========
   Called from ACTIVATE@0
   Called from TMSGBAR:CHECKTIMER@0
   Called from TMSGBAR:DATEON@0
   Called from TMSGBAR:NEW@0
   Called from WINMAIN@89


Any ideas?

Thanks,
Paul
-Paul
paulrhanson
 
Posts: 13
Joined: Fri Sep 12, 2008 2:40 am

Postby James Bott » Thu Dec 11, 2008 6:26 pm

Paul,

There is already a FWH function called winmain() which returns the main window object. Since you have a winmain() function also, yours is overriding the FWH function and this is most likely the problem.
Somewhere else in the program (probably in FWH code) winmain() is being called and the main window object is expected to be returned, not nil as yours is returning.

Traditionally, we use function Main() as the starting program function. Try changing your winMain() to Main().

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Thu Dec 11, 2008 8:05 pm

Paul,

>
I discovered that my CRect:New() method needs RETURN Self rather than RETURN NIL
>

Good point. Yes, that change is required from FW 16 bits to 32 bits.

Please notice that Class CRect is not a standard FiveWin Class, so its code may be in your sources.
regards, saludos

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

Postby Antonio Linares » Thu Dec 11, 2008 8:09 pm

Paul,

>
Called from ACTIVATE@0
Called from TMSGBAR:CHECKTIMER@0
>

Please check if you have a Class TTimer in your sources. It is quite common to modify a Class and include it in your own PRGs.

If that is the case, your modified Class TTimer may be returning nil instead of Self, too.
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests