HMGObjects usage

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
karweru
Posts: 220
Joined: Fri Aug 01, 2008 1:51 pm
DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
Contact:

HMGObjects usage

Post by karweru »

Hi Friends,

I downloaded HMG objects and extracted the files to c:\hmg where i have installed Hmg, in the process overwriting some files at the prompt. I've then written the code below, and when i compile it from HMG IDE, i get an 'undefined reference to WINDOW' at line 3

#include "hmg.ch"

Function Main
local oWin:=window():new()

oWin:Name(newWindowName())
oWin:Type(WND_MAIN)
oWin:Row(0)
oWin:Col(0)
oWin:Width(480)
oWin:Height(400)
oWin:Title("myDemo")
oWin:Icon("main.ico")
oWin:MinButton(.t.)
oWin:MaxButton(.t.)
oWin:Sizable(.f.)
oWin:SysMenu(.t.)
oWin:TitleBar(.f.)
oWin:HelpButton(.t.)

oWin:OnInit({||msgInfo("Welcome")})
OWin:OnRelease({||msgInfo()})

oWin:Center()
oWin:Activate()
Kindly guide me what I'm doing wrong. My desire is to develop my applications solely with HMG Objects.
Kind regards,
Gilbert.
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: HMGObjects usage

Post by dhaine_adp »

Hi Gilbert,
I downloaded HMG objects and extracted the files to c:\hmg where i have installed Hmg, in the process overwriting some files at the prompt. I've then written the code below, and when i compile it from HMG IDE, i get an 'undefined reference to WINDOW' at line 3
Try adding this line below to your code:

Code: Select all

#include "objects.ch"
Or better yet, browse on the samples of HMG Objects.

Regards,

Danny
Regards,

Danny
Manila, Philippines
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: HMGObjects usage

Post by dhaine_adp »

Hi,

In addition, HMG Objects were still in experimental stage. For a serious project I think it is not applicable because if in the future a major change occurs you have to rewrite your program. However for small project it might be fine (I'm not sure though) but it deserves to be tested to its breaking point so that weakness can be found.

You cannot mix the semi-oop syntax when you use HMG Objects. Example, WindowName.Release instead you have to use WindowName:Release(). Thus in effect you cannot use your personal UDF/library if it so happen containing those syntax.

I am not sure if semi-oop syntax can can be overriden by xtranslate or xcommand compiler directives.

On the other hand, here is a makefile if you wish to build HMG Objects as LibHMGObjects:

Code: Select all

HRB_DIR = c:/hmg/harbour
INC_DIR = c:/hmg/include
OBJ_DIR = f:/dad/hmgobjects/source --> replaced this with your source paths or obj path
LIB_DIR = f:/dad/hmgobjects/source --> replaced this with your source paths or lib path
SRC_DIR = f:/dad/hmgobjects/source --> replaced this with your source paths or src path

CFLAGS = -Wall -mno-cygwin -O3 

all: \
   $(LIB_DIR)/libhmgobjects.a \

$(LIB_DIR)/libhmgobjects.a : \
   $(OBJ_DIR)/objects.o 

	ar rc $@ $^

$(OBJ_DIR)/objects.o : $(OBJ_DIR)/objects.c

$(OBJ_DIR)/objects.c   : $(SRC_DIR)/objects.prg
	$(HRB_DIR)/bin\harbour.exe $^ -n    -I$(HRB_DIR)/include -i$(INC_DIR) -d__WINDOWS__ -o$@ $^

.prg.c:
	$(HRB_DIR)/bin\harbour.exe $^ -n   -I$(HRB_DIR)/include -i$(INC_DIR) -d__WINDOWS__ -o$@ $^

.c.o:
	gcc $(CFLAGS) -c -I$(INC_DIR) -I$(HRB_DIR)/include -o $@ $^

So then from the HMG-IDE you have to specify the library you have created as HMGObjects (If that is the name you have given).

Regards,

Danny
Regards,

Danny
Manila, Philippines
User avatar
karweru
Posts: 220
Joined: Fri Aug 01, 2008 1:51 pm
DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
Contact:

Re: HMGObjects usage

Post by karweru »

Thanks Danny. I will try your second solution. HMG Objects has a very attractive goal as stated by Roberto.
Other important design goal was to make it portable. So, different backend GUI
frameworks (GTK, QT, wxWidgets, etc.) could be easily 'pluged-in'.
Though experimental, I trust Roberto to make it happen, and I think if I use it for a real-life program, I might help in testing it to the limits.

Thanks again Danny.
Kind regards,
Gilbert.
User avatar
mustafa
Posts: 1177
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: HMGObjects usage

Post by mustafa »

Hola karweru
Mire si le sirve este ejemplo
un saludo
*----------------- Google -----------------*
Hello karweru
See if this example serves
greetings
Mustafa
Attachments
Sample_OPP.zip
(717.42 KiB) Downloaded 319 times
User avatar
karweru
Posts: 220
Joined: Fri Aug 01, 2008 1:51 pm
DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
Contact:

Re: HMGObjects usage

Post by karweru »

Thank you so much Mustafa. I downloaded your sample, and I've been able to make mine work now. Thank you again.
Kind regards,
Gilbert.
Post Reply