Olá,
Alguém sabe qual a propriedade do windows que faz com que a Window/Dialog atual fique Colorida e as telas por detras dela fiquem preto e branco, como no exemplo abaixo ?
Obrigado,
Rossine.
#include "fivewin.ch"
#define CBM_INIT 4 && should move to prg header
#define DIB_RGB_COLORS 0 && should move to prg header
static hBmp
static oWnd
static hLib
function main()
local oBrush
hBmp := nil
hLib := LoadLibrary( "freeimage.dll" )
DEFINE BRUSH oBrush STYLE "NULL"
DEFINE WINDOW oWnd STYLE nOr( WS_POPUP ) BRUSH oBrush
ACTIVATE WINDOW oWnd MAXIMIZED ON INIT Proceso() ;
ON PAINT Pinta( hDC )
FreeLibrary( hLib )
DeleteObject( hBmp )
return nil
function Proceso()
local hDib
local hInfoH, hBits, hInfo
local hWnd, hDC
// se puede hacer mas elegante pero esto es mas fácil
DibWrite( "screen.bmp", DibFromBitmap( WndBitmap( oWnd:hWnd )))
hDib := fiLoad( 0, "screen.bmp", 0 )
hDib := FI_2GREY( hDib )
hInfoH := fiGetInfoHeader( hDib )
hInfo := fiGetInfo( hDib )
hBits := fiGetBits( hDib )
hWnd := oWnd:hWnd
hDC := oWnd:GetDC()
hBmp := CreateDIBitmap( hDC, hInfoH, CBM_INIT, hBits, hInfo,DIB_RGB_COLORS )
oWnd:ReleaseDC()
oWnd:Refresh()
return nil
function pinta( hDC )
if hBmp != nil
DrawBitmap( hDC, hBmp, 0, 0 )
endif
return nil
DLL32 STATIC FUNCTION FI_2GREY( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_ConvertToGreyscale@4" LIB hLib
DLL32 STATIC FUNCTION FILOAD( nFormat AS LONG, cFileName AS LPSTR,nFlags AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_Load@12" LIB hLib
DLL32 STATIC FUNCTION FIGETINFOHEADER( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetInfoHeader@4" LIB hLib
DLL32 STATIC FUNCTION FIGETINFO( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetInfo@4" LIB hLib
DLL32 STATIC FUNCTION FIGETBITS( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetBits@4" LIB hLib
DLL32 STATIC FUNCTION CREATEDIBITMAP( hDC AS LONG, hInfoH AS LONG,nFlags AS LONG, hBits AS LONG, hInfo AS LONG, nUsage AS LONG ) AS LONG;
PASCAL FROM "CreateDIBitmap" LIB "gdi32.dll"
#include "fivewin.ch"
#define ROSA rgb(255,0,255)
function main()
local o
DEFINE WINDOW o TITLE "Convertir a Escala de grises"
ACTIVATE WINDOW o ON PAINT Pinta( hDC )
return nil
function pinta( hDC )
local hDCMem := CreateCompatibleDC( hDC )
local hBmpMem, hOldBmp
local hIcon
local nTop, nLeft
local nColor
local nRojo, nVerde, nAzul
hBmpMem := CreateCompatibleBitmap( hDC, 34, 34 )
hOldBmp := SelectObject( hDCMem, hBmpMem )
FillSolidRect( hDCMem, {0,0,34,34}, ROSA )
hIcon := ExtractIcon( "FauxS-XP.ico") // Cualquiera vale
DrawIcon( hDCMem, 1, 1, hIcon )
for nTop := 1 to 32
for nLeft := 1 to 32
nColor := GetPixel( hDCMem, nTop, nLeft )
if nColor == ROSA
loop
endif
nRojo := GetRValue( nColor )
nVerde := GetGValue( nColor )
nAzul := GetBValue( nColor )
nColor := Int(nRojo*0.3 + nVerde*0.59 + nAzul*0.11)
SetPixel( hDCMem, nTop, nLeft, rgb( nColor, nColor, nColor) )
next
next
SelectObject( hDCMem, hOldBmp )
DrawMasked( hDC, hBmpMem, 10, 50 )
DrawIcon( hDC, 10, 10, hICon )
DeleteObject( hBmpMem )
DeleteDC( hDCMem )
DestroyIcon( hICon )
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <winuser.h>
#include <wingdi.h>
#include "hbapi.h"
HB_FUNC( CREATECOMPATIBLEBITMAP )
{
hb_retnl( (LONG) CreateCompatibleBitmap( ( HDC ) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 3 ) ));
}
HB_FUNC( CREATECOMPATIBLEDC )
{
hb_retnl( (LONG) CreateCompatibleDC( ( HDC ) hb_parnl( 1 )));
}
void FillSolidRectEx( HDC hDC, RECT *rct, COLORREF nColor )
{
nColor = SetBkColor( hDC , nColor );
ExtTextOut( hDC, 0, 0, ETO_OPAQUE, rct, NULL, 0, NULL);
SetBkColor( hDC, nColor );
}
HB_FUNC( FILLSOLIDRECT )
{
RECT rct;
COLORREF nColor = hb_parnl( 3 );
rct.top = hb_parni( 2, 1 );
rct.left = hb_parni( 2, 2 );
rct.bottom = hb_parni( 2, 3 );
rct.right = hb_parni( 2, 4 );
FillSolidRectEx( (HDC) hb_parnl( 1 ), &rct, nColor );
}
#pragma ENDDUMP
static function GetRValue( nRGB )
return nLoByte( nLoWord( nRGB ) )
static function GetGValue( nRGB )
return nHiByte( nLoWord( nRGB ) )
static function GetBValue( nRGB )
return nLoByte( nHiWord( nRGB ) )
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 67 guests