BareBones - Skeleton

Just starting out? Need help? Post your questions and find answers here.
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

BareBones - Skeleton

Post by TronDoc »

I've been searching this forum,the help file & user's sites; experimenting
with everything I've found remotely resembling what I'm after...
...to no avail. Apparently some of the older examples and
snippets I've come across no longer function due to
changes in PureBasic itself.

Problem: I'm trying to incorporate an "About" window similar to
PureBasic's in a program of mine. Looking at the ide, common
and about sources is helpful, but I keep confusing myself on
how to get it to work in my own app.

What goes wrong: I have the main app, I've "included" the about
source and my "about" menu item calls the about window and
displays it just fine.. ..BUT.. ..I can't figure out how to properly
handle events to allow the closing of the about window and
return to my main app. Either I end up closing everything
or I end up in an endless loop and have to quit from the debugger.

Help wanted: A skeleton program showing how a main app can
call another window, get it's events and return to the main app.
--OR--
Pseudo code pointing out the structure I should be following
to accomplish this.

My understanding (possibly incorrect) would be as follows:
--Pseudo code--

run main app
show main window
handle events()
end

proc about()
show about window
handle aboutevents()
end proc

the mess I've made of my attempts can be found here:
http://trondoc.ezwebtech.com/prgrmng/d3/about.zip

Thanks.

Joe

P.S. I am not asking anyone to write the program for me! :D
P.P.S. If you suspect you've posted code somewhere that
may no longer work because of PureBasic updates..
..find it and kill it! LOL :lol: I'm sure I'm guilty of this
also.... ....I know of no simple/quick way to accomplish it either.
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

You're going to kick yourself when I tell you :-)

You're doing everything just fine except that you're passing the same window ID as your main window to openwindow when you call Open_Window_About() thus closing the main window..

Just change the #Window_About constant in about.pb to a different number (remember all windows need a unique identifier!)
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: BareBones - Skeleton

Post by ricardo »

Code: Select all

Procedure AnotherWindow()
  If OpenWindow(1,100,150,250,200,#PB_Window_SystemMenu,"OtherWindow")
    CreateGadgetList(WindowID())
    ButtonGadget(11,100,100,50,25,"Test")
  EndIf
EndProcedure


If OpenWindow(0,0,0,450,200,#PB_Window_SystemMenu,"Test")
  CreateGadgetList(WindowID())
  ButtonGadget(1,150,100,150,25,"Open another window")
  Repeat
    EventID=WaitWindowEvent()
    
    Select EventID
      
    Case #PB_EventGadget
      Select EventGadgetID()
        Case 1
          AnotherWindow()
        Case 11;The gadget from the other window must have DIFFERENT ids
          MessageRequester("click","Button from 2nd window",0)
      EndSelect
    Case #PB_EventCloseWindow
      If EventWindowID()= 1 ;Here you detect if the window to close is your additional window
        CloseWindow(1)
        UseWindow(0)
      Else
        Quit = 1
      EndIf
  EndSelect
  
Until Quit = 1
EndIf
In resume there are 2 important things:

1.- Check which window receives the #PB_EventCloseWindow by using the EventWindowID() that let you know which one was.

2.- The Gadgets of you additional windows must have different number ids from the ones of the main window, then it could be handled in the same event loop.

Best Regards
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

:arrow: :oops: kicking self! :roll:
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Post Reply