🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.win32
Article #2191

Re: Printing With Win32 API, MSDN example gives error

#2191
From: szuchymj
Date: Sun, 04 Sep 2005 01:16
29 lines
2113 bytes
Using the example at
http://community.borland.com/article/0,1410,16139,00.html I was able to
fix the problem. Here is my new code.

procedure printMain;
var
  Pd : TPrintDlg;
  DocInfo: TDocInfo;
begin
  FillChar(Pd, sizeof(Pd), 0);
  Pd.lStructSize := sizeof(Pd);
  Pd.hWndOwner := Form1.Handle;
  Pd.Flags := PD_RETURNDC;
    if PrintDlg(pd) then
    begin
    FillChar(DocInfo, sizeof(DocInfo), 0);
    DocInfo.cbSize := SizeOf(DocInfo);
    StartDoc(Pd.hDc, DocInfo);
    StartPage(Pd.hDc);
    TextOut(Pd.hDc, 100, 100, 'test123', length('test123'));
    EndPage(Pd.hDc);
    EndDoc(Pd.hDc);
    end;
end;

I do not yet know what was causing the problem in my previous code, but
on first glance it appears that a member of the DOCINFO structure or
the PRINTDLG structure was initialized to something it should not have
been.
Technical Details
Message-ID: <1125796596.258211.216430@o13g2000cwo.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!o13g2000cwo.googlegroups.com!not-for-mail
References: <1125794713.945948.34130@g43g2000cwa.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 113dfb,24b6e7811432affe
X-Google-Thread: 1091e5,24b6e7811432affe
X-Google-Attributes: gid113dfb,gid1091e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!o13g2000cwo.googlegroups.com!not-for-mail
From: szuchymj@jmu.edu
Newsgroups: comp.os.ms-windows.programmer.win32,borland.public.delphi.winapi
Subject: Re: Printing With Win32 API, MSDN example gives error
Date: 3 Sep 2005 18:16:36 -0700
Organization: http://groups.google.com
Lines: 30
Message-ID: <1125796596.258211.216430@o13g2000cwo.googlegroups.com>
References: <1125794713.945948.34130@g43g2000cwa.googlegroups.com>
NNTP-Posting-Host: 66.83.218.130
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1125796603 23132 127.0.0.1 (4 Sep 2005 01:16:43 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 4 Sep 2005 01:16:43 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: o13g2000cwo.googlegroups.com; posting-host=66.83.218.130;
   posting-account=h-CzxBMAAACeKXWvd0mMfZjAXz9xvSTYFf_H1NiezujMeUnvRCeTLg