Results 1 to 13 of 13

Thread: LABEL on listview

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    LABEL on listview

    I dont know if is possible.....

    i need to positioning in center of listview a transparent and foreground Label with the caption:"ATTENZIONE!" untill the listview is filled... and then hide the label.

    Tks.

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: LABEL on listview

    Not sure if you can do it with a label, but you can a textbox (and you can lock the textbox and make it LOOK like a label).

  3. #3
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    Re: LABEL on listview

    How do you get the textbox transparent?

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: LABEL on listview

    Ah....I SEEEE...so, you are saying OP wants a transparent 'something' with just LETTERS being shown, right?

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: LABEL on listview

    OK, so use a RICHTEXTBOX instead of a label...see this example:

    Put a RICHTEXTBOX on a form on top of a listbox...

    Code:
    Option Explicit
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Const GWL_EXSTYLE = (-20)
    Const WS_EX_TRANSPARENT = &H20&
    Private Sub Form_Load()
    Dim x As Integer
    For x = 0 To 10
        List1.AddItem (CStr(x))
    Next x
    Dim result As Long
    result = SetWindowLong(RichTextBox1.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT)
    End Sub

  6. #6
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    Re: LABEL on listview

    Very cool, sam

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: LABEL on listview

    This is really what .MousePointer = vbHourglass is for.

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,714

    Re: LABEL on listview

    You can also consider setting the empty markup text:



    It requires subclassing; but in the end it's probably the same amount of work if you want to always have it present when the ListView is empty and keep it in alignment after resize.

    In a WM_NOTIFY handling routine,
    Code:
        Case LVN_GETEMPTYMARKUP
            Dim nmlvem As NMLVEMPTYMARKUP
            Dim sEMText As String
            sEMText = "Empty markup text."
            CopyMemory ByVal VarPtr(nmlvem), ByVal lParam, LenB(nmlvem)
            CopyMemory nmlvem.szMarkup(0), ByVal StrPtr(sEMText), LenB(sEMText)
            nmlvem.dwFlags = EMF_CENTERED
            CopyMemory ByVal lParam, ByVal VarPtr(nmlvem), LenB(nmlvem)
            DoLVNotify = 1
            Exit Function
    
    'where
    Public Const L_MAX_URL_LENGTH = 2084
    Public Const EMF_CENTERED = &H1
    Public Type NMLVEMPTYMARKUP
        hdr As NMHDR
        dwFlags As Long
        szMarkup(0 To ((L_MAX_URL_LENGTH * 2) - 1)) As Byte
    End Type

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: LABEL on listview

    Quote Originally Posted by fafalone View Post
    You can also consider setting the empty markup text:



    It requires subclassing; but in the end it's probably the same amount of work if you want to always have it present when the ListView is empty and keep it in alignment after resize.

    In a WM_NOTIFY handling routine,
    Code:
        Case LVN_GETEMPTYMARKUP
            Dim nmlvem As NMLVEMPTYMARKUP
            Dim sEMText As String
            sEMText = "Empty markup text."
            CopyMemory ByVal VarPtr(nmlvem), ByVal lParam, LenB(nmlvem)
            CopyMemory nmlvem.szMarkup(0), ByVal StrPtr(sEMText), LenB(sEMText)
            nmlvem.dwFlags = EMF_CENTERED
            CopyMemory ByVal lParam, ByVal VarPtr(nmlvem), LenB(nmlvem)
            DoLVNotify = 1
            Exit Function
    
    'where
    Public Const L_MAX_URL_LENGTH = 2084
    Public Const EMF_CENTERED = &H1
    Public Type NMLVEMPTYMARKUP
        hdr As NMHDR
        dwFlags As Long
        szMarkup(0 To ((L_MAX_URL_LENGTH * 2) - 1)) As Byte
    End Type
    Exit function...
    But where the init of function code?
    And how to call it?

  10. #10
    Hyperactive Member
    Join Date
    Oct 2016
    Posts
    369

    Re: LABEL on listview

    fafalone expects you to write your own subclass and capture the WM_NOTIFY message

  11. #11
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,714

    Re: LABEL on listview

    Well it's just every ListView-related sample code on every VB6 website all use the same format, so I started from the point that since the sample code what I posted could be inserted into as-is is ubiquitous, nobody would have to write their own anything unless they had never seen a subclassed ListView in their life. Nothing wrong with that being the case it just wasn't my default assumption.
    See the Virtual Mode Grouping project in my sig for how to set up subclassing that handles LVN_ messages.

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: LABEL on listview

    I'M very sorry... i'm not in VB6 but VBA for excel.
    Tks

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: LABEL on listview

    Thread moved from the VB6 forum to the 'Office Development/VBA' forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width