Transparence

This forum is for eXpress++ general support.
Message
Author
c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Transparence

#1 Post by c-tec »

Hello,
I have modified the timer sample, works fine, but would like to have the effect only for the dialog area, not for the whole window with titlebar etc. Is this possible ?
If not, can I fix a window without frame to another window so they are moved, destroyed and resized together with the parent window ? So I could add two windows and change the transparency to simulate a blending effect.
regards
Rudolf


Code: Select all

#INCLUDE "dcdialog.CH"

LOCAL GetList[0], GetOptions, oTimer, oDlg, aBitmaps

aBitmaps := Directory('test*.bmp')

DCGETOPTIONS ;
   WINDOWWIDTH 1024 ;
   WINDOWHEIGHT 800

oTimer := DC_SetTimerEvent():new(200,{||ChangeBackground(@oDlg,aBitmaps)})

DCREAD GUI TITLE 'Rotating Bitmap Backgrounds' PARENT @oDlg OPTIONS GetOptions

oTimer:destroy()

RETURN nil

* -----------

PROC appsys ; RETURN

* -----------

STATIC FUNCTION ChangeBackground( oDlg, aBitmaps )
******************************************************************
STATIC snPointer := 0,lFirst ,oDA
LOCAL oBitmap
local nHandle,nTransparency,i
if empty(lFirst)
     sleep(10)
     lFirst := .f.
endif
nHandle := oDlg:getHwnd()
snPointer++

IF oDlg == nil .OR. oDlg:status() = 0 .OR. Len(aBitmaps) = 0
  RETURN nil
ENDIF

IF snPointer > Len(aBitmaps)
  snPointer := 1
ENDIF

oBitmap := DC_GetBitmap(aBitmaps[snPointer,1])

DC_SetWindowTransparency(nHandle,0)
FOR i := 0 TO 100 STEP 3
  Sleep(1)
  nTransparency := i// weniger transparenz
  DC_SetWindowTransparency(nHandle,nTransparency)
NEXT

DC_SetWindowTransparency(nHandle,100)
oDlg:lockUpdate(.t.)
oDlg:drawingArea:bitmap := oBitmap
oDlg:configure()
oDlg:lockUpdate(.f.)

FOR i := 100 TO 1 STEP -3
  Sleep(1)
  nTransparency := i // weniger transparenz
  DC_SetWindowTransparency(nHandle,nTransparency)
NEXT

DC_SetWindowTransparency(nHandle,0)
RETURN nil

Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Transparence

#2 Post by rdonnay »

I don't know if this will work but it's worth a try.

Change this:

nHandle := oDlg:getHwnd()

to this:

nHandle := oDlg:drawingArea:getHwnd()
The eXpress train is coming - and it has more cars.

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Transparence

#3 Post by c-tec »

Hello Roger,
was also my intention, but does not work. Jimmy wrote that it only works with windows not with xBase parts. Could this be the reason ? Otherwise I will try the solution with the separate windows for the images to blend.
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Transparence

#4 Post by Auge_Ohr »

c-tec wrote:Jimmy wrote that it only works with windows not with xBase parts.
Transparenxy only work on Top-Level Window while it need accept WS_EX_APPWINDOW Style for it.

as i told you you can use Windows API Animate this Way

Code: Select all

#define AW_HOR_POSITIVE 0x00000001
#define AW_HOR_NEGATIVE 0x00000002
#define AW_VER_POSITIVE 0x00000004
#define AW_VER_NEGATIVE 0x00000008

#define AW_CENTER 0x00000010
#define AW_HIDE 0x00010000
#define AW_ACTIVATE 0x00020000
#define AW_SLIDE 0x00040000
#define AW_BLEND 0x00080000

DLLFUNCTION AnimateWindow(hwnd,dwTime,dwFlags) USING STDCALL FROM USER32.DLL


   AnimateWindow(oStatic:GetHwnd() ,500,AW_HIDE+AW_CENTER )
   oStatic:SetCaption("schlafe ...")
   SLEEP(100)
   AnimateWindow(oStatic:GetHwnd() ,500,AW_ACTIVATE+AW_CENTER )

   AnimateWindow(oStatic:GetHwnd() ,500,AW_HIDE+AW_SLIDE+AW_HOR_POSITIVE )
   oStatic:SetCaption("hallo")
   SLEEP(100)
   AnimateWindow(oStatic:GetHwnd() ,500,AW_ACTIVATE+AW_SLIDE+AW_HOR_POSITIVE )

   //
   // AW_BLEND only work on Top-Level Window
   //
   AnimateWindow(oDlg:GetHwnd() ,500,AW_HIDE+AW_BLEND )
   oStatic:SetCaption("und weg ...")
   SLEEP(100)
   AnimateWindow(oDlg:GetHwnd() ,500,AW_ACTIVATE+AW_BLEND )
greetings by OHR
Jimmy

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Transparence

#5 Post by c-tec »

Hello Jimmy,
this does not work on a bitmap on my dialog. I need to blend form one image to another. Transparency would be the easiest way, I would overlay two images and change the transpareny to hide the old one and overlay the new one. But seems not work with bitmaps or statics.
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Transparence

#6 Post by rdonnay »

Jimmy wrote that it only works with windows not with xBase parts. Could this be the reason ?
Yes, that's probably correct.
When I wrote that API call function I recall now that I could only get it to work with a XbpDialog() window.
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Transparence

#7 Post by Auge_Ohr »

c-tec wrote:this does not work on a bitmap on my dialog. I need to blend form one image to another. Transparency would be the easiest way, I would overlay two images and change the transpareny to hide the old one and overlay the new one. But seems not work with bitmaps or statics.
you can put your Bitmap on a Static an "animate" Static.
greetings by OHR
Jimmy

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Transparence

#8 Post by c-tec »

Hello Jimmy,
I have it already on a static, but how to animate it ?
regards
Rudolf

Code: Select all


DCHOTKEY xbeK_ALT_N    ACTION {||shownextbmp(oPhotoStatic,aPhoto)}
...

aPhoto := {}
aadd(aPhoto,{addpath(al_path,"img\photo1.gif"),.t. })
aadd(aPhoto,{addpath(al_path,"img\photo2.gif"),.f. })
aadd(aPhoto,{addpath(al_path,"img\photo3.gif"),.f. })

@ 500,100 DCSTATIC TYPE XBPSTATIC_TYPE_BITMAP SIZE 250,350 OBJECT oPhotoStatic ID "BMPSTATIC1" OPTIONS XBPSTATIC_BITMAP_TILED PIXEL
DCBITMAP DC_GetBitMap(aPhoto[1,1],,,) PARENT oPhotoStatic ID "BITMAP1" //OBJECT oFormPage


function animate2(nMod,oPhotoStatic)
******************************************************************
local nHandle := oPhotoStatic:GetHwnd()
if nMod = 0
     AnimateWindow(nHandle,500,AW_HIDE+AW_BLEND )
else
     AnimateWindow(nHandle,500,AW_ACTIVATE+AW_BLEND )
     oPhotoStatic:configure()
endif
return .t.


function shownextbmp(oPhotoStatic,aPhoto)
******************************************************************
local x,oBitmap,nBmp := 0,oAktBmp
for x := 1 to len(aPhoto)
     if aPhoto[x,2]
          oAktBmp := DC_GetBitMap(aPhoto[x,1],,,)
          exit
     endif
next x
for x := 1 to len(aPhoto)
     if !aPhoto[x,2]
          altd()
          oBitmap := DC_GetBitMap(aPhoto[x,1],,,)
          aPhoto[x,2] := .t.
          animate2(0,oPhotoStatic)
          DC_BitMapDraw(oPhotoStatic,oBitMap)
          animate2(1,oPhotoStatic)
     else
          aPhoto[x,2] := .f.
     endif
next x
return .t.


Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Transparence

#9 Post by Auge_Ohr »

c-tec wrote:Hello Jimmy,
I have it already on a static, but how to animate it ?

Code: Select all

function animate2(nMod,oPhotoStatic)
******************************************************************
local nHandle := oPhotoStatic:GetHwnd()
if nMod = 0
     AnimateWindow(nHandle,500,AW_HIDE+AW_BLEND )
else
     AnimateWindow(nHandle,500,AW_ACTIVATE+AW_BLEND )
     oPhotoStatic:configure()
endif
return .t.
as i wrote
//
// AW_BLEND only work on Top-Level Window
//
you have to use other than AW_BLEND on Static (which is NOT a Top-Level Window)
try AW_CENTER or AW_SLIDE instead.
greetings by OHR
Jimmy

c-tec
Posts: 379
Joined: Tue Apr 20, 2010 1:36 am
Location: SALZBURG/AUSTRIA
Contact:

Re: Transparence

#10 Post by c-tec »

Hello Jimmy,
non of the works, I will try a workaround with an additional dialog window without frames that is fixed to the parent window.
regards
Rudolf
Rudolf Reinthaler
digital pen & paper systems
http://www.formcommander.net

Post Reply