Page 1 of 1
TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 7:12 am
by Silvio.Falconi
..
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 8:40 am
by Antonio Linares
Silvio,
FillRect() expects a HBRUSH not a RGB color:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162719(v=vs.85).aspxDEFINE BRUSH oBrush COLOR ...
FillRect( ::hDC, aRect, oBrush:hBrush )
...
oBrush:End()
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 9:07 am
by Silvio.Falconi
Antonio,
I allready tried with brush and it made an error
- Code: Select all Expand view
Application
===========
Path and name: C:\work\errori\tled\test.Exe (32 bits)
Size: 1,892,864 bytes
Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6715)
FiveWin Version: FWHX 13.01
Windows version: 5.1, Build 2600 Service Pack 2
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 05/21/13, 11:08:29
Error description: Error BASE/1070 Argument error: ==
Args:
[ 1] = C Verde
[ 2] = N 16777215
Stack Calls
===========
Called from: .\source\classes\BRUSH.PRG => TBRUSH:NEW( 132 )
Called from: test.prg => TLED:PAINT( 171 )
Called from: test.prg => (b)TLED:TLED( 78 )
Called from: => TLED:DISPLAY( 0 )
Called from: .\source\classes\CONTROL.PRG => TLED:HANDLEEVENT( 1690 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3177 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 270 )
Called from: test.prg => TEST( 59 )
the paint method
METHOD Paint CLASS TLED
local hDC := ::hDC
LOCAL aRect := GetClientRect(hDC)
LOCAL nClPixel, aLinea, aCarattere, cFila
LOCAL nI, nJ, nAltezza, nLarghezza
LOCAL y := 0
LOCAL x := 0
LOCAL cTmp
local oBrush
local aInfo := ::DispBegin()
DEFINE BRUSH oBrush COLOR ::nClrBack
FillRect( ::hDC, aRect, oBrush:hBrush )
if ::bPainted != nil
Eval( ::bPainted, ::hDC, self )
endif
oBrush:End()
::DispEnd( aInfo )
return 0
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 9:42 am
by Antonio Linares
Silvio,
Where "Verde" comes from ?
[ 1] = C Verde
[ 2] = N 16777215
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 10:26 am
by Silvio.Falconi
come from comboBox :
Local aColors:={"CLR_BLACK","CLR_BLUE" ,"CLR_GREEN", "CLR_CYAN" , ;
"CLR_RED" ,"CLR_MAGENTA","CLR_GRAY","CLR_HBLUE", ;
"CLR_HGREEN","CLR_HCYAN","CLR_HRED" ,"CLR_HMAGENTA", ;
"CLR_YELLOW","CLR_WHITE","CLR_HGRAY"}
Local aClr:={"Nero","Azurro","Verde","Cielo","Rosso","Magenta", ;
"Grigio","Azurro Intenso","Verde Intenso","Cielo Intenso", ;
"Rosso Intenso","Magenta Intenso","Amarillo","Bianco" ,"Grigio chiaro" }
@ 64, 50 combobox aGet[1] VAR nBackColor ITEMS aClr of oDlg Size 40,60 PIXEL ;
ON CHANGE(nColore:= aColors[VAL(ltrim(STR(AScan( aclr, Trim(nBackColor))))) ],;
nmsgbox(nColore),oLcd:nClrBack:=nColore,oLcd:refresh())
Isent you a test.prg
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 10:41 am
by Silvio.Falconi
If you make also :
oLcd := TLed():New(10,5,oDlg)
oLcd:nClrBack:= CLR_RED
not show the Red color But Black
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 12:35 pm
by Antonio Linares
Silvio,
GetClientRect() parameter is ::hWnd, not ::hDC
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 4:51 pm
by Silvio.Falconi
Yes sorry but not refresh() the same
at init give me the object on red color then when I change color it return black
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 5:31 pm
by Silvio.Falconi
Antonio,
the error is on on change when I select a color and it not save on variable the right color
@ 66, 8 SAY "Sfondo :" SIZE 69, 8 PIXEL OF oDlg
@ 64, 50 combobox aGet[1] VAR nBackColor ITEMS aClr of oDlg Size 40,60 PIXEL ;
ON CHANGE(nmsgbox(nBackColor),;
cColor:=aColors[nBackColor],;
nmsgbox(cColor) ,;
oLcd:nClrBack:=cColor,;
oLcd:refresh())
If I think this line have problem oLcd:nClrBack:=cColor,; because if I insert oLcd:nClrBack:= CLR_GREEN RUN OK
THE CHANGE NOT TRANSLATE THE ARRAY INTO CLR_XXXXX
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 8:47 pm
by Antonio Linares
Is cColor a string ? As you use "c" in front of it, looks like you store a string there, and you have to provide a number (RGB).
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 8:55 pm
by Silvio.Falconi
Antonio,
I wish make a combobox with a selection of colors we have on colors.ch
this combox must give us a the string of color to assign to oLcd:nclrBack to refresh the background of the object
Could help me please ?
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 8:59 pm
by Antonio Linares
Silvio,
Local aColors:={CLR_BLACK,CLR_BLUE ,CLR_GREEN, CLR_CYAN , ;
CLR_RED ,CLR_MAGENTA,CLR_GRAY,CLR_HBLUE, ;
CLR_HGREEN,CLR_HCYAN,CLR_HRED ,CLR_HMAGENTA, ;
CLR_YELLOW,CLR_WHITE,CLR_HGRAY}
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 9:36 pm
by Silvio.Falconi
ooopppssssss
Re: TO ANTONIO : HELP TO CREATE A NEW CLASS
Posted:
Tue May 21, 2013 10:50 pm
by Silvio.Falconi
OK..RESOLVED