Page 1 of 1

Trouble closing..

Posted: Wed Nov 04, 2009 12:32 am
by oToom
Okay stupid questions,

This closes (i dont get to see the very small box.

Code: Select all

; PureBasic Visual Designer v3.95 build 1485 (PB4Code)


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration


Open_Window_0()
OpenWindow(#Window_0, 702, 419, 5, 5, "",  #PB_Window_BorderLess | #PB_Window_ScreenCentered | #PB_Window_WindowCentered )
    CreateGadgetList(WindowID(#Window_0))
            BackColor(black)

AddKeyboardShortcut(#Window_0, #PB_Shortcut_Escape, #PB_Event_CloseWindow)

Repeat
  Event = WaitWindowEvent()
 
  Select Event

  
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver
Help appreviated, please and thanks!

Re: Trouble closing..

Posted: Wed Nov 04, 2009 3:00 am
by rsts
The particular code you provided won't even run, so it's not surprising you don't see anything.

cheers

Re: Trouble closing..

Posted: Wed Nov 04, 2009 3:16 am
by netmaestro

Code: Select all

Enumeration
  #Window_0
EndEnumeration

OpenWindow(#Window_0, 702, 419, 5, 5, "",  #PB_Window_BorderLess | #PB_Window_ScreenCentered | #PB_Window_WindowCentered )
SetWindowColor(#window_0, #Black)

AddKeyboardShortcut(#Window_0, #PB_Shortcut_Escape, 1)

Repeat
  Event = WaitWindowEvent()
  Select Event
    Case #PB_Event_Menu 
      If EventMenu()=1
        Break
      EndIf
  EndSelect
ForEver
This works, but bear in mind that if the tiny window doesn't have the keyboard focus, the ESC key won't do anything. Best replace it with something else like a hotkey or perhaps GetAsyncKeyState.

Re: Trouble closing..

Posted: Wed Nov 04, 2009 4:57 pm
by oToom
Thanks rsts for letting me know it wouldn't work.

Also thanks, netmaestro for some working code. Greatly appreciated :D