Страница: 1 | 2 |
|
Вопрос: list.list(0,1)
|
Добавлено: 23.01.09 20:38
|
|
Номер ответа: 16 Автор ответа: Smith
ICQ: adamis@list.ru
Вопросов: 153 Ответов: 3632
|
Профиль | | #16
|
Добавлено: 29.01.09 18:05
|
Private Sub listBox1_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
' Set the DrawMode property to draw fixed sized items.
ListBox1.DrawMode = DrawMode.OwnerDrawFixed
' Draw the background of the ListBox control for each item.
e.DrawBackground()
' Create a new Brush and initialize to a Black colored brush by default.
  im myBrush As Brush
' Determine the color of the brush to draw each item based on the index of the item to draw.
Select Case (e.Index)
Case 0
myBrush = Brushes.Red
Case 1
myBrush = Brushes.Orange
Case 2
myBrush = Brushes.Purple
End Select
' Draw the current item text based on the current Font and the custom brush settings.
e.Graphics.DrawString(ListBox1.Items(e.Index), e.Font, myBrush, New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
' If the ListBox has focus, draw a focus rectangle around the selected item.
e.DrawFocusRectangle()
End Sub
Господа нетчики, может кто-нибудь перевести это в ВБ6?
Ответить
|
Номер ответа: 24 Автор ответа: Smith
ICQ: adamis@list.ru
Вопросов: 153 Ответов: 3632
|
Профиль | | #24
|
Добавлено: 03.02.09 00:35
|
А я вот взял и сделал разлиновку в листбоксе.
Именно своей процедурой отрисовки и на VB6.
Brand, ну ведь нет там очень много гемороя
этот твой дотнет это новый наркотик от эмэс
- Public OldWndProc As Long
- Public SolidBrush As Long
- Public MyLineRect As RECT
-
- Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Public Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
- Public Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
-
- Private Type RECT
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
-
- Private Type DRAWITEMSTRUCT
- CtlType As Long
- CtlID As Long
- itemID As Long
- itemAction As Long
- itemState As Long
- hWndItem As Long
- hDC As Long
- rcItem As RECT
- itemData As Long
- End Type
-
- Private Declare Function FillRect Lib "user32" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush 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
- Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
- Private DIS As DRAWITEMSTRUCT
-
- public sub Main()
- MyLineRect.Left = 10
- SolidBrush = CreateSolidBrush(GetSysColor(CLng("&H" & Right$(Hex(Folders.ForeColor), 2))) + 10526880)
- OldWndProc = SetWindowLong(Main.hwnd, -4&, AddressOf MainWndProc)
- end sub
-
- Public Function MainWndProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
- MainWndProc = CallWindowProc(OldWndProc, hwnd, wMsg, wParam, lParam)
- If wMsg = &H2B& Then
- If Main.Folders.ListCount Then
- Call RtlMoveMemory(DIS, ByVal lParam, 48)
- With MyLineRect
- .Bottom = DIS.rcItem.Bottom
- .Top = DIS.rcItem.Bottom - 1
- .Right = DIS.rcItem.Right
- End With
- FillRect DIS.hDC, MyLineRect, SolidBrush
- End If
- End If
- End Function
С ходу это может и не заработает потому, что с скопировано с проекта где и в помине нет сабмэйн, короче вот вам, пинайте, проверять масти нет, а я спать пошел...
Ответить
|
Страница: 1 | 2 |
Поиск по форуму