Problem with Second Toolbar

Just starting out? Need help? Post your questions and find answers here.
Dr_Pixel
User
User
Posts: 36
Joined: Fri Oct 24, 2003 1:36 pm

Problem with Second Toolbar

Post by Dr_Pixel »

My program has a main window, plus several child windows

The main window has a toolbar created with the standard PB toolbar commands - it works with no problems

But, I tried adding a second toolbar, to one of the child windows.
It seems to work properly too, except for this:

If I try to use a Path Requester, it now opens in back of the program's window. If I then click on the program window, I get the "error sound", then the requester come to the front and works properly.

This happens every time, and only for the path requester - message requesters, save file, open file, etc. all come up in front as they should.

And, it is definately caused by adding the second toolbar - removing it fixes the problem.

So, is this a known problem? Is it only allowed to have one toolbar per program? Is it a bug with the Path Requester? Am I doing something wrong?

The second toolbar is created exactly the same as the first:

Window is opened, then the toolbar is created, then the window's gadgets.


I have Windows98se, if it matters.
Dr Pixel
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

1. if you use the
CreateToolBar(1, WindowID()) when you open a window

2. then you create another window and
CreateToolBar(2, WindowID())

the "windowid()" might be the problem. when you create the toolbar, the "windowid()" associates the toolbar to its PARENT window. if you create a SECOND toolbar and somehow the "windowid()" is associating the second toolbar with the FIRST window, the z order might be all messed up.

try:

Code: Select all

CreateToolBar(1, WindowID(mainwindow))

CreateToolBar(2, WindowID(childwindow))
also, check your window flags when you create your windows. or the setwindowlong_() command. if you use #hwnd_topmost flag, that will keep that window on top no matter what.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post by localmotion34 »

try this code:

Code: Select all

; PureBasic Visual Designer v3.90 build 1360


;- Window Constants
;
Enumeration
  #Window_0
  #Window_1
EndEnumeration


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 267, 146, 600, 300,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 0 )")
    If CreateGadgetList(WindowID())
    EndIf
    CreateToolBar(1,WindowID(0))
    ToolBarStandardButton(0, #PB_ToolBarIcon_New) 
    ToolBarStandardButton(1, #PB_ToolBarIcon_Open) 
    ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
  EndIf
EndProcedure

Procedure Open_Window_1()
  If OpenWindow(#Window_1, 0,30, 600, 300,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "New window ( 1 )")
    If CreateGadgetList(WindowID())
      
    EndIf
    CreateToolBar(2,WindowID(1))
    ToolBarStandardButton(3, #PB_ToolBarIcon_New) 
    ToolBarStandardButton(4, #PB_ToolBarIcon_Open) 
    ToolBarStandardButton(5, #PB_ToolBarIcon_Save)
  EndIf
EndProcedure

Open_Window_0()
Open_Window_1()
SetWindowParent(1,0)
Repeat 
  Select WaitWindowEvent() 
    Case  #PB_Event_CloseWindow 
      End 
      
    Case #PB_EventMenu
      Select EventMenuID()
        Case 4
          w$=PathRequester("test","")
          
      EndSelect
  EndSelect
  
ForEver 

 
hope this helps

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Post Reply