Example for Splitter, Always Subwin active and Window resize

Share your advanced PureBasic knowledge/code with the community.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Example for Splitter, Always Subwin active and Window resize

Post by GPI »

Updated for version 5.20

resize.

In PB3.7, you must use the callback for the resize, because you get no "offical" message :(

Ok here it is. Also when you try to activate Window(0) "Hallo", always the subwindow(1) is activate.

Code: Select all


Procedure Callback(WindowID, Message, wParam, lParam) 
  Result = #PB_ProcessPureBasicEvents 
  Select message
    Case #WM_MOUSEACTIVATE
      If windowid=WindowID(0)
        result=#MA_NOACTIVATEANDEAT
        SetActiveWindow_(WindowID(1))
      EndIf
    Case #WM_ACTIVATE
      If IsWindow(0)
        If windowid=WindowID(0)
          type=lparam&$ffff
          If type=#WA_ACTIVE
            SetActiveWindow_(WindowID(1))
          EndIf
        EndIf
      EndIf
    Case #WM_SIZE
      If windowid=WindowID(1)
        ResizeGadget(6,-1,-1,WindowWidth(1),WindowHeight(1))
      EndIf
      
  EndSelect
  ProcedureReturn Result 
EndProcedure 
OpenWindow(3,400,200,400,400,"hallo3")
OpenWindow(0,0,200,400,400,"Hallo")
OpenWindow(1,200,200,400,400,"Hallo2",#PB_Window_SizeGadget|#PB_Window_SystemMenu,WindowID(0))

SetWindowCallback(@callback())


;ContainerGadget(1,0,0,400,200)



ButtonGadget(2,0,0,190,200,"Test1")
ButtonGadget(4,210,0,190,200,"test2")
SplitterGadget(3, 0,0, 400,200, 2,4,  #PB_Splitter_Vertical|#PB_Splitter_Separator   ) 
;CloseGadgetList()
ButtonGadget(5,0,200,400,200,"Test3")
SplitterGadget(6, 0,0,400,400, 3,5)

SetGadgetState(3,300)

Repeat
  event=WaitWindowEvent()
  Select event
    Case #PB_Event_CloseWindow
      End
  EndSelect
  
ForEver
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Re: Example for Splitter, Always Subwin active and Window re

Post by Berikco »

GPI wrote:resize.

In PB3.7, you must use the callback for the resize, because you get no "offical" message :(
There is also no realtime message for WM_SIZE, or ScrollBar moved, this is a windows limitation.
For the TrackBar gadget, you get realtime messages, windows is realy wierd.

So only in a CallBack you get the messages, not with TranslateMessage(),Dispatchmessage() api.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: Example for Splitter, Always Subwin active and Window re

Post by fsw »

Berikco wrote: So only in a CallBack you get the messages, not with TranslateMessage(),Dispatchmessage() api.
When I look at C code for Windows (or other languages as well) the
TranslateMessage(),Dispatchmessage() part of the code is only used to keep
the application alive.

The WndProc callback is always used for events.
Didn't know PureBasic does it different.

Interesting ....

:?
Post Reply