Link to home
Start Free TrialLog in
Avatar of kevinward66
kevinward66

asked on

screen

how can i flip the screen vertically, horizontally and return it back to normal?
Avatar of f15iaf
f15iaf

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 ExtCtrls, jpeg;

type
 TForm1 = class(TForm)
   Image1: TImage;
    Image2: TImage;
   procedure FormShow(Sender: TObject);
   procedure FormCreate(Sender: TObject);
   procedure Image1Click(Sender: TObject);
 private
   { Private declarations }
 public
   can:Tcanvas;
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormShow(Sender: TObject);
var
       y:integer;
begin
       y:=0;
       for y:=0 to can.ClipRect.bottom do
       begin
               image1.Canvas.CopyRect(rect(0,y-1,can.ClipRect.Right,y),can,rect(0,can.ClipRect.bottom-y+1,can.ClipRect.Right,can.ClipRect.bottom-y));
       end;
       with(image1)do
       for y:=0 to Canvas.ClipRect.Right do
       begin
               image2.Canvas.CopyRect(rect(Can.ClipRect.Right-y-1,0,Can.ClipRect.Right-y,Can.ClipRect.bottom),image1.picture.Bitmap.Canvas,rect(y,0,y+1,Can.ClipRect.bottom));
       end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
       borderstyle:=bsnone;
       formstyle:=fsstayontop;
       image1.Align:=alclient;
       image2.Align:=alclient;
       left:=0;
       top:=0;
       height:=screen.height;
       width:=screen.width;
       can:=Tcanvas.create;
       can.handle:=getdc(0);
end;

procedure TForm1.Image2Click(Sender: TObject);
begin
       close;
end;

end.
Avatar of kevinward66

ASKER

this is EXCELLENT, but PLEASE let me explain more, i am sorry, i should have given you more detail at the start of the question

this is what i would ideally like, if its possible!


button 1 = flip screen horizontally
button 2 = flip screen vertically
button 3 = return screen to normal

ONCE AGAIN I AM SORRY, FOR NOT GIVING MORE DETAIL AT THE START!!! :-(
you can not use button after you flip the screen but only to click on a mouse.
ok, well can you provide the code that flips the screen BOTH horizontally & vertically

as the current code only flips it one way
you can not use button after you flip the screen but only to click on a mouse.
verticaly and hor
look at the start button there it is it should be in upper right corner
i meant my code already flips the screen vertically and horizontally
if it works give me the points
hello kevinward66 , , your question and explanation are not clear to me, you ask to flip the screen in your question and then you say
button 1 = flip screen horizontally
button 2 = flip screen vertically
button 3 = return screen to normal

but you don't say what buttons you are refering to. .  you can flip an Image of the screen but it is Only an Image, it is NOT a working Desktop screen where you can click the flipped program's buttons and have them work, however you could use the onClick event to do all the flips and then close the app. Here is some code for that

unit Flip1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClick(Sender: TObject);
  private
    { Private declarations }
    FlipNum: Byte;
    Rect1: TRect;
    ScreenBmp: TBitmap;
    procedure WMEraseBkgnd (var Msg : TMessage); message WM_ERASEBKGND;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  FlipNum := 0;
  Top := 0;
  Left := 0;
  Width := Screen.Width;
  Height := Screen.Height;
  BorderStyle := bsNone;
  Rect1 := Rect(0,0,Width,Height);
  ScreenBmp := TBitmap.Create;
  ScreenBmp.Width := Width;
  ScreenBmp.Height := Height;
end;

procedure TForm1.FormClick(Sender: TObject);
begin
{each click of the screen increases FlipNum
and flips the screen and then Closes the app}
case FlipNum of
0: begin
{I use BitBlt because it is faster but you can use CopyRect}
   BitBlt(ScreenBmp.Canvas.Handle, 0, 0, Width, Height,
      Form1.Canvas.Handle, 0, 0, SRCCOPY);
   Canvas.CopyRect(rect(0,Height,Width,0),ScreenBmp.Canvas,rect1);
   Inc(FlipNum);
   end;
1: begin
   Canvas.CopyRect(rect(Width,0,0,Height),ScreenBmp.Canvas,rect1);
   Inc(FlipNum);
   end;
2: begin
   Canvas.CopyRect(rect1,ScreenBmp.Canvas,rect1);
   Inc(FlipNum);;
   end;
3: Close;
else Close;
end;

end;

procedure TForm1.WMEraseBkGnd;
begin
{this prevents this app from erasing the screen}
  Msg.Result := 0;
end;

end.

 - - - - - - - - - - - - - - - - - - - - - - - -

if you want to use buttons, I can also do that with a timer, let me know.
Oh, I forgot to add this

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FreeAndNil(ScreenBmp);
end;
i will try this and get back to you, thanks for your help
this code is EXCELLENT, but instead of clicking on the screen each time to get the screen to move to the different positions, can you put each screen movement into a button click procedure.

thanks, SORRY to mess u around!!! :-(

ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Listening...