// The Dialog-Button to Show a adjusted-Dialog
// -----------------------------------------------------------
REDEFINE BUTTONBMP oBtn12 ID 75 OF oDlg3 ;
ACTION ( ALPHA_IMG(oDlg3, cImage) ) ;
BITMAP "preview" PROMPT " &Alpha-Channel" TEXTRIGHT
oBtn12:cTooltip = { "Preview" + CRLF + ;
"Alpha-Channel","Preview", 1, CLR_BLACK, 14089979 }
// ------------ Image-Resource in Folder for normal Preview
// ------------on Record-change in xBrowse => oBMP10:Refresh() -----
REDEFINE BITMAP oBMP10 ID 210 ADJUST RESOURCE "Blanc" OF oFolder:aDialogs[1] UPDATE
oBMP10:bPainted := {|hDC| DRAW_IMG1( oBMP10, cIMAGE ) }
// ------------ IMAGE - Preview in Folder -----------------------------------
FUNCTION DRAW_IMG1( oBitmap, cBitmap)
DEFINE IMAGE oImage FILENAME "&c_Path\" + ALLTRIM(cSUBDIR) + cBitmap
// Image-Size adjusted to BMP-resource in Folder
// If the Image is bigger, it is reduced to the < TBitmap-Resource > size
// --------------------------------------------------------------------------------
aRect := GETCLIENTRECT( oBitmap:hWnd )
hDC := oBitmap:GETDC()
IF nWIDTH < aRect[4] .and. nHEIGHT < aRect[3]
PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , nWIDTH, nHEIGHT )
ENDIF
IF nWIDTH > aRect[4] .and. nHEIGHT <= aRect[3]
nNewproz := ( aRect[4] / nWIDTH ) * 100
nNewHeight := ( nHEIGHT / 100 ) * nNewproz
PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , aRect[4], nNewHeight )
ENDIF
IF nWIDTH <= aRect[4] .and. nHEIGHT > aRect[3]
nNewproz := ( aRect[4] / nHEIGHT ) * 100
nNewWidth := ( nWIDTH / 100 ) * nNewproz
PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , nNewWidth, aRect[3] )
ENDIF
IF nWIDTH > aRect[4] .and. nHEIGHT > aRect[3]
nNewprozW := ( aRect[4] / nWIDTH ) * 100
nNewprozH := ( aRect[4] / nHEIGHT ) * 100
nNewWidth := ( nWIDTH / 100 ) * nNewprozW
nNewHeight := ( nHEIGHT / 100 ) * nNewprozW
PalBmpDraw( hDC, 0, 0, oImage:hBitmap, , nNewWidth, nNewHeight )
ENDIF
lRESIZE := .F.
ReleaseDC(hDC)
RETURN( NIL )
// ------------ ALPHA- IMAGE ( Dialog adjusted to Image ) ------------
//------------- give a little bit space around the Image ----------
// nHEIGHT + 50, nWIDTH + 40
// take care of the Dialog-border : ABPaint( hDC, 10, 10 ......
FUNCTION ALPHA_IMG(oDlg3, cBitmap)
Local oDlg, oBmp, oBrush, oBtn
// nHeight = Image-Height
// nWidth := Image-Width
DEFINE BRUSH oBrush STYLE "BORLAND"
DEFINE BITMAP oBmp FILENAME "&c_Path\" + ALLTRIM(cSUBDIR) + cBITMAP
DEFINE DIALOG oDlg FROM 35, 20 TO nHEIGHT + 50, nWIDTH + 40 ;
OF oDlg3 COLOR 0, "N/W" BRUSH oBrush ;
TITLE "BMP with Alpha-Channel" PIXEL
ACTIVATE DIALOG oDlg ;
ON PAINT ABPaint( hDC, 10, 10, oBmp:hBitmap, 220 )
oBrush:End()
oBmp:End()
RETURN( NIL )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 78 guests