Page 1 of 3

DRAW A TEXT ON A BITMAP

PostPosted: Mon Jul 16, 2012 6:33 pm
by Eoeo
i MADE :
n:=123

hDC := aBtn[nBotone]:GETDC()
SetTextColor( hDC,CLR_YELLOW)
SetBkMode( hDC, 0 )
TextOut( hDC, 2, 4,str(n) )
aBtn[nBotone]:ReleaseDC()

but I see for a second the number n with yellow color and then it hide...why ?

Re: DRAW A TEXT ON A BITMAP

PostPosted: Mon Jul 16, 2012 7:42 pm
by ukoenig
Image

Code: Select all  Expand view

@ 12, 10 IMAGE oImage SIZE 180, 170 OF oDlg2  FILENAME NIL PIXEL SCROLL  
oImage:LoadImage( , c_path + "\Images\" + cWLogo )
oImage:lTransparent := .T.
oImage:bPainted = { ||  SetBkMode( oImage:hDC, 1 ),;
             SetTextColor( oImage:hDC, CLR_YELLOW ),;
             TextOut( oImage:hDC, 50, 150, "
Hello" ), ;
             TextOut( oImage:hDC, 80, 150, "
World" ) }


Best Regards
Uwe :lol:

Re: DRAW A TEXT ON A BITMAP

PostPosted: Mon Jul 16, 2012 7:48 pm
by Eoeo
uwe, here crash
I use over 250 bitmaps...

Re: DRAW A TEXT ON A BITMAP

PostPosted: Mon Jul 16, 2012 8:06 pm
by Eoeo
WHEN i MAKE

@ nY*numero, nx*numero IMAGE aBtn[nBotone] SIZE BMP_H,BMP_V OF oPanel FILENAME NIL PIXEL NOBORDER
aBtn[nBotone]:LoadImage( , UMBRELLA_FREE )
aBtn[nBotone]:lTransparent := .T.

IT IS OK

WHEN i ADD THESE LINE IT CRASH AND NOT FOUND nBotone
aBtn[nBotone]:bPainted = { || SetBkMode( aBtn[nBotone]:hDC, 1 ),;
SetTextColor( aBtn[nBotone]:hDC, CLR_YELLOW ),;
TextOut( aBtn[nBotone]:hDC, 50, 150, str(n) ) }

Re: DRAW A TEXT ON A BITMAP

PostPosted: Mon Jul 16, 2012 9:55 pm
by Marcelo Via Giglio
Silvio,

I think you need to take the DC of the BMP not from the BTN

regards

Marcelo

Re: DRAW A TEXT ON A BITMAP

PostPosted: Mon Jul 16, 2012 10:56 pm
by Eoeo
how?

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 12:45 am
by Marcelo Via Giglio
Silvio,

I don't sure, but you can probe using this

aBtn[nBotone]:hBitmap1:hDC or

hDC := getDC( aBtn[nBotone]:hBitmap1 )

regards

Marcelo

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 6:14 am
by Eoeo
Not run

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 8:56 am
by Antonio Linares
Silvio,

You have to use that code from aBtn[ n ]:bPainted := { || ... }

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 9:29 am
by Eoeo
Dear Antonio,

Many year ago I made beach application and I used the sbutton class of Mercado. It made some errors on the refreshing od dialog

I use on the dialog a Panel control where I show the umbrellas and the TScrWnd to scroll the beach .

Last year I tried with btnbmp class to show umbrellas of a beach and it run ok only for small beach

I tried it run on 50/60 umbrellas but I need over 800 /1200

First the procedure show right all umbrellas then when I make controls ( date range, insert numbers and control to reservations archive) the procedure EXE crash

I tried it also with 10 umbrellas : then the 75 th operation it crash ( with 200 umbrellas crash on 13 th operation)


then I tried with Image controls but it crash ( I cannot write the number on each umbrellas) but with many umbrellas it crash also


How I must make to show the umbrellas ?

Domenico tried also with no solution !!!!

I need to found a solution because a customer have 2500 umbrellas on his beach

have you a solution and a small test to try ?



Antonio, For your message : have you check the resources consume in your app ?

I no use resources I use only sources calls sample :

#define UMBRELLA_FREE ".\BITMAPS\FREE.BMP"
#define UMBRELLA_OCCUPATED ".\BITMAPS\OCCUPATED.BMP"
#define UMBRELLA_DAILY ".\BITMAPS\DAYBEACH.BMP"
#define UMBRELLA_NOTPAYED ".\BITMAPS\NOTPAYED.BMP"
#define UMBRELLA_RESERVATION ".\BITMAPS\RESERV.BMP"




sample of planning


Image

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 9:34 am
by Antonio Linares
You may need to paint the umbrellas and not use a control for each one.

Keep an array in memory, with coordinates, situation, etc. of each umbrella.

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 9:52 am
by Eoeo
the final user must change the color of bitmaps ( 1,2,3,4,5 )

can you make a small test sample to understand how I must make it please ?

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 10:47 am
by Antonio Linares
Silvio,

Create a Class Umbrella:

CLASS Umbrella
DATA nTop, nLeft, nWidth, nHeight
DATA nStatus
etc...
METHOD paint() --> Here you paint a bitmap on its parent
METHOD IsOver( nRow, nCol ) // to detect a mouse click
ENDCLASS

as you see, it does not inherits from TControl. Then you keep an array of Umbrella objects.

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 1:10 pm
by Eoeo
and you think it can suopported many and many umbrellas ?

Re: DRAW A TEXT ON A BITMAP

PostPosted: Tue Jul 17, 2012 3:57 pm
by Antonio Linares
unlimited :-)