Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
%IDC_ListBox = 500
%IDC_Button = 600
Global hDlg, hProperty As Dword
Global MyArray() As String
Function PBMain() As Long
ReDim MyArray(27)
Array Assign MyArray() = "Name", "Text","Image","Top", "Left", "Width","Height","Tooltip", _
"FontName","FontSize", "FontAttr","FontColor","Style","ExtStyle", _
"MyControl","Test goes here!","Face","50","50","200","200","Description", _
"Courier","12","0","255","21","24"
Dialog New Pixels, 0, "Test",300,300,200,185, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button, "Show Property Dialog", 20,20,150,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_Command
If Cb.Ctl = %IDC_Button And Cb.CtlMsg = %BN_Clicked Then DisplayPropertyDialog
Case %WM_Destroy
Dialog End hProperty
End Select
End Function
Sub DisplayPropertyDialog
Dialog New Pixels, hDlg, "Property Dialog",100,100,200,185, %WS_SysMenu, 0 To hProperty
Control Add ListBox, hProperty, %IDC_ListBox, MyArray(), 0,0,200,200, %LBS_Notify Or %WS_TabStop Or %LBS_MultiColumn, %WS_Ex_Left
Control Send hProperty, %IDC_ListBox, %LB_SetColumnWidth, 100, 0
Dialog Show Modal hProperty Call PropertyProc
End Sub
CallBack Function PropertyProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
ListBox Select hProperty, %IDC_ListBox, 2
Case %WM_Command
Select Case Cb.Ctl
Case %IdCancel : Dialog End hProperty
Case %IdOk : EditProperty
Case %IDC_ListBox : If Cb.CtlMsg = %LBN_DblClk Then EditProperty
End Select
End Select
End Function
Sub EditProperty
Local x,y,w,h,iCount,iShift,iSelected As Long, value$,title$
ListBox Get Count hProperty, %IDC_ListBox To iCount
ListBox Get Select hProperty, %IDC_ListBox To iSelected
'determine if in 1st column or second
If iSelected <= iCount/2 Then
iShift = iCount/2
ListBox Get Text hProperty, %IDC_ListBox, iSelected To title$
Else
ListBox Get Text hProperty, %IDC_ListBox, iSelected-iCount/2 To title$
End If
'show InputBox next to dialog
ListBox Get Text hProperty, %IDC_ListBox, iSelected + iShift To value$
Dialog Get Loc hDlg To w,h
Dialog Get Loc hProperty To x,y : x = x + w : y = y + h
Dialog Get Size hProperty To w,h
value$ = InputBox$("Enter " + title$ + ":","Edit Property", value$, x+w+20, y + 20)
'validate results before committing to storage
If Len(value$) Then ListBox Set Text hProperty, %IDC_ListBox, iSelected + iShift, value$
ListBox Select hProperty, %IDC_ListBox, iSelected
End Sub
'gbs_00695
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm