Make a class with which you can modify the drawing standard list. He has event Draw, which is caused when the need render the next element of the list. To work, you need to install in the list of style Checked (flags), and assign this property ListBox clsTrickListBox.ListBox. You can also change the height of the elements and to cancel drawing.
';)
Private Function CreateAsm() As Long
Dim inIDE As Boolean
Dim AsmSize As Long
Dim ptr As Long
Dim isFirst As Boolean
If mControl Is Nothing Then Exit Function
lpPrev = GetWindowLong(mControl.hwnd, GWL_WNDPROC)
Debug.Assert MakeTrue(inIDE)
If inIDE Then AsmSize = &H3E Else AsmSize = &H1D
hHeap = GetPrevHeap()
If hHeap Then
If inIDE Then
Dim flag As Long
ptr = GetFlagPointer()
GetMem4 ByVal ptr, flag
If flag Then
FreeHeap
isFirst = True
AsmSize = AsmSize + &H4
End If
End If
Else
hHeap = HeapCreate(HEAP_CREATE_ENABLE_EXECUTE Or HEAP_NO_SERIALIZE, 0, 0)
If hHeap = 0 Then Err.Raise 7: Exit Function
If Not SaveCurHeap() Then HeapDestroy hHeap: hHeap = 0: Err.Raise 7: Exit Function
isFirst = True
If inIDE Then AsmSize = AsmSize + &H4
End If
lpAsm = HeapAlloc(hHeap, HEAP_NO_SERIALIZE Or HEAP_ZERO_MEMORY, AsmSize)
If lpAsm = 0 Then
If isFirst Then HeapDestroy hHeap
hHeap = 0
Err.Raise 7
Exit Function
End If
Dim prv As Long
Dim i As Long
If inIDE Then
If isFirst Then
GetMem4 0&, ByVal lpAsm
lpAsm = lpAsm + 4
End If
End If
ptr = lpAsm
If inIDE Then CreateIDEStub (ptr): ptr = ptr + &H21
CreateStackConv ptr
CreateAsm = True
End Function
Private Function GetFlagPointer() As Long
Dim he As PROCESS_HEAP_ENTRY
HeapLock hHeap
Do While HeapWalk(hHeap, he)
If he.wFlags And PROCESS_HEAP_ENTRY_BUSY Then GetFlagPointer = he.lpData: Exit Function
Loop
HeapUnlock hHeap
End Function
Private Function CountTrickList() As Long
Dim he As PROCESS_HEAP_ENTRY
HeapLock hHeap
Do While HeapWalk(hHeap, he)
If he.wFlags And PROCESS_HEAP_ENTRY_BUSY Then CountTrickList = CountTrickList + 1
Loop
HeapUnlock hHeap
End Function
Private Sub FreeHeap()
Dim he As PROCESS_HEAP_ENTRY
HeapLock hHeap
Do While HeapWalk(hHeap, he)
If he.wFlags And PROCESS_HEAP_ENTRY_BUSY Then
HeapFree hHeap, HEAP_NO_SERIALIZE, ByVal he.lpData
End If
Loop
HeapUnlock hHeap
End Sub
Private Function SaveCurHeap() As Boolean
Dim i As Long
Dim out As String
out = Hex(hHeap)
For i = Len(out) + 1 To 8: out = "0" & out: Next
SaveCurHeap = SetEnvironmentVariable(StrPtr("TrickListBox"), StrPtr(out))
End Function
Private Function GetPrevHeap() As Long
Dim out As String
out = Space(&H8)
If GetEnvironmentVariable(StrPtr("TrickListBox"), StrPtr(out), LenB(out)) Then GetPrevHeap = Val("&H" & out)
End Function
Private Function CreateStackConv(ByVal ptr As Long) As Boolean
Dim lpMeth As Long
Dim vTable As Long
GetMem4 ByVal ObjPtr(Me), vTable
GetMem4 ByVal vTable + WNDPROCINDEX * 4 + &H1C, lpMeth
GetMem4 &H5450C031, ByVal ptr + &H0: GetMem4 &H488DE409, ByVal ptr + &H4: GetMem4 &H2474FF04, ByVal ptr + &H8
GetMem4 &H68FAE018, ByVal ptr + &HC: GetMem4 &H0, ByVal ptr + &H10: GetMem4 &HE8, ByVal ptr + &H14
GetMem4 &H10C25800, ByVal ptr + &H18: GetMem4 &H9000, ByVal ptr + &H1C
GetMem4 ObjPtr(Me), ByVal ptr + &H10 ' Push Me
GetMem4 lpMeth - (ptr + &H14) - 5, ByVal ptr + &H14 + 1 ' Call WndProc
End Function
Private Function CreateIDEStub(ByVal ptr As Long) As Boolean
Dim hInstVB6 As Long
Dim lpEbMode As Long
Dim hInstUser32 As Long
Dim lpCallProc As Long
hInstVB6 = GetModuleHandle("vba6")
If hInstVB6 = 0 Then Exit Function
hInstUser32 = GetModuleHandle("user32")
If hInstUser32 = 0 Then Exit Function
lpEbMode = GetProcAddress(hInstVB6, "EbMode")
If lpEbMode = 0 Then Exit Function
lpCallProc = GetProcAddress(hInstUser32, "CallWindowProcA")
If lpCallProc = 0 Then Exit Function
GetMem4 &HE8, ByVal ptr + &H0: GetMem4 &H74C08400, ByVal ptr + &H4: GetMem4 &H74013C10, ByVal ptr + &H8
GetMem4 &H685814, ByVal ptr + &HC: GetMem4 &H50000000, ByVal ptr + &H10: GetMem4 &HE9, ByVal ptr + &H14
GetMem4 &HDFF00, ByVal ptr + &H18: GetMem4 &HEB000000, ByVal ptr + &H1C: GetMem4 &HEC, ByVal ptr + &H20
GetMem4 lpEbMode - ptr - 5, ByVal ptr + 1 + 0 ' Call EbMode
GetMem4 lpPrev, ByVal ptr + &HF ' Push PrevProc
GetMem4 lpCallProc - (ptr + &H14) - 5, ByVal ptr + 1 + &H14 ' Jmp CallWindowProcA
GetMem4 ptr - 4, ByVal ptr + &H1B ' dec dword ptr [Flag]
CreateIDEStub = True
End Function
Private Function MakeTrue(Value As Boolean) As Boolean: Value = True: MakeTrue = True: End Function
hi,i added a button name like Refresh button (code in refresh button is clear list box and then add again 300 item to list box)
1-i added more than 300 items to list box and then clicked on refresh (this time list box fill slow more than previeus time)
and then clicks on refresh again and then slow more than 1.
and after click on refresh button after 5 times or more,program will be crashed.
how can fix this problem?
i want clear list box and then fill without crash problem.
any body here can fix tricklistbox?
hi i attached here.
see lreloadnews_Click() and initdata() subrutin
initdata will be clear listbox tricked (list name is lstTest(0)) and then fill again
at first run,programm will be load json data and xml from urls and then fill lists and temp lists for search and then fill lstTest(0)
initdata() used for form load and then for refresh news.
click on refresh button and there is no problem for 1 time or less than 5 or 6 times but after it process will be slow ...
another problem is about when time i click on items in lstTest(0) and then click on lreloadnews.(slow process and then slower for click again and again)
...
oFnt = SelectObject(hdc, hFont(1)) ' save dc font
...
SelectObject hdc, hFont(0)
...
SelectObject hdc, hFont(2)
...
SelectObject hdc, oFnt ' To restore dc font
...
-how can change scrollbar theme and define hover effect? ( my means of hover effect is solid color or gradiant color or png image for hover?)
-how can set background image?
Last edited by Black_Storm; Mar 2nd, 2018 at 01:32 PM.
i am not pro for work with graphics but can u send a simple using this tricklistbox and with :
-changed scrollbar theme
-background image of list box changed
-hover item color changed(solid color or gradiant color or png background hover)
-alternative color for items
or how can show image(not icon) like as png for each item?(i used icon 150x35 pixel) but in draw event always show square size.
Last edited by Black_Storm; Mar 2nd, 2018 at 02:51 PM.
hover item color changed(solid color or gradiant color or png background hover)
Use TrackMouseEvent you can register hovering and when you get WM_MOUSEHOVER you can process it. Solid color - FillRect, gradient - GradientFill, picture - BitBlt/AlphaBlend/GDI+.
Code:
alternative color for items
SetTextColor.
or how can show image(not icon) like as png for each item?(i used icon 150x35 pixel) but in draw event always show square size.
hover item color changed(solid color or gradiant color or png background hover)
Use TrackMouseEvent you can register hovering and when you get WM_MOUSEHOVER you can process it. Solid color - FillRect, gradient - GradientFill, picture - BitBlt/AlphaBlend/GDI+.
Code:
alternative color for items
SetTextColor.
Use GDI/GDI+ function to draw an image.
can u send both examples( scorllbar and russian sample ) like as attachment? my language is not english or russian and please send both example ( scroll bar sample shown in picture source code and russian sample)
i know about gdi and .... but i want work with this trick list box.i writed code for example boolean variable and then a=not a and then check a if setcolortexet and ... but in rendering was been not good,can u send a sample to used this trick list box and then custom scroll bar theme or alternative color or image for back ground list box or hover effect?
i need just sample fot this list box
Black_Storm, it's the very old project which i didn't finish (when i wrote it i didn't know enough about WinApi and it contains a lot of bad-codes. I don't want publish the bad codes). All of updated controls i'll publish in that thread.
I'd say that this is something you will need to work out on your own. The Trick is under no obligation to write the code for you. If they don't want to release some source code for whatever reason, then that is their right. You can start a thread with the questions you want answered (though not here in the CodeBank), but otherwise, you'll have to consider this has reached an end.