Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do i make a screenshot of a memo (for example)

Posted on 2006-04-28
9
Medium Priority
?
791 Views
Last Modified: 2010-04-05
Hello

How do i get the graphical contents of a memo (or a richedit) control into a image's canvas ?
In other words, how do i make a "screenshot" of a delphi control (including everything inside it -eg. text, pictures for a richedit).

Ty.
0
Comment
Question by:Catalin80
  • 4
  • 4
9 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 16566362
Hello,
try this

  Image1.Canvas.Lock;
  memo1.PaintTo(Image1.Canvas.Handle,0,0);
  Image1.Canvas.Unlock;
  Image1.Invalidate;
0
 

Author Comment

by:Catalin80
ID: 16567646
Ok, that works for memo1.
For another 50 points, How about richedits and webbrowsers ?
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16567910
var
  RichEditHDC : cardinal;
begin
RichEditHDC := GetWindowDC(RichEdit1.Handle);
BitBlt(Image1.Canvas.Handle, 0, 0, RichEdit1.Width, RichEdit1.Height, RichEditHDC, 0, 0, srccopy);
ReleaseDC(RichEdit1.Handle, RichEditHDC);
end;


If using this method, RichEdit1 should not be overlapped by other windows
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Catalin80
ID: 16681732
Update: i need to do this for TWebBrowser also -> 200 points.
Ty.
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16683940
does TWebBrowser have a Handle property? (using D6Personal - there's no TWebBrowser by default, so I can't try it myself)
0
 

Author Comment

by:Catalin80
ID: 16683982
Yes it has, but the "screenshot" resulted by using its handle in RichEditHDC := GetWindowDC(RichEdit1.Handle) is blank.
0
 
LVL 11

Accepted Solution

by:
ZhaawZ earned 800 total points
ID: 16684023
works fine for me..

var
  HDC : cardinal;
begin
HDC := GetWindowDC(WebBrowser1.Handle);
BitBlt(Image1.Canvas.Handle, 0, 0, WebBrowser1.Width, WebBrowser1.Height, HDC, 0, 0, srccopy);
ReleaseDC(WebBrowser1.Handle, HDC);
Image1.Refresh;
end;
0
 

Author Comment

by:Catalin80
ID: 16684072
I don't know what i did wrong, i've copy-paste again and now it works. Ty.
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16684084
I believe it didn't work because of "Image1.Refresh" - it could be that it drawed a "screenshot" into a memory, but didn't draw it on the screen.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

572 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