Solved

Copy a not visible From into a Bitmap

Posted on 2001-06-12
28
275 Views
Last Modified: 2010-04-06
Hi,

Yesterdy I downloaded the Billenium Effects (just for fun )from
http://www.billeniumsoft.com/download.htm

I like to know how they copy the Form in the TFormTransitions in Bitmap to make the Transsion

Well with TFormGetFormImage it not possible to display some TWinControl Components like BitBtn or Radiobtn.

I will enjoy this discussion :-)))

Cesario
0
Comment
Question by:Cesario
  • 10
  • 7
  • 5
  • +5
28 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6181038
listening ;-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6181912
And paintTo doesnt't work either?

Haven't tried it, just thought I'd ask...

Tim.
0
 
LVL 2

Expert Comment

by:FrodoBeggins
ID: 6181926
I even save it to JPEF and sent it through socket :)

procedure frmCapture.SaveForm(FName: string; nQuality: integer);
Var
  JP  : TJpegImage;
  BMP : TBitmap;
  SCHandle : THandle;
begin
  SCHandle := GetWindowDC(frmCapture.Handle);
  if SCHandle<>0 then
  begin
    BMP:= TBitmap.Create;
    BMP.Width :=frmCapture.Width;
    BMP.Height:=frmCapture.Height;
    JP := TJpegImage.Create;
    if BitBlt(BMP.Canvas.Handle, 0, 0, frmCapture.Width, frmCapture.Height, SCHandle, 0, 0, SRCCOPY) then
    try
      JP.Assign(BMP);
      JP.CompressionQuality:=nQuality;
      JP.SaveToFile(FName);
    finally
      JP.Free;
      BMP.Free;
    end;
  end;
end;
0
 
LVL 8

Author Comment

by:Cesario
ID: 6181948
Hello FrodoBeggins,


get a Canvas from an invisible Form ?
You Code will not work.

I dont need a JPEG cause I need the Bitmap to make some transsion effect ;-)

Cesario
0
 
LVL 2

Expert Comment

by:FrodoBeggins
ID: 6181954
That (BitBlt(...)) is very quick method to capture the whole form. You even can capture the screen (if you use SCHandle:=windows.GetDC(0);)
0
 
LVL 2

Expert Comment

by:FrodoBeggins
ID: 6181971
That (BitBlt(...)) is very quick method to capture the whole form. You even can capture the screen (if you use SCHandle:=windows.GetDC(0);)
0
 
LVL 2

Expert Comment

by:FrodoBeggins
ID: 6181977
Uh. You have canvas, but nothing in it...
0
 
LVL 8

Author Comment

by:Cesario
ID: 6181981
Hi TimYates

Paintto does not work with all Components like BitBtn....
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6182007
Ahhh...
0
 
LVL 2

Expert Comment

by:FrodoBeggins
ID: 6182021
There is a walkarround. Make the form visible outside the monitor, capture it, make it invisivle again and move it back ;)
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6182165
Here is the solution for NT/2000, but the code posted there doesn't work in win9x. The trick is basically to hook the BeginPaint API, then post a WM_PAINT. The hook must be established in the context of the process, which owns the to-be-snapshoted window, of course (-> dll).

http://www.fengyuan.com/article/wmprint.html

If you combine Feng Yuan's idea with my code hooking package "madCodeHook", you can make this solution work for all systems.

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6182170
0
 
LVL 8

Author Comment

by:Cesario
ID: 6182253
Thanx Madshi for this good article.

Well I need some time to code it in Delphi.

do you have a fiqure about Billenium Effects.
How they draw the Forms ?

Have a nice day ;-)

Cesario
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6182303
Hi Cesario,

I'm sorry, I don't know "Billenium Effects"...

Regards, Madshi.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Author Comment

by:Cesario
ID: 6182312
Hi Madshi,
see the linke in my question
0
 
LVL 8

Author Comment

by:Cesario
ID: 6182313
Hi Madshi,
see the linke in my question
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6182913
listening :-)
0
 
LVL 4

Expert Comment

by:jeurk
ID: 6183070
Hello Madshi,
This is the link I was searching a while ago :)

Everybody,
Is someone willing to translate that sample to delphi ?
How much points would you ask :) ?
I want a working sample of course...

Let me know...
Thanks
John.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6183311
Hi John!

Perhaps (if I find a bit time during the next weekend) I'll write a(nother) little demo for my API hooking package. This demo would do exactly what is asked in this question. Of course this demo would then need (and ship with) "madCodeHook"...   :-)

Regards, Madshi.
0
 
LVL 8

Author Comment

by:Cesario
ID: 6184937
Madshi,

good idea.....

Best Regards

Cesario
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6197999
I'm not sure how these transition effects are made. Perhaps they're calling the "Paint" methods of all child windows, I'm not sure. Anyway, if I understand it correctly, then it is limited to Delphi forms of your own process, right?

Well, that is in fact something different then what I was thinking about (and what is described in FengYuan's article). Because they "only" handle Delphi forms of their own process, they have it much easier!

Anyway, my demo is ready, you can download the zip file here:

http://www.madshi.net/Snapshot.zip

It contains both binaries and sources. However, in order to compile the sources, you need D4 or D5, and you must have "madCodeHook" installed.

I've tested the demo under win9x only, but I guess it will work in winNT, too (perhaps someone of you with a running winNT system can check that?).

Known limitations:
(1) Be careful when snapshotting invisible/minimized windows. Most of the time it works without any problems, but sometimes strange effects or even crashes can happen, because the window get called with WM_PAINT, even though they're invisible. That *might* confuse some windows. E.g. Delphi's main window makes problems when being snapshotted with my demo while being minimized...   :-/
(2) Not all windows/controls (including some of my own :-) behave totally correctly. When they get a WM_PAINT message, they don't call BeginPaint, nor do they use the device context that is sent with WM_PAINT. Instead they simply use an already opened device context. Such controls are not included in the snapshots. E.g. the clock of the taskbar is not included, the rest is.

Regards, Madshi.
0
 
LVL 8

Author Comment

by:Cesario
ID: 6220604
Hi Madshi,

you demo doesent work on (WinNt4 SP6).
I will try tommorow to test it on Win98...


Thanx ;-)

Cesario
0
 
LVL 20

Accepted Solution

by:
Madshi earned 300 total points
ID: 6221143
How does it behave in WinNt4? Does it produce exceptions? Or do you get empty screenshots only? Or... ? Thnx...
0
 
LVL 8

Author Comment

by:Cesario
ID: 6221228
Hi Madshi,

No Exceptions but MSPAINT show me an empty sheet ( Screenshots ).

Regards

Cesario
0
 
LVL 8

Author Comment

by:Cesario
ID: 6227212
Ok....
The Points are for Madshi...

Best Regards

Cesario
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6227344
Thank you, did it work in win9x? I'll try winNT later, after I found the time to install it first...   :-)

Regards, Madshi.
0
 
LVL 8

Author Comment

by:Cesario
ID: 6227357
Win Win9x yes but WinNt no :-(

ciao

Cesario
0
 

Expert Comment

by:kbb2
ID: 7588798
The link you provided Madshi is no longer valid! Where can I find it?
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now