Jump to content

Deleting listviewitem leaves a black space


er453r
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

  • 2 weeks later...

_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

^_^

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...