Change the transparency of the window

Change the transparency of the window

Postby Natter » Sat Apr 22, 2023 4:39 pm

I need to change the transparency of the window.I try this way, but nothing changes. How can this problem be solved ?
Code: Select all  Expand view
#include "fivewin.ch"

function Main
private oDlg

  DEFINE DIALOG oDlg FROM 0,0 TO 300,300  PIXEL ;
           STYLE nOR(WS_POPUP, WS_THICKFRAME) ;
           COLOR CLR_BLACK, RGB(152, 251, 152) RESIZABLE

    ACTIVATE DIALOG oDlg  ON INIT   oDlg:nOpacity:=100 NOWAIT
    oDlg:bLDblClick:={||Chg_Tsp()}
return NIL

procedure Chg_Tsp
  oDlg:nOpacity:=iif(valtype(oDlg:nOpacity)="N", NIL, 100)
  oDlg:Refresh()
return
Last edited by Natter on Sat Apr 22, 2023 6:34 pm, edited 1 time in total.
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Change the transparency of the window

Postby karinha » Sat Apr 22, 2023 6:03 pm

Code: Select all  Expand view

#Include "FiveWin.ch"

STATIC oDlg

FUNCTION Main()

  DEFINE DIALOG oDlg FROM 0,0 TO 300,300 PIXEL TRUEPIXEL RESIZABLE           ;
     STYLE nOR(WS_POPUP, WS_THICKFRAME) COLOR CLR_BLACK, RGB(152, 251, 152)  ;
     TRANSPARENT

   oDlg:bLDblClick:={ || Chg_Tsp() } // Double Click()

   // error:
   // ACTIVATE DIALOG oDlg  ON INIT   oFrg:nOpacity:=100 NOWAIT

   ACTIVATE DIALOG oDlg ON INIT( oDlg:nOpacity := 100 ) // NOWAIT test

RETURN NIL

FUNCTION Chg_Tsp()

   ? "yes?"

  // oDlg:nOpacity:=iif(valtype(oDlg:nOpacity)="N", NIL, 100)

  oDlg:nOpacity := 180

  // oDlg:Update()
  // oDlg:Refresh()

RETURN NIL

//FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7808
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Change the transparency of the window

Postby Natter » Sat Apr 22, 2023 6:22 pm

I am interested in a non-modal (NOWAIT) window
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: Change the transparency of the window

Postby karinha » Sat Apr 22, 2023 8:12 pm

Code: Select all  Expand view

// C:\FWH..\SAMPLES\NATTER2.PRG

#Include "Fivewin.ch"
#Include "Gif.ch"

STATIC oDlg, oSayNat

FUNCTION Main()

   LOCAL oWnd
   LOCAL oMenu

   MENU oMenu

      MenuItem "nOpacity" ACTION( Test_nOpacit() )

   ENDMENU

   DEFINE WINDOW oWnd MENU oMenu TITLE "Natter nOpcity"

   ACTIVATE WINDOW oWnd CENTERED

RETURN NIL

FUNCTION Test_nOpacit()

   LOCAL n := 0, oSay, oGif, oFont, nEnd := 1000000, cText := SPACE(50)

   DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0,  -18 BOLD

   DEFINE DIALOG oDlg FROM 0,0 TO 300,300 PIXEL TRUEPIXEL RESIZABLE           ;
      STYLE nOR(WS_POPUP, WS_THICKFRAME) COLOR CLR_BLACK, RGB(152, 251, 152)  ;
      TRANSPARENT

   // FOR LOOPING
   @ 120, 10 SAY oSay PROMPT "TEXTO" OF oDlg PIXEL UPDATE SIZE 120, 30 ;
      FONT oFont CENTER COLOR CLR_BLACK, CLR_WHITE

   @ 200, 10 SAY oSayNat VAR cText   OF oDlg PIXEL UPDATE SIZE 250, 30 ;
      FONT oFont CENTER COLOR CLR_BLACK, CLR_WHITE

   oDlg:bLDblClick:={ || Chg_Tsp( oSayNat ) } // Double Click()

   ACTIVATE DIALOG oDlg CENTERED                                ;
      ON INIT(  CrearGif( oDlg ), oDlg:nOpacity := 100 ) NOWAIT ;
      VALID( n := nEnd, .T. )

   WHILE n < nEnd

      n++

      oSay:SetText( Str( n ) )

      IF n % 100 == 0

         SYSREFRESH()

      END

   END

   oDlg:End()
   oFont:End()

RETURN NIL

FUNCTION CrearGif( oDlg )

   LOCAL oGif

   @ 1, 1 GIF oGif FILE "..\gifs\matrix.gif" OF oDlg SIZE 300, 150 ADJUST

RETURN NIL

FUNCTION Chg_Tsp( oSayNat )

   LOCAL cTxtNat := SPACE(50)

   // oDlg:nOpacity:=iif(valtype(oDlg:nOpacity)="N", NIL, 100)

   oDlg:nOpacity := 180

   // oDlg:Update()
   // oDlg:Refresh()

   cTxtNat := "Perfecto, Perfect, <ESC> Exit."

   oSayNat:VARPUT( cTxtNat )
   oSayNat:Refresh()

RETURN NIL

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7808
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Change the transparency of the window

Postby Natter » Sun Apr 23, 2023 6:30 am

Thank you, Karinha, it was a useful example !
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 77 guests