I found a Solution, to fix my Transparent-painting-problems
for Say, Radios and Checkboxes using Class TFOLDEX :
Color :
Gradient :
Brush :
Image :
The Dialog :
- Code: Select all Expand view
// --------- FOLDER -----------------------
FUNCTION TEST_FOLDER(nPos)
LOCAL hDC, hDC1, oTmp, oBtn10, oBtn11, oBtn12, oBtn13
LOCAL nRadio3 := 1, lCheck3 := .T.
LOCAL oSay3, oRadio3, oCheck3, oBrush5, oTitle1, cTitle := "", cTitle1 := ""
LOCAL oFld, aPrompts := { " Tab& 1", " Tab &2", " Tab &3" }
LOCAL oSelex1, oSelex2
// INIT of used Colors, Brushes and Images
// ------------------------------------------------
// DIALOG
// -----------
// nOption2 := 4 // DIALOG = Color, Gradient, Brush, Image
// nMove2 := 0.50
// nColor2a := 14853684
// nColor2b := 16312263
// aColors2 := { { nMove2, nColor2a, nColor2b }, { nMove2, nColor2b, nColor2a } }
// lDirect2 := .T.
// cBrush2 := c_Path + "\bitmaps\Marble.bmp"
// cImage2 := c_Path + "\bitmaps\Back1.jpg"
// FOLDER
// -----------
// nOption3 := 3 // FOLDER = Color, Gradient, Brush, Image
// nMove3 := 0.50
// nColor3a := 14853684
// nColor3b := 16312263
// aColors3 := { { nMove3, nColor3a, nColor3b }, { nMove3, nColor3b, nColor3a } }
// lDirect3 := .T.
// cBrush3 := c_Path + "\bitmaps\Marble.bmp"
// cImage3 := c_Path + "\bitmaps\Back1.jpg"
// nTabH := 25
// nTabS := 5
// nTabpos := 1
// cTabBmp := c_Path + "\bitmaps\16edit.bmp"
// selected Dialog-Background
// --------------------------------
IF nOption2 = 1
cTitle1 := "COLOR"
ENDIF
IF nOption2 = 2
cTitle1 := "GRADIENT"
ENDIF
IF nOption2 = 3
cTitle1 := "BRUSH"
ENDIF
IF nOption2 = 4
cTitle1 := "IMAGE"
ENDIF
// Selected Folder-Background
// ---------------------------------
IF nPos = 1
cTitle := "Selected Dialog = " + cTitle1 + " / Folder = COLORS"
ENDIF
IF nPos = 2
cTitle := "Selected Dialog = " + cTitle1 + " / Folder = GRADIENT"
ENDIF
IF nPos = 3
cTitle := "Selected Dialog = " + cTitle1 + " / Folder = BRUSH"
ENDIF
IF nPos = 4
cTitle := "Selected Dialog = " + cTitle1 + " / Folder = IMAGE"
ENDIF
// Dialog-Background
// ----------------------
IF nOption2 = 1 // Color
DEFINE BRUSH oBrush5 COLOR nColor2a
DEFINE DIALOG oWndDlg RESOURCE "Painter5" OF oWndMain PIXEL TRANSPARENT ;
TITLE cTitle BRUSH oBrush5
oBrush5:End()
ENDIF
IF nOption2 = 2 // Gradient
DEFINE DIALOG oWndDlg RESOURCE "Painter5" OF oWndMain PIXEL TRANSPARENT ;
TITLE cTitle
ENDIF
IF nOption2 = 3 // Brush
DEFINE BRUSH oBrush5 FILENAME cBrush2
DEFINE DIALOG oWndDlg RESOURCE "Painter5" OF oWndMain PIXEL TRANSPARENT ;
TITLE cTitle BRUSH oBrush5
oBrush5:End()
ENDIF
IF nOption2 = 4 // Image
DEFINE IMAGE oTmp FILENAME cImage2
DEFINE DIALOG oWndDlg RESOURCE "Painter5" OF oWndMain PIXEL TRANSPARENT ;
TITLE cTitle
oBrush5 := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, 400, 300, .T. ) )
oWndDlg:SetBrush( oBrush5 )
oTmp:End()
oBrush5:End()
ENDIF
REDEFINE FOLDEREX oFld ID 110 PROMPT "T&est","&Tabs", "&Bmp" ;
BITMAPS c_Path + "\bitmaps\16edit.bmp", c_Path + "\bitmaps\16edit.bmp", c_Path + "\bitmaps\16edit.bmp" ;
DIALOGS "Sub1", "Sub2", "Sub3" ;
ROUND 5 ;
ON CHANGE ( nTabPos := oFld:nOption )
oFld:lTransparent := .T.
oFld:nFolderHeight := 30
oFld:nSeparator := 10
oFld:bClrText := {| o, n | nTColor }
oFld:oFont := oTextFont
REDEFINE SAY oSay3 ID 110 PROMPT cTEXTFONT1 OF oFld:aDialogs[1] FONT oTextFont PIXEL
oSay3:SetColor( nTColor, )
oSay3:lTransparent := .T.
REDEFINE RADIO oRadio3 VAR nRadio3 OF oFld:aDialogs[1] ID 120, 121 ;
ON CHANGE MsgBeep() ;
COLOR nTColor
oRadio3:SetFont( oTextFont )
AEval( oRadio3:aItems, { | oRad | oRad:lTransparent := .T. } )
REDEFINE CHECKBOX oCheck3 VAR lCheck3 ID 130 OF oFld:aDialogs[1] ;
ON CHANGE oCheck3:SetText( "New Text" )
oCheck3:lTransparent := .T.
oCheck3:SetFont( oTextFont )
oCheck3:SetColor( nTColor )
// -------------------------
REDEFINE SELEX oSelex1 VAR nTabH OF oFld:aDialogs[2] ID 500 ;
ITEMS "20", "25", "30", "35" ;
GRADIENT OUTTRACK { { 0.5, 16770250, 16312263 }, ;
{ 0.5, 16312263, 16770250 } } ;
GRADIENT INTRACK { { 0.5, 8388608, 16312263 }, ;
{ 0.5, 16312263, 8388608 } } ;
THUMBSIZE 40, 30 ROUNDSIZE 5 ;
COLOR THUMB 14853684 ;
COLORTEXT 128, 32768 ;
TITLE "Tab-Heigh" TOP ;
FONT oFont5 ;
ACTION( IIF( oSelex1:nOption = 1, nTabH := 20, NIL ), ;
IIF( oSelex1:nOption = 2, nTabH := 25, NIL ), ;
IIF( oSelex1:nOption = 3, nTabH := 30, NIL ), ;
IIF( oSelex1:nOption = 4, nTabH := 35, NIL ), ;
oFld:nFolderHeight := nTabH, oFld:Refresh() ) ;
COLORTITLE 0
// Init at startup
// -----------------
IF nTabH = 20
oSelex1:Setoption( 1 )
ENDIF
IF nTabH = 25
oSelex1:Setoption( 2 )
ENDIF
IF nTabH = 30
oSelex1:Setoption( 3 )
ENDIF
IF nTabH = 35
oSelex1:Setoption( 4 )
ENDIF
REDEFINE SELEX oSelex2 VAR nTabS OF oFld:aDialogs[2] ID 510 ;
ITEMS "5", "10", "15" ;
GRADIENT OUTTRACK { { 0.5, 16770250, 16312263 }, { 0.5, 16312263, 16770250 } } ;
GRADIENT INTRACK { { 0.5, 8388608, 16312263 }, { 0.5, 16312263, 8388608 } } ;
THUMBSIZE 40, 30 ROUNDSIZE 5 ;
COLOR THUMB 14853684 ;
COLORTEXT 128, 32768 ;
TITLE "Tab-Separator" TOP ;
FONT oFont5 ;
ACTION( IIF( oSelex2:nOption = 1, nTabS := 5, NIL ), ;
IIF( oSelex2:nOption = 2, nTabS := 10, NIL ), ;
IIF( oSelex2:nOption = 3, nTabS := 15, NIL ), ;
oFld:nSeparator := nTabS, oFld:Refresh() ) ;
COLORTITLE 0
// Init at startup
// -----------------
IF nTabS = 5
oSelex2:Setoption( 1 )
ENDIF
IF nTabS = 10
oSelex2:Setoption( 2 )
ENDIF
IF nTabS = 15
oSelex2:Setoption( 3 )
ENDIF
REDEFINE BTNBMP oBtn12 ID 30 OF oFld:aDialogs[2] 2007 ;
FILENAME c_path + "\Bitmaps\Reload.bmp" ;
LEFT ;
PROMPT " &Update " ;
FONT oFont5 ;
ACTION ( oWndDlg:End(), MDI_FOLDER(nPos) )
oBtn12:lTransparent = .t.
oBtn12:cTooltip := { "Update " + CRLF + ;
"Folder-Preview","Update", 1, CLR_BLACK, 14089979 }
// -------------------
REDEFINE BTNBMP oBtn13 ID 30 OF oFld:aDialogs[3] 2007 ;
FILENAME c_path + "\Bitmaps\Reload.bmp" ;
LEFT ;
PROMPT " &Update " ;
FONT oFont5 ;
ACTION ( oWndDlg:End(), MDI_FOLDER(nPos) )
oBtn13:lTransparent = .t.
oBtn13:cTooltip := { "Update " + CRLF + ;
"Folder-Preview","Update", 1, CLR_BLACK, 14089979 }
REDEFINE BITMAP oTITLE1 ID 100 ADJUST RESOURCE "Blanc" OF oWndDlg
oTITLE1:cTooltip := "Please select a Button"
oTITLE1:bLclicked := { |hDC| MsgAlert( "Test", "Attention" ) } // bRClicked
oTITLE1:bPainted := { |hDC| ;
DRAW_TITLE( oTITLE1, ; // BMP
hDC, ; // hDC
.T., ; // Horiz. or Vert.
14853684, ; // 1. Grad-Color
16314573, ; // 2. Grad-Color
0.50, ; // Color-Pos.
0, ; // Text-Pos from left ( 0 = centered )
oFont5, ; // Font
128, ; // Font-Color
cTitle) }
REDEFINE BTNBMP oBtn10 ID 20 OF oWndDlg ;
PROMPT " &Show INI-file" 2007 PIXEL ;
FONT oFont5 ;
LEFT ;
NOBORDER ;
FILENAME c_Path + "\bitmaps\Write.bmp" ;
ACTION WAITRUN( "Angelwriter.exe SETTINGS.INI" )
oBtn10:SetColor( 0, )
oBtn10:cTooltip := { "Open Ini-file" + CRLF + ;
"to check Values","INI-file" } // , 0, 14089979 }
REDEFINE BTNBMP oBtn11 ID 30 OF oWndDlg ;
PROMPT " &Write PRG" 2007 PIXEL ;
FONT oFont5 ;
LEFT ;
NOBORDER ;
FILENAME c_Path + "\bitmaps\Write.bmp" ;
ACTION MAKE_PRG(nOption1,nOption2)
oBtn11:SetColor( 0, )
oBtn11:cTooltip := { "Write" + CRLF + ;
"PRG and EXE-file","Create Project" } // , 0, 14089979 }
ACTIVATE DIALOG oWndDlg NOWAIT ;
ON INIT ( oWndDlg:Move( 50, 580, NIL, NIL, .T. ), ;
IIF( nOption2 = 2, GRADBRU(), NIL ), ; // Dialog-Gradient
oFld:SetOption( nTabpos ) ) ;
ON PAINT F_BACKGRD( nPos, oFld, hDC, nMOVE3, nColor3a, nColor3b, lDirect3, cBrush3, cImage3 )
RETURN NIL
The Folder-Background-Painting :
- Code: Select all Expand view
// -------- Folder - Background ---------------
FUNCTION F_BACKGRD( nStyle, oFld, hDC, nMove, nColor1, nColor2, lDirect, cBrush, cImage )
LOCAL n, oDlg, oBrush2, oBrush3, oImage2, hDC1
LOCAL aColors := { { nMOVE, nCOLOR1, nCOLOR2 }, { nMOVE, nCOLOR2, nCOLOR1 } }
LOCAL aRect := GetClientRect( oFld:hWnd )
FOR n := 1 to Len( oFld:aDialogs )
oDlg := oFld:aDialogs[ n ]
hDC1 = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
hBmpOld = SelectObject( hDC1, hBmp )
IF nStyle = 1 // Color
DEFINE BRUSH oBrush2 COLOR nColor1
FillRect( hDC1, aRect, oBrush2:hBrush )
ENDIF
IF nStyle = 2 // Gradient
GradientFill( hDC1, 0, 0, oDlg:nHeight, oDlg:nWidth, aColors, lDirect )
ENDIF
IF nStyle = 3 // Brush
DEFINE BRUSH oBrush2 FILENAME cBrush
FillRect( hDC1, aRect, oBrush2:hBrush )
ENDIF
IF nStyle = 4 // Image
DEFINE IMAGE oTmp FILENAME cImage
oBrush2 := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, oDlg:nWidth, oDlg:nHeight, .T. ) )
oTmp:End()
FillRect( hDC1, aRect, oBrush2:hBrush )
ENDIF
DeleteObject( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC1, hBmpOld )
oDlg:ReleaseDC()
NEXT
RETURN( NIL )
Drawing the Dialog-Title :
- Code: Select all Expand view
//------------- Gradient / Color- TITLE -----------
FUNCTION DRAW_TITLE( oBitmap, hDC, lDirect, nVColor, ;
nBColor, nMove, nLeft, oFont, nTColor, cTitle )
LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }
LOCAL aRect := GETCLIENTRECT( oBitmap:hWnd )
LOCAL oNewBrush, oBtn1
// DRAW_TITLE( oTITLE, ; // BMP
// hDC, ; // hDC
// .T., ; // Horiz. or Vert.
// 14853684, ; // 1. Grad-Color
// 16314573, ; // 2. Grad-Color
// 0.50, ; // Color-Pos.
// 0, ; // Text-Pos from left ( 0 = centered )
// oFont5, ; // Font
// 128, ; // Font-Color
// "MDI-Button Image ( adjusted ) ...") }
DEFINE BRUSH oNewBrush ;
COLOR GradientFill( hDC, 0, 0, aRect[3], aRect[4], aGrad, lDirect )
hOldFont := SelectObject( hDC, oFont:hFont )
nTXTLG := GettextWidth( hDC, cTitle )
nBMPLONG := oBitmap:Super:nWidth()
nBMPHIGHT := oBitmap:Super:nHeight()
nFONTHIGHT := oFont:nInpHeight * -1
IF nLEFT = 0
nLEFT := (nBMPLONG - nTXTLG) / 2
ENDIF
nNEWHIGHT := nFONTHIGHT
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
SetTextColor( hDC,nTColor)
SetBkMode( oBitmap:hDC, 0 )
TextOut( hDC, nTOP, nLEFT, cTitle )
RELEASE BRUSH oNewbrush
RETURN NIL
Drawing the Gradient-Dialog-Background ( ON INIT => nOption2 = 2 ) :
- Code: Select all Expand view
// ---- DIALOG GRADIENT-Background ---
FUNCTION GRADBRU()
LOCAL hDC1, aColors
aColors := { { nMove2, nColor2a, nColor2b }, { nMove2, nColor2b, nColor2a } }
hDC1 = CreateCompatibleDC( oWndDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oWndDlg:hDC, oWndDlg:nWidth(), oWndDlg:nHeight() - 25 )
hBmpOld = SelectObject( hDC1, hBmp )
// lDirect2 = definded Grad.-Direction
GradientFill( hDC1, 0, 0, oWndDlg:nHeight(), oWndDlg:nWidth(), aColors, lDirect2 )
DeleteObject( oWndDlg:oBrush:hBrush )
oWndDlg:oBrush:hBitmap = hBmp
oWndDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC1, hBmpOld )
oWndDlg:ReleaseDC()
oWndDlg:Refresh()
RETURN NIL
Best Regards
Uwe