Cool popup message/window

Share your advanced PureBasic knowledge/code with the community.
User avatar
Blue
Addict
Addict
Posts: 967
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Post by Blue »

Bonne_den_kule:
Very nice! Thank you for sharing your idea with us.


netmaestro:
netmaestro wrote:[...] no more hourglass for you[...]

Code: Select all

Procedure ShowWindow(window)
   ... thread for fader ...
EndProcedure

Procedure.l CreatePopupMessage(*DeviceName.s)
 ...
    tid = CreateThread(@ShowWindow(),window)
 ...
EndProcedure 
I love how you've simplified the code -- and added a lot of clarity to it -- by simply packaging the fader code in a separately threaded procedure. Brilliant. But is there some other advantage to doing things this way ? (besides making things a whole lot easier to understand and maintain!)

thanks.



[Later... Much later!]
"Oh! I see." said the blind man
I guess the thread IS the reason WHY the hourglass cursor disappears. Because the code runs independently, it does not have to either wait or keep anybody waiting. Hence, no need for the hourglass.
Does that sound right?
Do I get the little gold star ?
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

know its old but if you want a sliding window as well as fade

Code: Select all


#WindowLength=180
#WindowHeight=50
Global rect.RECT

Procedure ShowWindow(window)
  HideWindow(Window, 0)
  
  sf.f = (1-#WindowLength) / (1-255)
  
  For i=0 To 255 Step 10
    sX = (i * sf) - #WindowLength
    MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)
    SetLayeredWindowAttributes_(WindowID(window), 0, i, 2)
    Delay(20)
  Next
  Delay(1250)
  For i=255 To 0 Step -10
    sX = (i * sf) - #WindowLength
    MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)
    SetLayeredWindowAttributes_(WindowID(window), 0, i, 2)
    Delay(20)
  Next
EndProcedure

Procedure.l CreatePopupMessage(*DeviceName.s)
  Define Window.l, DummyWindow.l, i.l, TextGadget
  SystemParametersInfo_(#SPI_GETWORKAREA,0,rect.RECT,0)
  DummyWindow.l=OpenWindow(#PB_Any, 0, 0, 0, 0, "", #PB_Window_Invisible)
  Window=OpenWindow(#PB_Any, rect\right-#WindowLength, rect\bottom-#WindowHeight, #WindowLength, #WindowHeight, "Audio Device", #WS_POPUPWINDOW|#WS_DISABLED|#PB_Window_Invisible, WindowID(DummyWindow))
  SetWindowLong_(WindowID(window), #GWL_EXSTYLE,GetWindowLong_(WindowID(window),#GWL_EXSTYLE)|#WS_EX_LAYERED )
  If Window
    If CreateGadgetList(WindowID(Window))
      TextGadget=TextGadget(#PB_Any, 10, 10, 160, 30, "You have male:"+Chr($0A)+*DeviceName)
    EndIf
    StickyWindow(Window, 1)
    SetWindowColor(Window, RGB(255, 255, 255))
    tid = CreateThread(@ShowWindow(),window)
  EndIf
  Repeat:
    WaitWindowEvent(1)
  Until Not IsThread(tid)
  CloseWindow(Window)
  CloseWindow(DummyWindow)
EndProcedure

CreatePopupMessage(@"WTF!")

[/code]
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Cool :D
ImageThe happiness is a road...
Not a destination
Wolf
Enthusiast
Enthusiast
Posts: 234
Joined: Sat Apr 03, 2004 12:00 pm
Location: S.T

Post by Wolf »

Nice :wink:
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Very nice. Thanks for sharing.

(in my case it would be 'mail') :D

cheers
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

rsts wrote:Very nice. Thanks for sharing.

(in my case it would be 'mail') :D

cheers


just for your amusement, the needed file :lol:

http://www.idlearts.com/msg.zip

it's an ogg file and server refuses to fetch them.

Code: Select all


#WindowLength=180
#WindowHeight=50
Global rect.RECT

Procedure ShowWindow(window)
  HideWindow(Window, 0)
  sy.l 
  sf.f = (1-#WindowLength) / (1-255)
  sfy.f = (1-#WindowHeight) /(1-255)
  PlaySound(0)
  For i=0 To 255 Step 10
    sX = (i * sf) - #WindowLength
    MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)
    SetLayeredWindowAttributes_(WindowID(window), 0, i, 2)
    Delay(30)
  Next
  Delay(2000)
  For c = 1 To 25
  For a = 0 To 255 Step 10 
   sY = a * sfy 
   MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)  
   Delay(4)
  Next
  
  For d = 255 To 0 Step - 10 
   sY = d * sfy 
   MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)  
   Delay(4)
  Next
  Next 
  
  For i=255 To 0 Step -2
    sX = (i * sf) - #WindowLength
    MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)
    SetLayeredWindowAttributes_(WindowID(window), 0, i, 2)
    Delay(30)
  Next
  Delay(15000)
EndProcedure

Procedure.l CreatePopupMessage(*DeviceName.s)
  Define Window.l, DummyWindow.l, i.l, TextGadget
  SystemParametersInfo_(#SPI_GETWORKAREA,0,rect.RECT,0)
  DummyWindow.l=OpenWindow(#PB_Any, 0, 0, 0, 0, "", #PB_Window_Invisible)
  Window=OpenWindow(#PB_Any, rect\right-#WindowLength, rect\bottom-#WindowHeight, #WindowLength, #WindowHeight, "Audio Device", #WS_POPUPWINDOW|#WS_DISABLED|#PB_Window_Invisible, WindowID(DummyWindow))
  SetWindowLong_(WindowID(window), #GWL_EXSTYLE,GetWindowLong_(WindowID(window),#GWL_EXSTYLE)|#WS_EX_LAYERED )
  If Window
    If CreateGadgetList(WindowID(Window))
      TextGadget=TextGadget(#PB_Any, 10, 10, 160, 30, "You have male:"+Chr($0A)+*DeviceName)
      SetGadgetColor(TextGadget,#PB_Gadget_BackColor,RGB(255,255,255))
    EndIf
    StickyWindow(Window, 1)
    SetWindowColor(Window, RGB(255, 255, 255))
    tid = CreateThread(@ShowWindow(),window)
  EndIf
  Repeat:
    WaitWindowEvent(1)
  Until Not IsThread(tid)
  CloseWindow(Window)
  CloseWindow(DummyWindow)
EndProcedure

InitSound()
UseOGGSoundDecoder()
len = CatchSound(0, ?Music,154116)

CreatePopupMessage(@"WTF!")


DataSection 

Music: IncludeBinary "c:\msg.ogg"

EndDataSection

Last edited by idle on Tue Aug 05, 2008 1:26 am, edited 1 time in total.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

idle the link is broken :cry:
Wolf
Enthusiast
Enthusiast
Posts: 234
Joined: Sat Apr 03, 2004 12:00 pm
Location: S.T

Post by Wolf »

idle nice work, please add to next version joystick support !
User avatar
idle
Always Here
Always Here
Posts: 5917
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

jack wrote:idle the link is broken :cry:
I'll have to zip it, there's a problem on the server.

done, edited the previous post
wolf wrote: idle nice work, please add to next version joystick support


you may regret having said that once you've heard the msg. specifically the reference to joystick :lol:
Intrigued
Enthusiast
Enthusiast
Posts: 501
Joined: Thu Jun 02, 2005 3:55 am
Location: U.S.A.

Post by Intrigued »

idle wrote:know its old but if you want a sliding window as well as fade

Code: Select all


#WindowLength=180
#WindowHeight=50
Global rect.RECT

Procedure ShowWindow(window)
  HideWindow(Window, 0)
  
  sf.f = (1-#WindowLength) / (1-255)
  
  For i=0 To 255 Step 10
    sX = (i * sf) - #WindowLength
    MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)
    SetLayeredWindowAttributes_(WindowID(window), 0, i, 2)
    Delay(20)
  Next
  Delay(1250)
  For i=255 To 0 Step -10
    sX = (i * sf) - #WindowLength
    MoveWindow_(WindowID(window),rect\right-#WindowLength-Sx,(rect\bottom-#WindowHeight)-Sy,#WindowLength,#WindowHeight,1)
    SetLayeredWindowAttributes_(WindowID(window), 0, i, 2)
    Delay(20)
  Next
EndProcedure

Procedure.l CreatePopupMessage(*DeviceName.s)
  Define Window.l, DummyWindow.l, i.l, TextGadget
  SystemParametersInfo_(#SPI_GETWORKAREA,0,rect.RECT,0)
  DummyWindow.l=OpenWindow(#PB_Any, 0, 0, 0, 0, "", #PB_Window_Invisible)
  Window=OpenWindow(#PB_Any, rect\right-#WindowLength, rect\bottom-#WindowHeight, #WindowLength, #WindowHeight, "Audio Device", #WS_POPUPWINDOW|#WS_DISABLED|#PB_Window_Invisible, WindowID(DummyWindow))
  SetWindowLong_(WindowID(window), #GWL_EXSTYLE,GetWindowLong_(WindowID(window),#GWL_EXSTYLE)|#WS_EX_LAYERED )
  If Window
    If CreateGadgetList(WindowID(Window))
      TextGadget=TextGadget(#PB_Any, 10, 10, 160, 30, "You have male:"+Chr($0A)+*DeviceName)
    EndIf
    StickyWindow(Window, 1)
    SetWindowColor(Window, RGB(255, 255, 255))
    tid = CreateThread(@ShowWindow(),window)
  EndIf
  Repeat:
    WaitWindowEvent(1)
  Until Not IsThread(tid)
  CloseWindow(Window)
  CloseWindow(DummyWindow)
EndProcedure

CreatePopupMessage(@"WTF!")

[/code]
Nice idle!

Thanks
Intrigued - Registered PureBasic, lifetime updates user
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

:lol:

cheers
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

:lol: Too much !!!!
I have dancing on the desktop :D

Congratulation 8)
ImageThe happiness is a road...
Not a destination
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

Awesome thanks :D (I'm still laughing!)

:lol: should I bash the keyboard and give up?
:?
Post Reply