Jump to content
Turbine1991

Drawing to the client's window canvas

Recommended Posts

In the past I've managed to do this, since then the API has changed. I've looked through the wiki and it seems this is what I'd use:

TSCARBitmapClient - SCAR Divi Manual

 

But I'm uncertain how to use this functionality in the current state of the SCAR API.

 

Previously I used these capabilities in this manner:

debugCanvas := GetClientCanvas();

SafeDrawBitmap(img, debugCanvas, x1, y1);

 

I've only been able to find deprecated examples. Would someone be able to guide me with the current method of drawing on top of a window with a primitive shape.

 

Thank you.

Link to comment
Share on other sites

Um. There's a new client system using TScarClient

To draw on top of a window, idk. There's GetClient. TScarBitmapClient. FastDraw? etc. Everything is explained in Freddys video tutorials he made. However i forget if its possible to do what you want, the canvas might not be editable. Unless maybe theres a debug canvas ontop of the clients canvas.

 

Maybe Copy or Bitblt, or maybe Bitmap.DrawTo

You could make a blank canvas and put it on top of the client too, adjust it to whatever size and position it. Then just use Canvas. Text or. draw or whatever methods.

 

You could make your own form and draw on it.

 

Ill figure this out later. Posted this from my phone.

Edited by LordJashin
Link to comment
Share on other sites

Previously I understood how to do all this, perhaps I'll look through his more updated videos. It's how I found out about it awhile ago. But there wasn't really a mention in the version change-logs between 3.34 and 3.35.

 

From what I saw, GetClient can be used to get the scar window object and from there this could be done. But there's not a canvas in sight nor any functions supporting this. I'm considering using 3.34, but it would have been nice to use the new image classes introduced in 3.35 and up. It's getting the client canvas which is the difficult thing.

 

[Edit]

I just watched through 2 of his videos of 3.35, neither touched the exact subject.

Edited by Turbine1991
Link to comment
Share on other sites

Well if you really wanted this badly, you'd probably need multi threading in SCAR OR you could make a delphi forms plugin for SCAR. Otherwise the window might freeze up? Idk. All I know is that I produced this same sort of functionality in Free Pascal with window layers, transparent window, and the like. And i drew on it, this was the Targeting (Crosshairs) window used in the program I made. It Overlays any window your cursor is on.

 

http://forums.scar-divi.com/programming/2367-auto-licious-ide-development-uses-fpc-compiler.html

 

Same thing as SCAR's target, or works the same way i think . And that's a transparent window w/ the form drawn on and everything. My source code is linked on there too...

 

GL lol.

 

e.g. utargetwindow.pas or w/e

 

{
 uTargetSelection
 - SetTarget Form Unit

 Created by LordJashin32
 Copyright 2013 LordJashin32
 License: GPL/Others
 Last Updated: 8/9/2013
 Created: 7/27/2013

 Credits: Freddy

 Control:
  uAutolicious -> uTargetSelection:

  - procedure frmAutolicious.tbSetTargetMouseDown(Sender: TObject;
    Button: TMouseButton; Shift: TShiftState; X, Y: integer);
  - var ButtonPDown: Boolean;
}

unit uTargetSelection;

{$mode objfpc}{$H+}

interface

uses
 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
 LCLType, LCLIntf;

type

 TfrmTargetSelection = class(TForm)
   Shape1: TShape; // Colors the form
   Timer1: TTimer;

 public

   IsForShow: boolean; // Controls what instance does what in the timer

 private

   // CreateParams overrided to make the form transparent (Windows)
   {$IFDEF WINDOWS}
   procedure CreateParams(var Params: TCreateParams); override;
   {$ENDIF}
   // Used by the timer
   procedure CloseDown;

 published
   // Updates the form dynamically using GetWindowFromPoint (Windows method)
   procedure Timer1Timer(Sender: TObject);

 end;

var
 frmTargetSelection: TfrmTargetSelection; // One form for Alpha transparency
 frmTargetSelection1: TfrmTargetSelection; // One form for transparent
 frmTargetSelectionHandle: HWND; // Targeted Window from GetWindowFromPoint

 // Various Variables
 TargetSet, KeyPressd: boolean;


implementation

uses
 uAutolicious{$IFDEF WINDOWS}, Windows{$ENDIF};

{$R *.lfm}

{~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
procedure TfrmTargetSelection.CreateParams(var Params: TCreateParams);

Description: Changes the create params for the SelectWindow form so that it is
click through-able. (Windows Method)

Last Modified: 7/8/12 By LordJashin.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~}
{$IFDEF WINDOWS}
procedure TfrmTargetSelection.CreateParams(var Params: TCreateParams);
begin
 inherited CreateParams(Params);
 Params.ExStyle := WS_EX_TRANSPARENT;
end;

{$ENDIF}

{~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
procedure TfrmTargetSelection.CloseDown;

Description: Run by the Timer, Closes down the 2 instances, resets, and debugs
the target handle to the Debug SynEdit.

Last Modified: 7/31/13 By LordJashin.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~}

procedure TfrmTargetSelection.CloseDown;
var
 DebugStr: string;
begin
 {$IFDEF WINDOWS}
 frmTargetSelection.Timer1.Enabled := False;
 {$ENDIF}
 frmTargetSelection1.Timer1.Enabled := False;
 Screen.Cursor := crDefault;
 TargetSet := True;
 DebugStr := frmAutolicious.synDebug.Text;
 frmAutolicious.synDebug.Text :=
   'New Target Selected: ' + IntToStr(frmTargetSelectionHandle) + #13#10 + DebugStr;
 KeyPressd := False;
 ButtonPDown := False;
 {$IFDEF WINDOWS}
 frmTargetSelection.Close;
 {$ENDIF}
 frmTargetSelection1.Close;
end;

{~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
procedure TfrmTargetSelection.Timer1Timer(Sender: TObject);

Description: Gets the Window From Point at the current mouse point. Changes the
forms bounds to match the WindowFromPoint. One Instance is for SHOW only, to
make the appearance look better. If the handle found = the handle of
frmTargetSelection, then the shape is Disabled momentarily. The WindowFromPoint
its handle is stored in frmTargetSelectionHandle. This is setting the Target
window for Autolicious. If mbLeft is UP, or mbRight is DOWN. Then we call
CloseDown(); Various Variables are used to make sure the user doesn't make
this timer go on forever. Or doesn't click the button again while selecting
a target, etc.

Last Modified: 7/13/12 By LordJashin.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~}

procedure TfrmTargetSelection.Timer1Timer(Sender: TObject);
var
 P: TPoint;
 tempHandle: HWND;
 Rect: TRect;
 KeyState, KeyState1: boolean;
begin
 if not IsForShow then
 begin
   KeyState := (GetKeyState(VK_LBUTTON) and $8000 <> 0);
   KeyState1 := (GetKeyState(VK_RBUTTON) and $8000 <> 0);
   if (not KeyState) or KeyState1 then
     KeyPressd := True;
 end;
 if KeyPressd then
   CloseDown();
 P := Mouse.CursorPos;
 tempHandle := WindowFromPoint(P);
 if tempHandle = Handle then
 begin
   Shape1.Visible := False;
   Exit;
 end;
 GetWindowRect(tempHandle, Rect);
 BoundsRect := Rect;
 Shape1.Visible := True;
 if not IsForShow then
   frmTargetSelectionHandle := tempHandle;
end;

end.

Edited by LordJashin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...