IsCloseWindow

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

IsCloseWindow

Post by mestnyi »

I hope that Fred to pay attention :)

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  Import ""
  CompilerElse
    ImportC ""
    CompilerEndIf
    PB_Window_Objects.i
    PB_Object_Count( Object )
  EndImport
  
  Procedure IsWindowClose( Window = #PB_All )
    If Window = #PB_All
      ProcedureReturn PB_Object_Count( PB_Window_Objects.i )
    EndIf
    ProcedureReturn IsWindow( Window )
  EndProcedure
  
  CompilerIf #PB_Compiler_IsMainFile
    OpenWindow(1, 0, 0, 322, 150, "window 1", #PB_Window_SystemMenu )
    OpenWindow(2, 0, 230, 322, 150, "window 2", #PB_Window_SystemMenu )
    OpenWindow(3, 0, 460, 322, 150, "window 3", #PB_Window_SystemMenu )
    OpenWindow(4, 0, 0, 322, 150, "window 4", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    
    While IsWindowClose( 4 )
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow 
          CloseWindow( EventWindow() )
      EndSelect
    Wend
  CompilerEndIf
  
Last edited by mestnyi on Sat Dec 12, 2015 3:00 pm, edited 1 time in total.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: IsCloseWindow

Post by Little John »

mestnyi wrote:I hope that Fred to pay attention :)
I hope some day you will learn how to program properly in PB, and stop posting strange requests. :lol:
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: IsCloseWindow

Post by freak »

You should especially learn to put what you want in actual words rather than just posting a blob of code and hoping people will guess what you are asking for.

I'm guessing this post is a duplicate to this one: http://www.purebasic.fr/english/viewtop ... =3&t=61516
But I can't be sure because... well, both posts don't contain any words at all, so who knows what they are about.
quidquid Latine dictum sit altum videtur
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: IsCloseWindow

Post by mestnyi »

You should especially learn to put what you want in actual words rather than just posting a blob of code and hoping people will guess what you are asking for.
:)
I try to bring that there is no function handles the window is closed,
which will be automatically controlled closing Windows. :wink:
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: IsCloseWindow

Post by Little John »

mestnyi wrote:I try to bring that there is no function handles the window is closed,
which will be automatically controlled closing Windows. :wink:
I don't understand what you mean (I'm waiting for the translation into English).

However, when your program opens and closes windows, then you should know yourself
which windows are open and which are closed, no?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: IsCloseWindow

Post by IdeasVacuum »

Isn't IsWindow() suitable? IsWindow()
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: IsCloseWindow

Post by mestnyi »

Isn't IsWindow() suitable?
Don't see what fits? (Not IsWindow) it is necessary to specify the window for (IsCloseWindow) it is possible not to specify a particular window and specify #PB_All. When you close all the Windows we will automatically leave out of the loop
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: IsCloseWindow

Post by Little John »

If your program has dozens of open windows, you might want to reconsider your program design. ;-)

However, if you actually need somethinmg like that, you can easily code it yourself, e.g.

Code: Select all

Enumeration
   #Win1
   #Win2
   ; ...
   #WinLast
EndEnumeration


Procedure.i NumberOfOpenWindows (first.i, last.i)
   Protected.i i, count=0
   
   For i = first To last
      If IsWindow(i)
         count + 1
      EndIf  
   Next   
   
   ProcedureReturn count
EndProcedure


Repeat
   ; ...
Until NumberOfOpenWindows(#Win1, #WinLast) = 0

When creating windows with #Pb_Any, then e.g. an array can be used for storing the window handles.

There cannot anything and everything be built into PB.
[u]Fred[/u] wrote:If we start to add simple commands like that, the commandset will be too big.
Karellen
User
User
Posts: 83
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: IsCloseWindow

Post by Karellen »

Maybe I'm getting you completly wrong, but do you mean something like this?

Code: Select all

For i=0 To 9
  OpenWindow(i, Random(800), Random(300), 200+Random(200), 200+Random(200), "Window "+Str(i), #PB_Window_SystemMenu)
Next

Repeat
  event = WaitWindowEvent()
  window = EventWindow()
  
  If event = #PB_Event_CloseWindow
    CloseWindow(window)
    MessageRequester("Close Event", "Window "+Str(window)+" was closed.")
    If window=0
      End
    EndIf    
  EndIf
    
ForEver
Stanley decided to go to the meeting room...
Post Reply