Jump to content

~ Write "no result" when ListView is empty (SOLVED)


EKY32
 Share

Recommended Posts

It is impossible to create any control on the top of a GuiCtrlCreateListView, i want a label that says "no result" when the list view is empty.. is that possible anyway i don't know?

Thank you.

Edited by EKY32

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Link to comment
Share on other sites

Well well, thanls again it's useful Posted Image

But sir, i saw many programs have a list view control with an ordinary label on it, looks like this:

Posted Image

I'll be thankful if there is a better way.

Thank you you are great.

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Link to comment
Share on other sites

Ok, try the example below:

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global Const $clrWindowText = _WinAPI_GetSysColor($COLOR_WINDOWTEXT)
Global Const $clrWindow = _WinAPI_GetSysColor($COLOR_WINDOW)
Global $hForm, $hListView, $tRECT, $hDC

$tRECT = DllStructCreate($tagRect)
DllStructSetData($tRECT, "Left", 100)
DllStructSetData($tRECT, "Top", 100)
DllStructSetData($tRECT, "Right", 300)
DllStructSetData($tRECT, "Bottom", 250)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    $hForm = GUICreate("ListView label example.", 640, 300)

    $hListView = GUICtrlCreateListView("", 2, 2, 636, 268)
    $hListView = GUICtrlGetHandle($hListView)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Filename", 340)
    _GUICtrlListView_AddColumn($hListView, "Filesize", 80)
    _GUICtrlListView_AddColumn($hListView, "Filetype", 100)
    _GUICtrlListView_AddColumn($hListView, "Last modified", 100)

    ; uncomment to view result!
    ;_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)

    GUISetState()

    $hDC = _WinAPI_GetDC($hListView)

    _WM_PAINT()
    GUIRegisterMsg($WM_PAINT, "_WM_PAINT")

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    _Exit()

EndFunc   ;==>_Main

Func _WM_PAINT()

    Select
        Case Not _GUICtrlListView_GetItemCount($hListView)
            _WinAPI_UpdateWindow($hForm)
            _WinAPI_DrawText($hDC, "The list view is empty!", $tRECT, $DT_CENTER)
            _WinAPI_SetTextColor($hDC, $clrWindowText)
            _WinAPI_SetBkColor($hDC, $clrWindow)
            _WinAPI_SetBkMode($hDC, $TRANSPARENT)
    EndSelect

    Return 'GUI_RUNDEFMSG'
EndFunc   ;==>_WM_PAINT

Func _Exit()
    _WinAPI_ReleaseDC(0, $hDC)
    _WinAPI_InvalidateRect(0, 0)
    $tRECT = 0
    Exit
EndFunc   ;==>_Exit

Regards,

João Carlos.

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

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...