Layer a Dialog with a bitmap

Layer a Dialog with a bitmap

Postby Silvio.Falconi » Mon Jul 09, 2018 10:26 am

I wish show a bitmap on a dialog and make all transparent but it is transparent but i see also the border of the dialog
I tried also with oMessage:WinStyle(WS_BORDER, .f.) but the border of Dialos there is allways

Image

How I can resolve ?

the test

Code: Select all  Expand view

#include "FiveWin.ch"
#include "constant.ch"

function MsgFancy( cMsg )

   local oDlg, oBrush,oBmp1,oBmp2,oFont

   DEFINE FONT oFont NAME "Verdana" BOLD
   DEFINE BITMAP oBmp1 filename "MESSAGE.png"
   DEFINE BITMAP oBmp2 filename "MESSAGE.png"

   DEFINE BRUSH oBrush COLOR CLR_BLUE // STYLE NULL             // Transparent painting !

   DEFINE DIALOG oDlg SIZE 123,122;
      STYLE WS_POPUP ;
      BRUSH oBrush ;

   ACTIVATE DIALOG oDlg CENTERED ;
      ON PAINT ( PalBmpDraw( oDlg:hDC, 0, 0, oBmp2:hBitmap, 0, 0, 0, SRCPAINT ),;
                 PalBmpDraw( oDlg:hDC, 0, 0, oBmp1:hBitmap, 0, 0, 0, SRCAND ),;
                 oDlg:Say( 3.7, 10, cMsg,,, oFont ) ) ;
      ON LEFT CLICK oDlg:End() ;
      ON INIT SetTransparent( oDlg )

return nil

#define LWA_COLORKEY  2
#define GWL_EXSTYLE   -20
#define WS_EX_LAYERED 524288

static function SetTransparent( oDlg )
   SetWindowLong( oDlg:hWnd, GWL_EXSTYLE, nOr( GetWindowLong( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) )
   SetLayeredWindowAttributes( oDlg:hWnd, 0, 180, LWA_COLORKEY )
   return nil


 



the image
Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Layer a Dialog with a bitmap

Postby Antonio Linares » Mon Jul 09, 2018 2:57 pm

Silvio,

Please review FWH\samples\newhelp.prg

Press on the help button and then press on top of a control or the dialog itself.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Layer a Dialog with a bitmap

Postby Silvio.Falconi » Mon Jul 09, 2018 4:02 pm

yes I try it antonio same error
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Layer a Dialog with a bitmap

Postby nageswaragunupudi » Mon Jul 09, 2018 7:18 pm

This sample works with current versions of FWH. I will separately post another sample that works with 17.11
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBrush
   local aBtn[ 8 ], aCallOut := {}
   local n, nRow, nCol

   DEFINE BRUSH oBrush FILE "c:\fwh\bitmaps\sea.bmp" RESIZE
   DEFINE DIALOG oDlg SIZE 680,600 PIXEL TRUEPIXEL BRUSH oBrush

   nRow  := 300
   nCol  :=  40
   for n := 1 to 8
      @ nRow, nCol BTNBMP aBtn[ n ] FILE "UMBRELLA.PNG" SIZE 128,128 PIXEL OF oDlg FLAT NOBORDER
      aBtn[ n ]:lTransparent := .t.
      nCol  += 150
      if n == 4
         nRow  += 150
         nCol  := 40
      endif
   next

   @ 60,40 BTNBMP PROMPT "CALLOUT" SIZE 128,32 PIXEL OF oDlg 2007 CENTER ;
      ACTION If( Empty( aCallOut ), ;
                  ( aCallOut := {}, ;
                    AAdd( aCallOut, CallOutBtn( aBtn[ 3 ], "Silvio"  ) ), ;
                    AAdd( aCallOut, CallOutBtn( aBtn[ 6 ], "Antonio" ) ) ), ;
                 ( AEval( aCallOut, { |o| o:End() } ), aCallOut := {} ) )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE BRUSH oBrush

return nil

function CallOutBtn( oBtn, cMsg )

   local oDlg, oFont, nRow, nCol, aPt
   local nDlgWidth   := 128 // can specify a lower size

   nRow  := oBtn:nTop - ( nDlgWidth * 0.6 )
   nCol  := oBtn:nLeft - 20
   aPt   := ClientToScreen( oBtn:oWnd:hWnd, { nRow, nCol } )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE nDlgWidth,( nDlgWidth * 125/128) PIXEL TRUEPIXEL COLOR CLR_BLACK,1 STYLE WS_POPUP FONT oFont
   RELEASE FONT oFont

   WITH OBJECT oDlg
      :nSeeThroClr   := 1
      :bLClicked     := { || oDlg:End() }
      :bPainted      := { || oDlg:DrawImage( "CALLOUT.PNG" ), ;
                             oDlg:SayText( cMsg, { nil, nil, -0.2, nil } ) }
   END

   ACTIVATE DIALOG oDlg NOWAIT ;
      ON INIT ( oDlg:Move( aPt[ 1 ], aPt[ 2 ] ) )

return oDlg
 

Thanks to Mr. Silvio for sharing his bitmaps. I made a small change to the image.

Clicking callout button at the top, displays the callouts and clicking next time removes the callouts.
There is a provision to reduce the size of the callouts.

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Layer a Dialog with a bitmap

Postby nageswaragunupudi » Mon Jul 09, 2018 8:11 pm

This sample works with FWH 17.11
Code: Select all  Expand view
#include "fivewin.ch"


function Main()

   local oDlg, oBrush
   local aBtn[ 8 ], aCallOut := {}
   local n, nRow, nCol
   local aBmp

   aBmp  := WndReadPalBmpEx( nil, "CALLOUT.PNG" )

   DEFINE BRUSH oBrush FILE "c:\fwh\bitmaps\sea.bmp" RESIZE
   DEFINE DIALOG oDlg SIZE 680,600 PIXEL TRUEPIXEL BRUSH oBrush

   nRow  := 300
   nCol  :=  40
   for n := 1 to 8
      @ nRow, nCol BTNBMP aBtn[ n ] FILE "UMBRELLA.PNG" SIZE 128,128 PIXEL OF oDlg FLAT NOBORDER
      aBtn[ n ]:lTransparent := .t.
      nCol  += 150
      if n == 4
         nRow  += 150
         nCol  := 40
      endif
   next

   @ 60,40 BTNBMP PROMPT "CALLOUT" SIZE 128,32 PIXEL OF oDlg 2007 CENTER ;
      ACTION If( Empty( aCallOut ), ;
                  ( aCallOut := {}, ;
                    AAdd( aCallOut, CallOutBtn( aBtn[ 3 ], "Silvio", aBmp  ) ), ;
                    AAdd( aCallOut, CallOutBtn( aBtn[ 6 ], "Antonio", aBmp ) ) ), ;
                 ( AEval( aCallOut, { |o| o:End() } ), aCallOut := {} ) )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE BRUSH oBrush
   PalBmpFree( aBmp )

return nil

function CallOutBtn( oBtn, cMsg, aBmp )

   local oDlg, oFont, nRow, nCol, aPt
   local nDlgWidth   := 128 // can specify a lower size

   nRow  := oBtn:nTop - ( nDlgWidth * 0.6 )
   nCol  := oBtn:nLeft - 20
   aPt   := ClientToScreen( oBtn:oWnd:hWnd, { nRow, nCol } )
   if aPt[ 1 ] > 32768
      aPt[ 1 ] -= 65535
   endif
   if aPt[ 2 ] > 32768
      aPt[ 2 ] -= 65535
   endif

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE nDlgWidth,( nDlgWidth * 125/128) PIXEL TRUEPIXEL COLOR CLR_BLACK,1 STYLE WS_POPUP FONT oFont
   RELEASE FONT oFont

   WITH OBJECT oDlg
      :nSeeThroClr   := 1
      :bLClicked     := { || oDlg:End() }
      :bPainted      := { || oDlg:SayPalBmp( aBmp ), ;
                             oDlg:SayText( cMsg, { nil, nil, -0.2, nil } ) }
   END

   ACTIVATE DIALOG oDlg NOWAIT ;
      ON INIT ( oDlg:Move( aPt[ 1 ], aPt[ 2 ] ) )

return oDlg
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Layer a Dialog with a bitmap

Postby Silvio.Falconi » Mon Jul 09, 2018 9:33 pm

Good Mr Rao
I mean something of it also with a timer to show the message dialog for n seconds

ON INIT ( oDlg:Move( aPt[ 1 ], aPt[ 2 ] ),BuildTimer( oDlg ) )

Code: Select all  Expand view
function BuildTimer( oDlg )

   local oTimer
   local nStart := Seconds()

   DEFINE TIMER oTimer OF oDlg ;
      INTERVAL 10;
      ACTION If( Seconds() - nStart > 5, oDlg:End(),)

   ACTIVATE TIMER oTimer

return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Layer a Dialog with a bitmap

Postby Silvio.Falconi » Tue Jul 10, 2018 8:17 am

Rao,
I have problem if I use many btnbmp

this command aPt := ClientToScreen( oBtn:oWnd:hWnd, { nRow, nCol } )

not give the right points where move the dialog of messages
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Layer a Dialog with a bitmap

Postby nageswaragunupudi » Tue Jul 10, 2018 8:27 am

I edited the sample.
Added 6 lines after ClientToScreen
Please implement this and try
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Layer a Dialog with a bitmap

Postby Silvio.Falconi » Tue Jul 10, 2018 10:04 am

please can see at email ?
I tried with your 6 lines but here not run ok
please try with 60 btnbmp for a sample

i tried with 20 and the btn is the 13

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: Layer a Dialog with a bitmap

Postby Silvio.Falconi » Sun Jul 22, 2018 5:38 pm

Mr Rao,
here not run ok
I made some test and the callout is draw far from the umbrela I wish
Please compile this sample
I cannot Use 128 sizes for umbrellas but 40/60
I add akso a timer timer

Code: Select all  Expand view

#include "fivewin.ch"

#define SIZEH 40
#define SIZEW 40
#define NUMBER_UMBRELLAS  100


function Main()

   local oDlg, oBrush
   local aBtn[ NUMBER_UMBRELLAS ], aCallOut := {}
   local n, nRow, nCol
   local aBmp

   aBmp  := WndReadPalBmpEx( nil, "CALLOUT.PNG" )

   DEFINE BRUSH oBrush FILE "c:\work\fwh\bitmaps\sea.bmp" RESIZE
   DEFINE DIALOG oDlg SIZE 680,600 PIXEL TRUEPIXEL BRUSH oBrush

   nRow  := 120
   nCol  :=  5
   nUmbrella:= 0


   for n := 1 to NUMBER_UMBRELLAS
      @ nRow, nCol BTNBMP aBtn[ n ] FILE "UMBRELLA.PNG" SIZE SIZEW,SIZEH PIXEL OF oDlg FLAT NOBORDER Prompt ltrim(str(n))

      aBtn[ n ]:lTransparent := .t.
      nCol  += SIZEW+1
      nUmbrella+= 1
      if nUmbrella ==20
         nRow  += SIZEH+1
         nCol  := 5
          nUmbrella:= 0
      endif
   next

   @ 60,40 BTNBMP PROMPT "CALLOUT" SIZE 128,32 PIXEL OF oDlg 2007 CENTER ;
Action( CallOutBtn( aBtn[ 13 ], "Silvio"+CRLF+" Falconi ", aBmp  ),;
       CallOutBtn( aBtn[ 6 ], "Antonio"+CRLF+" Linares ", aBmp  )  )

      /*ACTION If( Empty( aCallOut ), ;
                  ( aCallOut := {}, ;
                    AAdd( aCallOut, CallOutBtn( aBtn[ 3 ], "Silvio"+CRLF+" falconi ", aBmp  ) ), ;
                    AAdd( aCallOut, CallOutBtn( aBtn[ 6 ], "Antonio"+CRLF+"Linares", aBmp ) ) ), ;
                 ( AEval( aCallOut, { |o| o:End() } ), aCallOut := {} ) )*/



   ACTIVATE DIALOG oDlg CENTERED
   RELEASE BRUSH oBrush
   PalBmpFree( aBmp )

return nil

function CallOutBtn( oBtn, cMsg, aBmp )

   local oDlg, oFont, nRow, nCol, aPt
   local nDlgWidth   := 89 // can specify a lower size

   nRow  := oBtn:nTop //- ( nDlgWidth * 0.6 )
   nCol  := oBtn:nLeft - 20
   aPt   := ClientToScreen( oBtn:oWnd:hWnd, { nRow, nCol } )

    if aPt[ 1 ] > 32768
      aPt[ 1 ] -= 65535
   endif
   if aPt[ 2 ] > 32768
      aPt[ 2 ] -= 65535
   endif



   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE nDlgWidth,( nDlgWidth * 125/128) PIXEL TRUEPIXEL COLOR CLR_BLACK,1 STYLE WS_POPUP FONT oFont
   RELEASE FONT oFont

   WITH OBJECT oDlg
      :nSeeThroClr   := 1
      :bLClicked     := { || oDlg:End() }
      :bPainted      := { || oDlg:SayPalBmp( aBmp ), ;
                             oDlg:SayText( cMsg, { nil, nil, -0.2, nil } ) }
   END

   ACTIVATE DIALOG oDlg NOWAIT ;
      ON INIT ( oDlg:Move( aPt[ 1 ], aPt[ 2 ] ),BuildTimer( oDlg ) )

   return oDlg


      function BuildTimer( oDlg )

   local oTimer
   local nStart := Seconds()



   DEFINE TIMER oTimer OF oDlg ;
      INTERVAL 10;
      ACTION If( Seconds() - nStart > 5, oDlg:End(),)

   ACTIVATE TIMER oTimer

return nil
 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 42 guests