Posted: Thu Dec 19, 2002 6:33 pm
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
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