Page 9 of 16

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 7:31 am
by mol
Code changing colors should look like:

Code: Select all

if ValType(::aFontColor) == 'U'
		xForeColor := '#000000;'
	else
		xForeColor := '#'+NtoC(aFontColor[1],16,2)+NtoC(aFontColor[2],16,2)+NtoC(aFontColor[3],16,2)+';'
	endif
	cStyleSheet += 'color:'+xForeColor + ';'
	if ValType(::aBackColor) == 'A'
		cStyleSheet += 'background-color:#'+NtoC(aBackColor[1],16,2)+NtoC(aBackColor[2],16,2)+NtoC(aBackColor[3],16,2)+';'
	endif
	
	if !empty(cStyleSheet)
		::oQTObject:setStyleSheet(cStyleSheet)
	endif
but, while compiling, I get an error about not found function NTOC
I need simple conversion from numbers to hex to paste color in #RRGGBB format.

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 7:44 am
by sudip
Excellent Marek :D Great :D

You got the answer :D

BTW, have you tried:

REQUEST NTOC

before calling NToC() function?

We are waiting for your solution.

There are some complex solutions I searched:
http://stackoverflow.com/questions/1777 ... ouble-spin

http://www.qtforum.org/article/23352/se ... idget.html

With Qt, we can do the same task in many ways. This is very good, but for a novice learner like me, it may be difficult ;)

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 8:37 am
by mol
looking for ntoc or rgb function in harbour source files, I found that xbpwindow.prg contains solution very similar to mine. So, I think, it could be right way :)

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 8:56 am
by mol
sudip wrote: BTW, have you tried:

REQUEST NTOC

before calling NToC() function?
REQUEST NTOC gives no solution :(

Still got an error while linking:

Code: Select all

Generating C source output to 'c:\temp\hbmk_bksrao.dir\demo_11.c'... Done.
c:/temp/hbmk_bksrao.dir/demo_11.o:demo_11.c:(.data+0x1f08): undefined reference
to `HB_FUN_NTOC'
c:/temp/hbmk_bksrao.dir/demo_11.o:demo_11.c:(.data+0x1f58): undefined reference
to `HB_FUN_NTOC'
collect2: ld returned 1 exit status
hbmk2: Error: Running linker. 1
I think it's caused by missing library containing CA TOOLS functions - LIBHBCT.A.
It's strange - this lib file is preset at c:\hmg.4\harbour\lib\win\mingw, but linker can't find NTOC function.
I think Roberto should help us

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 10:26 am
by sudip
Hello Marek,

Is following code helpful for decimal to hex conversion?

Code: Select all

Function DecToHexStr(mInt)
	Local aTemp := {}, aRem := 0, mDiv := 0, sHex := '', ;
		lNegative := (mInt < 0)
	
	If lNegative
		mInt *= -1
	EndIf
	
	mRem := mInt
	
	Do While !Empty(mDiv := Int(mInt / 16) )
	
		mRem := Mod(mInt, 16)
		
		Aadd(aTemp, mDiv)
		mInt := mRem
	
	EndDo
	
	Aadd(aTemp, mRem)
	
	sHex := If( lNegative, '-', '')
	
	For i := 1 To len(aTemp)
		sHex += If(aTemp[i] > 9, Chr(65+aTemp[i]-10), LTrim(Str(aTemp[i])))
	Next
	
	RETURN (sHex)
I got Rgb() function in one of my old codes:

Code: Select all

Function Rgb( r,g,b )

RETURN ( r + ( g * 256 ) + ( b * 256 * 256 ) )
I am not sure whether you are looking for this function. I am sorry, if you are looking for another function.

Again, thank you for your great work :)

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 11:10 am
by mol
I've copied numconv.prg from contrib\hbct
it contains conversion functions.
Thanks, Sudip

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 11:38 am
by mol
Roberto, is it possible to build sample with activated debugger?
When I've add -l option to build.bat, my app never appears on the screen and I must use task manager to kill it

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 12:05 pm
by esgici
Roberto Lopez wrote: Well... ..., so you do not need know C code at all.

Regarding OOP, I've created an extremely simple class hierarchy, so it should be 'understandable' for anyone, including those not familiarized with OOP, please, give it a try.

http://en.wikipedia.org/wiki/Object-ori ... rogramming
Thanks to encouraging and guidance :)

OK. I'll try..

That is being student afresh; this is scary but exciting ...

My sf.net user ID is esgici.

By the way, one of earliest web pages of HMG had a link to a site with very useful informations about OOP ;)

Best regards

--

Esgici

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 12:10 pm
by Roberto Lopez
mol wrote:Roberto, is it possible to build sample with activated debugger?
When I've add -l option to build.bat, my app never appears on the screen and I must use task manager to kill it
Regarding missing function, you could try to tell to hbmk2 to link the required library (-l parameter).

Regarding debugger, you could try adding -b parameter to hbmk2 and put a file called init.cld containing 'Options NoRunAtStartup' (without quotes).

This should do the trick.

Re: HMG 4 Started

Posted: Tue Aug 17, 2010 12:33 pm
by Roberto Lopez
esgici wrote:
Roberto Lopez wrote: Well... ..., so you do not need know C code at all.

Regarding OOP, I've created an extremely simple class hierarchy, so it should be 'understandable' for anyone, including those not familiarized with OOP, please, give it a try.

http://en.wikipedia.org/wiki/Object-ori ... rogramming
Thanks to encouraging and guidance :)

OK. I'll try..

That is being student afresh; this is scary but exciting ...

My sf.net user ID is esgici.

By the way, one of earliest web pages of HMG had a link to a site with very useful informations about OOP ;)

Best regards

--

Esgici
I've got you access as developer.

Regarding OOP model I'm still having very much discrepancies with the way it is used.

I'm talking about simple applications, IMHO it is counter intuitive and difficult in such cases. It is like to use a bulldozer to make a small hole in your garden :)

This is the reason because I'm, still providing xBase and alternate syntax with public windows.

But, I must admit that when you are handling a very complex code, it can (in some cases) make the things easier.

I've started programming with BASIC. I've wrote large applications, plenty of GOTO statements creating truly spaghetti code. When I've started to learn dBase III+ I've was very upset because it hasn't GOTO.

My thinking was: 'I'm an adult, I'm responsible for my unconditional control transfers, please, let me do it' :)

The same applies to OOP. It is designed to try to avoid bad coding. Basically it tries to stop you to have problems with variables and code that can be reused.

This restrictions make difficult to do simple things but makes easier complicated ones.

And besides that, I'm proud to be a person that is not afraid to change my opinions.

We grow, we got more experience and knowledge, so, we become different, better persons. I have no problem with that.

IMHO to remain 'static' with the same ideas along all of your life is not a good thing.