Page 1 of 1
Transparent Png on MDI Parent
Posted:
Wed May 08, 2024 7:41 pm
by byron.hopp
I have a Png file, it is suppose to be transparent, when I display it in an image editor it shows a checkered gray background. How can I make this transparent using @ Say Image. On Resize I move it so it always is in the lower right hand corner of the window. But I get the checkered background, not so pretty.
Re: Transparent Png on MDI Parent
Posted:
Wed May 08, 2024 8:28 pm
by karinha
ZIP in a small example and put megaupload for testing.
Re: Transparent Png on MDI Parent
Posted:
Thu May 09, 2024 2:04 pm
by Antonio Linares
Dear Byron,
Please post the code you are using to paint it
Re: Transparent Png on MDI Parent
Posted:
Thu May 09, 2024 2:08 pm
by nageswaragunupudi
If using MDI window:
- Code: Select all Expand view
DEFINE WINDOW oWnd MDI
oWnd:oWndClient:bPainted := { || oWnd:oWndClient:DrawImage( "..\bitmaps\pngs\2.png",,,,,,"RB" ) }
ACTIVATE WINDOW oWnd CENTERED
For normal window
- Code: Select all Expand view
DEFINE WINDOW oWnd MDI
oWnd:bPainted := { || oWnd:DrawImage( "..\bitmaps\pngs\2.png",,,,,,"RB" ) }
ACTIVATE WINDOW oWnd CENTERED
Re: Transparent Png on MDI Parent
Posted:
Fri May 10, 2024 7:38 pm
by byron.hopp
Seems to depend on the bitmap, this code works for some bitmaps, I have also used @ 0,0 Bitmap...
...main program
@ 0,0 Image oLogo File Mcs_AppPath() + "Images\SqlServerLogo.bmp" Of oWnd:oWndClient No Border
ACTIVATE WINDOW oWnd VALID MCS_EXIT(oWnd,cPath,pPRG_ABRV) ON INIT OpenMast() On Resize SetLogo( oLogo,oWnd )
RETURN (NIL)
Function SetLogo( oLogo,oWnd )
Local nX,nY
oWnd:CoorsUpdate()
oWnd:oWndClient:CoorsUpdate()
oLogo:CoorsUpdate()
oLogo:Hide()
nX := oWnd:oWndClient:nWidth() - oLogo:nWidth()
nY := oWnd:oWndClient:nHeight() - oLogo:nHeight()
oLogo:Move( nY,nX,oLogo:nWidth(),oLogo:nHeight(),.t. )
oLogo:Show()
return NIL
Re: Transparent Png on MDI Parent
Posted:
Sat May 11, 2024 10:23 am
by karinha
- Code: Select all Expand view
#include "FiveWin.ch"STATIC oWnd
FUNCTION Main
() LOCAL oIco, oBar, oBmp, oLogo
DEFINE ICON oIco FILE
"..\icons\fax.ico" DEFINE WINDOW oWnd
MDI FROM 1,
1 TO 22,
75 TITLE "Byron Logo" ;
MENU BuildMenu
() COLOR "B/W" ICON oIco
DEFINE BUTTONBAR oBar _3D
SIZE 26,
27 OF oWnd
DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\new.bmp" FLAT ;
ACTION MsgInfo( "New" ) ;
TOOLTIP
"Creates a new document" DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\open.bmp" FLAT ;
ACTION MsgInfo( cGetFile
( "*.*",
"Select a document to open" ) ) ;
TOOLTIP
"Opens a document" WHEN .F.
DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\floppy.bmp" FLAT ;
ACTION MsgInfo( Time
() ) TOOLTIP
"Saves this document" DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\printer.bmp" FLAT ;
ACTION MsgInfo( "Prints this document" ) TOOLTIP
"Print this document" GROUP
DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\prop.bmp" FLAT ;
ACTION PrinterSetup
() TOOLTIP
"Setup the printer" DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\HelpInd.bmp" FLAT ;
ACTION MsgInfo( Version
() ) TOOLTIP
"A multiple lines" + ;
Chr
( 13 ) + Chr
( 10 ) +
"tooltip!" GROUP
DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\Help.bmp" FLAT ;
ACTION MsgInfo( "fivewin power!" ) TOOLTIP
"fivewin power!" DEFINE BUTTON OF oBar FILENAME
"..\bitmaps\16x16\Exit.bmp" FLAT ;
ACTION( oWnd:
End() ) TOOLTIP
"Exit this app" GROUP
DEFINE MESSAGE OF oWnd ;
PROMPT FWVERSION +
" " + FWCOPYRIGHT ;
NOINSET
CENTERED KEYBOARD DATE CLOCK
DEFINE BITMAP oBmp FILENAME
"..\bitmaps\pngs\dvd.png" // DEFINE BITMAP oBmp FILENAME "..\bitmaps\sea.bmp" oWnd:
bPainted =
{| hDC | BmpTiled
( hDC, oWnd, oBmp
) } @
0,
0 Image oLogo FILE
".\Logo.jpg" Of oWnd:
oWndClient No Border
ACTIVATE WINDOW oWnd ;
ON RESIZE SetLogo
( oLogo, oWnd
)RETURN NILFUNCTION SetLogo
( oLogo, oWnd
) LOCAL nX, nY
oWnd:
CoorsUpdate() oWnd:
oWndClient:
CoorsUpdate() oLogo:
CoorsUpdate() oLogo:
Hide() nX := oWnd:
oWndClient:
nWidth() - oLogo:
nWidth() nY := oWnd:
oWndClient:
nHeight() - oLogo:
nHeight() oLogo:
Move( nY, nX, oLogo:
nWidth(), oLogo:
nHeight(), .T.
) oLogo:
Show()RETURN NILFUNCTION BuildMenu
() LOCAL oMenu
MENU oMenu
MENUITEM "Information" MENU MENUITEM "&About..." ;
ACTION MsgInfo( FWDESCRIPTION
) ;
FILENAME
"..\bitmaps\16x16\info.bmp" SEPARATOR MENUITEM "&End..." ;
ACTION( oWnd:
End() ) ;
FILENAME
"..\bitmaps\16x16\exit.bmp" ENDMENU MENUITEM "&Clients" MENU MENUITEM "&New..." ;
ACTION ( MsgStop
( "New Clients" ), ;
oWnd:
Say( 5,
5,
"New Clients...",
"GR+/G" ) ) ;
FILENAME
"..\bitmaps\16x16\faces.bmp" MENUITEM "&Modify..." ACTION MsgInfo( "Modif. Clients" ) ;
FILENAME
"..\bitmaps\edit.bmp" MENUITEM "&Delete..." ACTION MsgAlert
( "Del Clients" ) ;
FILENAME
"..\bitmaps\16x16\delete.bmp" SEPARATOR MENUITEM "&Browse..." ACTION MsgInfo( "Browse Clients" ) ;
FILENAME
"..\bitmaps\16x16\browse.bmp" ENDMENU MENUITEM "&Utilities" MENU MENUITEM "&Calculator..." ACTION WinExec
( "Calc" ) ;
FILENAME
"..\bitmaps\16x16\calc.bmp" MENUITEM "&Internet..." ;
ACTION WinExec
( "start iexplore www.fivetech.com",
0 ) ;
FILENAME
"..\bitmaps\16x16\explorer.bmp" ENDMENU ENDMENURETURN oMenu
STATIC FUNCTION BmpTiled
( hDC, oWnd, oBmp
) LOCAL nWidth := oWnd:
nWidth(), nHeight := oWnd:
nHeight() LOCAL nRow :=
0, nCol :=
0, n
LOCAL nBmpWidth := oBmp:
nWidth(), nBmpHeight := oBmp:
nHeight() IF oBmp:
hBitmap ==
0 RETURN NIL ENDIF WHILE nRow < nHeight
nCol =
0 WHILE nCol < nWidth
PalBmpDraw
( hDC, nRow, nCol, oBmp:
hBitmap ) nCol += nBmpWidth
END
nRow += nBmpHeight
END
RETURN NIL// FIN / END
Regards, saludos.
Re: Transparent Png on MDI Parent
Posted:
Mon May 13, 2024 4:59 am
by nageswaragunupudi
I once again repeat please.
As I suggested above, the method oWnd:DrawImage(...) is the best suited for this purpose.
Please DO NOT create controls like BITMAP,IMAGE,XIMAGE etc.
Please test this example in samples folder:
I have used one Png to display at bottom-right and another at bottom-left.
Window can be resized.
When the window is resized to a very small size, even these pngs get resized correspondingly.
Also please note the transparent rendering.
- Code: Select all Expand view
#include "fivewin.ch"
function Main()
local oWnd, oBrush, oBar
local cPng1 := "..\bitmaps\pngs\2.png"
local cPng2 := "..\bitmaps\pngs\pan_setting.png"
DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\beach.bmp"
DEFINE WINDOW oWnd MDI BRUSH oBrush TITLE "TRANSP LOGOS"
DEFINE BUTTONBAR oBar OF oWnd 2007
SET MESSAGE OF oWnd TO "" 2007
oWnd:oWndClient:bPainted := { || ;
oWnd:oWndClient:DrawImage( cPng1, { .6,.7,, },,,,, "RB" ), ;
oWnd:oWndClient:DrawImage( cPng2,{,,,.2},,,,,"LB" ) }
ACTIVATE WINDOW oWnd CENTERED
RELEASE BRUSH oBrush
return nil
Re: Transparent Png on MDI Parent
Posted:
Mon May 13, 2024 5:06 pm
by byron.hopp
Mr. Rao, yes that did it. I had to convert my app to a newer version of FiveWin and once I got that going it was good. Thanks so much for taking the time to explain.
Re: Transparent Png on MDI Parent
Posted:
Mon May 13, 2024 6:37 pm
by nageswaragunupudi
byron.hopp wrote:Mr. Rao, yes that did it. I had to convert my app to a newer version of FiveWin and once I got that going it was good. Thanks so much for taking the time to explain.
What is your FWH version?
Re: Transparent Png on MDI Parent
Posted:
Mon May 13, 2024 6:42 pm
by byron.hopp
#define FWCOPYRIGHT "(c) FiveTech Software, 1993-2023"
#define FWVERSION "FWH 23.07"
#define FW_VersionNo 23070
Re: Transparent Png on MDI Parent
Posted:
Mon May 13, 2024 7:11 pm
by nageswaragunupudi
My sample works perfectly with your version.
You need not update.
In fact my sample works with much older versions also ( though not very very old)
Works with all versions of FWH from 2018 onwards
Re: Transparent Png on MDI Parent
Posted:
Mon May 13, 2024 7:20 pm
by byron.hopp
No the version I sent you is the new, the other was xHb, I don't think it had the Method DrawImage. I am good now, your version works great, and seems better than what I was doing before. Thanks,