Вверх ↑
Ответов: 5227
Рейтинг: 587
#1: 2022-02-21 09:35:43 ЛС | профиль | цитата
Попробовал без канвы на чистом API сделать выделение инверсией цветов но получить картинку без инверсии так и не получилось.
Может кому повезёт больше чем мне
Add(MainForm,2953706,56,77)
{
Width=539
Height=391
Point(Handle)
}
Add(Button,11970534,119,77)
{
Left=20
Top=35
Width=90
Height=35
link(onClick,16364808:doCapture,[])
}
Add(InlineCode,16364808,189,77)
{
WorkPoints=#9:doCapture|
EventPoints=#5:onScr|
Code=#25:// autor andrestudio 2022|15:unit HiAsmUnit;|0:|9:interface|0:|38:uses kol,windows,Share,Debug,Messages;|0:|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|0:|9: public|22: onScr: THI_Event;|52: procedure doCapture(var dt: TData; idx: word); |22: procedure GetBMP;|5: end;|1: |91: function HookMouseProc(nCode: Integer; WParam: WPARAM; LParam: LPARAM): integer; stdcall;|51: procedure SetMouseHook(const IsEnabled: Boolean);|0:|14:implementation|0:|4:type|25: TMouseMoveHook = record|19: case Integer of|21: 0: (Hook: HHOOK);|24: 1: (Timer: THandle);|6: end;|0:|39: PMouseHookStruct = ^TMouseHookStruct;|36: tagMOUSEHOOKSTRUCT = packed record|15: pt: TPoint;|21: mouseData: DWORD;|17: flags: DWORD;|16: time: DWORD;|24: dwExtraInfo: PDWORD;|6: end;|40: TMouseHookStruct = tagMOUSEHOOKSTRUCT;|0:|3:var|15: f1: PControl;|32: MouseMoveHook: TMouseMoveHook;|18: sClass: LongInt;|21: OldX,OldY: integer;|24: x1,x2,y1,y2: integer; |17: Start: boolean;|2: |49:procedure SetMouseHook(const IsEnabled: Boolean);|5:const|19: WH_MOUSE_LL = 14;|5:begin|19: if IsEnabled then|85: MouseMoveHook.Hook := SetWindowsHookEx(WH_MOUSE_LL, @HookMouseProc, HInstance, 0)|6: else|44: UnhookWindowsHookEx(MouseMoveHook.Hook);|9:end; |2: |89:function HookMouseProc(nCode: Integer; WParam: WPARAM; LParam: LPARAM): Integer; stdcall;|3:var|10: DC: HDC;|11: R: TRect;|13: h: THAndle;|5:begin|70: Result := CallNextHookEx(MouseMoveHook.Hook, nCode, WParam, LParam);|52: if (WParam = WM_MOUSEMOVE) and (Start = True) then|7: begin|41: x2 := PMouseHookStruct(LParam)^.pt.X;|41: y2 := PMouseHookStruct(LParam)^.pt.Y;|19: dc := GetDC(0);|57: //h := WindowFromPoint(PMouseHookStruct(LParam)^.pt);|27: SetROP2(dc, R2_XORPEN);|37: Rectangle(dc,x1, y1, oldx, oldy);|38: Rectangle(dc, x1, y1, x2, y2); |20: ReleaseDC(0,dc);|27: OldX := x2; OldY := y2;|6: end;|5: |34: if WParam = WM_LBUTTONDOWN then |7: begin|41: x1 := PMouseHookStruct(LParam)^.pt.X;|41: y1 := PMouseHookStruct(LParam)^.pt.Y;|27: OldX := x1; OldY := y1;|16: // подложили|20: f1.Left := x1-1;|25: f1.Top := y1-1; |18: Start := True;|6: end;|2: |54: if (WParam = WM_LBUTTONUP) and (Start = True) then |8: begin |24: SetMouseHook(False);|34: R := MakeRect(x1, y1, x2, y2);|31: InvalidateRect(0,@R,False);|30: THiAsmUnit(sClass).GetBMP;|6: end;|7: |6:end; |0:|29:procedure THiAsmClass.GetBMP;|3:var|10: dc: HDC;|19: Bmp: Kol.PBitmap;|19: w,h,x,y: integer;|14: pos: TPoint;|5:begin|35: x := Min(x1,x2); y := Min(y1,y2);|39: w := Max(x1,x2)-x; h := Max(y1,y2)-y;|17: dc := GetDC(0);|24: Bmp := NewBitmap(w,h);|68: BitBlt(Bmp.Canvas.Handle,0,0,Bmp.Width,Bmp.Height,DC,x,y,SRCCOPY);|25: _hi_OnEvent(onScr,bmp);|22: bmp.CopyToClipboard;|12: bmp.Free; |10: f1.Hide;|4:end;|0:|32:procedure THiAsmClass.doCapture;|6:begin |17: Start := False;|34: if not Assigned(f1) then begin |64: f1 := NewForm(Applet,''); // подложка для защиты от выделения|56: f1.GetWindowHandle; // элементов редактирования|25: f1.Style := 101187584;|23: f1.ExStyle := 65536;|17: f1.Width := 2;|18: f1.Height := 2;|41: f1.AlphaBlend := 1; // 0 не сработает!|8: end; |12: f1.Show; |0:|26: sClass := LongInt(Self);|23: SetMouseHook(True); |4:end;|0:|0:|4:end.|
link(onScr,12267643:doLoad,[])
}
Add(Image,12267643,252,77)
{
Left=155
Top=45
Width=300
Height=215
}


карма: 4
Мой форум - http://hiasm.bbtalk.me/ схемы, компоненты...
0
Редактировалось 3 раз(а), последний 2022-02-21 10:11:46