Page 1 of 1

Why can not close the window ?

Posted: Tue Aug 19, 2008 8:31 pm
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 ?????

Posted: Tue Aug 19, 2008 8:35 pm
by freak
because you have no CloseWindow() command, just an endless loop.

Posted: Tue Aug 19, 2008 8:45 pm
by Fluid Byte
Why can not post properly and use less question marks ?????

Me not undastand! :cry: :cry: :cry: :cry:

Posted: Tue Aug 19, 2008 9:05 pm
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))

Posted: Tue Aug 19, 2008 9:09 pm
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 :)

Posted: Tue Aug 19, 2008 9:13 pm
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.

Posted: Tue Aug 19, 2008 9:55 pm
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 ...

Posted: Tue Aug 19, 2008 11:36 pm
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...

Posted: Tue Aug 19, 2008 11:39 pm
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:

Posted: Wed Aug 20, 2008 8:41 am
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. :!: