Page 1 of 1
Classes ... anyone?
Posted: Fri Mar 21, 2008 3:35 pm
by SteveLai
I have been programming in FiveWin, FWH and Harbour for a long time without really knowing what a class is? OK I'm not ashamed to admit I'm very thick, but could someone please explain how to use a class.prg file. I know there's lots of examples in FWH\source\classes\*.prg, but what does one do with a new class.prg file?
How to use CLASSES
Posted: Fri Mar 21, 2008 5:25 pm
by ukoenig
Hello SteveLai,
I will show the Logic on a program, i'm just working on.
The Bar < Test > had before the same colours
like < Colour-Gradient >, i changed the values.
At start it shows default colors
The Vars => e_COLOR1, e_COLOR2 and e_COLTEXT
i changed from the outside.
Code: Select all
// ------------------------------------------------------------------------
IF nCOLEND = "111" // Glass-Optik is shown
REDEFINE INFOBAR oInfoBar2 ID 103 COLOR e_COLOR1 GLASS ;
BITMAP e_BITMAP PROMPT SPACE(e_POSLEFT) + ;
"Test" COLOR e_COLTEXT LEFT FONT oBFont ;
OF oDlg5 UPDATE BORDER
ELSE
IF nORIENT = "1" // Horizontal Color
REDEFINE INFOBAR oInfoBar2 ID 103 GRADIENT e_COLOR1, ;
e_COLOR2 HORIZONTAL ;
BITMAP e_BITMAP PROMPT SPACE(e_POSLEFT) + ;
"Test" COLOR e_COLTEXT LEFT FONT oBFont ;
OF oDlg5 UPDATE BORDER
ENDIF
IF nORIENT = "2" // Vertical Color
REDEFINE INFOBAR oInfoBar2 ID 103 GRADIENT e_COLOR1, ;
e_COLOR2 BITMAP e_BITMAP ;
PROMPT SPACE(e_POSLEFT) + "Test" COLOR e_COLTEXT ;
LEFT FONT oBFont OF oDlg5 UPDATE BORDER
ENDIF
ENDIF
// When i press this Button, i want to show new values
// ---------------------------------------------------------------------
REDEFINE BUTTONBMP oBtn9 ID 601 OF oDlg5 ;
ACTION ( NEW_COLOR(oInfoBar2) ) ;
BITMAP "colors" PROMPT SPACE(5) + "&Test" TEXTRIGHT
oBtn9:cToolTip = { "Bar-Color-Test", "Test", 1, CLR_BLACK, 14089979 }
.....
.....
//------------------------------
FUNCTION NEW_COLOR(oInfoBar2)
When you want to use CLASS - informations,
the function must know the OBJECT ( oInfoBar2 ).
The functions are allways belong to a OBJECT ( in this sample => oInfobar2 )
e_COLTEXT, e_COLOR1 and e_COLOR2 have the new values i want to test.
oInfoBar2:cPrompt := "Test" // Write "Test" to the Var => cPrompt
oInfoBar2:oFontPrompt := oBFont // Show a try-out Font for the Text
oInfoBar2:nClrPrompt := e_COLTEXT // Show a try-out Color for the Text
IF e_COLEND = 9 // Glass - look
oInfoBar2:nClrLabel := e_COLOR1 // Show a try-out Color for the text
oInfoBar2:lDrawGradient := .F.
oInfoBar2:lGlass := .T.
ELSE
oInfoBar2:nBeginColor := e_COLOR1 // Show a Color Start-Grad.
oInfoBar2:nEndColor := e_COLOR2 // Show a Color End-Grad
IF e_ORIENT = 1
oInfoBar2:lVertGradient := .F.
ENDIF
IF e_ORIENT = 2
oInfoBar2:lVertGradient := .T.
ENDIF
ENDIF
oInfoBar2:Paint() // METHOD Paint()
oInfoBar2:Refresh() // REFRESH oInfoBar2
// With this, the BAR => oInfoBar2 is UPDATED with the new Values !!!
// You send directly informations to the OBJECT oInfobar2
RETURN( NIL )
Some Lines of the Class
--------------------------------
// On Top there are DATA
// These are the used vars inside the CLASS
// and can be modified from outside
// see Function NEW_COLOR(oInfoBar2)
DATA cPrompt AS CHARACTER
DATA nClrPrompt AS NUMERIC
DATA oFontPrompt AS OBJECT
DATA nClrLabel AS NUMERIC
DATA lDrawGradient AS LOGICAL
DATA lGlass AS LOGICAL
DATA lVertGradient AS LOGICAL
DATA nBeginColor AS NUMERIC
DATA nEndColor AS NUMERIC
// These DATAS i have given new Values
// Then you have METHOD ( Functions )
METHOD Paint() // I paint oInfoBar2 with the new values
.....
.....
Maybe it shows the Logic a little bit.
Regards
Uwe
Posted: Fri Mar 21, 2008 5:32 pm
by Otto
Steve,
Sure you know about James „An Introduction to FiveWin“. (*****)
I mention it here only in case if you don’t.
Regards,
Otto
http://ourworld.compuserve.com/homepage ... wintro.htm
Intellitech does most of its software development in the FiveWin programming language. This section contains information primarily of interest to other FiveWin programmers.
Feature Articles
Introduction to FiveWin
An article on programming in the FiveWin programming language. Discusses the basics: FiveWin, resources and resource editors, SDI & MDI windows, dialogs, menus, toolbars, message bars, buttons, colors, icons, etc. Also discusses the concept of a dataDialog class. Good for those just getting started with FiveWin and those considering FiveWin.
Introduction to Object-Oriented Programming Using FiveWin: Part I
Basics of OOP including encapsulation, inheritance, polymorphism and granularity. Also discusses Fivewin's class syntax.
Introduction to Object-Oriented Programming Using FiveWin: Part II
Covers class design with examples of building business object classes to emulate real-world business objects.
Getting to grips with classes
Posted: Fri Mar 21, 2008 6:00 pm
by SteveLai
Many thanks ukoenig ... I will study and try to understand your sample.
Thanks too Otto; I've read James Bott's guide and I think I can follow most of it.
============???
What I don't understand is how to create an EXE from a PRG file containing Function Main and another PRG file containing Create Class.
For instance, re Gale FORd's example on Google Map ...
i.e. You can download this class and TestWebMap prg at
http://www.hotshare.net/file/24300-4713157df9.html
There is TestWebMap.prg for the Function Main and WebMap.prg for the Create Class; the resource is provided in TestWebMap.rc
When I try to create the EXE, I get ...
xLINK: error: Unresolved external symbol '??2@YAPAXI@Z'.
xLINK: error: Unresolved external symbol '??3@YAXPAX@Z'.
xLINK: fatal error: 2 unresolved external(s).
I have tried combining the two files directly as well as #include one from another without success. I am not doing something right?
Any words of wisdom will be much appreciated.
Posted: Fri Mar 21, 2008 7:17 pm
by Antonio Linares
Steve,
Please link this OBJ with your application:
http://rapidshare.com/files/101302540/xhb.obj.html
Problem solved .. thanks everyone!
Posted: Mon Mar 24, 2008 11:46 am
by SteveLai
Many thanks Antonio ... that little OBJ worked like magic; and now I feel rather sheepish ... I think this is something that I should be able to resolve myself? ... where to start? ... the mystery remains!. I salute you guys out there ... thank you.
Posted: Mon Mar 24, 2008 12:09 pm
by Antonio Linares
Steve,
> I think this is something that I should be able to resolve myself?
No. Its a low level technical issue. We solved it here
> ... where to start? ... the mystery remains!
Here you have a brief explanation about it:
The class TActiveX uses some C++ low level source code. With Borland and Microsoft C compilers there is no problem as those missing symbols are provided by Borland and Microsoft. But xHB C compiler (it is PellesC compiler just renamed) does not provide C++ support at all.
In my little OBJ there is a replacement for those C++ missing symbols.
Is your EXE working fine ? If yes, then simply don't care about it