here is an attempt at a powerpoint like listview that i have been working on. give it a try and see what you think. post any comments or suggestions you have about it.
Code: Select all
Global PPL ,rect.RECT,scrollareachildfirstchild,scrollareachildnextchild,scrollareachildlastchild,scrollareachild
Structure FindWindowData
childwindowhandle.l ; variable to store a handle
EndStructure
Global NewList FindChild.FindWindowData()
Procedure.l EnumChildProc(hChild, lParam)
AddElement(FindChild())
FindChild()\childwindowhandle= hChild
ProcedureReturn 1
EndProcedure
Global Dim PPTimages(100)
rect.RECT
Procedure PPTcallback(WindowID,message,wParam,lParam)
If IsGadget(PPL)
scrollareachild=GetWindow_(GadgetID(PPL),#GW_CHILD)
scrollareachildfirstchild=GetWindow_(scrollareachild,#GW_CHILD)
scrollareachildnextchild=GetWindow_(scrollareachildfirstchild,#GW_HWNDNEXT)
scrollareachildlastchild=GetWindow_(scrollareachildfirstchild,#GW_HWNDLAST)
ClearList(FindChild())
EnumChildWindows_(scrollareachild, @EnumChildProc(), 0)
Result=#PB_ProcessPureBasicEvents
Select message
Case #WM_COMMAND
ResetList(FindChild())
ForEach FindChild()
Index = ListIndex(FindChild())
If lParam = FindChild()\childwindowhandle
SetWindowLong_(FindChild()\childwindowhandle,#GWL_EXSTYLE,#WS_EX_DLGMODALFRAME)
RedrawWindow_(GetParent_(FindChild()\childwindowhandle),0,0,3)
SetWindowPos_( dockhandle,0,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE)
ShowWindow_(FindChild()\childwindowhandle,#SW_SHOW)
Debug "you pressed image" + " " + Str(Index+1)
ForEach FindChild()
If lParam <> FindChild()\childwindowhandle
SetWindowLong_(FindChild()\childwindowhandle,#GWL_EXSTYLE,#WS_EX_WINDOWEDGE )
;RedrawWindow_(GetParent_(FindChild()\childwindowhandle),0,0,3)
RedrawWindow_(FindChild()\childwindowhandle,0,0,3)
RedrawWindow_(GetParent_(GetParent_(FindChild()\childwindowhandle)),0,0,3)
ShowWindow_(FindChild()\childwindowhandle,#SW_SHOW)
EndIf
Next
EndIf
Next
EndSelect
EndIf
ProcedureReturn Result
EndProcedure
Procedure PPtListview(x,y,Width,Height,Imagenumber)
imagex=5
imagewidth=Width-30
imageheightF.f=imagewidth*(5/7)
imageheightF$=StrF(imageheightF)
Result$ = StringField(imageheightF$, 1,".")
imageheight=Val(Result$)
imagey=0-imageheight
If Imagenumber>4
scrollheight=Imagenumber*(imageheight+10)
Else
scrollheight=600
EndIf
scrollarea=ScrollAreaGadget(#PB_Any, x,y,Width,Height, Width-20,scrollheight, 10)
For a=1 To Imagenumber
imagey=imagey+ 5+ imageheight
PPTimages(a)=ImageGadget(#PB_Any,imagex,imagey, imagewidth, imageheight, Image0,#PB_Image_Border)
PPT=GetWindowLong_(GadgetID(PPTimages(a)),#GWL_STYLE)
SetWindowLong_(GadgetID(PPTimages(a)),#GWL_STYLE,PPT|#SS_NOTIFY)
Next
CloseGadgetList()
SetWindowCallback(@PPTcallback())
ProcedureReturn scrollarea
EndProcedure
Procedure GetPPTstate(PPTlistview)
ResetList(FindChild())
While NextElement(FindChild())
Index = ListIndex(FindChild())
If GetWindowLong_(FindChild()\childwindowhandle,#GWL_EXSTYLE)=257
ProcedureReturn Index+1
Break
Else
EndIf
Wend
EndProcedure
Procedure SetPPTstate(PPTlistview,item,State)
If State =0
ResetList(FindChild())
While NextElement(FindChild())
SetWindowLong_(FindChild()\childwindowhandle,#GWL_EXSTYLE,#WS_EX_WINDOWEDGE)
RedrawWindow_(FindChild()\childwindowhandle,0,0,3)
RedrawWindow_(GetParent_(GetParent_(FindChild()\childwindowhandle)),0,0,3)
ShowWindow_(FindChild()\childwindowhandle,#SW_SHOW)
Wend
ElseIf State=1
ResetList(FindChild())
While NextElement(FindChild())
If ListIndex(FindChild())=item-1
SetWindowLong_(FindChild()\childwindowhandle,#GWL_EXSTYLE,#WS_EX_DLGMODALFRAME)
RedrawWindow_(GetParent_(FindChild()\childwindowhandle),0,0,3)
SetWindowPos_( dockhandle,0,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE)
ShowWindow_(FindChild()\childwindowhandle,#SW_SHOW)
Else
SetWindowLong_(FindChild()\childwindowhandle,#GWL_EXSTYLE,#WS_EX_WINDOWEDGE)
RedrawWindow_(FindChild()\childwindowhandle,0,0,3)
RedrawWindow_(GetParent_(GetParent_(FindChild()\childwindowhandle)),0,0,3)
ShowWindow_(FindChild()\childwindowhandle,#SW_SHOW)
EndIf
Wend
EndIf
EndProcedure
OpenWindow(0,0,0,600,600,"PPTlistview Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
PPL=PPtListview(10,10,190,500,4)
ButtonGadget(1,250,100,150,20,"Get PPTLv State")
ButtonGadget(2,250,130,150,20,"Set PPTLv State To 0")
ButtonGadget(3,250,160,150,20,"Set PPTLv State To 2")
;-Event Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case 1
State=GetPPTstate(PPL)
MessageRequester("","PPT Listview State =" +" " +Str(State))
Case 2
SetPPTstate(PPL,0,0)
Case 3
SetPPTstate(PPL,2,1)
EndSelect
EndSelect
ForEver