Вверх ↑
Разработчик
Ответов: 26061
Рейтинг: 2120
#1: 2021-08-31 00:13:13 ЛС | профиль | цитата
Вариант выпадающего списка с изменяемой шириной. Ширину скроллинга при малом количестве элементов списка убрать не получилось, слишком много заморочек.



Схема

Add(MainForm,10377423,266,231)
{
Width=730
Height=295
Position=1
Point(onMouseEnter)
}
Add(ComboBox,7723821,378,161)
{
Left=75
Top=30
Width=155
Height=21
Strings=#29:12321797000008638863667888888|5:11113|5:57396|35:97957395050930593988590385935395035|5:45464|5:67867|5:87867|5:34535|5:adaad|
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|
VarPoints=#7:sHandle|
DataPoints=#7:PHandle|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|38:uses kol,Share,Debug,Windows,Messages;|0:|5:const|26: CB_SETMINVISIBLE = 5889;|26: CB_GETMINVISIBLE = 5890;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|24: sControl: PControl;|25: Info: TComboBoxInfo;|9: public|19: onGetTrackIdx,|19: onGetTrackTxt,|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;|33: Size_Params: TNCCalcSizeParams;|24: itemidx: integer = -1;|15: dRect: TRect;|15: sRect: TRect;|0:|88:function MyWndProc(wnd: THandle; wMsg: Cardinal; wParam, lParam: DWORD): DWORD; stdcall;|3:var|18: i, len: integer;|16: buffer: PChar;|13: st: string;|5:begin|14: case wMsg of|14: WM_MOUSEMOVE:|10: begin;|47: i:= SendMessage(wnd, LB_GETCURSEL, 0, 0);|27: if i <> itemidx then|11: begin|53: len := SendMessage(wnd, LB_GETTEXTLEN, i, 0);|32: GetMem(buffer, len + 1);|57: SendMessage(wnd, LB_GETTEXT, i, integer(buffer));|35: SetString(st, buffer, len);|24: FreeMem(buffer);|45: _hi_onEvent(fclass.onGetTrackIdx, i);|46: _hi_onEvent(fclass.onGetTrackTxt, st);|12: end; |19: itemidx := i;|11: end; |18: WM_NCCALCSIZE:|9: begin|48: Size_Params := PNCCalcSizeParams(lParam)^;|35: sRect := Size_Params.rgrc[0];|110: SetWindowPos(wnd,0,0,0, dRect.Right - dRect.Left, sRect.Bottom - sRect.Top, SWP_NOMOVE or SWP_NOZORDER);|11: end; |12: WM_SIZE:|6: begin|43:// ShowScrollBar(wnd, SB_VERT, false);|10: 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);|3:var|25: i, len, count: integer;|16: buffer: PChar;|13: st: string;|11: pDC: HDC;|18: hOldFont: HFONT;|18: SizeFont: TSize;|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;|6: end;|57: count := SendMessage(Info.hwndList, LB_GETCOUNT, 0, 0);|0:|28: for i := 0 to count - 1 do|7: begin|59: len := SendMessage(Info.hwndList, LB_GETTEXTLEN, i, 0);|28: GetMem(buffer, len + 1);|63: SendMessage(Info.hwndList, LB_GETTEXT, i, integer(buffer));|31: SetString(st, buffer, len);|20: FreeMem(buffer);|32: pDC := GetDC(Info.hwndList);|56: hOldFont := SelectObject(pDC, sControl.Font.Handle);|63: GetTextExtentPoint32(pDC, PChar(st), Length(st), SizeFont);|32: SelectObject(pDC, hOldFont);|18: DeleteDC(pDC);|71: if SizeFont.cx + 23 > (dRect.Right - dRect.Left) then |53: dRect.Right := SizeFont.cx - dRect.Left + 23; |6: 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,11182890:doText,[])
link(onGetTrackTxt,4062415:doText,[(459,244)(459,279)])
link(PHandle,7723821:PHandle,[])
}
Add(ChanelToIndex,995737,336,231)
{
link(onIndex,3059356:doGetTrackIdx,[])
}
Add(Edit,11182890,469,231)
{
Left=240
Top=30
Text=""
}
Add(Edit,4062415,469,273)
{
Left=300
Top=30
Width=255
Text=""
}

карма: 22

0
Редактировалось 3 раз(а), последний 2021-08-31 00:17:52