Different results with ABPaint( hDC, .. ) ? SOLVED

Different results with ABPaint( hDC, .. ) ? SOLVED

Postby ukoenig » Sun Jan 11, 2009 2:28 pm

Hello,

I have one Function to use < ABPaint( hDC, 20, 20, oBmp1:hBitmap, 220 ) >
to test on different backgrounds.
It works for brushes, colors, gradients without problems.
If I use a Image, < ABPaint > shows the image of the background with the
size of the Alpha-Bmp ( only in the function, not at start ).

Image

Code: Select all  Expand view

FUNCTION NEW_WIN()
LOCAL oWnd1, oBtn1, oImage, oBmp1

cALPHA := ALLTRIM( W_C_ALPHA )
IF !EMPTY ( cALPHA )
   DEFINE BITMAP oBmp1 FILENAME "&c_pfad\IMAGE\" + cALPHA
ENDIF

DEFINE WINDOW oWnd1 TITLE "Background for Windows"

@ 37, 150 BUTTONBMP oBtn1 OF oWnd1 ACTION  oWnd1:End() ;
      BITMAP "Quit" PROMPT "      &Exit" TEXTRIGHT SIZE 100, 40 ;
      MESSAGE "Quit"

oBtn1:cToolTip =  { "Close" + CRLF + ;
                                  "Windows","Close", 1, CLR_BLACK, 14089979 }

IF W_POS1 = 14       // Picture Background
   cNEWLOGO := "&c_pfad\IMAGE\" + ALLTRIM(W_LOGO)
   IF W_LOGOTYP = "B"      // Brush
      IF ! Empty( cNEWLOGO ) .and. File( "&cNEWLOGO" )
         DEFINE BRUSH oImage FILE "&cNEWLOGO"
         SET BRUSH OF oWnd1 TO oImage
      ELSE
         MsgAlert("No file selected !","Attention" )
      ENDIF
   ENDIF
ENDIF
IF W_LOGOTYP = "I"      // Image
   IF ! Empty( cNEWLOGO ) .and. File( "&cNEWLOGO" )
      @ 0, 0 IMAGE oImage SIZE 150, 150 OF oWnd1  ADJUST
      oImage:Progress( .f. )
      oImage:LoadBmp( "&cNEWLOGO" )
   ELSE
      MsgAlert("No file selected !","Attention" )
   ENDIF
ENDIF

ACTIVATE WINDOW oWnd1 MAXIMIZED ;
ON INIT NEW_COLOR1a(oWnd1) ;
ON PAINT ( IIF( W_STYLE = 1 .and. W_POS1 <= 10 , gradpaint1( hDC, oWnd1 ), NIL ), ;
   IIF( W_POS1 > 10 .and. W_POS1 < 14, SHOW_WBRU( oWnd1 ), NIL ), ;
   IIF(W_POS1 = 14, DRAWBITMAP( hDC, oImage:hbitmap, 0, 0,;
      oWnd1:nWidth(), oWnd1:nHeight() ), NIL ),;
   IIF( !EMPTY( W_C_ALPHA ),  ;
      ABPaint( hDC, W_T_ALPHA, W_L_ALPHA, oBmp1:hBitmap, 220 ), NIL ) )

RETURN NIL



If I do it on Start-Screen, it works fine.

Image

Code: Select all  Expand view

FUNCTION  MAIN()
...
...
DEFINE WINDOW oWnd TITLE "Background for Windows and Dialog"

// Background
// -------------
@ 0, 0 IMAGE oImage SIZE 150, 150 OF oWnd ADJUST
oImage:Progress( .f. )
oImage:LoadBmp( "BRAINSTORM.JPG" )

// Alpha-Bmp
// -------------
DEFINE BITMAP oBmp1 FILENAME "A_LOGO2.bmp"
...
...
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON PAINT ( DRAWBITMAP( hdc, oImage:hbitmap, 0, 0,;
   oWnd:nWidth(), oWnd:nHeight()), ;
   ABPaint( hDC, 20, 20, oBmp1:hBitmap, 220 ) ) ;
VALID MsgYesNo( "Do you want to end?" )

RETURN NIL


I use the same syntax in MAIN and FUNCTION, but with different result.
With a small change, I got another result :
The small Background is still visible on Top/Left and the Alpha-Bmp is added.
I defined a extra hDC for the Alpha-Bmp but there is still another one running.

Image

Code: Select all  Expand view

IIF( !EMPTY( W_C_ALPHA ),  ;
   ( hDC := oBmp1:GETDC(), ABPaint( hDC, 50, 50, oBmp1:hBitmap, 220 ) ), NIL ) )



Regards
Uwe :lol:
Last edited by ukoenig on Mon Jan 12, 2009 12:16 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Different results with ABPaint( hDC, .. ) ?

Postby Antonio Linares » Mon Jan 12, 2009 12:23 am

Uwe,

If you call oBmp:GetDC() then you have to make a call to oBmp:ReleaseDC() too:

hDC := oBmp1:GETDC(), ( ABPaint( hDC, 50, 50, oBmp1:hBitmap, 220 ), oBmp1:ReleaseDC() ), ...
regards, saludos

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

Re: Different results with ABPaint( hDC, .. ) ?

Postby ukoenig » Mon Jan 12, 2009 10:24 am

Dear Antonio,
thank You very much. I have done some more tests.
The reason for the funny window-display might be, that I open the preview-window
from inside a folder-page ?
With another test, using two dialogs for the preview, I got the same result.

Code: Select all  Expand view

// ---------- Start Window-Preview ---------------

REDEFINE BUTTONBMP oBtn15  ID 90 OF oFld:aDialogs[1] ;
ACTION ( NEW_WIN() ) ;
BITMAP "Search" PROMPT "       Preview" TEXTRIGHT
oBtn15:cToolTip =  { "Open" + CRLF + ;
                                  "the Preview-Window","Preview", 1, CLR_BLACK, 14089979 }


// ------- WINDOW - TEST --------------------------

FUNCTION NEW_WIN()
LOCAL oWnd1, oBtn1, oImage1, oBmp1

DEFINE WINDOW oWnd1 TITLE "Background for Windows"

@ 37, 150 BUTTONBMP oBtn1 OF oWnd1 ACTION  oWnd1:End() ;
      BITMAP "Quit" PROMPT "      &Exit" TEXTRIGHT SIZE 100, 40 ;
      MESSAGE "Quit"
oBtn1:cToolTip =  { "Close" + CRLF + ;
                         "Windows","Close", 1, CLR_BLACK, 14089979 }

IF W_POS1 = 14       // Picture Background
   cNEWLOGO := "&c_pfad\IMAGE\" + ALLTRIM(W_LOGO)
   IF W_LOGOTYP = "B"      // Brush
      IF ! Empty( cNEWLOGO ) .and. File( "&cNEWLOGO" )
         DEFINE BRUSH oImage1 FILE "&cNEWLOGO"
         SET BRUSH OF oWnd1 TO oImage
      ELSE
         MsgAlert("No file selected !","Attention" )
      ENDIF
   ENDIF
   IF W_LOGOTYP = "I"      // Image
      IF ! Empty( cNEWLOGO ) .and. File( "&cNEWLOGO" )
         @ 0, 0 IMAGE oImage1 SIZE 150, 150 OF oWnd1  ADJUST
         oImage1:Progress( .f. )
         oImage1:LoadBmp( "&cNEWLOGO" )
      ELSE
         MsgAlert("No file selected !","Attention" )
      ENDIF
   ENDIF
ENDIF

// W_STYLE = 1 .and. W_POS1 <= 10  (  GRADIENT )
// W_POS1 > 10 .and. W_POS1 < 14  (  BRUSH )
// W_POS1 = 14 .and. W_LOGOTYP = "I"  ( IMAGE )   !!! these values are true
// !EMPTY( W_C_ALPHA )  ( ALPHA-BLENDED BMP )   !!! this value is filled

ACTIVATE WINDOW oWnd1 MAXIMIZED ;
ON INIT  NEW_COLOR1a(oWnd1) ;
ON PAINT ( IIF( W_STYLE = 1 .and. W_POS1 <= 10 , gradpaint1( hDC, oWnd1 ), NIL ), ;
          IIF( W_POS1 > 10 .and. W_POS1 < 14, SHOW_WBRU( oWnd1 ), NIL ), ;
          IIF( W_POS1 = 14 .and. W_LOGOTYP = "I", ( DRAWBITMAP( hDC, oImage1:hbitmap, 0, 0,;
                        oWnd1:nWidth(), oWnd1:nHeight() ) ), NIL ), ;
          IIF( !EMPTY( W_C_ALPHA ), ALPHA_BMP(hDC), NIL ) )

RETURN NIL

// ----------------------------

FUNCTION ALPHA_BMP(hDC)
LOCAL oBmp1

cALPHA := ALLTRIM( W_C_ALPHA )
IF !EMPTY ( cALPHA )
   DEFINE BITMAP oBmp1 FILENAME "&c_pfad\IMAGE\" + cALPHA
ENDIF
ABPaint( hDC, W_L_ALPHA, W_T_ALPHA, oBmp1:hBitmap, 220 )

RETURN( NIL )



The function above starts only the window-preview.
There is still the same function with a dialog-dislay on top of the window. ( see screenshot )
Inside the dialog on top of the window, the alpha-channel-bmp- display is OK.

DEFINE WINDOW oWnd1 TITLE "Background for Windows and Dialog"
The next post shows the difference

Image

Regards
Uwe :lol:
Last edited by ukoenig on Mon Jan 12, 2009 12:11 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Different results with ABPaint( hDC, .. ) ? SOLVED

Postby ukoenig » Mon Jan 12, 2009 12:05 pm

Hello,

I could solve the display-problem changing for Image-disply from < normal window to MDI >
The problem is only the window, not the dialog.

Code: Select all  Expand view

DEFINE WINDOW oWnd1 TITLE "Background for Windows"  MDI MENU TMenu():New()



Image

I don't understand the different Image-display and the reason for it.
It seems, inside a non-MDI-window, ABPaint(...) is called twice.
It works with this solution, but maybe is there a better way how to do it ?

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests