Jump to content
Sign in to follow this  
er453r

Deleting listviewitem leaves a black space

Recommended Posts

er453r

Hi. My ListView has $LV_VIEW_TILE style. When I try to delete items from it (with _GUICtrlListViewDeleteItem) they are deleted, but the space after the deleted item is not filled. It just disappears, and leaves a black place. Any ideas?

I've tried to delete all items, and redraw the whole list, but it takes too long. Thanks in advance.

Share this post


Link to post
Share on other sites
FireLord

Some code would prompt a reply quicker I'm guessing.


[center]See the Helpfile[/center]
While Alive()
	 DrinkWine();
}
[center][/center]

Share this post


Link to post
Share on other sites
er453r

There's little coding here... but with pictures :P

We have a ListView:

post-19050-1195348519_thumb.jpg

Now:

_GUICtrlListViewDeleteItem($list,2)

Effect:

post-19050-1195348527_thumb.jpg

Hope it helps.

Share this post


Link to post
Share on other sites
GaryFrost

Being there is no script to look at, we'll have to guess.

Try

GuiSetState(@SW_LOCK)

before the delete and

GuiSetState(@SW_UNLOCK)

after the delete

if this don't work

you might want to look at the beta, and do something like

_GUICtrlListView_BeginUpdate

_GUICtrlListView_DeleteItem

_GUICtrlListView_EndUpdate

look at _GuiCtrlListView_SetItemPosition in beta

Tile/Icon view doesn't re-arrange the items automatically as far as I know

might also look at _GUICtrlListView_Arrange

on a roll here, won't re-arrange automatically unless you have $LVS_AUTOARRANGE style set

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
er453r

Ok, beta does wonders. BUT it doesn't support $LV_VIEW_TILE style :P

Share this post


Link to post
Share on other sites
GaryFrost

Ok, beta does wonders. BUT it doesn't support $LV_VIEW_TILE style :P

_GUICtrlListView_SetView($listview, 4)


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
er453r

Found it myself at least... Thanks for all the help :P

edit: maybe one more thing. Is it possible to change the tile icon size?

ok, managed myself ;)

Edited by er453r

Share this post


Link to post
Share on other sites
er453r

And is it possible to change font in listview?

Share this post


Link to post
Share on other sites
GaryFrost

And is it possible to change font in listview?

here's what sets the font of the UDF created listview

_SendMessage($hList, $WM_SETFONT, _WinAPI_GetStockObject ($DEFAULT_GUI_FONT), True)

if your using the GuiCtrlCreateListview, might look at GUICtrlSetFont

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
er453r

_SendMessage($hList, $WM_SETFONT, _WinAPI_GetStockObject ($DEFAULT_GUI_FONT), True)
Hm. And which part corresponds to size/weight?

And I'm using betas

_GUICtrlListView_Create
Edited by er453r

Share this post


Link to post
Share on other sites
GaryFrost

Hm. And which part corresponds to size/weight?

And I'm using betas

_GUICtrlListView_Create
_SendMessage($hList, $WM_SETFONT, _WinAPI_GetStockObject ($DEFAULT_GUI_FONT), True)

_WinAPI_GetStockObject ($DEFAULT_GUI_FONT) gets the handle to the default gui font.

the $WM_SETFONT message takes a handle to a font.

_WinAPI_CreateFontIndirect and $tagLOGFONT is what you need, the $tagLOGFONT isn't listed in the help at the moment, should be soon, but you can find it in the StructureConstants.au3 file

You'll also need to know how to do DllStruct functions


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
er453r

And how can I control the resizing of the beta ListView?

Share this post


Link to post
Share on other sites
drube

_SendMessage($hList, $WM_SETFONT, _WinAPI_GetStockObject ($DEFAULT_GUI_FONT), True)

_WinAPI_GetStockObject ($DEFAULT_GUI_FONT) gets the handle to the default gui font.

the $WM_SETFONT message takes a handle to a font.

_WinAPI_CreateFontIndirect and $tagLOGFONT is what you need, the $tagLOGFONT isn't listed in the help at the moment, should be soon, but you can find it in the StructureConstants.au3 file

You'll also need to know how to do DllStruct functions

Thanks, Gary. :)

Can you do it for us, then it won't end up in a mess like this:

#include <GUIConstants.au3>
#Include <GuiListView.au3>

Opt("GUIOnEventMode", 1)
$Form1 = GUICreate('testing', 767, 452, 193, 115, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS), 0)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_Close")
$LV1h = _GUICtrlListView_Create($Form1, '', 0, 0, 766, 390, _
                BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $WS_VSCROLL, $WS_CHILD, $WS_VISIBLE))
_GUICtrlListView_SetExtendedListViewStyle($LV1h, BitOR($LVS_EX_GRIDLINES,$LVS_EX_HEADERDRAGDROP, $WS_EX_CLIENTEDGE))

_GUICtrlListView_AddColumn($LV1h, 'Name', 230, 2)
_GUICtrlListView_AddItem($LV1h, 'Gemma Atkinson')
_GUICtrlListView_AddItem($LV1h, 'Jason "J" Brown')

GUISetState(@SW_SHOW)

_SetFont_hWnd($LV1h, 12.5, 400, 2, 'Lucida Console')

While True
    GuiGetMsg(); Idle
WEnd

Func Form1_Close()
    Exit 0
EndFunc


Func _SetFont_hWnd($hwnd, $size=8.5, $weight=400, $attr=0, $fontname="")
    Local $_tagfont = DllStructCreate($tagLOGFONT)
    Local $hDC = _WinAPI_GetDC($hwnd)
; lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72)
    Local $lf_height = -($size * _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSY)) / 72
    _WinAPI_ReleaseDC($hwnd, $hDC)

    DllStructSetData($_tagfont, 'Height', $lf_height);
    DllStructSetData($_tagfont, 'Width', 0); 
    DllStructSetData($_tagfont, 'Escapement', 0); 
    DllStructSetData($_tagfont, 'Orientation', 0); 
    DllStructSetData($_tagfont, 'Weight', $weight); 
    DllStructSetData($_tagfont, 'Italic',   BitAND($attr, 0x2))
    DllStructSetData($_tagfont, 'Underline', BitAND($attr, 0x4))
    DllStructSetData($_tagfont, 'StrikeOut', BitAND($attr, 0x8))
    DllStructSetData($_tagfont, 'CharSet', 0); 0 = ANSI_CHARSET
    DllStructSetData($_tagfont, 'OutPrecision', 0); 0 = OUT_DEFAULT_PRECIS
    DllStructSetData($_tagfont, 'ClipPrecision', 0); 0 = CLIP_DEFAULT_PRECIS
    DllStructSetData($_tagfont, 'Quality', 0); 0 = DEFAULT_QUALITY
; 0 = DEFAULT_PITCH, 1 = FIXED_PITCH, 2 = VARIABLE_PITCH
; $FF_DONTCARE = 0 (FF_ROMAN = 16, FF_SWISS = 32, FF_MODERN = 48, FF_SCRIPT = 64, FF_DECORATIVE = 80)
    DllStructSetData($_tagfont, 'PitchAndFamily', BitOR(0, $FF_DONTCARE))
    DllStructSetData($_tagfont, 'FaceName', $fontname); 

    Local $h_font = _WinAPI_CreateFontIndirect($_tagfont)
    _SendMessage($hwnd, $WM_SETFONT, $h_font, True)
EndFunc

^_^

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×