Panel - InnerSize, Reopen, Display-Window-ID

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

Panel - InnerSize, Reopen, Display-Window-ID

Post by GPI »

Updated for version 5.20

Code: Select all

; When PB creates a Panel, it also create a Display-Window for each Item, that you add.
; Sometimes you need the ID of this display window, but PB doesn't have a function for this.
; I found out, that Windows give the user the ability to save a value with every tab item and
; I test it: This value is the Display window id.
; When you want to open a RichEdit (or something like this) you need a Parent-Window-ID and in a
; Panel, this parent-id is the Display-Window-ID!
; Also when you can get the size of the display-window and reopen a panel-tab to add new gadgets.
;
; BIG WARNING:
; This is a undocumented Function of PB and it can be changed in the future!
; On PB 3.62 it works perfect.
; 
; @Fred: Official-Version of this Functions would be nice ;)

; When PB creates a Panel, it also create a Display-Window for each Item, that you add.
; Sometimes you need the ID of this display window, but PB doesn't have a function for this.
; I found out, that Windows give the user the ability to save a value with every tab item and
; I test it: This value is the Display window id.
; When you want to open a RichEdit (or something like this) you need a Parent-Window-ID and in a
; Panel, this parent-id is the Display-Window-ID!
; Also when you can get the size of the display-window and reopen a panel-tab to add new gadgets.
;
; BIG WARNING:
; This is a undocumented Function of PB and it can be changed in the future!
; On PB 3.62 it works perfect.
; 
; @Fred: Official-Version of this Functions would be nice ;)

Procedure GetPanelDisplayWindowID(Gadget,Item) ; WARNING! Undocumentated
  tc_item.tc_item
  tc_item\mask=#TCIF_PARAM 
  SendMessage_(GadgetID(Gadget),#TCM_GETITEM,Item,tc_item)
  ProcedureReturn tc_item\lparam
EndProcedure
Procedure GetInnerSizeWidth(Gadget)
  rect.rect
  GetWindowRect_(GetPanelDisplayWindowID(Gadget,GetGadgetState(Gadget)),rect)
  ProcedureReturn rect\right-rect\left
EndProcedure
Procedure GetInnersizeHeight(Gadget)
  rect.rect
  GetWindowRect_(GetPanelDisplayWindowID(Gadget,GetGadgetState(Gadget)),rect)
  ProcedureReturn rect\bottom-rect\top
EndProcedure
Procedure OpenPanelItem(Gadget,Item)
  ProcedureReturn UseGadgetList(GetPanelDisplayWindowID(Gadget,Item))
EndProcedure

;- Small (and dirty) example:

OpenWindow(1,0,200,400,400,"hallo",#PB_Window_SystemMenu)

PanelGadget(0,0,0,400,400)
AddGadgetItem(0,-1,"Test1")
AddGadgetItem(0,-1,"Test2")
AddGadgetItem(0,-1,"Test3")
CloseGadgetList()


Width=GetInnerSizeWidth(0)
Height=GetInnersizeHeight(0)

OpenPanelItem(0,0)
ButtonGadget(1,0,0,Width,Height,"Test1")
OpenPanelItem(0,1)
ButtonGadget(1,10,10,Width-20,Height-20,"Test2")
 
Repeat 
 Select WaitWindowEvent() 
  Case #WM_LBUTTONDOWN
    GetCursorPos_(point.point)
    Debug WindowFromPoint_(point\x|point\y<<32)
  
  Case #PB_Event_CloseWindow 
   End 
 EndSelect 
ForEver
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Thanks for sharing your ideas 8)

One suggestion though:
IMHO 'UsePanelItem' is a better term than 'OpenPanelItem'.
In PureBasic 'Open...' creates something, but 'OpenPanelItem' doesn't create the PanelItem, it uses it.
(as I said IHMO)

Keep up the good work :!:

Franco
always :?
Fred
Administrator
Administrator
Posts: 18224
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

OpenGadgetList() will be available on the next version (and support Panel too).
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Fred wrote:OpenGadgetList() will be available on the next version (and support Panel too).
This OpenPanelItem was only a "Bonus". I had searched a methode to find a method to get the handle of the display-window of the panel-item. I need this to open a scintella-edit (or for a richedit). Also with this handle i can get easy the the size of the display-window.

So please make a
GetPanelDisplayWindowID()
Function in the next release.

(or say, that my methode is secure for the future :)
Fred
Administrator
Administrator
Posts: 18224
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

This method should be secure for the future, yes.
Post Reply