Notifications
Clear all

[Closed] Using ObjectListView in maxform control

Hi guys!

I’m trying to use ObjectListView instead of standard listview in my scripts, and I could not force Enter/Ecs/Tab keys working.

I found this thread by Denis and it helped me to deal with that keys when I was using DataGridView:
http://forums.cgsociety.org/showthread.php?t=939103

But with ObjectListView it does not work.

I wonder may be OLV itself blocks/overrides DLGC_WANTALLKEYS message?

16 Replies

ObjectListView probably needs LVM_GETEDITCONTROL message to get edit control (instead of TVM_GETEDITCONTROL)

where can i get ObjectListView?
edit… never mind. i found it.

Sorry Denis, I mistyped, it was WM_GETDLGCODE that should be catched in the hook.

Actually it catches, debug shows that this message gets catched right on the some-edit-starting-event, then DLGC_WANTALLKEYS is passed but nothing happens.

LVM_GETEDITCONTROL by the way never gets called in hook.

OLV is so cool, I could not resist to not use it in the scripts. I even decided to rewrite some of tool to use this control instead of LV and DGV.

The only thing (so far) is to have keys enter/tab working.

everything works right for listview. objectlistview is extended listview control as i see. so it has to work for OLV as well:


fn CreateNativeWindowOps forceRecompile:on = if forceRecompile do
(
	source = ""
	source += "using System;
"
	source += "using System.Windows.Forms;
"
	source += "public class WindowHook : NativeWindow
"
	source += "{
"
	source += "	private const int WM_GETDLGCODE	 = 0x0087;
"
	source += "	private const int DLGC_WANTALLKEYS  = 0x0004;
"
	source += "	public WindowHook() { }
"
	source += "	protected override void WndProc(ref Message m)
"
	source += "	{
"
	source += "		switch (m.Msg)
"
	source += "		{
"
	source += "			case WM_GETDLGCODE:
"
	source += "				m.Result = (IntPtr)DLGC_WANTALLKEYS;
"
	source += "				break;
"
	source += "			default:
"
	source += "				base.WndProc(ref m);
"
	source += "				break;
"
	source += "		}
"
	source += "	}
"
	source += "}
"

	csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
	compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

	compilerParams.ReferencedAssemblies.AddRange #("System.dll", "System.Windows.Forms.dll")

	compilerParams.GenerateInMemory = true
	compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
		
	global NativeWindowOps = compilerResults.CompiledAssembly
)
CreateNativeWindowOps()

try(destroydialog lv_rol) catch()
rollout lv_rol "ListView Test" width:200 height:200
(
	local hook = dotnetobject "WindowHook"
	
	dotnetcontrol lv "ListView" width:200 height:200 pos:[0,0] 
	on lv AfterLabelEdit s e do
	(	
		hook.ReleaseHandle()
	)
	on lv BeforeLabelEdit s e do
	(	
		LVM_FIRST = 0x1000
		LVM_GETEDITCONTROL = (LVM_FIRST + 24)
		
		hwnd = windows.SendMessage s.Handle LVM_GETEDITCONTROL 0 0
		hook.AssignHandle (dotnetobject "IntPtr" hwnd)
	)
	on lv_rol open do
	(
		lv.LabelEdit = on
		lv.View = lv.View.Details
		lv.HeaderStyle = lv.HeaderStyle.Clickable
		lv.Columns.Add "Items" 150
		for item in #("listview item 1", "listview item 2", "listview item 3") do lv.items.Add item
	)
)
createdialog lv_rol

Obviously it should but it is not working.

This thing does not returning the handle of the editor:

windows.SendMessage s.Handle LVM_GETEDITCONTROL 0 0

But I can get the editor handle by using this in StartEditing handler:

event_args.Control.Handle

I attached the hook to that handle but it does not work.

It seems OLV blocks something inside. It is based on ListView, but there’s so much code around it that I’m not sure if it has something in common with original.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

is StartEditing a specific OLV event?
probably they overrode whole edit label mechanism. they show their own textbox control.
can you check what is the class of this control?
you probably can easy setup KeyDown and KeyUp events for the control.

Yes it they have specific event.
It is TextBox control.

Thank you Denis, I completely forgot about simple things Will try with KeyDown.

don’t forget to set the textbox property AcceptsReturn to TRUE and turn off enableAccelerators

I’ve made Enter and Esc working with KeyUp event handler, it is all right now.

I’ve read a little a source code of ObjectListView and noticed that all key presses handled by ProcessDialogKey function. It seems that 3ds max blocks totally this function, since ObjectListView works with Ctrl-A, Ctrl-C, Tabs and so on.

I believe that all that keys can be processed with keydown/keyup functions but may be there is any way to force ProcessDialogKey work in MaxForm?

Thank you!

OLV… do you use it in-house? i would never use any third party ‘anything’ in my production. especially if it’s free.

Page 1 / 2