Invisble Gadget - Bug only on Win2000 ?

Just starting out? Need help? Post your questions and find answers here.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Invisble Gadget - Bug only on Win2000 ?

Post by Ralf »

Can someone test this code please and report used OS?

i am trying to add a window fading in/out routine to my very simple and small program. first i tried it with SetLayeredWindowAttributes_ but i doesnt worked for fading off. many thanxx to GreenGiant who showing me another way using AnimateWindow_! His AnimateWindow example works very fine and is exactly what i needed!

i added the AnimateWindow_ fading in/out routine but it does not really works! when the fading works, it will display only the window and only one gadget (the OK buttongadget) but Frame3D and StringGadget are still invisble while fading window in and even if window is complete faded in! how is this possible? when using RedrawWindow_ after AnimateWindow_ (fading window in), the invisible objects will be shown after fading! But i want to fade in the window with all needed objects (window, ok-button, frame3d, stringgadget) :twisted:

try enable/disable the lines:

Code: Select all

 HideWindow(#Window_Main,0) 
and

Code: Select all

RedrawWindow_(WindowID(#Window_Main), 0, 0, 7) 
:roll:

here is the link where i asked for another problem and stopped with this problem. so i created a new topic! viewtopic.php?t=12397


just try out this cutted source. someone having same problems with invisble objects? compiled with pb3.91 - windows2000, sp4 - thanxx

Code: Select all


cWindowMainTitle$   = "bla"
     
#winw = 453
#winh = 428

#AW_BLEND = $80000      ; AnimateWindow 
#AW_HIDE = $10000       ; AnimateWindow
#AW_ACTIVATE = $20000


; ----------------------------------------------------------------------------------------------------------- 
; D e f i n e   W i n d o w   a n d   G a d g e t   N u m b e r s 
; ----------------------------------------------------------------------------------------------------------- 

    Enumeration 
      #Window_Main
      #Window_Invisible
      #Gad_Main_Banner
      #Gad_Main_StringGadget
      #Gad_Main_OK
      #Gad_Main_Edit
      ;
      #Gad_Config_LoadText
      #Gad_Config_SaveText
      #Gad_Config_CreateData
      #Gad_Config_RestoreData
      #Gad_Config_Back
    EndEnumeration


    Global hWnd, hWnd_Main
    Global cAdminsMessage$, cRootFolder$, cUserLoggedOn$, cUserLoggedOnMD5$, cEditorText$
    Global lConfigMode, cPassWord$
    Global lFade,lFadeStep


    Procedure MyHideWindowFromTaskbar(lWindowID, lNewWindowHandle, lMode) 
      If lMode=1 
        HideWindow(lWindowID,1) 
      EndIf 
      SetWindowLong_(WindowID(lWindowID),#GWL_HWNDPARENT,lNewWindowHandle) 
      ProcedureReturn 
    EndProcedure
     
; ----------------------------------------------------------------------------------------------------------- 
; C r e a t e   W i n d o w s   a n d   G a d g e t s
; ----------------------------------------------------------------------------------------------------------- 

    ; -------- Window Invisible --------
    
    OpenWindow(#Window_Invisible, 0, 0, 0, 0, #PB_Window_Invisible,"") 
    HideWindow(#Window_Invisible, 1)                                    ; 1 = hide
 
    ; -------- Main_Window --------
    
    hWnd_Main = OpenWindow(#Window_Main, 0, 119, #winw, #winh, #PB_Window_Invisible | #PB_Window_WindowCentered  , cWindowMainTitle$)
    SetWindowPos_(WindowID(#Window_Main), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE)   ;Ever on TOP of other Appz 
    MyHideWindowFromTaskbar(0, WindowID(#Window_Invisible), 0) 

    ;---- Enable this line and see that the STringGadget and Frame3D object are still created!
    ;
    ;    HideWindow(#Window_Main,0)    
 
    ; -------- Main_Window - Create Gadgets --------
    
    If CreateGadgetList(WindowID(#Window_Main))
    ;{
      ; -------- Gadgets for Main Page --------
      ;
      Frame3DGadget(77,0,102,453,4,"",#PB_Frame3D_Flat)
      StringGadget(#Gad_Main_StringGadget, 20, 115, 410, 270, "",#PB_String_MultiLine|#PB_String_ReadOnly|#ES_AUTOVSCROLL|#WS_VSCROLL| #ESB_DISABLE_LEFT| #ESB_DISABLE_RIGHT )
      ButtonGadget(#Gad_Main_OK,          190, 395,  50,  25, "OK")
      ButtonGadget(#Gad_Main_Edit,        380, 395,  50,  25, "Edit") 
      ;
      ; -------- Gadgets for Config Page --------
      ;
      ButtonGadget(#Gad_Config_LoadText,     20, 395, 80, 25, "Bla1")
      ButtonGadget(#Gad_Config_SaveText,    100, 395, 80, 25, "Bla2") 
      ButtonGadget(#Gad_Config_CreateData,  200, 395, 80, 25, "Bla3") 
      ButtonGadget(#Gad_Config_RestoreData, 280, 395, 80, 25, "Bla4") 
      ButtonGadget(#Gad_Config_Back,        380, 395, 50, 25, "Bla5") 
    ;}
    EndIf
    
    ; -------- Hide Gadgets for Main and Config Page --------
    
    HideGadget(#Gad_Main_Edit         , 1)
    HideGadget(#Gad_Config_LoadText   , 1)                          ; 1 = Hide all Config Gadgets
    HideGadget(#Gad_Config_SaveText   , 1)
    HideGadget(#Gad_Config_CreateData , 1)
    HideGadget(#Gad_Config_RestoreData, 1)
    HideGadget(#Gad_Config_Back       , 1)

    ; -------- FadeIn Window --------          ; Funktioniert erst wenn in Repeat Until loop
     
    ;---- B U G  ????????
    
    AnimateWindow_(WindowID(#Window_Main),1000,#AW_BLEND) 
 ;   RedrawWindow_(WindowID(#Window_Main), 0, 0, 7)  
    
  

; ----------------------------------------------------------------------------------------------------------- 
; W i n d o w C a l l B a c k   -   K e y b o a r d E v e n t s    ^ ^ H i d d e n P a r t s ^ ^
; ----------------------------------------------------------------------------------------------------------- 
   
    
    Procedure MyWindowCallback(lWindowID,lMessage,wParam,lParam) 
      res = #PB_ProcessPureBasicEvents 
     
      If lMessage=#WM_KEYDOWN 
        
        ; -------- CHeck keyboard inputs for hidden parts --------
        
        If wParam = 13 Or Len(cPassWord$) > 64
          cPassWord$ = ""
        Else 
          cPassWord$ = cPassWord$ + Chr(wParam)       
        EndIf
        
        Debug cPassWord$ 
    
        If wParam = 86              ; GadgetID;Asc(86)
          MessageRequester("bla","bla",0)
        EndIf
        
        Select cPassWord$
          Case "PASSWORD1"
          Case "PASSWORD2"
        EndSelect
         
      EndIf 
      ProcedureReturn res 
    EndProcedure 

    SetWindowCallback(@MyWindowCallback())  
    


; ----------------------------------------------------------------------------------------------------------- 
; M a i n L o o p
; ----------------------------------------------------------------------------------------------------------- 
    
    Repeat
      lEvent = WaitWindowEvent()
      ;
      If lEvent = #PB_EventGadget
        lGadgetID = EventGadgetID()
        Select lGadgetID
          Case #Gad_Main_OK 
            lEvent = #PB_EventCloseWindow
        EndSelect
      EndIf 
    Until lEvent = #PB_EventCloseWindow
    
    ; -------- FadeOff Window --------
   
AnimateWindow_(WindowID(#Window_Main),1000,#AW_BLEND | #AW_HIDE) 

End
[/code]
Last edited by Ralf on Sun Sep 19, 2004 12:43 pm, edited 2 times in total.
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Well this is what I see:
Image
I assume this is what should be there. I don't know why its working for me but not for you though. I'm using XP home by the way.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

strange! seems on your XP it works! on my windows2000 system fading in works but dont display the frame3d and stringgadget! here is a screenshot while fading in! as you may see, frame3d and stringgadget are still invisble. if you click with your mouse in that regions (stringgadget) you will only the cursor. or when a part of the window will re redrawed (half window out of screen) you will see this area. dont know how to solve this problem! Fred :?:

here is a screenshot showing the bug on my system [url]http://www.f*enix-b3rlin.de/bug/bug.png[/url]

here is the compiled exe using 3.91! [url]http://www.f*enix-b3rlin.de/bug/bug.exe[/url]

NOTE: Change the * inside url to "o" and "3" to "e" - thanxx
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

If someone can test this source and maybe the executeable (see link) with reporting what happes by telling about the used OS would be very nice!
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Ralf wrote:If someone can test this source and maybe the executeable (see link) with reporting what happes by telling about the used OS would be very nice!
I get the same result as you do, i.e. no vissible framegadget etc... Win2k sp4.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Okay, I just found here...

http://codejock.com/forum/forum_posts.a ... 1&get=last

...that if you change one line of code in your example, the gadgets ARE drawn;
however, they are NOT shown during the animation, so it's up to you whether
it's worth using this change. :)

This commented line in your example:

Code: Select all

; RedrawWindow_(WindowID(#Window_Main), 0, 0, 7)
Must become this:

Code: Select all

RedrawWindow_(WindowID(#Window_Main), 0, 0, #RDW_INVALIDATE)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

using xp pro and its working all good :D
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Try adding #SWP_SHOWWINDOW to line 57 where you SetWindowPos_()
Here's what I see.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Try adding #SWP_SHOWWINDOW to line 57 where you SetWindowPos_()

Then the fade-in effect doesn't work because the window is immediately visible. ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Using win2000pro:

With the original code, get the original problem but it fades in and fades out ok.

Using Sparkie's #SWP_SHOWWINDOW corrects the problem but there is no fade in. There is a fade out.

With PB's #RDW_INVALIDATE there is fade in, the window then shows OK, and there is a fade out. Looks ok.

Hope that helps with your multi-OS fact-gathering. :)
@}--`--,-- A rose by any other name ..
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

oops, I guess I was staring at the screen too long. :oops:
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

many thanxx for all your tips and replies! also it seems to be only a problem with windows2000!? i tried all the tips and tested to add #RDW_INVALIDATE - which shows ALL gadgets after fading in. until now (since about 2 weeks of experience and bughunting) i havent found any easy way for a fading in and out routine for windows :evil:

With the help of this great comunity i tried two different ways to realise the fading effects. the first methode using...

Code: Select all

SetWindowLong_(WinHandle,#GWL_EXSTYLE,#WS_EX_LAYERED)
SetLayeredWindowAttributes_ 
worked nearly fine. the fading seemed to be smoother as AnimateWindow!? I havent found a way for fading off window after a repeat/until loop. viewtopic.php?t=12397 So i got the tip to use AnimateWindow which faded nice in and out - but doesnt shows correct the gadgets while fading in - still unbelievable!


here is what i found out after some experience:
  • - try to set the flag for 3dborder to 0 instead 1,2,4...)
    - try to set the flag for stringgadget to 4 instead the one we want to use!

if someone of you gurus :) find any way to solve my problem on windows2000 platform, please let me know. the project i am working on should be finish since last friday ;( i cant give this project free as long i havent managed the fading with visible gadgets :evil:
[/list]
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

That example that I gave you that used the #WS_EX_LAYERED SetWindowLong thing was slightly spaghetti-ish code, but should have faded in and out properly.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

GreenGiant wrote:That example that I gave you that used the #WS_EX_LAYERED SetWindowLong thing was slightly spaghetti-ish code, but should have faded in and out properly.
yes, your example works fine (fade in and out). but when i tried to add your routine to my program, the fading in worked fine. in your example the fading off is inside an eventloop (repeat/forever). in my program i am using a mainloop (repeat/until) and then i added your fading off routine. the window was directly closed without fading. any idea how to solve this problem? (i posted the source where i used repeat/until).

many thanxx
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post by GreenGiant »

Okay, I got your code and quickly mangled in that other way of fading. Seems to work, I havent really checked it too thoroughly though.

Code: Select all

cWindowMainTitle$   = "bla" 
      
#winw = 453 
#winh = 428 

#AW_BLEND = $80000      ; AnimateWindow 
#AW_HIDE = $10000       ; AnimateWindow 
#AW_ACTIVATE = $20000 


Global a 
Global hWnd 
Global diff 

Procedure SetWinTransparency() 
  a=a+diff 
  If a>255 
    ActivateWindow() 
    KillTimer_(hWnd,2) 
  ElseIf a<0 
    End 
  Else 
    SetWindowLong_(hWnd,#GWL_EXSTYLE,$00080000)              
    SetLayeredWindowAttributes_(hWnd,0,a,2) 
  EndIf 
EndProcedure

; ----------------------------------------------------------------------------------------------------------- 
; D e f i n e   W i n d o w   a n d   G a d g e t   N u m b e r s 
; ----------------------------------------------------------------------------------------------------------- 

    Enumeration 
      #Window_Main 
      #Window_Invisible 
      #Gad_Main_Banner 
      #Gad_Main_StringGadget 
      #Gad_Main_OK 
      #Gad_Main_Edit 
      ; 
      #Gad_Config_LoadText 
      #Gad_Config_SaveText 
      #Gad_Config_CreateData 
      #Gad_Config_RestoreData 
      #Gad_Config_Back 
    EndEnumeration 


    Global hWnd, hWnd_Main 
    Global cAdminsMessage$, cRootFolder$, cUserLoggedOn$, cUserLoggedOnMD5$, cEditorText$ 
    Global lConfigMode, cPassWord$ 
    Global lFade,lFadeStep 


    Procedure MyHideWindowFromTaskbar(lWindowID, lNewWindowHandle, lMode) 
      If lMode=1 
        HideWindow(lWindowID,1) 
      EndIf 
      SetWindowLong_(WindowID(lWindowID),#GWL_HWNDPARENT,lNewWindowHandle) 
      ProcedureReturn 
    EndProcedure 
      
; ----------------------------------------------------------------------------------------------------------- 
; C r e a t e   W i n d o w s   a n d   G a d g e t s 
; ----------------------------------------------------------------------------------------------------------- 

    ; -------- Window Invisible -------- 
    
    OpenWindow(#Window_Invisible, 0, 0, 0, 0, #PB_Window_Invisible,"") 
    HideWindow(#Window_Invisible, 1)                                    ; 1 = hide 

    ; -------- Main_Window -------- 
    
    hWnd_Main = OpenWindow(#Window_Main, 0, 119, #winw, #winh, #PB_Window_Invisible | #PB_Window_WindowCentered  , cWindowMainTitle$) 
    SetWindowPos_(WindowID(#Window_Main), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE)   ;Ever on TOP of other Appz 

;    MySetWinTransparency()      
    MyHideWindowFromTaskbar(0, WindowID(#Window_Invisible), 0) 

    ;---- Enable this line and the StringGadget appear 
    ; 


    ; -------- Main_Window - Create Gadgets -------- 
    
    If CreateGadgetList(WindowID(#Window_Main)) 
    ;{ 
      ; -------- Gadgets for Main Page -------- 
      ; 
      Frame3DGadget(77,0,102,453,4,"",#PB_Frame3D_Flat) 
      StringGadget(#Gad_Main_StringGadget, 20, 115, 410, 270, "",#PB_String_MultiLine|#PB_String_ReadOnly|#ES_AUTOVSCROLL|#WS_VSCROLL| #ESB_DISABLE_LEFT| #ESB_DISABLE_RIGHT ) 
      ButtonGadget(#Gad_Main_OK,          190, 395,  50,  25, "OK") 
      ButtonGadget(#Gad_Main_Edit,        380, 395,  50,  25, "Edit") 
      ; 
      ; -------- Gadgets for Config Page -------- 
      ; 
      ButtonGadget(#Gad_Config_LoadText,     20, 395, 80, 25, "Bla1") 
      ButtonGadget(#Gad_Config_SaveText,    100, 395, 80, 25, "Bla2") 
      ButtonGadget(#Gad_Config_CreateData,  200, 395, 80, 25, "Bla3") 
      ButtonGadget(#Gad_Config_RestoreData, 280, 395, 80, 25, "Bla4") 
      ButtonGadget(#Gad_Config_Back,        380, 395, 50, 25, "Bla5") 
    ;} 
    EndIf 
    
    ; -------- Hide Gadgets for Main and Config Page -------- 
    
    HideGadget(#Gad_Main_Edit         , 1) 
    HideGadget(#Gad_Config_LoadText   , 1)                          ; 1 = Hide all Config Gadgets 
    HideGadget(#Gad_Config_SaveText   , 1) 
    HideGadget(#Gad_Config_CreateData , 1) 
    HideGadget(#Gad_Config_RestoreData, 1) 
    HideGadget(#Gad_Config_Back       , 1) 

    ; -------- FadeIn Window --------          ; Funktioniert erst wenn in Repeat Until loop 
    
    ;---- BUG ???? This line dont display the StringGadget!, Enable this line and it works! 
    
      hWnd=WindowID(#Window_Main) 
      diff=1 
      SetWinTransparency() 
      HideWindow(#Window_Main,0) 
      SetTimer_(hWnd,2,5,@SetWinTransparency())  
    
    
  

; ----------------------------------------------------------------------------------------------------------- 
; W i n d o w C a l l B a c k   -   K e y b o a r d E v e n t s    ^ ^ H i d d e n P a r t s ^ ^ 
; ----------------------------------------------------------------------------------------------------------- 
    
    
    Procedure MyWindowCallback(lWindowID,lMessage,wParam,lParam) 
      res = #PB_ProcessPureBasicEvents 
      
      If lMessage=#WM_KEYDOWN 
        
        ; -------- CHeck keyboard inputs for hidden parts -------- 
        
        If wParam = 13 Or Len(cPassWord$) > 64 
          cPassWord$ = "" 
        Else 
          cPassWord$ = cPassWord$ + Chr(wParam)        
        EndIf 
        
        Debug cPassWord$ 
    
        If wParam = 86              ; GadgetID;Asc(86) 
          MessageRequester("bla","bla",0) 
        EndIf 
        
        Select cPassWord$ 
          Case "PASSWORD1" 
          Case "PASSWORD2" 
        EndSelect 
          
      EndIf 
      ProcedureReturn res 
    EndProcedure 

    SetWindowCallback(@MyWindowCallback())  
    
    ;---- BUG ???? even here it dont work 
    
;    AnimateWindow_(WindowID(0),1000,#AW_BLEND) 
    
; ----------------------------------------------------------------------------------------------------------- 
; M a i n L o o p 
; ----------------------------------------------------------------------------------------------------------- 
    
    Repeat 
      lEvent = WaitWindowEvent() 
      ; 
      If lEvent = #PB_EventGadget 
        lGadgetID = EventGadgetID() 
        Select lGadgetID 
          Case #Gad_Main_OK 
            lEvent = #PB_EventCloseWindow 
        EndSelect 
        If lEvent=#PB_EventCloseWindow
          diff=-1 
          SetTimer_(hWnd,3,10,@SetWinTransparency()) 
        EndIf
      EndIf 
    ForEver 
    
    ; -------- FadeOff Window -------- 
End 
Post Reply