Why can not close the window ?

Just starting out? Need help? Post your questions and find answers here.
Rascal
User
User
Posts: 30
Joined: Mon Sep 17, 2007 11:06 pm

Why can not close the window ?

Post by Rascal »

Code: Select all


Enumeration
  #Window_0
EndEnumeration


Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
    EndIf
 Repeat
 Until WaitWindowEvent() = #PB_Event_CloseWindow
 Debug "OK"
EndIf
EndProcedure

Procedure Main()
Open_Window_0()
Debug " End"
While #True
Sleep_(1000)
Wend
EndProcedure

WaitThread(CreateThread(@Main(),#Null))

Why can not close the window ?????
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

because you have no CloseWindow() command, just an endless loop.
quidquid Latine dictum sit altum videtur
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Why can not post properly and use less question marks ?????

Me not undastand! :cry: :cry: :cry: :cry:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

Fluid Byte, what is your problem?. I see others get banned over insults but your way of "passive" offensive statements really get on my nerve.

Specially, when it comes to people who is just learning like I am, you do not help, you are part of the problem if you only mock them.

Me not undastand!
If you want to play dumb, with that avatar you're doing very well already.


OP:

Code: Select all

Enumeration
	#Window_0
EndEnumeration

Procedure Open_Window_0()
	If OpenWindow(#Window_0, 216, 0, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
		If CreateGadgetList(WindowID(#Window_0))
		EndIf
	EndIf
EndProcedure

Procedure Main()
	Open_Window_0()
	Repeat
	Until WaitWindowEvent() = #PB_Event_CloseWindow
EndProcedure

WaitThread(CreateThread(@Main(),#Null))

:lol: should I bash the keyboard and give up?
:?
superadnim
Enthusiast
Enthusiast
Posts: 480
Joined: Thu Jul 27, 2006 4:06 am

Post by superadnim »

Kaeru Gaman wrote:@superadnim

have you tested your code before posting it?

you create the window in a different thread than you check the events, this will never work.

Quote:
Notes:
When opening a Window from a thread, the thread must also call WindowEvent() or WaitWindowEvent() in a loop to process events for this window, as window events are not sent between different threads.

http://www.purebasic.com/documentation/ ... event.html
If so, then explain me why the window closes when I fire the event by clicking on the nice X button at the top right corner :?

Please do not delete your posts, it breaks the conversation!
Thanks :)

:lol: should I bash the keyboard and give up?
:?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

@superadnim

because your program ends then, but this is not what he asked for.
not the event closes the window, the end of the program does.

this was also the misassumption Rascal made.

like freak said, adding a CloseWindow in the appropriate place will do the job:

Code: Select all

Enumeration
  #Window_0
EndEnumeration


Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
    EndIf
 Repeat
 Until WaitWindowEvent() = #PB_Event_CloseWindow
 CloseWindow(#Window_0)
 Debug "OK"
EndIf
EndProcedure

Procedure Main()
Open_Window_0()
Debug " End"
While #True
Sleep_(1000)
Wend
EndProcedure

WaitThread(CreateThread(@Main(),#Null))

[edit]
superadnim wrote:Please do not delete your posts, it breaks the conversation!
Thanks :)
when I realize within 30secs I posted bullshit, it's my right to delete my post again. :mrgreen:

I misread from where the opening Proc was called.
if it was called from the body of the program before starting the thread,
then opening and eventcheck would have been in seperated threads and then it would not work.
oh... and have a nice day.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Fluid Byte, what is your problem?
My Problem are people who don't give a **** about posting a proper request for a problem to be solved. My problem are people who in most cases don't even bother to post more than one short sentence if they say anything at all. MY problem are people who think it's a matter of course to post some code and get their problem fixed quickly. My problem are also people who make intense use of punctuation marks and smileys wich is very anyoing to say the least.

So are we clear now?
I see others get banned over insults but your way of "passive" offensive statements really get on my nerve.
No offense, but what you see is BS. I know exactly 2 people who got banned: thefool & mysticboy. And mysticboy was banned for malware and spreading illegal copies of PB. So where the hell are those "others getting banned over insults" you talking about? I really wanna see them. Must be many ...
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

C'mon Fluid, go easy, use the 60 second rule... If you're not careful, you're gonna' surpass TheFool... (I think it's about time he would return, by the way, bans should not last forever, because then people would never learn, but that's up to Fred and his team.)

Some people just have some troubles with the language (me, for example, am a very good example of poorly spoken English, and even worse at expressing my sincerest thoughts eloquantly (gosh, I hope I spelled that right, see what I mean)) whilst other people simply haven't done their proper searches through the forum (yes, all the answers are there, really). Well, most of 'm, anyway.

Now, as for Rascal, may I suggest Rascal to have a peek here:

http://www.xs4all.nl/~bluez/datatalk/pu ... #2_windows

... or perhaps simply start here...

http://www.xs4all.nl/~bluez/datatalk/purebasic.htm#top

It may also be a good idea to have a look at Kale's book, as well as all the examples in the never applauded enough code archive. (I'm pretty sure the above average participant will easily drop in the right link, me, I'm lost some of my memory abilities years ago since I got married, marriage is bad enough but it got worse since I stopped drinking :-))

But of course, I assume Rascal did check out those resources and simply didn't understand it yet.

I tell you honestly, there were a number of things totally lost on me when I just switched over from GfaBasic16 to PureBasic 3.xx...
Last edited by blueznl on Tue Aug 19, 2008 11:40 pm, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Demivec
Addict
Addict
Posts: 4280
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Fluid Byte wrote:
Fluid Byte, what is your problem?
My Problem are people who don't give a **** about posting a proper request for a problem to be solved. My problem are people who in most cases don't even bother to post more than one short sentence if they say anything at all. MY problem are people who think it's a matter of course to post some code and get their problem fixed quickly. My problem are also people who make intense use of punctuation marks and smileys wich is very anyoing to say the least.

So are we clear now?
Here's a few more things which are problematic when present. Problem, people posting in excessive font sizes and colors making the equivalent of shouts for "HELP ME, I'm too annoying to ignore." Problem, no expression of thanks or feedback on the help received (= ungrateful).

Just a note, Rascal is off to a better start on several of these points than has been evident in the past, maybe someone is filling in for the day. :wink:
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

blueznl wrote:If you're not careful, you're gonna' surpass TheFool...
That's almost impossible, he cursed so much lol :lol:
blueznl wrote:(I think it's about time he would return, by the way, bans should not last forever, because then people would never learn, but that's up to Fred and his team.)
I agree totally, maybe we should sign a petition to "release" thefool. :D
blueznl wrote:Some people just have some troubles with the language
Using fat, gigantic, red letters is not really a language problem but a matter of common sense. :!:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Post Reply