Вверх ↑
Разработчик
Ответов: 26048
Рейтинг: 2110
#1: 2021-08-30 14:05:31 ЛС | профиль | цитата
Rysik писал(а):
вопрос актуален, ибо даже подсказок нету при наведении на один из пунктов

Прототип подсказки к пунктам длиннее ширины списка

Схема

Add(MainForm,10377423,266,231)
{
Width=730
Height=295
Point(onMouseEnter)
}
Add(ComboBox,7723821,378,161)
{
Left=75
Top=30
Width=155
Height=21
Strings=#44:12321455549839590752729090702702720752096502|5:11113|34:5739639639639639863986853963939893|5:11122|5:45464|5:67867|5:87867|5:34535|5:56546|5:46464|5:46546|
ReadOnly=0
Point(PHandle)
Point(onMouseLeave)
Point(onMouseEnter)
Point(onMouseWheel)
link(onMouseEnter,995737:doWork2,[(417,188)(417,153)(326,153)(326,244)])
}
Add(InlineCode,3059356,392,231)
{
WorkPoints=#13:doGetTrackIdx|
EventPoints=#13:onGetTrackIdx|13:onGetTrackTxt|12:onMouseLeave|
VarPoints=#7:sHandle|
DataPoints=#7:PHandle|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|38:uses kol,Share,Debug,Windows,Messages;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|24: sControl: PControl;|25: Info: TComboBoxInfo;|9: public|19: onGetTrackIdx,|19: onGetTrackTxt,|18: onMouseLeave,|24: PHandle: THI_Event;|58: procedure doGetTrackIdx(var _Data:TData; Index:word);|57: procedure sHandle(var _Data:TData; Index:word); |34: destructor Destroy; override;|5: end;|0:|14:implementation|0:|3:var|23: sDefWndProc: Pointer;|22: global: integer = 0;|22: fclass: THiAsmClass;|26: Track: TTrackMouseEvent;|33: Size_Params: TNCCalcSizeParams;|24: itemidx: integer = -1;|15: aRect: TRect;|17: dRect: TRect; |0:|88:function MyWndProc(wnd: THandle; wMsg: Cardinal; wParam, lParam: DWORD): DWORD; stdcall;|3:var|18: i, len: integer;|16: inRect: TRect;|23: xPos, yPos: smallint;|16: buffer: PChar;|13: st: string;|11: pDC: HDC;|18: hOldFont: HFONT;|20: SizeFont: TSize; |5:begin|14: case wMsg of|14: WM_MOUSEMOVE:|10: begin;|47: i:= SendMessage(wnd, LB_GETCURSEL, 0, 0);|61: SendMessage(wnd, LB_GETITEMRECT, i, cardinal(@inRect));|29: xPos := LOWORD(lParam);|34: yPos := HIWORD(lParam); |0:|38: Track.cbSize := Sizeof( Track );|33: Track.dwFlags := TME_LEAVE;|29: Track.hwndTrack := wnd;|29: TrackMouseEvent(Track);|12: |23: if yPos >= 0 then|12: begin |29: if i <> itemidx then|13: begin|55: len := SendMessage(wnd, LB_GETTEXTLEN, i, 0);|34: GetMem(buffer, len + 1);|59: SendMessage(wnd, LB_GETTEXT, i, integer(buffer));|37: SetString(st, buffer, len);|26: FreeMem(buffer);|22: pDC := GetDC(wnd);|69: hOldFont := SelectObject(pDC, fclass.sControl.Font.Handle);|69: GetTextExtentPoint32(pDC, PChar(st), Length(st), SizeFont);|38: SelectObject(pDC, hOldFont);|24: DeleteDC(pDC);|47: _hi_onEvent(fclass.onGetTrackIdx, i);|66: if SizeFont.cx > (dRect.Right - dRect.Left) then |50: _hi_onEvent(fclass.onGetTrackTxt, st);|14: end; |21: itemidx := i;|10: end;|10: end; |18: WM_NCCALCSIZE:|9: begin|48: Size_Params := PNCCalcSizeParams(lParam)^;|35: aRect := Size_Params.rgrc[1];|11: end; |12: WM_SIZE:|6: begin|43:// ShowScrollBar(wnd, SB_VERT, false);|10: end; |18: WM_MOUSELEAVE:|9: begin|20: itemidx := -1;|39: _hi_onEvent(fclass.onMouseLeave);|11: exit;|8: end;|6: end;|67: Result := CallWindowProc(sDefWndProc, wnd, wMsg, wParam, lParam);|4:end;|0:|31:destructor THiAsmClass.Destroy;|5:begin|38: if not Assigned(sControl) then exit;|34: ZeroMemory(@Info, SizeOf(Info));|30: Info.cbSize := SizeOf(Info);|41: GetComboBoxInfo(sControl.Handle, Info);|68: SetWindowLong(Info.hwndList, GWL_WNDPROC, cardinal(@sDefWndProc));|16: inherited; |6:end; |0:|65:procedure THiAsmClass.doGetTrackIdx(var _Data:TData; Index:word);|5:begin|48: sControl := PControl(ToIntegerEvent(PHandle));|38: if not Assigned(sControl) then exit;|0:|34: ZeroMemory(@Info, SizeOf(Info));|30: Info.cbSize := SizeOf(Info);|41: GetComboBoxInfo(sControl.Handle, Info);|0:|20: if global = 0 then|7: begin|70: sDefWndProc := Pointer(GetWindowLong(Info.hwndList, GWL_WNDPROC));|68: SetWindowLong(Info.hwndList, GWL_WNDPROC, cardinal(@MyWndProc));|43: GetWindowRect(Info.hwndList,dRect); |16: global := 1;|19: fclass := Self;|10: end; |4:end;|0:|59:procedure THiAsmClass.sHandle(var _Data:TData; Index:word);|5:begin|48: sControl := PControl(ToIntegerEvent(PHandle));|38: if not Assigned(sControl) then exit;|0:|34: ZeroMemory(@Info, SizeOf(Info));|30: Info.cbSize := SizeOf(Info);|41: GetComboBoxInfo(sControl.Handle, Info);|2: |33: dtInteger(_Data,Info.hwndList);|5:end; |0:|4:end.|
link(onGetTrackIdx,3594222:doWork2,[])
link(onGetTrackTxt,16549724:doEvent1,[])
link(PHandle,7723821:PHandle,[])
link(onMouseLeave,3594222:doWork3,[(442,251)])
}
Add(ChanelToIndex,995737,336,231)
{
link(onIndex,3059356:doGetTrackIdx,[])
}
Add(BaloonToolTips,3227334,532,245)
{
link(Handle,3059356:sHandle,[(538,236)(573,236)(573,285)(398,285)])
}
Add(Hub,16549724,476,238)
{
OutCount=3
link(onEvent1,3880845:doWork2,[])
link(onEvent2,3227334:doCreate,[])
link(onEvent3,3227334:doShow,[(508,258)(508,265)])
}
Add(HubEx,3880845,518,238)
{
Angle=1
link(onEvent,3227334:doDestroy,[(522,258)])
}
Add(HubEx,3594222,438,231)
{
Angle=3
link(onEvent,3880845:doWork1,[(442,216)(522,216)])
}


Это только прототип. Сделать полноценную подсказку тоже можно, но это сложнее и за отдельную плату, а так сами пробуйте.
КМК, изменение ширины списка тоже можно без проблем сделать, но это не оправдано, тк может наезжать на сопутствующие элементы интерфейса, что совсем не комильфо.
карма: 22

0
Редактировалось 1 раз(а), последний 2021-08-30 14:10:09