Restored from previous forum. Originally posted by Henrik.
Hi all.
I can' figure out why this is happning?
My originally source is to complex now, so i found one on the forum and change it abit to showe my problem.
The problem is:
I have 2 windows, on window_1 i have some gadgets i want to resize acordingly to the window they belong.
But they resize accordingly to the wrong window.
The code comes here.
You have to resize first window_2 and then window_1 to see the effect.
Thanks
Henrik
--------------
Global hwnd, hwnd2, Count1, Count2
Declare Resize_Window()
Procedure MyCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select WindowID
Case WindowID(1)
Select message
Case #WM_SIZE
Resize_Window()
result=0
EndSelect
Case WindowID(2) ; splash window
Select message
Case #WM_SIZE
SetGadgetText(5,"Window 2 sized")
result=0
Case #WM_TIMER
SetGadgetText(6,"Window 2 timer "+Str(count2))
count2+1
result=0
SetGadgetText(5,"")
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
Procedure Resize_Window()
ResizeGadget(3, -1, -1, WindowWidth(), -1)
ResizeGadget(4, -1, -1, WindowWidth(), -1)
EndProcedure
hwnd= OpenWindow(1, 200,100, 673, 155 ,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget| #PB_Window_SizeGadget,"PB Window 1")
If CreateGadgetList(WindowID())
ButtonGadget(1,2,2,64,18,"Button1")
ButtonGadget(2,70,2,64,18,"Button2")
StringGadget(3, 10,45, 0, 20, "resize accordingly to the wrong window.")
Frame3DGadget(4, 0, 30, 0, 2, "", 2) ; resize accordingly to the wrong window.
EndIf
hwnd2= OpenWindow(2, 200, 300, 173, 155 ,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget| #PB_Window_SizeGadget,"PB Window 2")
;
If CreateGadgetList(WindowID())
TextGadget(5,20,20,300,20,"Timer")
TextGadget(6,20,40,300,20,"Timer")
Resize_Window()
SetWindowCallback(@myCallback())
;SetTimer_(hwnd, 1, 500, 0)
SetTimer_(hwnd2, 1, 800, 0)
Repeat
EventID=WaitWindowEvent()
If EventID = #PB_EventCloseWindow And EventWindowID()=2
CloseWindow(2)
EndIf
Until EventID = #PB_EventCloseWindow And EventWindowID()=1
EndIf
End
resize window problem
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Marc.
Hi Henrik,
put a line
into your Resize_Window()-Procedure (as the first line,
before the other commands) and it works... I suppose
PB uses the width of the active window for resizing.
Regards,
Marc
Hi Henrik,
put a line
Code: Select all
UseWindow(1)
before the other commands) and it works... I suppose
PB uses the width of the active window for resizing.
Regards,
Marc
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Henrik.
Allright, all right,
I was in a mental -"IT must be the callback ting"- loop
But i just realized that's it's the Resize_Window() function.
ResizeGadget(4, -1, -1, WindowWidth(), -1)
WindowWidth() keeps the value off the last window created.
Now, i need to tell "ResizeGadget" which window the "WindowWidth() value" belonges to.
Sorry i'am babbling here
I'am to messed up right now, to figure this out
guess i need some coffee
Henrik.
Allright, all right,
I was in a mental -"IT must be the callback ting"- loop
But i just realized that's it's the Resize_Window() function.
ResizeGadget(4, -1, -1, WindowWidth(), -1)
WindowWidth() keeps the value off the last window created.
Now, i need to tell "ResizeGadget" which window the "WindowWidth() value" belonges to.
Sorry i'am babbling here
I'am to messed up right now, to figure this out
guess i need some coffee
Henrik.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Henrik.
Ups Marc did'nt see your post
Tanks Marc
I try that, i think it vill give me annother problem.
but i try it anny way
)
Ups Marc did'nt see your post
Tanks Marc
I try that, i think it vill give me annother problem.
but i try it anny way
Originally posted by Henrik
Allright, all right,
I was in a mental -"IT must be the callback ting"- loop
But i just realized that's it's the Resize_Window() function.
ResizeGadget(4, -1, -1, WindowWidth(), -1)
WindowWidth() keeps the value off the last window created.
Now, i need to tell "ResizeGadget" which window the "WindowWidth() value" belonges to.
Sorry i'am babbling here
I'am to messed up right now, to figure this out
guess i need some coffee
Henrik.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Henrik.
sorry Marc.
But Marc
The UseWindow(1) works according to the source i posted
But not according to my original code because i'am using Panel's dynamically.
So when i use my "AddGadgetItem(100,-1,Name$(x))", nexttime it is adding the new-panel in the beginning off the panelbare, and not in the end, like it is suppose to,uhmm in my code at least.
dunno if it's posible to understand what i'am saying here
i hope so
Thanks
Henrik.
All right, thistime i have check if anybody have postedOriginally posted by Marc
Hi Henrik,
put a lineinto your Resize_Window()-Procedure (as the first line,Code: Select all
UseWindow(1)
before the other commands) and it works... I suppose
PB uses the width of the active window for resizing.
Regards,
Marc
But Marc
The UseWindow(1) works according to the source i posted
But not according to my original code because i'am using Panel's dynamically.
So when i use my "AddGadgetItem(100,-1,Name$(x))", nexttime it is adding the new-panel in the beginning off the panelbare, and not in the end, like it is suppose to,uhmm in my code at least.
dunno if it's posible to understand what i'am saying here
i hope so
Thanks
Henrik.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Marc.

haven't tried that in PB myself, I only remember having lots of fun with resizing in Delphi....
Beats meOriginally posted by Henrik
But not according to my original code because i'am using Panel's dynamically.
So when i use my "AddGadgetItem(100,-1,Name$(x))", nexttime it is adding the new-panel in the beginning off the panelbare, and not in the end, like it is suppose to,uhmm in my code at least.
haven't tried that in PB myself, I only remember having lots of fun with resizing in Delphi....
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Henrik.

Well to clarify.
what Marc wrote did in fact worke.
And Thanks for that Marc.
The problem i "_NOW_" have has nothing to do with "UseWindow(1)"
But has to do with the fact that i'am using two panel's -"PanelGadget(100,bla,bla)" - and when i try to add a new panel-item with "AddGadgetItem(100,-1,Name$(x))"
it uses number-of-items from the last -"PanelGadget(200,bla.bla)"- created.
But stuff is getting too messy now, have to make a simpel code, and try to figuer out how to switch between the two PanelGadget's
Thanks. & Cu
Henrik.
LolOriginally posted by Marc
Beats me
haven't tried that in PB myself, I only remember having lots of fun with resizing in Delphi....
Well to clarify.
what Marc wrote did in fact worke.
And Thanks for that Marc.
The problem i "_NOW_" have has nothing to do with "UseWindow(1)"
But has to do with the fact that i'am using two panel's -"PanelGadget(100,bla,bla)" - and when i try to add a new panel-item with "AddGadgetItem(100,-1,Name$(x))"
it uses number-of-items from the last -"PanelGadget(200,bla.bla)"- created.
But stuff is getting too messy now, have to make a simpel code, and try to figuer out how to switch between the two PanelGadget's
Thanks. & Cu
Henrik.