Results 1 to 2 of 2

Thread: Creating an Enabled FileList in which you cannot make Selections.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    25

    Question Creating an Enabled FileList in which you cannot make Selections.

    Hey all!

    My objective is to have a FileList which has black color text, but I don't want the user to be able to make selections (which highlights an item)

    I was also looking to see if it was possible to disable the FileList, and re-color the text, but this won't work.


    Is there a way where I can prevent the user from making selections? Perhaps by cancelling the MouseDown event?

    I'm looking for a very simple solution. If it's too much effort, I'll just leave it as is. :P



    Thanks for the help, it's greatly appreciated.
    God Bless,
    -Nick.

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Creating an Enabled FileList in which you cannot make Selections.

    Code:
    'In a BAS module
    
    Option Explicit
    
    Private Declare Function DefSubclassProc Lib "comctl32.dll" Alias "#413" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function SetWindowSubclass Lib "comctl32.dll" Alias "#410" (ByVal hWnd As Long, ByVal pfnSubclass As Long, ByVal uIdSubclass As Long, ByVal dwRefData As Long) As Long
    Private Declare Function RemoveWindowSubclass Lib "comctl32.dll" Alias "#412" (ByVal hWnd As Long, ByVal pfnSubclass As Long, ByVal uIdSubclass As Long) As Long
    
    Public Function Subclass(ByRef FileLstBox As FileListBox) As Boolean
        Subclass = SetWindowSubclass(FileLstBox.hWnd, AddressOf SubclassProc, ObjPtr(FileLstBox), AddressOf SubclassProc)
    End Function
    
    Private Function SubclassProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long, _
                                  ByVal uIdSubclass As Long, ByVal dwRefData As Long) As Long
        Const WM_CHAR = &H102&, WM_DESTROY = &H2&, WM_KEYDOWN = &H100&, WM_LBUTTONDOWN = &H201&
    
        Select Case uMsg
            Case WM_LBUTTONDOWN, WM_KEYDOWN, WM_CHAR
                Exit Function
    
            Case WM_DESTROY
                uIdSubclass = RemoveWindowSubclass(hWnd, dwRefData, uIdSubclass):  Debug.Assert uIdSubclass
        End Select
    
        SubclassProc = DefSubclassProc(hWnd, uMsg, wParam, lParam)
    End Function
    Code:
    'Call it like this
    
    Private Sub Form_Load()
        Subclass File1
    End Sub
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

Tags for this Thread

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