powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / StatusBar: на одной из панелей иконка+текст
2 сообщений из 2, страница 1 из 1
StatusBar: на одной из панелей иконка+текст
    #36658210
Дмитрий77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Есть VB-based StatusBar из 3-х панелей.
Хочется нарисовать достойную картинку + текст на 3-й панели.
Через API я его целиком рисовать умею, но не хочу, ибо уже есть (да и перерисовки замучаюсь отрабатывать).
Картинка через VB эта ерунда: 256цветов, да еще срезает, надо от этого уходить.
Если текст писать через VB, то картинка на него наложится.
Поэтому тестируем так:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
Private Sub StBarCommand_Click()
    Dim lngIcon As Long
    lngIcon = LoadImage(App.hInstance, MAKEINTRESOURCE( 135 ), IMAGE_ICON,  16 ,  16 , LR_DEFAULTCOLOR)
    Call SendMessageLong(StatusBar1.hwnd, SB_SETICON,  2 , ByVal lngIcon)
    SetText StatusBar1.hwnd,  2 , SBT_SUNKEN, "Test text"
End Sub

Public Sub SetText(hStatBar As Long, _
                   bPart As Byte, _
                   wNewDrawOp As Integer, _
                   sText As String)
   'ф-ция устанавливает текст в панели StatusBar
   'Sets the specified part's text.
  '
  'bPart:zero-based part to set, 255 = simple mode text.
  'wNewDrawOp:text drawing operation.
  'sText:text to set

   Dim wCurDrawOp As Integer

   'Get the part's current drawing operation
   'before it might be updated below.
   wCurDrawOp = GetCurDrawOp(hStatBar, bPart, False)

   'Set the text w/ the drawing operation
   SendMessage hStatBar, SB_SETTEXT, ByVal bPart Or wNewDrawOp, ByVal sText
  
   'Redraw the status bar only if the part's drawing
   'operation changed (reduces flicker).
   If wCurDrawOp <> wNewDrawOp Then InvalidateRect1 hStatBar, ByVal  0 , True
  
End Sub
Private Function GetCurDrawOp(hStatBar As Long, _
                             bPart As Byte, _
                             fRtnString As Boolean) As String
  
   'Returns the current text drawing operation for the specified part.
   '
   'SB_GETTEXTLENGTH is used to determine the part's current
   'drawing operation. SB_GETTEXT will rtn the exact same value,
   'but requires a text buffer.
   '
   'When not in simple mode, SB_GETTEXTLENGTH  retrieves the
   'text length for the part specified by bPart (0-254, 255 parts max).
   'If in simple mode, SB_GETTEXTLENGTH will retrieve the simple
   'mode text length *only* if bPart specifies any *valid* part index.
   'The simple mode text length is NOT retrieved when bPart = 255
   '(as is used to set text w/ SB_SETTEXT). Also applies to
   'SB_GETTEXT.
   '
   'If fRtnString = True, returns the text drawing operation constant
   'string. If False, returns the text drawing operation constant value.

   Dim dwRtn As Long

   dwRtn = SendMessage(hStatBar, SB_GETTEXTLENGTH, ByVal bPart,  0 )

   'The text drawing operation for the specified
   'part is contained in the high word of dwRtn.
   dwRtn = (dwRtn And &HFFFF0000) \ &HFFFF&

   If fRtnString Then

     'Returning the string
      Select Case dwRtn
         Case SBT_SUNKEN:    GetCurDrawOp = "SBT_SUNKEN"
         Case SBT_NOBORDERS: GetCurDrawOp = "SBT_NOBORDERS"
         Case SBT_POPOUT:    GetCurDrawOp = "SBT_POPOUT"
      End Select

   Else

     'Returning the value
      GetCurDrawOp = dwRtn
  
   End If
End Function

Все замечательно, имеем картинка без срезаний, справа текст.
Делаем form_resize, текст исчезает.
Что там надо отрабатывать (думаю какой-то msg через сабклассинг статусбара мочить) чтоб все нормально было?
М.б. просто какой пример по теме простенький...
...
Рейтинг: 0 / 0
StatusBar: на одной из панелей иконка+текст
    #36658220
Дмитрий77
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А с другой стороны,...кто мне запретит забабахать кучу пробелов, пусть себе на пробелы накладывается сколько угодно, тода даже с SetText возиться не надо.

Код: plaintext
1.
2.
3.
4.
5.
6.
Private Sub StBarCommand_Click()
    Dim lngIcon As Long
    lngIcon = LoadImage(App.hInstance, MAKEINTRESOURCE( 135 ), IMAGE_ICON,  16 ,  16 , LR_DEFAULTCOLOR)
    Call SendMessageLong(StatusBar1.hwnd, SB_SETICON,  2 , ByVal lngIcon)
    'SetText StatusBar1.hwnd, 2, SBT_SUNKEN, "Test text"
    StatusBar1.Panels( 3 ).Text = "       Test text"
End Sub
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / StatusBar: на одной из панелей иконка+текст
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]