0

Here is my problem : I have to port an old sofware made for windows NT 4 (i thought) with an old Borland on Windows 7 or newer. The program is running well ( no problem with dependency walker, App Verifier shows a Bad DEVMODE buffer but this error exists on XP and it works well).

The programm have to print a label with some information, this works good on windows XP but on seven numbers are blurry, i don't know why and i don't how to troubleshoot that.

My printer works because i can print a text on seven perfectly and if i print with a pdf printer the problem still the same so i thought that the problem is from windows.

Any idea?

Edit 1 : I have some parts of the source code but parts that were included in the IDE are missing. The printer is not in cause i think because it's the same for the two tests and the problem still here with a PDF printer

here is the source code of print :

 //---------------------------------------------------------------------------
 #include <vcl.h>
 #pragma hdrstop
 #include <printers.hpp>
 #include "FileCtrl.hpp"
 #include "IniFileName.h"
 #include "PrnEtiQ.h"
 #include "CheckDll.h"
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 #pragma resource "*.dfm"
 TEtiquette *Etiquette;
 //---------------------------------------------------------------------------
 __fastcall TEtiquette::TEtiquette(TComponent* Owner) : TForm(Owner)
 {
 }
 //---------------------------------------------------------------------------
 void __fastcall TEtiquette::PrintEti(AnsiString Name,double OD,double           OG,double xrb,int PrnIndex)
 {
  if (PrnIndex==-1) return;
  TIniFile * pIni=new TIniFile(GetIniFileName());
  if (pIni)
  {
    DecalX=pIni->ReadInteger("ETIQUETTE","Decal_X",150);
    DecalY=pIni->ReadInteger("ETIQUETTE","Decal_Y",0);
    pIni->WriteInteger("ETIQUETTE","Decal_X",DecalX);
    pIni->WriteInteger("ETIQUETTE","Decal_Y",DecalY);
    delete pIni;
  } 
  else
  {
    DecalX=150;
    DecalY=0;
  }
  LblName->Caption=Name;
  PerimDroit->Caption=FormatFloat("##0.0000",OD);
  PerimGauche->Caption=FormatFloat("##0.0000",OG);
  XRB->Caption=FormatFloat("##0.00",xrb);
  Printer()->PrinterIndex=PrnIndex;
  int MemoWidth=Width;
  int MemoHeight=Height;
  Width=MemoWidth+DecalX;
  Height=MemoHeight+DecalY;
  Panel1->Left=DecalX;
  Panel1->Top=DecalY;
  Print();
  Width=MemoWidth;
  Height=MemoHeight;
  Panel1->Left=0;
  Panel1->Top=0;
 }
 //---------------------------------------------------------------------------

and here is the .DFM file which describe the shape of the label

object Etiquette: TEtiquette
Left = 167
Top = 149
HorzScrollBar.Visible = False
VertScrollBar.Visible = False
BorderIcons = []
BorderStyle = bsNone
ClientHeight = 33
ClientWidth = 142
Color = clWhite
UseDockManager = True
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial Black'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 18
object Panel1: TPanel
  Left = 0
  Top = 0
  Width = 143
  Height = 34
  BevelOuter = bvNone
  Color = clWhite
  Font.Charset = ANSI_CHARSET
  Font.Color = clWindowText
  Font.Height = -13
  Font.Name = 'Arial Black'
  Font.Style = []
  ParentFont = False
  TabOrder = 0
  object PerimGauche: TLabel
    Left = 4
    Top = 0
    Width = 65
    Height = 11
    AutoSize = False
    Caption = '200.00'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentColor = False
    ParentFont = False
  end
  object PerimDroit: TLabel
    Left = 72
    Top = 0
    Width = 66
    Height = 11
    Alignment = taRightJustify
    AutoSize = False
    Caption = '100.00'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentColor = False
    ParentFont = False
  end
  object XRB: TLabel
    Left = 40
    Top = 12
    Width = 57
    Height = 11
    Alignment = taCenter
    AutoSize = False
    Caption = '123.45'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentColor = False
    ParentFont = False
  end
  object LblName: TLabel
    Left = 4
    Top = 20
    Width = 42
    Height = 14
    Caption = '18241_1'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = []
    ParentColor = False
    ParentFont = False
  end
end
end

As you can see, fonts are hardcoded so i don't think that the problem is there futhermore i checked the fonts and they are in the same version.

Edit 2 : https://drive.google.com/file/d/0B0AeGDmETlPXbGlPX3dUSG1WUzg/view?usp=sharing

Spektre
  • 49,595
  • 11
  • 110
  • 380

1 Answers1

0

As your question is not specific enough so here some hints that could help instead of answer:

Do you have the source code for the printing?

search source code for things like:

#include <Printers.hpp>
TPrinter *prn = Printer();
// here open dialog window... set the printing parameters
prn->BeginDoc();
// here draw the printed image to prn->Canvas
prn->NewPage();
// here draw the printed image to prn->Canvas
// ...
prn->EndDoc();

Try to copy the prn->Canvas to Graphics::TBitmap *bmp->CopyRect(...) and then save it to file bmp->SaveToFile("print.bmp");. To check if the problem is in rendering the image prior to printing it or not. Also post printing code here so we see if there is not anything suspicious. If you not familiar with Canvas/Bitmap under VCL see:

What about posting an image of correct and incorrect print.

Now I can think of few possibilities like:

  1. some Win7 enhance text feature altering used fonts

  2. different used font parameters from XP

    can try to copy XP fonts to your Win7 (do not forget to save the originals one)

  3. wrongly selected printer paper area in pixels

    (x64 Windows is running Win32 apps in WOW64 emulator which has different set of drivers at disposal may be it returns different printer/parameters or something)

  4. newer printer drivers (like HP)

    adds on default toner saving by scaling printed image to 97% making aliasing/blurring artifacts. Check printing dialog window for such things

  5. usage of some 3th party component

    I stop using those because they are quickly being outdated unsupported and makes my life a hell while porting to newer OS,compiler whatever. Not to mention they are usually insainly priced

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380
  • I can't add a picture :/ – Florian GERARD Jun 24 '15 at 09:49
  • @FlorianGERARD 1. you can post the images somewhere and post links to it here someone will copy it for you here. 2. after look at your source I see no printing code try to look for `Printer()` function body somewhere the printing is invoked by `Printer()->EndDoc();` your code just move/hide some panels and adjust Memo while printing (probably hiding the tool bars). When you find the actual printing routine intercept its image to see if the problem is in the rendering or printing itself. – Spektre Jun 24 '15 at 11:08
  • @FlorianGERARD if you are in compilable state then you can place breakpoint on the `Print();` line and Press F7 to step into it. Also you are accessing ini files so make sure you do not have problem with decimal point `,` or `.` inside ini files ... – Spektre Jun 24 '15 at 11:10
  • this is the deepest source code of the soft, printers.hpp belongs to Borland, this is an old IDE which doesn't run on windows 7 (16 bits program). I found Printers.hpp and Printers.pas (yes it's pascal) but i don't know if i can compile it again. – Florian GERARD Jun 24 '15 at 12:31
  • @FlorianGERARD you got it wrong the printing routine is not part of VCL it is a custom source code somewhere not in `Printers.hpp` You need to search source code of the application not the VCL and RTL stuff from borland. – Spektre Jun 24 '15 at 13:47
  • I can't find any function named "Print" in my source code – Florian GERARD Jun 24 '15 at 14:39
  • @FlorianGERARD then try to find `EndDoc` in the source code. if it is not there either then: 1. you are missing some files 2. printing is done a different way 3. printing is done inside linked Obj,Dll,or some component. You need to intercept the image that is going to printing and check if the distortion is there or not. If it is then the error is in rendering not printing and you should check resolution,DPI,font settings,and scalability settings of the object that is printed (my bet is a bitmap or Printer()->Canvas) – Spektre Jun 26 '15 at 07:58
  • I Don't know if some files are missing or if the print function is from some Borland api but anyway i can't compile the code so i don't know how to debug it. I know that there are two home made Dlls but they're just here to do some calculation, all others Dlls are Windows's ones. – Florian GERARD Jun 26 '15 at 08:56
  • @FlorianGERARD why cant you compile it? what errors are there? what IDE was it written in and in which one you trying to compile it now? to open project relevantly you need to open *.bdsproj (bds2006) or *.bpr (bcb 3,4,5,6). if you open just some *.c,h,cpp,hpp,dfm,pas file then you are not opening the whole application. Things like unresolved external means you have not linked some obj,dll or included c/cpp/pas file. – Spektre Jun 26 '15 at 09:03
  • @FlorianGERARD Borland VCL si just an API the printing function itself must be somewhere (not part of VCL!!!) So the `Print();` is either invoking printing from VCL (I doubt it because it is not called as member of Printer() instead as a global function or custom member of formular) but the print it self is elsewhere in your code or you have some function imported/or coded somewhere – Spektre Jun 26 '15 at 09:08
  • @FlorianGERARD search `Etiquette.h` for `Print();` if it is there then it is an member of that form (can be added as `extern`) if not then it must be present in some file included prior to its use ... You can also try to look for it inside exe,dll,lib,obj files with some PE explorer tool – Spektre Jun 26 '15 at 09:11
  • I can open the project with Borland 5.0 on my XP machine but some include file are missing at least, i suppose that all the path are correct because this is the old project that was used to make the soft. I don't know exactly with what ide was made the soft, i know that we used Borland but i have no information about this soft in particular. theorically I should port this soft making the less modification as i can. It was working well on windows XP so i wonder if it is possible to make Seven behave just like XP, there is no error on windbg so windows can understand my program – Florian GERARD Jun 26 '15 at 12:09
  • @FlorianGERARD which include files are missing (those names can tell a lot)?, Most VCL Visual components have enabled scalability on default making problems with higher DPI settings on Windows. btw as you can not compile how do you want to make changes to the exe? – Spektre Jun 26 '15 at 12:14
  • i wondered if there is some settings to enable or disable/enable some options to make things right. Includes missing are by example : OvcLB.Hpp, AdPort.hpp, OoMisc.hpp, OvcBase.hpp. I didn't find any information on them on google (nothing very interesting), they are not on my source folder and i didn't find them in borland too. Maybe there is something i didn't understand but the printer is the same as XP so my printers DPI are exactly the same so why windows would scale my label ? – Florian GERARD Jun 26 '15 at 12:44
  • @FlorianGERARD it looks like some custom components for Delphi/BCB from a quick google search I found these: [Orpheus: OvclLB,OvcBase](http://sourceforge.net/projects/tporpheus/) and [TPA Pro / AsyncPro: AdPort,OoMisc](http://tpapro.sourceforge.net/) so try to download them install into BCB and try to compile the project again. As I mentioned before 3th party components are pain in the ass if you need to port or maintain apps for a long time – Spektre Jun 26 '15 at 15:21
  • @FlorianGERARD PS I meant also DPI of desktop ...not just Printer ... as VCL components are practically Windows windows they share DPI from the base classes ... Old applications have sometimes problems if run on modern hi resolution desktops (does not matter if virtual or real) ... causing invalid font sizes and bad resizing effects/atifacts – Spektre Jun 26 '15 at 15:33
  • I solved my problem : your explanation about dpi of desktop made me tried some things like changing screen resolution, modify cleartype .... Modify cleartype helped me a little but doesn't solve the problem. My printing become clear with 256 colors mode in compatibility options? maybe it disable shadow on letter or an another fonction. Thanks for your help, it helps me great :) – Florian GERARD Jun 29 '15 at 09:38