Page 3 of 3

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 1:50 pm
by infratec
A version which uses #PB_Window_WindowCentered.
And don't generate an error :mrgreen:
Therfore UnbindEvent() was needed.

Code: Select all

Procedure CloseAboutWindow()
  
  Protected Win.i
  
  Win = EventWindow()
  
  If GetWindowData(Win)
    RemoveWindowTimer(Win, 1)
    UnbindEvent(#PB_Event_Timer, @CloseAboutWindow(), Win)
  EndIf
  UnbindEvent(#PB_Event_DeactivateWindow, @CloseAboutWindow(), Win)
  CloseWindow(Win)
  
EndProcedure


Procedure About(Timeout.i=0)
  
  Protected Win.i
  
  Win = OpenWindow(#PB_Any, 0, 0, 200, 100, "About", #PB_Window_Tool | #PB_Window_WindowCentered, WindowID(GetActiveWindow()))
  
  TextGadget(#PB_Any, 10, 10, 100, 20, "This is a demo")
  BindEvent(#PB_Event_DeactivateWindow, @CloseAboutWindow(), Win)
  If Timeout
    SetWindowData(Win , #True)
    AddWindowTimer(Win, 1, Timeout)
    BindEvent(#PB_Event_Timer, @CloseAboutWindow(), Win)
  EndIf
  
EndProcedure


Define.i Event

OpenWindow(0, 0, 0, 400, 300, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateMenu(0, WindowID(0))
MenuTitle("Help")
MenuItem(1, "About")


About(2000)

Repeat
  
  Event = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_Menu
      If EventMenu() = 1
        About()
      EndIf
  EndSelect
  
Until Event = #PB_Event_CloseWindow
Bernd

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 2:22 pm
by Blue
Hi Bernd
You can read into minds now ? Impressive.

I was indeed trying to work out how exactly when, where and how to unBind the event, so i could integrate the genial Bernd Closing Method (gBCM, as we all know it) approach into a large project structured with many modules. It looks, so far, like i won't be able to use separate event loops for different child windows.
Still working it out, so i'll dive into this sometimes this morning, and, garanteed, i'll be back hounding you with questions. :wink:

Presently, i can't avoid being distracted by my smart phone, which is showing me the amazingly squinty face of my first grand-daughter. :shock:
This is a rocking experience, believe me. :o -> :) -> :D -> :lol:

She just stepped into our world 2 hours ago.
Long live [yet unNamed] Baby girl.

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 2:26 pm
by infratec
Happy Birthday

To .... noname. :mrgreen:

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 2:43 pm
by Blue
Isn't it something, to be born in 2015 ?
In 2100, when she turns 75, she'll be coding with
      PureBasic v.272.1 (X64, X128, X256 or X512, your choice)
      (just a bugs correction release)
just like her GrandPa.
Imagine that !

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 3:14 pm
by blueb
Hopefully they can add in the year 2100. :mrgreen: :mrgreen:

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 3:30 pm
by Blue
Oh, no, really ? Another bug in PureBasic 6.40 beta 8 ? :shock:
Cross my heart and... Well, you know the rest. :oops:

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 3:54 pm
by blueb
I was referring to the fact that your grandchild will be 85 in 2100 NOT 75! :D

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 4:07 pm
by Blue
blueb wrote:I was referring to the fact that your grandchild will be 85 in 2100 NOT 75! :D
I know, BlueB.
I thought i'd get a laugh out of you with some silly attempt at blaming PB for my lousy arithmetic.
Sorry for being obscure. :|

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 9:38 pm
by Blue
infratec wrote:A version which uses #PB_Window_WindowCentered.
And don't generate an error :mrgreen:
Therfore UnbindEvent() was needed.
[...code skipped...]

Bernd
Perfect, your version #2. 8)
Your #1 was perfect as well, so I guess this would make #2 plusPerfect (?), of course. :shock:

Version #2 just adds this little extra flexibilty that I didn't even realize i was missing.
And it's a good lesson on where to properly use UnbindEvent().
Thanks.


PS: [Unnamed] baby girl is now known as Charlotte
A name full of promises to come.

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 9:57 pm
by Vera
Image ~ wishing you lots of fun with your granddad

Re: Simple non-modal custom dialog box closing automatically

Posted: Wed Sep 30, 2015 10:55 pm
by Blue
Charlotte NMP (newly minted person) says
"Thank you, Vera !
That's the nicest message I've received in my whole life !"


Luckily for you, Vera, I happened to be nearby with my NMC (Newly Minted Code) PB App 8) to decode Charlotte's extensive personal dictionary.
Otherwise, you may have misunderstood her "Arrreuh! Arrreuh!" for something unintelligible.

But then, what are GrandPas for ?