Global Dim image.l(2)
Structure inf
gadgethght.l
scrollgadget.l
parent.l
duinum.l[10]
State.l[10]
hwnd.l[10]
parenthwnd.l[10]
imagehwnd.l[10]
button.l[10]
buttonstate.l[10]
width.l
height.l[10]
hyperlink.l[50]
textgad.l[10]
yvalue.l[10]
scrollheight.l
type.l
EndStructure
image(0)=CatchImage(#PB_Any,?up1)
image(1)=CatchImage(#PB_Any,?up)
Global NewList dui.inf()
Global Dim icon.l(100)
EndProcedure
Procedure checkscrollheight(DUIpane)
scrollmax=20
SelectElement(dui(),DUIpane)
For a=0 To 9
If dui()\height[a]=0
scrollmax=dui()\yvalue[a-1]+dui()\height[a-1]
Break
EndIf
Next
If scrollmax>dui()\scrollheight
SetGadgetAttribute(dui()\scrollgadget,#PB_ScrollArea_InnerHeight,scrollmax+10)
SetWindowPos_(GadgetID(dui()\scrollgadget),0,0,0,dui()\width+30,dui()\gadgethght,#SWP_NOMOVE)
RedrawWindow_(GadgetID(dui()\scrollgadget),0,0,#RDW_ALLCHILDREN)
Else
SetGadgetAttribute(dui()\scrollgadget,#PB_ScrollArea_InnerHeight,dui()\scrollheight)
SetWindowPos_(GadgetID(dui()\scrollgadget),0,0,0,dui()\width+13,dui()\gadgethght,#SWP_NOMOVE)
RedrawWindow_(GadgetID(dui()\scrollgadget),0,0,#RDW_ALLCHILDREN)
EndIf
EndProcedure
Procedure moveproc(hwnd,msg,wParam,lParam)
Select msg
Case #duiup
SelectElement(dui(),lParam)
heighttomove=dui()\height[wParam]-20
For a=wParam+1 To 9
height=dui()\height[a]-20
yval=dui()\yvalue[a]-heighttomove
SetWindowPos_(dui()\hwnd[a],0,5,yval,0,0,#SWP_NOSIZE)
dui()\yvalue[a]=yval
Next
checkscrollheight(lParam)
ProcedureReturn 0
Case #duidown
SelectElement(dui(),lParam)
heighttomove=dui()\height[wParam]-20
For a=wParam+1 To 9
height=dui()\height[a]
yval=dui()\yvalue[a]+heighttomove
SetWindowPos_(dui()\hwnd[a],0,5,yval,0,0,#SWP_NOSIZE)
dui()\yvalue[a]=yval
Next
checkscrollheight(lParam)
ProcedureReturn 0
EndSelect
ProcedureReturn CallWindowProc_(GetProp_(hwnd,"OldProc2"),hwnd,msg,wParam,lParam)
EndProcedure
Procedure buttonproc(hwnd,msg,wParam,lParam)
Select msg
Case #WM_CTLCOLORSTATIC
*style= GetWindowLong_(lParam,#GWL_USERDATA)
Select *style
Case #DUI_XPstyle
#clnavy=$00800000
blue = CreateSolidBrush_(#clnavy)
ForEach dui()
For a=0 To 9
If IsGadget(dui()\textgad[a])And lParam=GadgetID(dui()\textgad[a])
SetTextColor_(wParam,#White) ;Text colour
SetBkColor_(wParam, #clnavy) ;Background colour
EndIf
Next
Next
ProcedureReturn blue
Case #DUI_Classic
SetBkMode_(wParam,#TRANSPARENT)
blue = CreatePatternBrush_(ImageID(200))
ForEach dui()
For a=0 To 9
If IsGadget(dui()\textgad[a])And lParam=GadgetID(dui()\textgad[a])
SetTextColor_(wParam,#White) ;Text colour
EndIf
Next
Next
ProcedureReturn blue
EndSelect
Case #WM_COMMAND
parent=GetParent_(hwnd)
ForEach dui()
For a=0 To 9
If parent=dui()\hwnd[a]
currentdui=ListIndex(dui())
scrollparent=GetParent_(dui()\hwnd[a])
If dui()\State[a]=1
SetWindowPos_(dui()\hwnd[a],0,0,0,dui()\width,22,#SWP_NOMOVE)
dui()\State[a]=0
PostMessage_(scrollparent,#duiup,a,ListIndex(dui()))
SendMessage_(GadgetID(dui()\button[a]),#BM_SETIMAGE,#IMAGE_BITMAP,ImageID(image(1)))
ElseIf dui()\State[a]=0
SetWindowPos_(dui()\hwnd[a],0,0,0,dui()\width,dui()\height[a],#SWP_NOMOVE)
dui()\State[a]=1
PostMessage_(scrollparent,#duidown,a,ListIndex(dui()))
SendMessage_(GadgetID(dui()\button[a]),#BM_SETIMAGE,#IMAGE_BITMAP,ImageID(image(0)))
EndIf
Break
EndIf
Next
Next
ProcedureReturn 0
Case #WM_LBUTTONDBLCLK
parent=GetParent_(hwnd)
ForEach dui()
For a=0 To 9
If parent=dui()\hwnd[a]
currentdui=ListIndex(dui())
scrollparent=GetParent_(dui()\hwnd[a])
If dui()\State[a]=1
SetWindowPos_(dui()\hwnd[a],0,0,0,dui()\width,20,#SWP_NOMOVE)
SendMessage_(GadgetID(dui()\button[a]),#BM_SETCHECK,#BST_UNCHECKED,0)
dui()\State[a]=0
PostMessage_(scrollparent,#duiup,a,ListIndex(dui()))
SendMessage_(GadgetID(dui()\button[a]),#BM_SETIMAGE,#IMAGE_BITMAP,ImageID(image(1)))
ElseIf dui()\State[a]=0
SetWindowPos_(dui()\hwnd[a],0,0,0,dui()\width,dui()\height[a],#SWP_NOMOVE)
SendMessage_(GadgetID(dui()\button[a]),#BM_SETCHECK,#BST_CHECKED,0)
PostMessage_(scrollparent,#duidown,a,ListIndex(dui()))
dui()\State[a]=1
SendMessage_(GadgetID(dui()\button[a]),#BM_SETIMAGE,#IMAGE_BITMAP,ImageID(image(0)))
EndIf
Break
EndIf
Next
Next
EndSelect
ProcedureReturn CallWindowProc_(GetProp_(hwnd,"OldProc1"),hwnd,msg,wParam,lParam)
EndProcedure
ProcedureDLL DUIpane(number,x,y,panewidth,height,DUItype); Creates A Pane To House DUIhwnd's
border=#PB_ScrollArea_Single
AddElement(dui())
SelectElement(dui(),number)
dui()\gadgethght=height
dui()\width=panewidth-10
scroll=ScrollAreaGadget(#PB_Any,x,y,panewidth,height,panewidth-5,height-20,30,border )
dui()\scrollgadget=scroll
dui()\scrollheight=height-20
child=GetWindow_(GadgetID(scroll),#GW_CHILD)
dui()\parent=child
SetProp_(child,"OldProc2",SetWindowLong_(child, #GWL_WNDPROC, @moveproc()))
dui()\type=DUItype
icon(number)=CreateImage(number+200,dui()\width,20)
StartDrawing(ImageOutput(number+200))
Select DUItype
Case #DUI_Classic
i = dui()\width
Color1=RGB($80,$80,$80)
Color2=GetSysColor_(4)
sRed.f = Red(Color1) : r.f = (Red (Color1) - Red (Color2))/i
sGreen.f = Green(Color1) : g.f = (Green(Color1) - Green(Color2))/i
sBlue.f = Blue(Color1) : b.f = (Blue (Color1) - Blue (Color2))/i
For a = 0 To i-1
xx.f = sRed - a*r
yy.f = sGreen - a*g
zz.f = sBlue - a*b
Line(a,0,0,20,RGB(xx,yy,zz))
Next a
StopDrawing()
Case #DUI_XPstyle
#clnavy=$00800000
Box(0,0,dui()\width,20,#clnavy)
StopDrawing()
EndSelect
ProcedureReturn scroll
EndProcedure
ProcedureDLL AddDUIhwnd(DUIpane,Position,text.s); Add A DUIhwnd that Can Contain Links To Commands
SelectElement(dui(),DUIpane)
dui()\duinum[Position]=Position
dui()\height[Position]=50
totalheight=20
If Position=0
dui()\yvalue[Position]=20
ElseIf Position<>0
For a=0 To Position-1
totalheight=totalheight+dui()\height[a]+20
Next
dui()\yvalue[Position]=totalheight
EndIf
mainhandle=OpenWindow(#PB_Any,5,dui()\yvalue[Position],dui()\width,50,"",#PB_Window_Invisible)
dui()\hwnd[Position]=WindowID(mainhandle)
SetWindowLong_(dui()\hwnd[Position],#GWL_STYLE, #WS_CHILD|#WS_BORDER|#WS_CLIPCHILDREN|#WS_CLIPSIBLINGS )
SetParent_(dui()\hwnd[Position],dui()\parent)
CreateGadgetList(dui()\hwnd[Position])
dui()\imagehwnd[Position]=ImageGadget(#PB_Any,0,0,dui()\width,20,0)
SetGadgetState(dui()\imagehwnd[Position],icon(DUIpane))
If region
SetWindowRgn_(dui()\hwnd[Position],region,#True)
EndIf
dui()\button[Position]=ButtonGadget(#PB_Any,dui()\width-22,2,16,16,"^")
style = GetWindowLong_(GadgetID(dui()\button[Position]), #GWL_STYLE)
toggleStyle=style|$1083|$8000|#BS_BITMAP
SetWindowLong_(GadgetID(dui()\button[Position]), #GWL_STYLE, toggleStyle)
SendMessage_(GadgetID(dui()\button[Position]),#BM_SETIMAGE,#IMAGE_BITMAP,ImageID(image(0)))
SetProp_(GadgetID(dui()\button[Position]),"OldProc3",SetWindowLong_(GadgetID(dui()\button[Position]), #GWL_WNDPROC, @clickproc()))
SetParent_(GadgetID(dui()\button[Position]),GadgetID(dui()\imagehwnd[Position]))
dui()\textgad[Position]=TextGadget(#PB_Any,0,4,dui()\width-19,20,text,#PB_Text_Center)
SetGadgetFont(dui()\textgad[Position],FontID1)
SetWindowLong_(GadgetID(dui()\textgad[Position]),#GWL_USERDATA,dui()\type)
SetParent_(GadgetID(dui()\textgad[Position]),GadgetID(dui()\imagehwnd[Position]))
SendMessage_(GadgetID(dui()\button[Position]),#BM_SETCHECK,#BST_CHECKED,0)
SetProp_(GadgetID(dui()\imagehwnd[Position]),"OldProc1",SetWindowLong_(GadgetID(dui()\imagehwnd[Position]), #GWL_WNDPROC, @buttonproc()))
If dui()\type=#DUI_XPstyle
region=CreateRoundRectRgn_(0,0,dui()\width+1,56,9,9)
If region
SetWindowRgn_(dui()\hwnd[Position],region,#True)
EndIf
EndIf
ShowWindow_(dui()\hwnd[Position],#SW_SHOW)
SetWindowPos_(dui()\hwnd[Position],0,0,0,dui()\width,50,#SWP_NOMOVE)
RedrawWindow_(dui()\hwnd[Position],0,0,#RDW_ALLCHILDREN )
UpdateWindow_(dui()\hwnd[Position])
dui()\State[Position]=1
checkscrollheight(DUIpane)
EndProcedure
ProcedureDLL addDUIlink(DUIpane,DuiHwnd,Position,text.s,color.l,image.l); Add A Link To Execute A Command Or List An Item You Want To Display
SelectElement(dui(),DUIpane)
UseGadgetList(dui()\hwnd[DuiHwnd])
hyperlink=HyperLinkGadget(#PB_Any, 20, (Position*20) +25,dui()\width-20,20,text, color)
img=ImageGadget(#PB_Any,2,(Position*20) +25,16,16,image)
RedrawWindow_(dui()\hwnd[DuiHwnd],0,0,#RDW_ALLCHILDREN )
ShowWindow_(dui()\hwnd[DuiHwnd],#SW_SHOWNORMAL)
UpdateWindow_(dui()\hwnd[DuiHwnd])
If Position =0
dui()\height[DuiHwnd]=50
ElseIf Position>0
dui()\height[DuiHwnd]=50+(Position*20)
If dui()\type=#DUI_XPstyle
region=CreateRoundRectRgn_(0,0,dui()\width+1,dui()\height[DuiHwnd]+5,9,9)
If region
SetWindowRgn_(dui()\hwnd[DuiHwnd],region,#True)
EndIf
EndIf
SetWindowPos_(dui()\hwnd[DuiHwnd],0,0,0,dui()\width,dui()\height[DuiHwnd],#SWP_NOMOVE)
If Position>=1
For a=DuiHwnd+1 To 9
SetWindowPos_(dui()\hwnd[a],0,5,dui()\yvalue[a]+(20),0,0,#SWP_NOSIZE)
dui()\yvalue[a]=dui()\yvalue[a]+(20)
Next
EndIf
EndIf
checkscrollheight(DUIpane)
RedrawWindow_(GadgetID(img),0,0,7)
ProcedureReturn hyperlink
EndProcedure
ProcedureDLL HideDUI(DUIpane,DuiHwnd,State);Hide Or Show And Individial DUIhwnd
SelectElement(dui(),DUIpane)
If State=0
If dui()\State[DuiHwnd]=0
SelectElement(dui(),DUIpane)
parent=GetParent_(dui()\hwnd[DuiHwnd])
SetWindowPos_(dui()\hwnd[DuiHwnd],0,0,0,dui()\width,dui()\height[DuiHwnd],#SWP_NOMOVE)
SendMessage_(GadgetID(dui()\button[DuiHwnd]),#BM_SETCHECK,#BST_CHECKED,0)
dui()\State[DuiHwnd]=1
PostMessage_(parent,#duidown,DuiHwnd,ListIndex(dui()))
SendMessage_(GadgetID(dui()\button[DuiHwnd]),#BM_SETIMAGE,#IMAGE_BITMAP,ImageID(image(0)))
EndIf
ElseIf State=1
If dui()\State[DuiHwnd]=1
SelectElement(dui(),DUIpane)
parent=GetParent_(dui()\hwnd[DuiHwnd])
SetWindowPos_(dui()\hwnd[DuiHwnd],0,0,0,dui()\width,20,#SWP_NOMOVE)
SendMessage_(GadgetID(dui()\button[DuiHwnd]),#BM_SETCHECK,#BST_UNCHECKED,0)
dui()\State[DuiHwnd]=0
PostMessage_(parent,#duiup,DuiHwnd,ListIndex(dui()))
SendMessage_(GadgetID(dui()\button[DuiHwnd]),#BM_SETIMAGE,#IMAGE_BITMAP,ImageID(image(1)))
EndIf
EndIf
EndProcedure
ProcedureDLL GetDUIstate(duinumber);Determine Whether a DUIhwnd is Expanded Or Collapsed
SelectElement(dui(),duinumber)
returnvalue=dui()\State[duinumber]
ProcedureReturn returnvalue
EndProcedure
ProcedureDLL ChangeDUIdisplay(DUIpane,DUItype); Change the DUI to Classic or XP Theme
SelectElement(dui(),DUIpane)
img.l=CreateImage(#PB_Any,dui()\width,20)
StartDrawing(ImageOutput(img))
Select DUItype
Case #DUI_Classic
i = dui()\width
Color1=RGB($80,$80,$80)
Color2=GetSysColor_(4)
sRed.f = Red(Color1) : r.f = (Red (Color1) - Red (Color2))/i
sGreen.f = Green(Color1) : g.f = (Green(Color1) - Green(Color2))/i
sBlue.f = Blue(Color1) : b.f = (Blue (Color1) - Blue (Color2))/i
For a = 0 To i-1
xx.f = sRed - a*r
yy.f = sGreen - a*g
zz.f = sBlue - a*b
Line(a,0,0,20,RGB(xx,yy,zz))
Next a
StopDrawing()
Case #DUI_XPstyle
#clnavy=$00800000
Box(0,0,dui()\width,20,#clnavy)
StopDrawing()
EndSelect
Select DUItype
Case #DUI_Classic
dui()\type=DUItype
For a=0 To 9
If IsGadget(dui()\textgad[a])And IsGadget(dui()\imagehwnd[a])
SetWindowLong_(GadgetID(dui()\textgad[a]),#GWL_USERDATA,DUItype)
SetGadgetState(dui()\imagehwnd[a],ImageID(img))
regn=CreateRectRgn_(0,0,dui()\width+1,dui()\height[a])
SetWindowRgn_(dui()\hwnd[a],regn,#True)
EndIf
Next
RedrawWindow_(GadgetID(dui()\scrollgadget),0,0,#RDW_ALLCHILDREN)
Case #DUI_XPstyle
dui()\type=DUItype
For a=0 To 9
If IsGadget(dui()\textgad[a])And IsGadget(dui()\imagehwnd[a])
SetWindowLong_(GadgetID(dui()\textgad[a]),#GWL_USERDATA,DUItype)
SetGadgetState(dui()\imagehwnd[a],ImageID(img))
EndIf
Next
For a=0 To 9
If IsWindow_(dui()\hwnd[a])
region=CreateRoundRectRgn_(0,0,dui()\width+1,dui()\height[a]+5,9,9)
If region
SetWindowRgn_(dui()\hwnd[a],region,#True)
EndIf
EndIf
Next
RedrawWindow_(GadgetID(dui()\scrollgadget),0,0,#RDW_ALLCHILDREN)
EndSelect
;
EndProcedure
Not really.. i wrote an exact copy of the WinXP menu thing, including support for controls, large icons (even in the header), small icons, collapsing, removing, floating, name it... 16kb DLL out of C# 2005.
Of course, it needs a run-time package to work tho but hey, the code should compile fine under .NET 1.0 and 1.1 as well as i used no .NET 2.0 specific things... EVERYBODY has .NET 1.0 at least (those who don't, need to buy a calculator and stop using computers..).
TomTheTim wrote:
EVERYBODY has .NET 1.0 at least (those who don't, need to buy a calculator and stop using computers..).
Still, nice work bro! Looking good.
troll alert
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
I wrote a similar window to manage child windows
(Sorry no code to share)
However, seeing the image on page 1, the control seems to present itself as Windows is set to classic mode.
I haven't seen your code but in XP theme mode the controls shows itself differently.
Here is an exe you could run, it handles xp themes as classic mode.
(Unless i have uploaded the wrong one )