I have lday,lNumbers,lPayed
I have problems because the command not work as I wish and I not understood why
on command there are if function
it take only the second parameter
sample :
IF(lpayed,CLR_RED,COLOR_ARANCIONE)
if take the second color while lpayed is true why ?
another sample
if(lday, DrawImage( hDC, BMP_DAY , { 2, 40, 20, 20 }),)
lday is true but it now draw anything why ?
on the picture the second images must have the number with red background and must have a small image (BMP_DAY) on the right top angle
this images
BMP_DAY
OMB_LIBERO
OMB_OCCUPATO
this the test
- Code: Select all Expand view RUN
#include"fivewin.ch"
#include "constant.ch"
#define OMB_LIBERO ".\bitmaps\ombrellone_verde.png"
#define OMB_OCCUPATO ".\bitmaps\ombrelloneOccupato.png"
#define BMP_DAY ".\bitmaps\giornaliero.png"
#define COLOR_ARANCIONE nRGB( 238, 152, 25 )
#define OMB_W 60
#define OMB_H 60
Function test()
local nOmbrelloni := 4 // Total number of Umbrellas 3
local oDlg, oFont, aBtn[ nOmbrelloni ]
local nBottom := 48.4
local nRight := 155
local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight := nBottom * DLG_CHARPIX_H
Local cCursor:= TCursor():New(,'HAND')
local aStatus:= { "Reserved", "Confirmed", "Occupied", "Canceled", "Empty" }
Local nColor_Payed := nRGB( 238, 152, 25 )
Local nColor_NoPayed := CLR_RED
Local nFila,nNumber,nRow,nCol,n
Local nStatus,cTypeRoom,cPosNome
Local lNumBers,lday,lpayed
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE nWidth, nHeight PIXEL;
TRUEPIXEL FONT oFont
nRow := 60
nCol := 10
nNumber:=1
nFila:=1
nStatus:= 1
cTypeRoom :="O"
cPosNome:=""
lNumBers:=.T.
lday:=.F.
lpayed :=.T.
for n := 1 to nOmbrelloni
IF n=2 //only umbrella number 2
lday:=.T.
nStatus:= 2
lpayed :=.F.
endif
@ nRow, nCol BTNBMP aBtn[ n ] RESOURCE GiveBmp(nStatus) ;
SIZE OMB_W,OMB_H PIXEL OF oDlg ;
FLAT TOP COLOR CLR_WHITE NOBORDER ;
TOOLTIP cPosNome
aBtn[ n]:Cargo := {aStatus[nStatus],n,cTypeRoom, str(nFila)}
aBtn[n]:bPainted := { | hDC, cP, oBtn |if(lNumBers, DrawText2(hDC, oFont:hFont, 2, LTrim( Str(oBtn:Cargo[2])) + " " ,38, 3, 40, 62,CLR_WHITE, IF(!lpayed,CLR_RED,COLOR_ARANCIONE) ),),;
if(lday, DrawImage( hDC, BMP_DAY , { 2, 40, 20, 20 }),) }
nCol += OMB_W
If nNumber == 20
nNumber:=1
nRow += OMB_H+1
nFila +=1
nCol := 10
else
nNumber++
Endif
nStatus :=1
cPosNome:=""
lpayed := .f.
lDay:=.f.
next n
ACTIVATE DIALOG oDlg CENTERED
RETURN NIL
Function GiveBmp(nStato)
Local cFileBmp
Do case
case nStato=1
cFileBmp:=OMB_LIBERO
case nStato=2
cFileBmp:=OMB_OCCUPATO
Endcase
RETURN cFileBmp
//------------------------------------------------------------------------//
function DrawImage(hdc,cFile,arect)
local oGraphics := Graphics():New( hDC )
local oImage:= GDIBmp():new(cFile )
Local nTop:=arect[1]
local nLeft :=arect[2]
local nWidth:=arect[3]
local nHeight:=arect[4]
//DrawImage( oImage, nTop, nLeft, nWidth, nHeight )
oGraphics:DrawImage( oImage , nTop, nLeft, nWidth, nHeight )
oGraphics:destroy()
Return nil
//-----------------------------------------------------------------------------//
FUNCTION DrawText2( hDC, hFont, nBkMode, cText, nTop, nLeft, nWidth, nHeight,color,color2 )
LOCAL hFontOld:= SelectObject( hDC, hFont )
LOCAL nBkOld := SetBkMode( hDC, nBkMode )
SetTextColor( hDC, color )
setBkColor( hDC, color2 )
DrawText( hDC, cText, { nTop, nLeft, nTop+nWidth, nLeft+nHeight } )
SelectObject( hDC, hFontOld )
SetBkMode( hDC, nBkOld )
RETURN( NIL )
//-----------------------------------------------------------------------------//