Dana Posted December 18, 2009 Posted December 18, 2009 I'm not sure of the best way to proceed here.I'm working on an app with a listview to display data read from a file, and accept new data. The list is 16 columns and an indefinite number of rows (could be thousands). There also needs to be a "totals" line for ten of the columns, which is always displayed beneath the appropriate columns. I have a second listview for this, with no header, placed in the appropriate place. This seems to work if I don't move anything. I'm having no trouble with the data manipulation but the GUI is giving me fits.Part of the problem is that I want to always display all of the columns on any likely size monitor (I'm assuming 1024 as the minimum width). This means a fontsize of 7, which is small but not completely unreadable. I also want the main window to be resizeable, which leads to my first problem. When I resize the window, all of the columns adjust in size, even though I've explicitly set their widths. This wouldn't be so bad if the lower (one line) listview didn't resize a bit differently, so it no longer lines up. Also if I resize the window, I get two horizontal scroll bars... I want one scroll bar that keeps both listviews lined up.Ideally, I'd like to be able to resize the window, and have the right hand edge simply cover up part of the listview (the far rightmost column is the largest, a "remarks" column which is OK if it's partially obscured).I tried putting the datalists in a non-resizeable child window, inside a resizeable main window, but I'm having other problem with the child window (namely, that I can't get it to work at all... but that's another thread).Is there a better approach?-Dana
Dana Posted December 18, 2009 Author Posted December 18, 2009 OK, I have it... part way. I need to set GUICtrlSetResizing ($listview, $GUI_DOCKLEFT) and not use $GUI_DOCKSIZE... which means I have to do it a little differently than I planned, but it seems to work. Thus I don't need to mess with child windows, but at least I've learned something doing it.Question: Is there any way to get an event when the horizontal scrollbar of a datalist is moved? Or do I just have to check the x position of an item each time through the "while 1" loop and compare it with the last position? Seems CPU intensive, there should be something like GUISetOnEvent($GUI_EVENT_RESIZED, "userfunction")?-Dana
danielkza Posted December 19, 2009 Posted December 19, 2009 OK, I have it... part way. I need to set GUICtrlSetResizing ($listview, $GUI_DOCKLEFT) and not use $GUI_DOCKSIZE... which means I have to do it a little differently than I planned, but it seems to work. Thus I don't need to mess with child windows, but at least I've learned something doing it.Question: Is there any way to get an event when the horizontal scrollbar of a datalist is moved? Or do I just have to check the x position of an item each time through the "while 1" loop and compare it with the last position? Seems CPU intensive, there should be something like GUISetOnEvent($GUI_EVENT_RESIZED, "userfunction")?-DanaBy 'datalist', do you mean 'ListView control'? If yes, you need to intercept one of it's notification messages using GUIRegisterMsg.I think you may be looking for LVN_BEGINSCROLL or LVN_ENDSCROLL.
Dana Posted December 20, 2009 Author Posted December 20, 2009 Sorry, yes, I mean listview... $datalist is the control id. OK, I have" GUIRegisterMsg($WM_NOTIFY, "scrolled") <snip> While 1 $msg = GUIGetMsg() Sleep(1250) ; keep the GUI from eating up all the CPU cycles WEnd <snip> Func scrolled($gui, $msg) If $msg = $GUI_EVENT_CLOSE Then Exit ElseIf ($msg = "LVN_BEGINSCROLL" Or $msg = "LVN_ENDSCROLL") Then MsgBox(4096, "debug", _GUICtrlListView_GetItemPositionX(GUICtrlGetHandle($datalist) & @CRLF & $msg, 0)) Else EndIf EndFunc ;==>scrolled However, since this doesn't work, I assume I'm missing something. Obviously "LVN_BEGINSCROLL" is not the actual $msg contents. -Dana
Dana Posted December 21, 2009 Author Posted December 21, 2009 OK, well, I did it the inelegant way, but it works: While 1 Sleep(250) ; keep the GUI from eating up all the CPU cycles ; check if colums have been resized or scrolled and adjust position of totals if so For $i = 0 To 15 $colwidth[$i] = _GUICtrlListView_GetColumnWidth($datalist, $i) If $i = 0 Then $curcolpos = 0 Else $curcolpos = $curcolpos + $colwidth[$i - 1] EndIf $colpos[$i] = $curcolpos If $oldcolpos[$i] <> $colpos[$i] Or $basecolpos <> _GUICtrlListView_GetItemPositionX(GUICtrlGetHandle($datalist), $i) Then ;MsgBox(4096, "debug", "scroll moved " & _GUICtrlListView_GetItemPositionX(GUICtrlGetHandle($datalist), $i)) GUICtrlSetPos($totcol[5], $colpos[5] + 30 + _GUICtrlListView_GetItemPositionX(GUICtrlGetHandle($datalist), 5), $h - 93) For $c = 6 To 14 GUICtrlSetPos($totcol[$c], $colpos[$c] + 30 + _GUICtrlListView_GetItemPositionX(GUICtrlGetHandle($datalist), $c), $h - 90) $oldcolpos[$c] = $colpos[$c] Next $basecolpos = _GUICtrlListView_GetItemPositionX(GUICtrlGetHandle($datalist), $i) EndIf Next WEnd $colwidth[] and $basecolpos are initially defined when the listview is created. I'm assuming that to use LVN_ENDSCROLL, etc. I'd have to create the listview using the UDF version... perhaps I'll revisit it later to make it more elegant but now I'd rather move on to the actual functions of the program. -Dana
AdmiralAlkex Posted December 21, 2009 Posted December 21, 2009 I'm assuming that to use LVN_ENDSCROLL, etc. I'd have to create the listview using the UDF version... perhaps I'll revisit it later to make it more elegant but now I'd rather move on to the actual functions of the program.-DanaYou're assuming wrong, just take a look at the example in the helpfile, it's obviously created to be used for both native and UDF controls. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now