Page 1 of 1

How to fill a bitmap from resources with a solid color ?

Posted: Tue Mar 25, 2008 1:38 pm
by ukoenig
Hello,

I want to fill a Bitmap from resource with a solid Color
I think, i have to do something like this
but something doesn't work
No errors, but there is no Color to see.
In 2 Bitmaps, i want to show the used 2 Basic-Colors
Foreground / Background how they look next to each other.

Image

Code: Select all


// nColor1 = Foreground
// nColor2 = Background

REDEFINE BITMAP oBmp1  ID 770 ADJUST RESOURCE "Blanc"  OF oDlg5
hDC := oBmp1:GetDC()
oBmp1:bPainted := { |hDC|OnPaint( hDC,cTEXT,nCOLOR1,oBFont) } 
oBmp1:ReleaseDC()

REDEFINE BITMAP oBmp2  ID 771 ADJUST RESOURCE "Blanc"  OF oDlg5
hDC := oBmp2:GetDC()
oBmp2:bPainted := { |hDC|OnPaint( hDC,cTEXT,nCOLOR2,oBFont) } 
oBmp2:ReleaseDC()


//----------------------------------------------------------------// 

FUNCTION ONPAINT(hDC,cMsg,nBkColor,oFont) 
LOCAL hOldFont 

hOldFont := SelectObject( hDC, oFont:hFont ) 
 // 1 = Transparent  I need solid Color => set to 0
 // -------------------------------------------------------
SetBkMode( hDC, 0 )   
SetTextColor( hDC,nBkColor)
TextOut( hDC, 10, 70, cMsg ) 
SelectObject( hDC, hOldFont ) 
SetBkColor( hDC,nBkColor )  ???  nothing to see

//  ??????    Top, Bottom, Right, Left ?????
// ----------  Maybe something like that ???---------------------------

//  FillRect( hDC, { 10, 10, 10, 10 }, nBkColor )   

RETURN NIL

Regards

uwe :lol:

2 Colors next to each other

Posted: Tue Mar 25, 2008 8:11 pm
by ukoenig
In 2 Bitmaps i want to show 2 selected colors
how it looks, to use them in rows or cols of xbrowse
or other objects, where you need more than 1 color.

Regards

Posted: Tue Mar 25, 2008 10:55 pm
by Detlef Hoefner
Uwe,

maybe this coulds be an easier way to go.
Instead of bitmaps take the background of a say object:

Code: Select all

#include "FiveWin.ch" 

////////////////
PROCEDURE Main() 
////////////////
LOCAL oDlg
LOCAL oSay1, oSay2
LOCAL cVar := " "



   DEFINE DIALOG oDlg NAME "DLG_1"

   REDEFINE SAY oSay1 ID 10 PROMPT cVar OF oDlg COLORS CLR_BLACK, nRGB(  255,   0,   0 )
   REDEFINE SAY oSay2 ID 20 PROMPT cVar OF oDlg COLORS CLR_BLACK, nRGB(    0, 255,   0 )
   REDEFINE SAY oSay2 ID 30 PROMPT cVar OF oDlg COLORS CLR_BLACK, nRGB(    0,   0, 255 )

   ACTIVATE DIALOG oDlg CENTERED 

RETURN 
Regards,
Detlef

Change Backgrounds of Bitmaps

Posted: Tue Mar 25, 2008 11:45 pm
by ukoenig
Hello Detlef,

At first i wanted to use says, but i want to give the users
a source with the source-creator, to use this as background
for xBrowse or other objects, as bitmap.
The easy way is, to use a infobar-object with one color.
But i try, to make the tool useful for FW-users
( without Via-Coral ) as well.
Get the TFont- source of a selected font. The color-values
und more. The basic-structure for windows and dialogs.
It is still more possible.

Thank you for the reply.

Regards
Uwe