I found a code to have a TreeView with Gradient background.
When I run my project within vb it works great, as soon as I compile it into an .exe windows has an error and shuts down, doesnt tell me what error is though.
Any ways, the code consists of a module then a call to the module, I will post here and maybe one of you experts can find the reason of the error?
I had this question with my other post but decided to separate it.
I will also upload the sample I downloaded
MODULE CODE
VB Code:
'---Bas module code---
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type PAINTSTRUCT
hDC As Long
fErase As Long
rcPaint As RECT
fRestore As Long
fIncUpdate As Long
rgbReserved As Byte
End Type
Private Declare Function BeginPaint Lib "user32" _
(ByVal hWnd As Long, lpPaint As PAINTSTRUCT) As Long
Private Declare Function EndPaint Lib "user32" _
(ByVal hWnd As Long, lpPaint As PAINTSTRUCT) As Long
Private Type TRIVERTEX
x As Long
y As Long
Red As Integer
Green As Integer
Blue As Integer
Alpha As Integer
End Type
Private Type GRADIENT_TRIANGLE
Vertex1 As Long
Vertex2 As Long
Vertex3 As Long
End Type
Const GRADIENT_FILL_TRIANGLE As Long = &H2
Private Declare Function GradientFillTri Lib "msimg32" Alias "GradientFill" (ByVal hDC As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_TRIANGLE, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdcDest As Long, ByVal nXOriginDest As Long, ByVal nYOriginDest As Long, ByVal nWidthDest As Long, ByVal nHeightDest As Long, ByVal hdcSrc As Long, ByVal nXOriginSrc As Long, ByVal nYOriginSrc As Long, ByVal nWidthSrc As Long, ByVal nHeightSrc As Long, ByVal crTransparent As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetDC& Lib "user32" (ByVal hWnd As Long)
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, ByVal lpRect As Long, ByVal bErase As Long) As Long
Private Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function ValidateRectBynum& Lib "user32" Alias "ValidateRect" (ByVal hWnd As Long, ByVal lpRect As Long)
Declare Function ReleaseDC& Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long)
I guess this is not as easy of a repair as I thought it would be.
I have emailed the author of the code but am still waiting a reply.
If some one would download and compile the project and tell us their outcome that would be great.
I originally got the code from http://www.freevbcode.com/ShowCode.asp?ID=2135
Thanx, Planethax
Well, it runs fine in the IDE, but crashes as an .exe
I added a few error traps, but it still crashes.
I've sent an error report once. Next, I'll look at the info.
Running XP Home on my laptop 512MB ram.
Last edited by dglienna; May 4th, 2005 at 05:11 PM.
Thanx dglienna.
Your the best!!!!!
I am now going to compare the two to see axactly what you did,
Hey I may learn something? Prolly not though lol.
Thanx again.
I would put a msgbox in each section of the select case near crash2 in the module. I noticed that it loops through there about 5 times. I would guess that one of them fails. If you find out, we may be able to pinpoint the cause. Right now it just exits the function on the error.