<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=41592&amp;view=findpost&amp;p=270774</guid>
        <pubDate>Fri, 26 Dec 2003 06:40:53 +0000</pubDate>
        <title>[Раздел] Печать</title>
        <link>https://forum.sources.ru/index.php?showtopic=41592&amp;view=findpost&amp;p=270774</link>
        <description><![CDATA[Song: <strong class='tag-b'>Вместо печати графики я хочу использовать резидентный шрифт принтера. Как? </strong><br>
<br>
--------------------------------------------------------------------------------<br>
<br>
Используте функцию Windows API - GetStockObject() чтобы получить дескриптор (handle) шрифта по умолчанию устройства (DEVICE_DEFAULT_FONT) и передайте его Printer.Font.Handle. <br>
Пример:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;</div><div class="code_line">uses Printers;</div><div class="code_line">procedure TForm1.Button1Click(Sender: TObject);</div><div class="code_line">var tm : TTextMetric;    </div><div class="code_line">    i : integer;</div><div class="code_line">begin    </div><div class="code_line"> if PrintDialog1.Execute then    </div><div class="code_line">  begin        </div><div class="code_line">   Printer.BeginDoc;        </div><div class="code_line">   Printer.Canvas.Font.Handle := GetStockObject(DEVICE_DEFAULT_FONT);        </div><div class="code_line">   GetTextMetrics(Printer.Canvas.Handle, tm);        </div><div class="code_line">   for i := 1 to 10 do Printer.Canvas.TextOut(100,i * tm.tmHeight + tm.tmExternalLeading,&#39;Test&#39;);       Printer.EndDoc;    </div><div class="code_line">  end;</div><div class="code_line">end;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
2-ой пример:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">unit Esc1;</div><div class="code_line">&nbsp;</div><div class="code_line">interface</div><div class="code_line">&nbsp;</div><div class="code_line">uses</div><div class="code_line">&nbsp;&nbsp;SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,</div><div class="code_line">&nbsp;&nbsp;Forms, Dialogs, StdCtrls;</div><div class="code_line">&nbsp;</div><div class="code_line">type</div><div class="code_line">&nbsp;&nbsp;TForm1 = class(TForm)</div><div class="code_line">&nbsp;&nbsp; &nbsp;Button1: TButton;</div><div class="code_line">&nbsp;&nbsp; &nbsp;procedure Button1Click(Sender: TObject);</div><div class="code_line">&nbsp;&nbsp;private</div><div class="code_line">&nbsp;&nbsp; &nbsp;{ Private declarations }</div><div class="code_line">&nbsp;&nbsp;public</div><div class="code_line">&nbsp;&nbsp; &nbsp;{ Public declarations }</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;Form1: TForm1;</div><div class="code_line">&nbsp;</div><div class="code_line">implementation</div><div class="code_line">&nbsp;</div><div class="code_line">{ add the printers unit }</div><div class="code_line">uses</div><div class="code_line">&nbsp;&nbsp; Printers;</div><div class="code_line">&nbsp;</div><div class="code_line">{$R *.DFM}</div><div class="code_line">&nbsp;</div><div class="code_line">{ declare the &quot;PASSTHROUGH&quot; structure }</div><div class="code_line">type TPrnBuffRec = record</div><div class="code_line">&nbsp;&nbsp;BuffLength : word;</div><div class="code_line">&nbsp;&nbsp;Buffer : array [0..255] of char;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TForm1.Button1Click(Sender: TObject);</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;Buff : TPrnBuffRec;</div><div class="code_line">&nbsp;&nbsp;TestInt : integer;</div><div class="code_line">&nbsp;&nbsp;s : string;</div><div class="code_line">begin</div><div class="code_line">&nbsp;</div><div class="code_line">{ Test to see if the &quot;PASSTHROUGH&quot; escape is supported }</div><div class="code_line">&nbsp;&nbsp;TestInt := PASSTHROUGH;</div><div class="code_line">&nbsp;&nbsp;if Escape(Printer.Handle,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QUERYESCSUPPORT,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sizeof(TestInt),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@TestInt,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;nil) &#62; 0 then begin</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;{ Start the printout }</div><div class="code_line">&nbsp;&nbsp; &nbsp;Printer.BeginDoc;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;{ Make a string to passthrough }</div><div class="code_line">&nbsp;&nbsp; &nbsp;s := &#39; A Test String &#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;{ Copy the string to the buffer }</div><div class="code_line">&nbsp;&nbsp; &nbsp;StrPCopy(Buff.Buffer, s);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;{ Set the buffer length }</div><div class="code_line">&nbsp;&nbsp; &nbsp;Buff.BuffLength := StrLen(Buff.Buffer);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;{ Make the escape}</div><div class="code_line">&nbsp;&nbsp; &nbsp;Escape(Printer.Canvas.Handle,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PASSTHROUGH,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Buff,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;{ End the printout }</div><div class="code_line">&nbsp;&nbsp; &nbsp;Printer.EndDoc;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">end.</div></ol></div></div></div></div>]]></description>
        <author>Song</author>
        <category>Базы данных, репортинг, печать</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=41592&amp;view=findpost&amp;p=255733</guid>
        <pubDate>Mon, 01 Dec 2003 18:41:53 +0000</pubDate>
        <title>[Раздел] Печать</title>
        <link>https://forum.sources.ru/index.php?showtopic=41592&amp;view=findpost&amp;p=255733</link>
        <description><![CDATA[Song: <strong class='tag-b'>Печать с масштабированием</strong><br>
<br>
Нижеприведённый пример показывает как вывести на печать изображение, помещённое в Image1 с масштабированием.<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">procedure TForm1.Button1Click(Sender: TObject);</div><div class="code_line">// © Song</div><div class="code_line">Var ScaleX, ScaleY: Integer;</div><div class="code_line">Begin</div><div class="code_line"> Printer.BeginDoc;</div><div class="code_line"> With Printer Do</div><div class="code_line">  try</div><div class="code_line">   ScaleX:=GetDeviceCaps(Handle,LogPixelsX) div PixelsPerInch;</div><div class="code_line">   ScaleY:=GetDeviceCaps(Handle,LogPixelsY) div PixelsPerInch;</div><div class="code_line">   Canvas.StretchDraw(Rect(0,0,Image1.Picture.Width*ScaleX,Image1.Picture.Height*ScaleY),Image1.Picture.Graphic);</div><div class="code_line">  finally</div><div class="code_line">   EndDoc;</div><div class="code_line">  end;</div><div class="code_line">End;</div></ol></div></div></div></div><br>
<br>
<span class="tag-color tag-color-named" data-value="green" style="color: green"><span class="tag-font" data-value="Arial" style="font-family:Arial"><span class='tag-size' data-value='8' style='font-size:8pt;'>Тема - элемент ЧАВО. Подготовлена by © Song</span></span></span>]]></description>
        <author>Song</author>
        <category>Базы данных, репортинг, печать</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=41592&amp;view=findpost&amp;p=246623</guid>
        <pubDate>Mon, 17 Nov 2003 07:02:53 +0000</pubDate>
        <title>[Раздел] Печать</title>
        <link>https://forum.sources.ru/index.php?showtopic=41592&amp;view=findpost&amp;p=246623</link>
        <description><![CDATA[Song: <b>Определение количества заданий в спулере печати</b><br><br>Spooler печати Windows посылает WM_SPOOLERSTATUS каждый раз при добавлении и удалении заданий в очереди печати. В следующем примере показано как перехватить это сообщение:<br>[doHTML]<br>&lt;b&gt;type&lt;/b&gt;&lt;br&gt;       TForm1 = &lt;b&gt;class&lt;/b&gt;(TForm)&lt;br&gt; &nbsp; &nbsp; Label1: TLabel;&lt;br&gt;       &lt;b&gt;private&lt;/b&gt;&lt;br&gt; &nbsp; &nbsp; { &lt;b&gt;Private&lt;/b&gt; declarations }&lt;br&gt; &nbsp; &nbsp; &lt;b&gt;procedure&lt;/b&gt; WM_SpoolerStatus(&lt;b&gt;var&lt;/b&gt; Msg : TWMSPOOLERSTATUS);&lt;br&gt; &nbsp; &nbsp;   message WM_SPOOLERSTATUS;&lt;br&gt;       &lt;b&gt;public&lt;/b&gt;&lt;br&gt; &nbsp; &nbsp; { &lt;b&gt;Public&lt;/b&gt; declarations }&lt;br&gt;       &lt;b&gt;end&lt;/b&gt;;&lt;br&gt;&lt;br&gt;     &lt;b&gt;var&lt;/b&gt;&lt;br&gt;       Form1: TForm1;&lt;br&gt;&lt;br&gt;     &lt;b&gt;implementation&lt;/b&gt;&lt;br&gt;&lt;br&gt;     {&#036;R *.DFM}&lt;br&gt;&lt;br&gt;     &lt;b&gt;procedure&lt;/b&gt; TForm1.WM_SpoolerStatus(&lt;b&gt;var&lt;/b&gt; Msg : TWMSPOOLERSTATUS);&lt;br&gt;     &lt;b&gt;begin&lt;/b&gt;&lt;br&gt;       Lable1.Caption := IntToStr(msg.JobsLeft) +&lt;br&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&#39; Jobs currenly in spooler&#39;;&lt;br&gt;       msg.Result := 0;&lt;br&gt;     &lt;b&gt;end&lt;/b&gt;;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;&lt;small&gt;Источник: &lt;a href=&quot;http://www.vlata.com/delphi/&quot; target=_blank&gt;Дельфи. Вокруг да около.&lt;/a&gt;&lt;/small&gt;&lt;br&gt;&lt;br&gt;[/doHTML]]]></description>
        <author>Song</author>
        <category>Базы данных, репортинг, печать</category>
      </item>
	
      </channel>
      </rss>
	