Page 1 of 1

dialogos transparentes

Posted: Mon Mar 03, 2008 9:11 pm
by Marcelo Via Giglio
Holas,

si les interesa el tema de transparencia, pueden probrar
#include "fivewin.ch"
#include "Slider.ch"

FUNCTION main()

LOCAL oDlg, nTrans := 128, para

DEFINE DIALOG oDlg FROM 10,10 TO 20,40

@ 1,1 SLIDER nTrans OF oDlg;
HORIZONTAL ;
LEFT DIRECTION ;
RANGE 0, 255 ;
MARKS 25 ;
ON THUMBPOS ( setlayeredwindowattributes( oDlg:hWnd, 0, ntrans, 2 ), sysrefresh() );
ON CHANGE ( setlayeredwindowattributes( oDlg:hWnd, 0, ntrans, 2 ), sysrefresh() )

ACTIVATE DIALOG oDlg CENTER ON INIT ( para := getwindowlong( oDlg:hWnd, -20 ), ;
setwindowlong( oDlg:hWnd, -20, nOr( para, 524288 ) ) , ;
setlayeredwindowattributes( oDlg:hWnd, 0, ntrans, 2 ) )

RETURN(NIL)

DLL32 function getwindowlong( hwnd as LONG, index as LONG ) AS LONG PASCAL FROM "GetWindowLongA" lib "user32.dll"
DLL32 function setwindowlong( hwnd as LONG, index as LONG, newlog as LONG ) AS LONG PASCAL FROM "SetWindowLongA" lib "user32.dll"
DLL32 function setlayeredwindowattributes( hwnd as LONG, crkey as LONG, alpha as WORD, flag as LONG ) AS LONG PASCAL FROM "SetLayeredWindowAttributes" lib "user32.dll"
No pude hacer que la transparencia varie mientras cambia el slider, pero quien sabe alguien lo logre.

saludos

Marcelo

Posted: Mon Mar 03, 2008 11:04 pm
by Silvio
I'm founding some thing of it but I wish show a bitmap trasparent
If you go to mg sample you found a car bmp you can see only this car and not see the dialog...
Do U undestand ?

Posted: Tue Mar 04, 2008 2:25 am
by Rochinha
See this sample:

Code: Select all

/*
 *
 * *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 * Programador: Jose Carlos da Rocha
 * CopyRights.: 5Volution Desenvolvimento
 * *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 *
 */
#include "fivewin.ch"

#define SRCPAINT       15597702
#define SRCAND         8913094

function main()
   DEFINE BRUSH oBrush STYLE NULL
   DEFINE DIALOG oWnd TITLE "Transparence" SIZE 800,600 BRUSH oBrush STYLE WS_POPUP
                                        
   ACTIVATE DIALOG oWnd CENTERED ;
               ON PAINT ShowBmp( oWnd, "transpr1.bmp", "transpr2.bmp" ) ;
               VALID iif(MsgYesNo('Deseja encerrar o programa?','Atencao'),.t.,.f.) 

function ShowBmp( oDlg, cBmp1, cBmp2 )
   local hDC  := oDlg:hDC
   local oBmp1, oBmp2
   DEFINE BITMAP oBmp1 FILENAME cBmp1
   DEFINE BITMAP oBmp2 FILENAME cBmp2
   DrawBitmap( hDC, oBmp2:hBitmap, 0, 0, 0, 0, SRCPAINT )
   DrawBitmap( hDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCAND )
   oBmp1:End()
   oBmp2:End()
   return nil
And here, the bitmaps http://www.5volution.com/forum/transpr.zip

Posted: Tue Mar 04, 2008 10:04 am
by Silvio
I saw it but I cannot move the dialog with the mouse
If you go to see the sample of minigui you can understand me

Posted: Tue Mar 04, 2008 1:58 pm
by Rochinha
Silvio

Can you send me?

irochinha@itelefonica.com.br

Posted: Tue Mar 04, 2008 4:04 pm
by Silvio
i sent now the prg

Posted: Tue Mar 04, 2008 11:17 pm
by Rochinha
Test this now:

Code: Select all

/*
 *
 * *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 * Descricao..: Modulo de PDV
 * Programador: Jose Carlos da Rocha
 * CopyRights.: Konectiva Automacao
 * *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 *
 */
#include "fivewin.ch"

#define SRCPAINT       15597702
#define SRCAND         8913094

function main()
   PUBLIC lNoPaint := .f.
   DEFINE BRUSH oBrush STYLE NULL
   DEFINE DIALOG oWnd TITLE "Transparence" SIZE 800,600 BRUSH oBrush STYLE WS_POPUP
                                        
   @ 0,0 BITMAP filename "" OF oWnd NOBORDER PIXEL SIZE 10,10 ON LEFT CLICK WindowMove()

   ACTIVATE DIALOG oWnd CENTERED ;
               ON PAINT ShowBmp( oWnd, "transpr1.bmp", "transpr2.bmp" ) ;
               VALID iif(MsgYesNo('Deseja encerrar o programa?','Atencao'),.t.,.f.) 

function ShowBmp( oDlg, cBmp1, cBmp2 )
   local hDC  := oDlg:hDC
   local oBmp1, oBmp2
   DEFINE BITMAP oBmp1 FILENAME cBmp1
   DEFINE BITMAP oBmp2 FILENAME cBmp2
   DrawBitmap( hDC, oBmp2:hBitmap, 0, 0, 0, 0, SRCPAINT )
   DrawBitmap( hDC, oBmp1:hBitmap, 0, 0, 0, 0, SRCAND )
   oBmp1:End()
   oBmp2:End()
   return nil

function WindowMove()
   Do while GetKeyState(VK_LBUTTON)
      onde:=GetCursorpos()
      MoveWindow( oWnd:hWnd, onde[1], onde[2], 20, 20, .t. )
      SysRefresh()
      If !GetKeyState(VK_LBUTTON)
         Exit
      Endif
   Enddo
   MoveWindow( oWnd:hWnd, onde[1], onde[2], 800, 600, .t. )
   Return nil