A question about => Folder,hDC and BMP-painting (solved)

A question about => Folder,hDC and BMP-painting (solved)

Postby ukoenig » Tue Sep 23, 2008 10:46 am

Hello,

I got a problem, trying to change colors and bitmaps from inside folders :

I want to define new dialog-colors inside a folder with a bitmap-preview
and than show the result in a extra preview-dialog.
I don't want to change the Main-dialog-background.
The preview is a extra-dialog and has nothing to do with the folder.

The source, to define a color/brush for a bitmap and show the result in a extra dialog-preview :

Code: Select all  Expand view
A Preview-Bitmap in folder-page 7
---------------------------------------
REDEFINE BITMAP oBmp22  ID 145 ADJUST RESOURCE "DlgSampl"  OF oFld:aDialogs[7]
oBmp22:bPainted := { |hDC| OnPaint5( hDC, oBMP22) } 


// ---------- The Bitmap-Refresh-Function -------------------------------------

FUNCTION ONPAINT5( hDC, oBmp22 )
LOCAL oBrush1

IF DLG_STYLE1 < 3
   IF nHEADGRAD = 1
      aGrad1 := { { nMOVE1, BR_COLOR1, BR_COLOR2 }, ;
      { nMOVE1, BR_COLOR2, BR_COLOR1 } }
   ENDIF
   IF nHEADGRAD = 2
      aGrad1 := { { nMOVE1, BR_COLOR1, BR_COLOR1 }, ;
      { nMOVE1, BR_COLOR1, BR_COLOR1 } }
   ENDIF
ENDIF
IF DLG_STYLE1 > 2 .and. DLG_STYLE1 < 5
   IF nHEADGRAD = 1
      aGrad1 := { { nMOVE7, DLG_COLOR1, DLG_COLOR2 }, ;
      { nMOVE7, DLG_COLOR2, DLG_COLOR1 } }
   ENDIF
   IF nHEADGRAD = 2
      aGrad1 := { { nMOVE7, DLG_COLOR1, DLG_COLOR1 }, ;
      { nMOVE7, DLG_COLOR1, DLG_COLOR1 } }
   ENDIF
ENDIF
// DLG_STYLE1
// 1 = Dialog-backgroung from xBrowse-Header Horizontal
// 2 = Dialog-background from xBrowse-Header Vertical
// 3 = New Gradient for Dialog-background Horizontal
// 4 = New Gradient for Dialog-background Vertical
// 5 = Mono-Color for Dialog-background from 1. xBrowse-header-color
// 6 = Brush-selection for Dialog-background
IF DLG_STYLE1 <  5
   IF DLG_STYLE1 = 1 .or. DLG_STYLE1 = 3
      GradientFill( hDC,  0, 0, 193, 255, aGrad1, .T. )
   ENDIF
   IF DLG_STYLE1 = 2  .or. DLG_STYLE1 = 4
      GradientFill( hDC,  0, 0, 193, 255, aGrad1, .F. )
   ENDIF
ENDIF
IF DLG_STYLE1 =  5
   DEFINE BRUSH oBrush1 COLOR DLG_COLOR1
   FillRect(oBmp22:hDC, GetClientRect( oBmp22:hWnd ), ;
   oBrush1:hBrush )
   oBrush1:End()
ENDIF
IF DLG_STYLE1 =  6
   DEFINE BRUSH oBrush1 FILENAME LOGO3
   FillRect(oBmp22:hDC, GetClientRect( oBmp2:hWnd ), oBrush1:hBrush )
   oBrush1:End()
ENDIF

RETURN NIL

//---------  TEST-DATABASE ( The Action from the Preview-Button ) -------------//

STATIC FUNCTION Test_Browse5()
Local oDlg5, oLbx30, oBrush5, oBmp5
Local cAlias := cGetNewAlias( "CUST" )
LOCAL oBmp1, nBMPheight

nFOR := 1

REQUEST DBFCDX
USE CUSTOMER NEW ALIAS (cAlias) SHARED VIA "DBFCDX"
GO TOP

DEFINE DIALOG oDlg5 RESOURCE "TESTSOURCE"
....
....
....

ACTIVATE DIALOG oDlg5 CENTERED  ;
ON PAINT DLG_BACK( oDlg5 ) ;
ON INIT ( oDlg5:Move( 30, 10, oDlg5:nWidth, oDlg5:nHeight, .f. ), ;
                SHOW_BAR( oDlg5 ), OBRW_PEN( oLbx30) )

(cAlias)->( dbCloseArea() )

RETURN ( NIL )   



The color-defines for a new dialog-background :

Image

If i change to the main-dialog with the preview-button.
As soon, the button gets the focus,
the tooltipp shows the color of the bitmap from the folder-page.

Image

I do the preview :

Image

I close the preview and the main-dialog got the color from
the preview-dialog.

Image

I don't know, why the main-dialog uses colors, defined inside a folder-page to show in a extra dialog.
I think, it has to do something with < hDC >.

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Painting in Folders

Postby ukoenig » Tue Sep 23, 2008 9:54 pm

I solved my painting-problems in folders.
For the gradient-painting on the Main-dialog, i used the same
function like for the Gradient-painting in the Preview-dialog.
( with funny results )
That didn't work. I had to do a extra Gradpaint.
The functions inside the folders have been OK.
It works fine now.

Code: Select all  Expand view

ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
ON PAINT ( gradpaint0( hDC, oDlg ), SetDialogsGradient( oFld ) ) ;
ON INIT ( oDlg:Move( 30 , 10, oDlg:nWidth, oDlg:nHeight, .f. ), ;
      RESULT_1_2(), oResult12:Refresh() )

RETURN ( NIL )

// --------- Gradient-Painting ( Main-Dialog ) ------------

static func gradpaint0( hDC, oDlg )
local aGrad1, oBrush1

aGrad1 := { { nMOVE1, BR_COLOR1, BR_COLOR2 },{ nMOVE1, BR_COLOR2, BR_COLOR1 } }
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad1, .T. )

RETURN NIL

// --------- Gradient-Painting ( Folder ) -------------------

FUNCTION SetDialogsGradient( oFld )
local n, oDlg

for n = 1 to Len( oFld:aDialogs )
   oDlg = oFld:aDialogs[ n ]                                     
   oDlg:bPainted = { | hDC | GradientFill( hDC, 0, 0, oDlg:nHeight, ;
   oDlg:nWidth, { { 0.50, 12609872, 16045947 } } ) }
next   

RETURN NIL   



Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests