Transparent Png on MDI Parent
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Transparent Png on MDI Parent
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.
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
Re: Transparent Png on MDI Parent
ZIP in a small example and put megaupload for testing.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Antonio Linares
- Site Admin
- Posts: 42268
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Transparent Png on MDI Parent
Dear Byron,
Please post the code you are using to paint it
Please post the code you are using to paint it
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Transparent Png on MDI Parent
If using MDI window:
For normal window
Code: Select all | Expand
DEFINE WINDOW oWnd MDI
oWnd:oWndClient:bPainted := { || oWnd:oWndClient:DrawImage( "..\bitmaps\pngs\2.png",,,,,,"RB" ) }
ACTIVATE WINDOW oWnd CENTERED
Code: Select all | Expand
DEFINE WINDOW oWnd MDI
oWnd:bPainted := { || oWnd:DrawImage( "..\bitmaps\pngs\2.png",,,,,,"RB" ) }
ACTIVATE WINDOW oWnd CENTERED
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: Transparent Png on MDI Parent
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
...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
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
Re: Transparent Png on MDI Parent
Code: Select all | Expand
#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 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
FUNCTION 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
ENDMENU
RETURN 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
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Transparent Png on MDI Parent
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.
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
#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
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: Transparent Png on MDI Parent
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.
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Transparent Png on MDI Parent
What is your FWH version?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.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: Transparent Png on MDI Parent
#define FWCOPYRIGHT "(c) FiveTech Software, 1993-2023"
#define FWVERSION "FWH 23.07"
#define FW_VersionNo 23070
#define FWVERSION "FWH 23.07"
#define FW_VersionNo 23070
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
- nageswaragunupudi
- Posts: 10691
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Transparent Png on MDI Parent
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
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
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: Transparent Png on MDI Parent
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,
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services