hey everybody I'm trying to get text out of multi-selected items/checkbox in REPORTVIEW
and I need help with that,
here is a piece of code I'm trying to play with to get a demo of this concept:
#DefineFunction LVGetItemText(hListView,iItem,iSubItem)
user32=StrCat(DirWindows(1),"user32.dll")
LVM_FIRST = 4096
LVM_GETITEMTEXTA = LVM_FIRST + 45
bufsize = 255 ; you can make this value bigger if your item's text is very long, or rewrite this UDF in a more clever way to use the TextStrLen variable below
TextBuf=BinaryAlloc(bufsize + 1)
TextAd=IntControl(42,TextBuf,0,0,0)
;-----Make LVITEM structure----------------------------------------------------
LVITEM=BinaryAlloc(36) ; Create buffer for structure
BinaryPoke4(LVITEM,0,1) ; mask
BinaryPoke4(LVITEM,4,iItem) ; iItem
BinaryPoke4(LVITEM,8,iSubItem) ; iSubitem
;BinaryPoke4(LVITEM,12,0) ; state
;BinaryPoke4(LVITEM,16,0) ; stateMask
BinaryPoke4(LVITEM,20,TextAd) ; pszText
BinaryPoke4(LVITEM,24,255) ; cchTextMax
;BinaryPoke4(LVITEM,28,0) ; iImage
;BinaryPoke4(LVITEM,32,0) ; LParam
;-------------------------------------------------------------------------------
TextStrLen = DllCall(user32,long:"SendMessageA",long:hListView,long:LVM_GETITEMTEXTA,long:iItem,lpbinary:LVITEM) ; this fills the TextBuffer we made and returns the string length (though not actually used by us here)
Message("StrLen",textstrlen)
BinaryEodSet(TextBuf,bufsize + 1)
itemtext=BinaryPeekStr(TextBuf,0,bufsize) ;selected item
BinaryFree(LVITEM)
BinaryFree(TextBuf)
Return itemtext
#EndFunction
#DefineFunction MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
Switch MyDialog_Message ; Switch based on Dialog Message type
Case @deInit ; Standard Initialization message
DialogProcOptions(MyDialog_Handle,@dePbPush,@true)
DialogProcOptions(MyDialog_Handle,@deMiSelect,@true)
DialogProcOptions(MyDialog_Handle,@dcText,@true)
DialogProcOptions(MyDialog_Handle, @deRvrSelect, @true)
DialogProcOptions(MyDialog_Handle, @deRvhClick, @true)
DialogProcOptions(MyDialog_Handle, @deRvrDblclick, @true)
DialogProcOptions(MyDialog_Handle, @deRviCheck, @true)
DialogProcOptions(MyDialog_Handle, @deRviText, @true)
DialogControlSet(MyDialog_Handle, "ReportView_1", @dcCheck , @true)
Return(@retdefault)
Case @deRviText
message("", LVGetItemText(MyDialog_Handle, 0,0))
message("MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd, ", strcat(MyDialog_Handle,",",MyDialog_Message,",",MyDialog_Name,",",MyDialog_EventInfo,",",rsvd))
Case @deRviCheck
message("", LVGetItemText(MyDialog_Handle, 0,1))
message("MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd, ", strcat(MyDialog_Handle,",",MyDialog_Message,",",MyDialog_Name,",",MyDialog_EventInfo,",",rsvd))
Case @deRvhClick
message("", LVGetItemText(MyDialog_Handle, 1,0))
message("MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd, ", strcat(MyDialog_Handle,",",MyDialog_Message,",",MyDialog_Name,",",MyDialog_EventInfo,",",rsvd))
Case @deRvrDblclick
message("", LVGetItemText(MyDialog_Handle, 1,1))
message("MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd, ", strcat(MyDialog_Handle,",",MyDialog_Message,",",MyDialog_Name,",",MyDialog_EventInfo,",",rsvd))
Case @deRvrSelect
message("", LVGetItemText(MyDialog_Handle, 2,2))
message("MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd, ", strcat(MyDialog_Handle,",",MyDialog_Message,",",MyDialog_Name,",",MyDialog_EventInfo,",",rsvd))
Case @dePbPush
If MyDialog_Name == "PushButton_RightClickMe" ; Right Click Me!
message("right", MyDialog_Name)
Pause('Notice','You left-clicked the button')
Return(@retNoExit )
ElseIf MyDialog_Name == "PushButton_Cancel" ; Cancel
Pause('Notice','You pressed Cancel')
Return(@retCancel)
EndIf ; MyDialog_Name
Return(@retDefault)
Case @deMiSelect
If MyDialog_Name == "cmi1_PushButton_RightClickMe" ; PushButton_RightClickMe Context Menu One
Pause('You Selected:','Context menu One')
Return(@retNoExit )
ElseIf MyDialog_Name == "cmi3_PushButton_RightClickMe" ; cmi1_PushButton_RightClickMe Subcontext Menu One
message("sub", MyDialog_Name)
Pause('You Selected:','Subcontext menu One')
Return(@retNoExit )
ElseIf MyDialog_Name == "cmi2_PushButton_RightClickMe" ; PushButton_RightClickMe Context menu Two
Pause('You Selected:','Context menu Two')
Return(@retNoExit )
ElseIf MyDialog_Name == "mbi1_MyDialog" ; Dialog_Bar Menu Item One
;NOTICE : The user-defined callback is not called in response to the mouse selection of menu
;item that have an associated dropdown menus or submenus. The associated dropdown or submenu
;is displayed instead. Hot-keys should not be used with menu items that display a dropdown
;or submenu.
Return(@retNoExit )
ElseIf MyDialog_Name == "mbi2_MyDialog" ; mbi1_MyDialog SubMenu Item One
Pause('You Selected:','SubMenu item One')
Return(@retNoExit )
ElseIf MyDialog_Name == "mbi3_MyDialog" ; Dialog_Bar Menu Item Two
Pause('You Selected:','Menu item Two')
Return(@retNoExit )
EndIf ; MyDialog_Name
Return(@retDefault)
EndSwitch ; MyDialog_Message
Return(@retDefault)
#EndFunction ; End of Dialog Callback MyDialogCallbackProc
;MENUITEMs can be displayed on a menu bar or as a menu item associated with a drop-down, context menu or submenu.
;
;Dropdown menus are created by placing the name of a MENUITEM displayed in the menu bar in the parent attribute
;of the menu item's template entry. A submenu is started by placing the name of a MENUITEM other than a menu bar
;displayed menu item in the parent attribute.
;
;Context menus are usually activated by right-clicking the client area of a control or dialog. Create context
;menus by specifying the name of a control in the parent attribute. If you use the DEFAULT keyword as the
;MENUITEM parent, the context menu will by associated with the dialog and display when the user right clicks on
;an 'empty' area of the dialog or on any control that does not already have a system or template supplied context
;menu.
rvVariable1[0] = "banana"
rvVariable1[1] = "mishmish"
MyDialogFormat=`WWWDLGED,6.2`
MyDialogCaption=`Menu Sample`
MyDialogX=241
MyDialogY=080
MyDialogWidth=242
MyDialogHeight=116
MyDialogNumControls=010
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`073,047,078,012,PUSHBUTTON,"PushButton_RightClickMe",DEFAULT,"Right Click Me!",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`093,093,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`000,000,000,000,MENUITEM,"cmi1_PushButton_RightClickMe","PushButton_RightClickMe","Context Menu One",DEFAULT,10,DEFAULT`
MyDialog004=`000,000,000,000,MENUITEM,"cmi3_PushButton_RightClickMe","cmi1_PushButton_RightClickMe","Subcontext Menu One",DEFAULT,10,DEFAULT`
MyDialog005=`000,000,000,000,MENUITEM,"cmi2_PushButton_RightClickMe","PushButton_RightClickMe","Context menu Two",DEFAULT,20,DEFAULT`
MyDialog006=`000,000,000,000,MENUBAR,"Dialog_Bar"`
MyDialog007=`000,000,000,000,MENUITEM,"mbi1_MyDialog","Dialog_Bar","Menu Item One",DEFAULT,10,DEFAULT`
MyDialog008=`000,000,000,000,MENUITEM,"mbi2_MyDialog","mbi1_MyDialog","SubMenu Item One",DEFAULT,10,DEFAULT`
MyDialog009=`000,000,000,000,MENUITEM,"mbi3_MyDialog","Dialog_Bar","Menu Item Two",DEFAULT,20,DEFAULT`
MyDialog010=`159,027,058,066,REPORTVIEW,"ReportView_1",rvVariable1,DEFAULT,DEFAULT,100,142606336,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed=Dialog("MyDialog")
exit
arrArray[0] = "dudu"
arrArray[1] = "dudu2"
MyDialogFormat=`WWWDLGED,6.2`
MyDialogCaption=`ReportView Select all`
MyDialogX=138
MyDialogY=141
MyDialogWidth=566
MyDialogHeight=243
MyDialogNumControls=004
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`165,223,036,012,PUSHBUTTON,"PushButton_SelectAll",DEFAULT,"Select All",2,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`265,223,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`365,223,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog004=`187,063,174,100,REPORTVIEW,"ReportView_1",arrArray,DEFAULT,DEFAULT,30,142606336,DEFAULT,DEFAULT,"192|192|192"`
ButtonPushed=Dialog("MyDialog")
exit
;maybe also good idea for debugging:
#DefineFunction TimerProc(MyDialogHandle,MyDialogMessage,MyDialogControlID,MyDialogEventInfo,MyDialogChangeInfo)
Switch MyDialogMessage
Case @deInit
; enable 1 second timer events
;DialogProcOptions(MyDialogHandle, @deTimer, 1000)
Return (@retdefault)
Case @detimer
Clock=DialogControlGet(MyDialogHandle, "VaryText_1", @dcTitle)
Clock=Clock-1
If Clock==0 Then Return(2) ; exit, buttonpushed==2
DialogControlSet(MyDialogHandle, "VaryText_1", @dcTitle, Clock)
Return(@retDefault)
EndSwitch ; MyDialogMessage
Return(@retDefault) ; Do default processing
#EndFunction
TimerFormat=`WWWDLGED,6.2`
TimerCaption=`Timer Example`
TimerX=078
TimerY=129
TimerWidth=121
TimerHeight=117
TimerNumControls=003
TimerProcedure=`TimerProc`
TimerFont=`DEFAULT`
TimerTextColor=`DEFAULT`
TimerBackground=`DEFAULT,DEFAULT`
TimerConfig=0
TimerDPI=`96,8,16`
Timer001=`012,082,035,014,PUSHBUTTON,"PushButton_1",DEFAULT,"OK",1,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer002=`066,082,035,014,PUSHBUTTON,"PushButton_2",DEFAULT,"Cancel",0,DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Timer003=`023,015,070,053,VARYTEXT,"VaryText_1",clock,"10",DEFAULT,DEFAULT,@csCenter,"Tahoma|49152|70|34","128|0|0",DEFAULT`
ButtonPushed=Dialog("Timer")
Apologies if I didn't read enough and missed something but, assuming I understand, wouldn't DialogControlGet() with @dcSelect (6) option be a lot easier?
Jim
Make that the @dcGetChecked request as the third parameter to the DialogControlGet function.
#DefineFunction MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
Switch MyDialog_Message ; Switch based on Dialog Message type
Case @deInit ; Standard Initialization message
DialogProcOptions(MyDialog_Handle,@dePbPush,@true)
break
Case @dePbPush
If MyDialog_Name == "PushButton_RightClickMe" ; Right Click Me!
aSelected = DialogControlGet( MyDialog_Handle, "ReportView_1", @dcGetChecked , 0)
if ArrInfo(aSelected, 6) then strText = ArrayItemize(aSelected, @LF)
else strText = 'None'
Message('Checked Items', strText)
Return(@retNoExit )
endif
break
endswitch
return @retDefault
#EndFunction
rvVariable1[0] = "banana"
rvVariable1[1] = "mishmish"
MyDialogFormat=`WWWDLGED,6.2`
MyDialogCaption=`Menu Sample`
MyDialogX=241
MyDialogY=080
MyDialogWidth=242
MyDialogHeight=116
MyDialogNumControls=010
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`073,047,078,012,PUSHBUTTON,"PushButton_RightClickMe",DEFAULT,"Right Click Me!",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`093,093,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`000,000,000,000,MENUITEM,"cmi1_PushButton_RightClickMe","PushButton_RightClickMe","Context Menu One",DEFAULT,10,DEFAULT`
MyDialog004=`000,000,000,000,MENUITEM,"cmi3_PushButton_RightClickMe","cmi1_PushButton_RightClickMe","Subcontext Menu One",DEFAULT,10,DEFAULT`
MyDialog005=`000,000,000,000,MENUITEM,"cmi2_PushButton_RightClickMe","PushButton_RightClickMe","Context menu Two",DEFAULT,20,DEFAULT`
MyDialog006=`000,000,000,000,MENUBAR,"Dialog_Bar"`
MyDialog007=`000,000,000,000,MENUITEM,"mbi1_MyDialog","Dialog_Bar","Menu Item One",DEFAULT,10,DEFAULT`
MyDialog008=`000,000,000,000,MENUITEM,"mbi2_MyDialog","mbi1_MyDialog","SubMenu Item One",DEFAULT,10,DEFAULT`
MyDialog009=`000,000,000,000,MENUITEM,"mbi3_MyDialog","Dialog_Bar","Menu Item Two",DEFAULT,20,DEFAULT`
MyDialog010=`159,027,058,066,REPORTVIEW,"ReportView_1",rvVariable1,DEFAULT,DEFAULT,100,142606336,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed=Dialog("MyDialog")
Yeah...what he said.
Jim
thanks i will check it out!