Gradient in 64 Bit App

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2061
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Gradient in 64 Bit App

Post by AUGE_OHR »

hi,

i have this Code to paint a Gradient.
it work in 32 Bit App but fail in 64 Bit App whre i only get "black" ... WHY :?:

Code: Select all

HBRUSH LinearGradientBrush( HDC pDC, long cx, long cy, COLORREF crFrom, COLORREF crTo, BOOL bVert )
{
   HDC     memDC;
   HBITMAP memBmp;
   HBRUSH  pGradientBrush = ( HBRUSH ) NULL;

   memDC  = CreateCompatibleDC( pDC );
   memBmp = CreateCompatibleBitmap( pDC, cx, cy );

   if( memDC && memBmp )
   {
      TRIVERTEX     rcVertex[ 3 ];
      GRADIENT_RECT gRect;

      rcVertex[ 0 ].x     = 0;
      rcVertex[ 0 ].y     = 0;
      rcVertex[ 0 ].Red   = ( unsigned short ) ( GetRValue( crFrom ) << 8 );
      rcVertex[ 0 ].Green = ( unsigned short ) ( GetGValue( crFrom ) << 8 );
      rcVertex[ 0 ].Blue  = ( unsigned short ) ( GetBValue( crFrom ) << 8 );
      rcVertex[ 0 ].Alpha = 0;

      rcVertex[ 1 ].x     = cx;
      rcVertex[ 1 ].y     = cy;
      rcVertex[ 1 ].Red   = ( unsigned short ) ( GetRValue( crTo ) << 8 );
      rcVertex[ 1 ].Green = ( unsigned short ) ( GetGValue( crTo ) << 8 );
      rcVertex[ 1 ].Blue  = ( unsigned short ) ( GetBValue( crTo ) << 8 );
      rcVertex[ 1 ].Alpha = 0;

      rcVertex[ 2 ].x     = cx;
      rcVertex[ 2 ].y     = cy;
      rcVertex[ 2 ].Red   = ( unsigned short ) ( GetRValue( crFrom ) << 8 );
      rcVertex[ 2 ].Green = ( unsigned short ) ( GetGValue( crFrom ) << 8 );
      rcVertex[ 2 ].Blue  = ( unsigned short ) ( GetBValue( crFrom ) << 8 );
      rcVertex[ 2 ].Alpha = 0;

      gRect.UpperLeft  = 0;
      gRect.LowerRight = 1;

      SelectObject( memDC, memBmp );

      GdiGradientFill( memDC, rcVertex, 3, &gRect, 2, bVert ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H );

      pGradientBrush = CreatePatternBrush( memBmp );

      DeleteObject( memBmp );
      DeleteObject( memDC );
   }

 return pGradientBrush;}
i don´t see any Parameter which must be change ... and i got no Error ...
who have a Idea :idea:
have fun
Jimmy
Post Reply