Page 1 of 1
IsCloseWindow
Posted: Thu Feb 26, 2015 6:31 pm
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
Re: IsCloseWindow
Posted: Thu Feb 26, 2015 6:47 pm
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.

Re: IsCloseWindow
Posted: Thu Feb 26, 2015 7:44 pm
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.
Re: IsCloseWindow
Posted: Thu Feb 26, 2015 8:20 pm
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.

Re: IsCloseWindow
Posted: Thu Feb 26, 2015 8:38 pm
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.

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?
Re: IsCloseWindow
Posted: Fri Feb 27, 2015 12:12 am
by IdeasVacuum
Isn't IsWindow() suitable?
IsWindow()
Re: IsCloseWindow
Posted: Fri Feb 27, 2015 7:17 am
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
Re: IsCloseWindow
Posted: Fri Feb 27, 2015 5:06 pm
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.
Re: IsCloseWindow
Posted: Sun Mar 01, 2015 4:36 pm
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