Closed shaoerkuai closed 1 year ago
It panics because the listview doesn't exist yet. Windows will tell you when the controls are ready by sending you a WM_INITDIALOG
message, which is when you have your controls.
Since this is a very basic mistake, I suggest you to learn the basics of Win32 API first.
I just learned the Window Procedure and has made list view worked without panic.
Here is a workaround that might help other users who don't know much about the Win32 API:
notify := myWindow.wnd.On()
make sure that DO PUT IT before RunAsMain(), since RunAsMain will block.
notify.WmCreate(func(p wm.Create) int {
// DO WHAT YOU WANT
dwStyle := myWindow.table.ExtendedStyle()
dwStyle |= co.LVS_EX_FULLROWSELECT
dwStyle |= co.LVS_EX_GRIDLINES
myWindow.table.SetExtendedStyle(true, dwStyle)
myWindow.table.Columns().Add([]int{80, 70, 120}, "Col 1", "Col 2", "Col 3")
return 0
})
I think I will contribute some basic docs pr to the project once I figure out some things, this is a promising project if someone sticked to windows classic gui programming (I am working on embbed devices testing tools development, and I don't need Qt or Fyne, they areunnecessary).
Demo:
I'm using ListView.Add().Columns() but nothing shown:(
And if call me.table.Items().Add("value1", "value2")
A panic occured :panic: LVM_SETITEMTEXT col 1, "value2" failed.