?
Solved

Printing Form

Posted on 2000-03-03
5
Medium Priority
?
193 Views
Last Modified: 2010-04-04
Hello.
How to prevent components eg buttons on a form from being printed? Any help is greatly appreciated.
0
Comment
Question by:zulhilmi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2581343
5 points isnt much appreciation ...
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2581622
before you start printing make them invisible
0
 

Expert Comment

by:mrissmann
ID: 2585469
Why?  What are you trying to accomplish?

Mark Rissmann
0
 

Accepted Solution

by:
zb_russia earned 20 total points
ID: 2590945
Can take advantage of my experience (seal of tables, graphs, images etc.). This my answer is included in Russian faq on Delphi. I give back so, as for this work it is necessary to take not less than 400-500 numbers.

Q>:
How correctly to print any information (raster and vectorial images),
And also how to make a condition of preliminary survey?
A>:

   Small preface.

Since basic mine of work is connected to a spelling soft for institute, manufactured geodatas, and in a department, where working, as are tormented problems of a seal (in one case - it is necessary to print map, with isoline, having fill., subscripts and other; in other a case - tables and complicated painting on appearance).
In a result, my colleague wrote a piece, in which he managed to achieve a qualitative seal in two of regims: MetaFile, Bitmap.
The work with MetaFile at us has developed already hystorycal - rather conveniently to describe function, which something of paint (though on screen, though where), which get TCanvas, and to palm off on her that canvas of the display, êàíâàñ metafile, and then this of Metafile put on a seal.
There is enough solve only problem scaling, then - forward.

Principal head pain at such method - painting of large pieces, which take the whole sheet or his majority, it is necessary this metafile on size to do at once in pixels on this sheet. Then at a modification size (preview by a seal) - distortion a diminution not critical, and here at magnification of a line and font not "creep".

So:

List of ideas, which were written (ñ) Andrew Aristov , programmer of a department of a software SibNIINP, Tyumen. Mine here only - attach from above settings for personal use.

All of work is reduced to the following pitches:

1. To receive necessary coefficents.
2. Construct metafila or bmp for a consequent conclusion on a seal.
3. Print.

Lower sample a piece (please me not beat, but was written by I and I wrote for enough curve realization with passing parameters over global variables) I use to receive coefficients of recalculation.

KScale - for recalculation size font, and then I are already pawned on it of size and I receive two new coefficients for kW, kH - which and the heights fonts allow me with allowance for to remove graphics and other. At me of work kW < > kH, that come to take into account.

Have decided an item 1.

procedure SetKoeffMeta; // set coefficient
var
  PrevMetafile : TMetafile;
  MetaCanvas : TMetafileCanvas;
begin
  PrevMetafile  :=  nil;
  MetaCanvas    :=  nil;
  try
    PrevMetaFile  :=  TMetaFile.Create;
    try
      MetaCanvas  :=  TMetafileCanvas.Create( PrevMetafile, 0 );
      kScale := GetDeviceCaps( Printer.Handle, LOGPIXELSX ) / Screen.PixelsPerInch;
      MetaCanvas.Font.Assign( oGrid.Font);
      MetaCanvas.Font.Size := Round( oGrid.Font.Size * kScale );
      kW := MetaCanvas.TextWidth('W') /  oGrid.Canvas.TextWidth('W');
      kH := MetaCanvas.TextHeight('W') / oGrid.Canvas.TextHeight('W');
    finally
      MetaCanvas.Free;
    end;
  finally
    PrevMetafile.Free;
  end;
end;

Have decided an item 1.

....
var
  PrevMetafile : TMetafile;
  MetaCanvas : TMetafileCanvas;
begin
  PrevMetafile  :=  nil;
  MetaCanvas    :=  nil;

  try
    PrevMetaFile  :=  TMetaFile.Create;

    PrevMetafile.Width  :=  oWidth;
    PrevMetafile.Height :=  oHeight;

    try
      MetaCanvas  :=  TMetafileCanvas.Create( PrevMetafile, 0 );

      // Here there should be your code - with allowance for scaling.
      // I have born this thing in assigned procedure, and given block
      // I call only for painting whole page.

      see PS1.

    finally
      MetaCanvas.Free;
    end;
....


PS1. The code, which is used for painting. OCanvas - TCanvas metafile.

....
var
  iHPage : integer; // high page
begin
  with oCanvas do begin

    iHPage := 3000;

   // fill rect metafile white - for further work
    Pen.Color   := clBlack;
    Brush.Color := clWhite;
    FillRect( Rect( 0, 0, 2000, iHPage ) );

   // set font - consider other scaling
    oCanvas.Font.Assign( oGrid.Font);
    oCanvas.Font.Size := Round( oGrid.Font.Size * kScale );

....
    xEnd := xBegin;
    iH := round( RowHeights[ iRow ] * kH );
    for iCol := 0 to ColCount - 1 do begin
      x := xEnd;
      xEnd := x + round( ColWidths[ iCol ] * kW );
      Rectangle( x, yBegin, xEnd, yBegin + iH );
      r := Rect( x + 1, yBegin + 1, xEnd - 1, yBegin + iH - 1 );
      s := Cells[ iCol, iRow ];

      DrawText( oCanvas.Handle, PChar( s ), Length( s ), r, DT_WORDBREAK or  DT_CENTER );


Principal, that it is important to remember at this stage is to not overlook, that all deduced plants should use circumscribed coefficients(as you receive them is already your matter). In this case - I of work  with make over TStringGrid, whici have made for mupti-pages seales.

The last item - is necessary organize metafile or bmp to print.

....
var
  Info: PBitmapInfo;
  InfoSize: Integer;
  Image: Pointer;
  ImageSize: DWORD;
  Bits: HBITMAP;
  DIBWidth, DIBHeight: Longint;
  PrintWidth, PrintHeight: Longint;
begin
....

  case ImageType of

    itMetafile: begin
      if Picture.Metafile<>nil then
        Printer.Canvas.StretchDraw( Rect(aLeft, aTop, aLeft+fWidth,
                 aTop+fHeight), Picture.Metafile);
    end;

    itBitmap: begin

      if Picture.Bitmap<>nil then begin
        with Printer, Canvas do begin
          Bits := Picture.Bitmap.Handle;
          GetDIBSizes(Bits, InfoSize, ImageSize);
          Info := AllocMem(InfoSize);
          try
            Image := AllocMem(ImageSize);
            try
              GetDIB(Bits, 0, Info^, Image^);
              with Info^.bmiHeader do begin
                DIBWidth := biWidth;
                DIBHeight := biHeight;
              end;
              PrintWidth := DIBWidth;
              PrintHeight := DIBHeight;
              StretchDIBits(Canvas.Handle, aLeft, aTop, PrintWidth,
                        PrintHeight, 0, 0, DIBWidth, DIBHeight, Image, Info^,
                        DIB_RGB_COLORS, SRCCOPY);
            finally
              FreeMem(Image, ImageSize);
            end;
          finally
            FreeMem(Info, InfoSize);
          end;
        end;
      end;
    end;
  end;

In what the idea PreView consists? There is having on hands Metafila, Bmp - painting with recalculate an appearance image (it is necessary to calculate left top an angle and size "preview" image (or representation).
For a featuring image it is enough to use StretchDraw.

After it was possible to deduce plants on a seal, problem of creation PreView resolution as "the home representation".

By the way, when we of work with Bmp, for lock we use the following hint - we note bit image over such of procedure:

    w:=MulDiv(Bmp.Width,GetDeviceCaps(Printer.Handle,LOGPIXELSX),Screen.Pixels
              PerInch);
    h:=MulDiv(Bmp.Height,GetDeviceCaps(Printer.Handle,LOGPIXELSY),Screen.Pixel
              sPerInch);
    PrevBmp.Width:=w;
    PrevBmp.Height:=h;
    PrevBmp.Canvas.StretchDraw(Rect(0,0,w,h),Bmp);

    aPicture.Assign(PrevBmp);


Image scaling with minimum distortions, and here of a seal - suit bmp to print just how is circumscribed above.
The result - ours of bmp of a seal hardly is less, than to print her of over WinWord, but it is outwardly - without any distortions and other.

Imho, I for itself of problem of a seal solve. Summare, has made PreView for myStringGrid, where I remove complicated multiline titles and other. On some sheets, there was something up-saw, but with printer at me of problem will not be already precisely :)

PS. By the way, Andrew Aristov because of work has made complicated geomap, which till quality not worse, and can and better, than produces Surfer (experts will understand).


0
 

Author Comment

by:zulhilmi
ID: 2595746
An excellent technical answer.
I really appreciated it.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

719 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