archive-com.com » COM » E » EFG2.COM

Total: 878

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • efg's Delphi Files, Directories, I/O Page
    C Disks Drives D File I O IOResults Critical Errors E Stream I O F Port I O Links Delphi Tutorial Reading Writing Files http ourworld compuserve com homepages TK Boyd Dt2b htm Robert Clemnzi s File I O Page

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/IO/index.html (2016-02-14)
    Open archived version from archive

  • efg's Reference Library: Delphi Graphics Info and Links
    printers Also see Printer Demo 1 How can I clear a TImage How can I clear a Canvas How can I convert from graphics format X to graphics format Y Why is double buffering important How can I display a rotated font How can I print a rotated font How can I rotate a bitmap How can I use OpenGL DirectX How can I prevent flickering How can I display

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Graphics/index.html (2016-02-14)
    Open archived version from archive

  • efg's Reference Library: Delphi Math Functions
    miscellaneous IsNaN Get Set87ControlWord GetRoundMode Engineering Mathematics hyperbolic functions sinh cosh tanh inverse functions special functions bessel functions beta gamma erf complex math and functions linear algebra matrices eigenvalues eigenvectors digital signal processing fourier transforms FFTs ordinary and partial differential equations Numerical Methods interpolation extrapolation numerical integration derivatives polynomials functional evaluation Chebyshev approximation optimization simplex powell root finding non linear equations Statistics and Probability statistics min max sum mean stddev

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/MathFunctions/index.html (2016-02-14)
    Open archived version from archive

  • efg's Computer Lab -- Delphi Math Info
    explicitly converted to another integer type through typecasting Most standard routines that take integer arguments truncate Int64 values to 32 bits However the High Low Succ Pred Inc Dec IntToStr and IntToHex routines fully support Int64 arguments Also the Round Trunc StrToInt64 and StrToInt64Def functions return Int64 values A few routines including Ord cannot take Int64 values at all Both Delphi 4 and 5 define a ULARGE INTEGER variant record that can be viewed as two DWORD s LowPart and HighPart or a single LongLong QuadPart While a ULARGE INTEGER can hold an unsigned 64 bit quantitity there are no known Delphi functions for manipulating these quantities The LARGE INTEGER variant record is just like the ULARGE INTEGER definition except the HighPart is a LongInt instead of a DWORD In Delphi 3 The TLargeInteger variant record was defined like LARGE INTEGER in D4 D5 CAUTION There is at least one problem introduced somehow indirectly by the new Int64 support in Delphi 4 Example Given variables A and B of type Byte or Word with A 40 and B 45 the expression A B is 5 as expected as it has been in Delphi 1 2 and 3 but A B DIV 4 is 1 073 741 822 slightly unexpected There is no compiler warning about this possible consequence Borland claims this is NOT a bug In Delphi 4 if A and B are LongWords 32 bit unsigned values the expression A B is 4 294 967 291 IMHO Borland should treat all unsigned quantities in a like way Note See 7 12 98 post D4 Arithmetic Bug or Feature when subtracting byte values to various Delphi newsgroups and replies for some additional details This is fixed in D5 A B 5 and A B DIV 4 1 as expected See Ray Lischner s Delphi 4 Integers The Long and the Short of It in March April 1999 Visual Developer pp 92 93 Ray Lischner s UseNet Post with reasons why to use Int64 instead of Comp Baji Kimran s comment about Ray s reason 1 I think the reason for only 18 digits being correct is that the FPU has a float to BCD instruction that is used to convert to decimal and it has a bug for 19 digits See Marc Palmer s UseNet Post about Int64 range checking problems See Performance of large integer types In a UseNet posting Baji Kimran says in my experience if the dividend is 2 32 Int64 div and mod are pretty slow Then a comp is considerably faster than an Int64 div You can even do a mod function on comps faster than int64 mod if the dividend is 2 32 If you have a mixture of arithmetic types in a program the actual mix of operations determines whether comp or int64 is faster If there are many div or mod operations comp is usually faster since they are so slow on int64 2 32 Thanks to Roman Krejci for correcting an error in the above table about the generic integer in Delphi versions 2 3 2 Aug 1998 B 3 What are the floating point data types Type Delphi Version Min Value Max Value Significant Digits Bytes Real generic 1 3 2 9 x 10 39 1 7 x 10 38 11 12 6 4 6 5 0 x 10 324 1 7 x 10 308 15 16 8 Real48 4 6 2 9 x 10 39 1 7 x 10 38 11 12 6 Single all 1 5 x 10 45 3 4 x 10 38 7 8 4 Double all 5 0 x 10 324 1 7 x 10 308 15 16 8 Extended all 3 4 x 10 4932 1 1 x 10 4932 19 20 10 Comp all 2 63 1 or 9 2 x 10 18 2 63 1 or 9 2 x 10 18 19 20 8 Currency 2 6 922 337 203 685 477 5808 922 337 203 685 477 5807 19 20 8 Notes The generic type Real in Delphi 4 5 is equivalent to Double The 6 byte Real48 type was called Real in earlier versions of Object Pascal If you are recompiling code that uses the older 6 byte Real type you may want to change it to Real48 You can also use the REALCOMPATIBILITY ON compiler directive to turn Real back into the 6 byte type Real48 is maintained for backward compatibility Since its storage format is not native to the Intel CPU family it results in slower performance than other floating point types Extended offers greater precision than other real types but is less portable Be careful using Extended if you are creating data files to share across platforms The Comp computational type is native to the Intel CPU and represents a 64 bit integer A Comp is classified as a real however it does not behave like an ordinal type Comp is maintained for backward compatibility only Use the Int64 type for better performance Currency is a fixed point data type that minimizes rounding errors in monetary calculations It is stored as a scaled 64 bit integer with the four least significant digits implicitly representing decimal places When mixed with other real types in assignments and expressions Currency values are automatically divided or multiplied by 10000 Ray Lischner s UseNet Post with reasons why to use Int64 instead of Comp Tips and Tricks from Delphi in a NutShell Double type pp 184 186 shows how to extract sign exponent mantissa Extended type pp 202 204 shows how to extract sign exponent mantissa Single type pp 342 344 shows how to extract sign exponent mantissa Real48 type p 309 Comp type p 166 Currency type p 173 B 4 How can I learn more about floating point numbers See Borland s Tech Info 1027 An Overview of Floating Point Numbers http community borland com article 0 1410 15855 00 html The math in the article is OK but the programming examples are in C unfortunately The article Reviewing Delphi by the numbers in the April 1998 Delphi Developer s Journal pp 7 11 is a good overview of ordinal and floating point types in Delphi B 5 What is IEEE floating point IEEE 754 is a standard way to store floating point values on a variety of computers The Single Double and Extended data types are all stored in IEEE format The older Real values are not stored in IEEE format See efg s NaN Tech Note IEEE Standard 754 Floating Point Numbers www research microsoft com hollasch cgindex coding ieeefloat html Formally Verifying IEEE Compliance of Floating Point Hardware http developer intel com technology itj q11999 articles art 5 htm A German description of IEEE 754 Gleitkommazahlen nach IEEE is available from http www informatik uni halle de lehre pascal sprache pas ieee html Future 64 bit Intel Architecture The Computation of Transcendental Functions on the IA 64 Architecture http developer intel com technology itj q41999 articles art 5 htm IA 64 Floating Point Operations and the IEEE Standard for Binary Floating Point Arithmetic http developer intel com technology itj q41999 articles art 6 htm John Herbster s T BinaryFloatingPoint program for analyzing the extended double and single binary point numbers B 6 How can I convert my old Real values to IEEE doubles See Richard Biffl s BPREAL C function and related files BPReal ZIP To convert Turbo Pascal 3 0 BCD reals 10 byte binary coded decimal reals with 18 significant digits to Turbo Pascal 5 0 floating point numbers download Turbo Pascal 5 5 from the Borland Community Museum http community borland com museum and install it Look for BCD PAS in the Turbo3 directory B 7 How can I convert between Microsoft Binary and IEEE format Mac format TI1431C Converting between Microsoft Binary and IEEE format http community borland com article 0 1410 16431 00 html Mark Di Val s Usenet Post showing Microsoft s conversion functions in C C Alex Grigny de Castro s UseNet Post show Mac number float format conversion Jason Welter s E Mail instructing how to reverse doubles for Macs B 8 What is a NAN How can I test for one What is an INF value How can I do arithmetic with NAN and INF values In IEEE math a NAN is not a number i e an undefined value INF is infinity and can be positive or negative Sample of easy way to define NAN and INF values procedure TForm1 ButtonSpecialClick Sender TObject CONST Infinity 1 0 0 0 NaN 0 0 0 0 begin INF NAN ShowMessage FloatToStr Infinity FloatToStr NaN end TI1716 Testing for Not a Number NaN http community borland com article 0 1410 16716 00 html Ray Lischner s math10 zip has some information about NANs and INFs but only compiles in Delphi 1 See IEEE754 TXT for a short Delphi 3 unit that defines NAN PositiveInfinity etc and shows an example of how to use such values in expressions Also includes a DoubleToHex function to display double s in logical hex format See efg s Exploring Numbers Not a Number and Infinity Delphi Developer October 1998 pp 9 14 B 9 What is IEEE rounding efg s Set8087CW and SetRoundMode rounding example See Set8087CW for examples The default IEEE rounding rule is to round to the nearest even integer For example ROUND 2 5 2 but ROUND 3 5 4 This is also called banker s rounding Ray Lischner s math10 zip only compiles in Delphi 1 but has code to control how the rounding is performed by manipulating the control word of the FPU Look for functions GetRoundMode and SetRoundMode to control rounding with a TRoundMode constant with values rmNearest rmDown rmUp rmTruncate To change the rounding mode see the function Set8087CW in the Miscellaneous Function section of the Delphi General Functions Page B 10 How can I round a floating point number in the traditional way below 0 5 rounds down 0 5 and above rounds up FAQ1814D txt Explanation sic of rounding http community borland com article 0 1410 16814 00 html See Set8087CW for how to control rounding modes B 11 When I do a StrToFloat 1234 5544 I get something like 1234 55440000000003 What is wrong here Nothing is wrong here This is just a limitation of floating point numbers The actual source of error is called roundoff error This error is due to the fault of floating point arithmetic and to the fact that most decimal fractions become repeating fractions in the binary number system Such numbers cannot be represented in a finite number of bits The word roundoff is not always accurate in this connection and comes from the fact that many computers when cutting off the last digits from a number round the number to its closest equivalent Some computers do not round but merely cut off the last bits with the resulting error still properly called roundoff error as opposed to truncation error which is the term used when a series expansion is truncated From Introduction to Numerical Methods Peter A Stark Macmillian Company 1970 B 12 I m trying to compare two floating point numbers that should be equal Why aren t the two values equal TI2139 How to Compare Floating Point Numbers http community borland com article 0 1410 17139 00 html Numerical Accuracy 101 for Delphi Developers http efd home mindspring com acc101 htm Typically you can use relative or absolute comparisons to avoid problems with fuzz a term used with the language APL with floating point numbers Because of this fuzz with floating point numbers comparison of two calculated floating point numbers should be based on either absolute or relative error For an absolute error comparison use something like IF ABS CalculatedValue TrueValue FuzzValue THEN where FuzzValue is application specific For a relative error comparison use something like IF ABS CalculatedValue TrueValue TrueValue AcceptableRelativeError THEN where AcceptableRelativeError is application specific and obviously TrueValue 0 0 HOWEVER this form of comparision can lead to divide by zero problems An alternative suggested in a UseNet Post by Hans Bernhard Broeker avoids this problem by using IF ABS CalculatedValue TrueValue ABS AcceptableRelativeError TrueValue THEN The Delphi 3 math unit performs relative comparisons like this but it s not exposed in the unit s interface FUNCTION RelSmall X Y Extended Boolean Returns True if X is small relative to Y CONST C1 Double 1E 15 C2 Double 1E 12 BEGIN Result Abs X C1 C2 Abs Y END Ray Lischner has approximate comparison functions in his Math10 ZIP FltLE FltLT FltGE FltGT FltEQ FltNE Adam Majewski suggests this function to compute machine epsilon 10 7 2005 function calceps real calceps pas This function returns the machine EPSILON or floating point tolerance the smallest positive real number such that 1 0 EPSILON 1 0 EPSILON is needed to set various tolerances for different algorithms While it could be entered as a constant I prefer to calculate it since users tend to move software between machines without paying attention to the computing environment Note that more complete routines exist Idan Nof 12 List 1999 10 00 posts on comp lang pascal borland var e e0 extended i integer begin calculate machine epsilon e0 1 i 0 repeat e0 e0 2 e 1 e0 i i 1 until e 1 0 or i 50 note safety check e0 e0 2 Writeln Machine EPSILON e0 calceps e0 end calceps B 13 Explain how a comp type is a floating point type but is a 64 bit integer Note Use the new Int64 type in Delphi 4 or later Since the floating point unit FPU deals with this 64 bit integer the comp type is treated as if it were a floating point type even though it is a 64 bit integer Delphi s VCL defines a type called TLargeInteger type that has a QuadPart comp type but also a LowPart and HighPart that are LongInts You can speed up conversion of a comp to an integer type using TLargeInteger See Borland s Assigning a comp type to an integer FAQ 1965D In D4 the TLargeInteger is an Int64 but through a pLargeInteger pointer the LowPart HighPart and QuadPart of the Int64 can still be accessed like in D3 In D4 a TULargeInteger and a pULargeInteger are defined much like the TLargeInteger and pLargeInteger The HighPart of a TULargeInteger is a DWORD i e unsigned while the HighPart of a TLargeInteger is a LongInt i e signed While not very intuitive you must treat a comp type as a float when converting to a string Specifically you must use FloatToStr or FormatFloat to convert to a string Consider the following example VAR c TLargeInteger s STRING c QuadPart MaxComp MaxComp defined in Delphi math unit s Format 8X 8X d d f c HighPart c LowPart c HighPart c LowPart c QuadPart The resulting string s contains the following 7FFFFFFFFFFFFFFF 2147483647 1 9 22337203685477581E18 Another example of using TLargeInteger is in Using the WIN API high resolution performance counter FAQ 2028D B 14 How can I get Delphi to perform stronger type checking on user defined types For example how can I define a type that descends from a double but not pass this type to any function expecting a double without a warning See Borland FAQ 2126D Getting stronger type checking B 15 Unsigned 32 Integers for Delphi 2 3 By Ray Lischner The Unsigned unit implements unsigned 32 bit integer arithmetic comparisons conversions and division Freeware Source code and help file included In Delphi 1 0 you must also download the FltMath unit in math10 zip B 16 Floating Point Optimzation Floating Point Optimization Guidelines www optimalcode com float htm C Delphi Math Tips and Tricks Topic Tip or Trick C 1 Integer to Float Simple assignment x i C 2 Integer to String s IntToStr i or Format 6 6d 1234 returns 001234 C 3 Float to Integer TRUNC 3 5 3 or ROUND see IEEE Rounding above C 4 Float to String Format FormatFloat or FloatToStr but also FloatToDecimal FloatToStrF FloatToText FloatToTextFmt Examples Format 3f times d is 16s Measurement Value Key C sprintf format specifications FormatFloat 0 0 Factor FloatToStr x C 5 String To Float Sting To Integer If d is a double d StrToFloat 1234 5544 If i is an integer i StrToInt 1234 C 6 How can I localize numbers to display correctly in both the U S and European formats What is the ThousandSeparator What is the DecimalSeparator VAR x DOUBLE i INTEGER BEGIN x 1234567 8945 Button1 Caption ThousandSeparator ThousandSeparator DecimalSeparator LabelUSA Caption FormatFloat x ThousandSeparator DecimalSeparator LabelEuropean Caption FormatFloat x The resulting strings are remember IEEE rounding rounds towards an even number USA 1 234 567 894 European 1 234 567 894 Treat an integer the same way and use FormatFloat to get a ThousandSeparator in an integer string C 7 Dynamically allocated arrays one dimension Arrays are incredibly useful and crop up in just about every project we create But out of the box they are rather inflexible as you need to decide upfront how big your array should be Not any more Brian Long explains how to make your arrays dynamic resizeable and powerful for Delphi 1 right through to Delphi 4 with its new built in dynamic arrays feature Delphi Magazine Issue 37 September 1998 How to Create an Array of 2 000 000 doubles in Delphi 1 Delphi1LargeArray ZIP Also see example below in Open Array Slice Function I don t particularly like Borland s solution How can I resize an array sorry Joe since it requires turning off all range checking FAQ 1830D Also look at Borland s Tech Info Report Dynamically Allocating Arrays TI 1093D Dr Dobb s Journal on huge arrays in Turbo Pascal ftp garbo uwasa fi pc turbopas ddj8803 zip Dr Dobb s Journal on virtual arrays in

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/MathInfo/index.html (2016-02-14)
    Open archived version from archive

  • efg's Computer Lab -- Delphi Math Resources
    efficient floating point routines rounding comparison for both scientific and financial apps and runtime evaluation of mathematical expressions Numerical Accuracy 101 for Delphi Developers MRNG a fast BASM implementation of the Mother of all Pseudo Random Number Generators by Fedor V Kozhevnikov Igor Pavluk and Serge Korolev http www rxlib com TCurrencyEdit Input of money amounts and other numbers too TRxCalcEdit and TRxDBCalcEdit data aware version take the display and editing of numeric data one step further they provide a popup calculator to help you calculate the number TRxDice TRxCalculator Numerics for RAD by Janez Makovsek and Marjan Slatinek www dewresearch com Dew Research introduces an object oriented library for Delphi Pascal MtxVec is the first object oriented numerical library available for Delphi and CBuilder users The library offers top performance not seen in competitive products and features the highest Performance Time to implement ratio of any numerical software available today for personal computers Delphi Page by Rente Schaaf www xmission com renates delphi html TMathImage TExpress Surface Plot Collection D3PlotProject by Gary Darby www delphiforfun org Numeric edit components Validating numeric input Several math algorithm programs Scientific mathematics SIMD Introduction by Dr Chris Rorden Department of Psychology University of Nottingham Understanding floating point values in a Delphi environment by Guido Gybels What Every Computer Scientist Should Know About Floating Point Arithmetic by David Goldberg A reprint of his article published in the March 1991 issue of ACM Computing Surveys Not Delphi specific but an invaluable resource GSL GNU Scientific Library www gnu org software gsl gsl html Other Links Delphi Delphi math articles As the Crow Files Determining the Shortest Path through a Network by Rod Stephens in December 1998 Delphi Informant pp 34 40 File DI9812RS ZIP Random Thoughts A Look at Generating Random Numbers with Delphi by Keith Wood March 1997 Delphi Informant pp 62 72 Delphi math components Many math related items can be found at the Delphi Super Page http delphi icm edu pl Mathematics Components and Tools http delphi about com msubMathematic htm Torry s site has a number of math related components but look for them under Science After Torry s reorganization and without a search engine I just dropped all the broken links I had to Torry s site www torry net Applied Analytic Systems Components TDescStat TDiscreteSim TLPSolver TMLRegress TSLRegress www aasdt com delphi components html TMLRegress Tutorial www aasdt com statistics mlrtutorial index html Delphi math libraries EZMath by Robert Bullock Math processor assembly or Delphi versions of functions Tan ArcCot ArcTan2 and Log10 Delphi code for Cot ArcSin ArcCsc ArcCos ArcSec Log Power EuclideanNorm http www muohio edu bullocrm ezmath zip Help floating point math in Delphi math10 zip by Ray Lischner Floating point comparisons rounding modes NANs Infinity Floating Point Rounding SetRoundMode Floating point comparison functions Delphi 1 does not compile in Delphi 3 http www tempest sw com freeware Select Delphi components Delphi math links Multiple Regression Statistical Analysis TzCalc www xs4all nl dgb delmath html C

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/MathInfo/Resources.htm (2016-02-14)
    Open archived version from archive

  • efg's Delphi Miscellany
    of Pascal www oberon ch resources component pascal history html UCSD p System Museum www threedee com jcm psystem Borland Museum http community borland com museum Antique Software Turbo Pascal version 5 5 http community borland com article 0 1410 20803 00 html Bob Swart s UseNet Post with D1 D6 release dates Borland Inprise Pascal Versions www emsps com oldtools borpasv htm Delphi 10 Years in the Making pp 4 7 Delphi Component Design by Danny Thorpe Why the name Delphi by Danny Thorpe http community borland com article 0 1410 20396 00 html A Little History D1 D5 pp 15 18 Delphi 5 Developer s Guide by Teixeria and Pacheco Old Used and Out of Print Borland Inprise Software www emsps com oldtools borland htm IDE Hidden Features of the Delphi 5 IDE http community borland com article 0 1410 20624 00 html Internet general Internet Programming with Delphi by Marco Cantù http community borland com article 0 1410 27143 00 html Overbyte ICS Internet Component Suite http www overbyte be Introduction to Indy www pbe com Kudzu Articles IntroToIndy Streaming images from Web Applications http community borland com article 0 1410 20378 00 html Web Broker Overview and Review www xapxone com html dl304 htm IE Delphi www euromind com iedelphi index html Internet ASP Delphi and ASP Getting Started with Active Server Pages www delphizine com features 2000 07 di200007cj f di200007cj f asp Internet Browser IE Delphi www euromind com iedelphi Internet CGI Writing a Fancy CGI hit counter in Delphi 5 http community borland com article 0 1410 20201 00 html CGI Expert Home Page www cgiexpert com cgiexpert home htm Delphi CGI Programs http tothpaul free fr uscgi htm Simple CGI s in Delphi www undu com Articles 990315b html A Database Chart on the Web pp 65 67 Chapter 22 online bonus chapter of Mastering Delphi 5 by Marco Cantù Picture This on the Web A CGI Program to Deliver Database Pictures Delphi Informant Feb 1998 CGI Win A practical approach to remote access database www cs monash edu au vtran cgiwin htm Bryan Valencia s Choosing between CGI WIN CGI and ISAPI www 209software com books wpid Internet E Mail Send an E mail from Delphi http delphifaq com fq q2058 shtml Internet Messaging Made Easy www delphizine com features 2000 10 di200010kr f di200010kr f asp How to send e mail and faxes from your Delphi C Builder application www bhnet com br simonet howtoprojs htm Indy formerly Winshoes http www nevrona com Indy Streaming images from Web Applications How to stream jpeg s gif s files resource s creating images on the fly and setting MIME type information http community borland com article 0 1410 20378 00 html Internet SOAP Simple Object Access Protocol Introduction to SOAP www agnisoft com soap soapintro htm Using SOAP with Delphi www msdelphi com Articles SOAP Using 20SOAP 20with 20Delphi htm Pure SOAP www puresoftwaretech com puresoap Internet WebBroker WebBroker Images www drbob42 com delphi5 examin11 htm Interrupt List by Ralf Brown www cs cmu edu afs cs cmu edu user ralf pub WWW files html Keystrokes IDE Column block in D4 Hold ALT key down while selecting a block Rudy Velthuis UseNet Post about keystrokes to insert the set of compiler directives into a source file Ctrl O O Ctr Shft R record and stop recording keystrokes Ctrl Shft P plays recorded keystrokes Ctrl E starts incremental search Ctrl K E makes the current word completely lowercase Ctrl K F makes the current word complete uppercase Ctrl O U inverts case in selected portion Ctrl Alt E Euro Bryan Valencia s UseNet Post with other IDE shortcuts Copyright symbol Alt 0169 Shift Ctrl C Add the Implementation framework for given method Example In the public section of a TForm1 definition enter procedure WMSpoolerstatus var msg TWMSpoolerstatus message WM SPOOLERSTATUS With the cursor somewhere in this area enter Shift Ctrl C The following will be automatically added to the unit procedure TForm1 WMSpoolerstatus var msg TWMSpoolerstatus begin end Keystrokes Runtime Appendix D Virtual Key Code Chart Tomes Graphical pp 861 865 How to Simulate Visual Basic s SendKeys in Delphi www drdelphi com delphi right tips sendkeys htm Sndkey32 pas is included on the Delphi installation CD Info Extras SndKey32 pas makes it easy to simulate keyboard usage This unit includes two routines that simulate popular Visual Basic routines Sendkeys and AppActivate SendKeys takes a PChar as its first parameter and a boolean as its second like so SendKeys KeyString Wait where KeyString is a string of key names and modifiers that you want to send to the current input focus and Wait is a boolean variable or value that indicates whether SendKeys should wait for each key message to be processed before proceeding See the table below for more information AppActivate also takes a PChar as its only parameter like so AppActivate WindowName where WindowName is the name of the window that you want to make the current input focus SendKeys supports the Visual Basic SendKeys syntax Print Screen Detecting if the PrintScreen key has been pressed Borland FAQ 930D Trapping the Windows system key PrintScreen Borland FAQ 1719D Links about Printing and PrintScreen Links about Capturing Bitmaps and PrintScreen Disable PrintScreen with Ctrl Alt combinations WMHotKey RegisterHotKey Morten Jacobsen s E Mail with example Peter Below s UseNet Post about how to disable the print screen key by defining it as a hotkey and then ignoring it How can I create a system wide keyboard hook under Win32 http delphifaq com fq q2108 shtml How to scroll your form with pgUp and pgDn TI 593D Making accelerators work with a TPageControl TI 315D Making the Enter key work like a Tab in a TDBGrid TI 737D Making your own hotkeys TI 587D ShortCut Keys For Delphi TI 4549D How do I hide my application from the Alt Tab menu Virtual Keys Standard Set Listed after line 17950 in Delphi 5 Windows PAS line 17751 in Delphi 4 line 11271 in Delphi 3 Lists the virtual key values TI 546D Ralph Friedman s Team B UseNet Post about how to capture the ESC key ESC key cancel If a button on a form has the Cancel property set to TRUE which is set automatically for a TBitBtn with Kind bkCancel and ModalResult mrCancel the OnClick handler is called when the ESC key is pressed If the ModalResult is other than mrNone the form will also close after the OnClick is processed Intercepting Keystrokes www developers demon co uk intercept html Virtual Key Codes www drdelphi com delphi right tips vkcodes htm www erols com dparsons right tips vkcodes htm How do I turn the Caps Lock or Num Lock keys on off www xploiter com programming delphi tips3 shtml tip23 Disable alt tab and ctrl esc keys www xploiter com programming delphi tips3 shtml tip22 PageUp PageDown to Scroll Up Down in TMemo in UseNet Post by Alexandru Preda Slavisa Milojkovic s post to DelphiGames group about CM DIALOGKEY message to trap the TAB key Steve Koterski s UseNet Post on how to simulate a TAB Bill Artemik s UseNet Post about Enter as Tab Jason Wallace s UseNet Post Simulating the Tab Key Ralph Friedman s UseNet Post Trapping Tab Shift Tab Peter Below s UseNet Post Arrow keystroke with panels Peter Below s UseNet Post with PostKeyEx32 procedure to simulate key presses Peter Below s UseNet Post with SetLockKey example of using GetAsyncKeyState Peter Below s UseNet Post with SetLockKey example to set Caps Lock programmatically Ian Davies UseNet Post with SetLockKey example Blocking CTRL ALT DEL in Windows 95 These routines are based on information from the Microsoft Knowledgebase article Q161133 How to Block CTRL ALT DEL and ALT TAB in Windows 95 Note According to this documentation the routines below will NOT work under Windows NT Routine names adapted from suggestion by Geir Bratlie royal sn no in 12 8 96 post to comp lang pascal delphi misc Re Help Trapping KB Keys PROCEDURE TurnSystemKeysOff VAR dummy INTEGER BEGIN SystemParametersInfo SPI SCREENSAVERRUNNING INTEGER TRUE Dummy 0 END TurnSystemKeysOff PROCEDURE TurnSystemKeysOn VAR dummy INTEGER BEGIN SystemParametersInfo SPI SCREENSAVERRUNNING INTEGER FALSE Dummy 0 END TurnSystemKeysOn Let s Build a Compiler by Jack Crenshaw www iecc com compilers crenshaw Microsoft Office Word Excel Access Powerpoint Also see Automation Section above For Automation constants see this directory C Program Files Borland Delphi5 Ocx Servers Word Control Part I Microsoft Word as an Automation Server www delphizine com features 2000 09 di200009rg f di200009rg f asp Automating Word Part II Word Components in Delphi and Using OLE www delphizine com features 2000 10 di200010rg f di200010rg f asp Delphi in the Office Writing Office 2000 Add ins in Delphi http www delphizine com features 2000 05 di200005rl f di200005rl f asp In Chapter 16 of Mastering Delphi 5 pp 746 750 Marco Cantù explains Sending Data to Microsoft Word and Building an Excel Table A PowerPoint example is in the Delphi directory under C Program Files Borland Delphi6 Demos ActiveX OleAuto SrvComp PowerPoint Creating a Microsoft Excel Spreadsheet Viewer Using Delphi 5 s ADOExpress http community borland com article 1 1410 20066 00 html Comments by Danny Thorpe Inprise in JEDI Digest 82 21 Sept 99 Delphi 5 includes a set of component wrappers for most of the MS Office applications The component wrappers use early binding interfaces instead of late binding variants For other automatable applications Delphi 5 s Import ActiveX will now generate component wrappers for non visual controls and automation interfaces Keep in mind that Microsoft makes no claim to compatibility of automation interfaces between versions of their Office applications The automation method names and parameters are different for each version of Word for example and even between different language versions of the same product German French versions of Word 7 It s really irritating Automation with Delphi www djpate freeserve co uk Automation htm Deborah Pate s UseNet Post about how to add formulas to an Excel spreadsheet Delphi Word Automation FAQ www softmosis ca WordFAQ html HowTo Automate Word 97 to Perform Mail Merge from Delphi http support microsoft com support kb articles q229 3 10 asp Example of working with MS Excel 97 from Delphi http delphi icm edu pl ftp d30free excel97e zip Delphi 3 and Automation with Excel http vzone virgin net graham marshall excel htm Delphi 3 and Automation with Word http vzone virgin net graham marshall word htm How to Use Word 97 as a Report Engine www undu com Articles 990216a html www undu com Articles 990502b html updated Peter Below s UseNet Post about how to close MS Word Printing Reports Using Word www undu com Articles 990212b html XLS Read Write is two native Delphi components TXLSRead and TXLSWrite designed for accessing microsoft Excel XLS files There is no need for any other files to be installed including Excel http delphi icm edu pl ftp d10free axxlsrw zip Menno Avegaart s UseNet Post How to create an Excel sheet directly procedure TFormExcelDemo Button1Click Sender TObject VAR Excel variant i Integer begin TRY Excel CreateOleObject Excel Application EXCEPT ShowMessage Cannot start Excel exit END Excel Workbooks Add FOR i 1 TO 7 DO Excel Cells 1 i Value i Excel Workbooks Close end OLE OLE Drag and Drop Applications www unitoops com uoole examples Optimization High Performance Delphi www optimalcode com Worked Examples www optimalcode com examples htm Optimization Fundamentals www optimalcode com basics htm Optimization Coding Guidelines www optimalcode com opguide htm Delphi 32 bits Efficiency Performance Optimisation www drbob42 com delphi perform htm Optimizing Object Pascal in Delphi Developer Programming Optimization www azillionmonkeys com qed optimize html Steve Schafer s UseNet Post about WITH and optimization by version of Delphi Michael Abrash s Graphics Programming Black Book Chapter 7 Local Optimization Chapter 21 Unleashing the Pentium s V pipe Chapter 63 Floating Point for Real Time 3D Byte Alignment Danny Thorpe in Delphi JEDI Digest Number 74 10 Sep 99 Delphi 5 s alignment padding now supports 8 byte alignment as well Data types 8 bytes or larger will be aligned to 8 byte boundaries This is the source of the mysterious 6 to 10 performance improvement when code is recompiled with D5 even though the instruction sequences are pretty much the same as D4 Profilers ProDelphi inserts statements into the source code At the start and the end of a procedure the actual number of used CPU cycles is read At the end of the procedure it is calculated how many CPU cycles have been used by the procedure itself and by all called procedures ProDelphi works like a stopwatch www prodelphi de Registry How to programmatically make your programs run on Windows startup www chami com tips delphi 112796D html Software Engineering The Best Influences on Software Engineering IEEE Software Jan Feb 2000 Programming Languages Hall of Fame Fortran Cobol Turbo Pascal Visual Basic www computer org software so2000 pdf s1010 pdf The Seven Habits of Highly Defective Developers www embedded com 98 9807br htm SQL SQL Tips www 209software com books p4dp SQLtips html System Information Serguei s UseNet Post with routines GetServerDescription and GetUserDescription System Constants Chapter 6 in Delphi in a Nutshell pp 422 427 The SysUtils Unit Appendix B in Delphi in a Nutshell pp 488 542 Snooping System Information Delphi 5 Developer s Guide Chapter 14 pp 483 541 by Teixeria and Pacheco Getting a list of active processes pp 514 521 Delphi Programming Problem Solver Neil Rubenking s Tasks32 example is very good and shows results in a TListView See this shorter D5 version of getting a list of processes Rainer Queck s UseNet Post about How to get the computer details in NT Delphi and C Builder 4 component for access to physical memory on Windows NT http delphi icm edu pl ftp d30share memport zip Pradeep Prabhakar s UseNet Post about obtaining the number of CPUs using GetSystemInfo Paul Toth s UseNet Post with TBIOS Record and interface for WOW32 DLL in your Windows System directory David Henningsson s UseNet Post with GetComputerName example WinInfo Returns following MacAdress BiosName BiosVer BiosDate Workgroup ComputerName Comment ProductId ProductKey SystemRoot RegisteredOwner RegisteredOrganization ProgramFilesDir BootCount CommonFilesDir ConfigPath DevicePath MediaPath OtherDevicePath PF AccessoriesName ProgramFilesPath SM AccessoriesName Version VersionNumber WallPaperDir ProductName ProductType http delphi icm edu pl ftp d20free bbwininf zip Robert Lee s UseNet Post with GetProcessorSerialNumber Luis Ortega s UseNet Post with assembly code for CPUID Azret s UseNet Post with assembly code for CPUID in AzCPUId unit Le Site Web de Michel http perso wanadoo fr bardou michel delphi htm getversion zip http perso wanadoo fr bardou michel delphi htm sysexploitation zip NT Exception Unit Process Resource Viewer for NT Performance Data Viewer for NT NT Service NT Computer Access Rights www wilsonc demon co uk delphi htm Tibetty s UseNet Post with function RegisterService Alex V Demin s UseNet Post explaining how to use GetVersion API call to detect the version of Windows Displaying System Resources in Win 9x and NT 4 TMemoryStatus Borland TI 1582D Interface for Microsoft Windows Performance Monitoring Project DELPHI Conversion Library by Marcel van Brakel ftp delphi jedi org api PerfMon zip Hardware SWAG Software Archive Group 60 examples www gdsoft com swag hardware zip requires Reader Non Delphi www sysinternals com Online Intel Documentation www x86 org intel doc inteldocs htm Design a Windows NT Service to Exploit Special Operating System Facilities www microsoft com msj 1097 winnt htm Windows Version Info using GetVersion Ex API call VAR OSVersionInfo TOSVersionInfo OSPlatform STRING OSVersionInfo dwOSVersionInfoSize SizeOf OSVersionInfo GetVersionEx OSVersionInfo CASE OSVersionInfo dwPlatformId of VER PLATFORM WIN32s OSplatform Win32s under Windows 3 x VER PLATFORM WIN32 WINDOWS OSplatform Windows 95 VER PLATFORM WIN32 NT OSplatform Windows NT END Memo Lines Add OSPlatform Memo Lines Add Major Version IntToStr OSVersionInfo dwMajorVersion Memo Lines Add Minor Version IntToStr OSVersionInfo dwMinorVersion Memo Lines Add Build Number IntToStr OSVersionInfo dwBuildNumber Memo Lines Add Platform ID IntToStr OSVersionInfo dwPlatformID Memo Lines Add CSDVersion OSVersionInfo szCSDVersion System Tips Delphi Informant s The Secret World of PIDLs Working with Windows Shell Item Identifiers Dec 1999 Shell Extensions in Delphi 3 www raize com DelphiByDesign DbD47 htm Running Programs using RunFileDlg in From the Shell Part I Dialog Boxes You ve Always Needed Delphi Informant April 1999 From the Shell Part II More Undocumented Shell Dialog Boxes Writing Control Panel Applications in Delphi www optimalcode com Guido cplapps html Creating Control Panel Applets with Delphi in Delphi Developer Nov 1998 Writing to the NT Event Log NT Event Management Made Easy www delphizine com features 1998 10 di199810th f di199810th f asp Using Delphi to call C functions with variable argument lists using STDCALL calling convention www inlink com schutnik kelly delphi cdecl htm Simulate MDI without Multiple Document Interface overhead www elementkjournals com ddj 9704 ddj9741 htm Shutdown in NT in Ray Adams UseNet Post A Resource Monitor for Delphi www drbob42 com delphi resmon htm TFindComputerDialog is a component wrapper for an undocumented Windows API function http delphi icm edu pl ftp d20free finddlgs zip HeadConv C Header Converter How to Use C DLLs with Delphi www drbob42 com delphi headconv htm Control Panel Applets http www delphizine com features 2000 01 di200001pr f di200001pr f asp Jeff Overcash s UseNet Post with IsWin98 function Calling a Delphi DLL from your BCB Code http community borland com article 0 1410 17596 00 html Zoralliln s UseNet Post showing use of GetEnvironmentVariable and WinExec Lester Hanger UseNet Post about redirecting DOS output From the Shell Dialog Boxes You ve Always Needed Examples Browsing for Folders About Windows Dialog Formatting Disks Choosing Icons Run Dialog Box Delphi Informant April 1999 Vol 5 No 4 pp 8 22 File di9904kb zip at www informant com delphi dfiles asp Examples Finding Files Finding Computers Browsing for Files Displaying Object Properties Networking Shutting Down Out of Memory Delphi

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Miscellany/index.html (2016-02-14)
    Open archived version from archive

  • efg's Computer Lab -- Delphi Printing Info and Links
    95 98 that instead of printing on paper transforms documents in standard files BMP TIF PCX DCX and TXT www eurosistemi it uk vpd htm Virtual Printer works like a common printer but you don t get any printout It gives you the whole printout as a collection of Enhanced Metafiles that you can view and print with the EMF Viewer www mabuse de noframe vprinter html Envelopes Printing Envelopes in Delphi 5 Developer s Guide by Teixeira and Pacheco pp 166 183 on the CD Errors Detecting Print Errors Borland FAQ 1762D No Default Printer Selected Error Message Borland FAQ 2386 D Printing in Progress Error Do not try to reset the Printer Orientation after a Printer BeginDoc has been issued The Printer Orientation should be set before calling Printer BeginDoc See Error Codes page Floodfill UseNet Post with responses to How can I use FloodFill on Printer Canvas Steve Schafer Not all GDI devices support FloodFill Printers are especially unlikely to support it Joe Hecht the reason is there is often no frame buffer used for a printer FloodFilling against pixels already printed is kinda difficult Fonts The size of my text characters changes on different printers OK on some printers and very small on other printers How can I set the font size to be the same physical size on different printers The best way to fix a bug in TPrinter Assuring Proper Font Scaling When Printing TI 1547D Thanks to Joe Hecht for this information Set the Height in a device independent way and never use the font size Printer Canvas Font Height MulDiv GetDeviceCaps Printer Canvas Handle LOGPIXELSY FontSize 72 Thanks to Jeff Wormsley for this concise statement Use a resident font for printing www scalabium com faq dct0068 htm How to use the default resident font in the printer Borland FAQ 1133D How can I print using a rotated font Assuming the printer supports rotating fonts and the font is a TrueType or other rotatable font see Joe Hecht s solution Different Font Colors Print As Same Color http support microsoft com support kb articles Q209 8 79 ASP Generic Text Printer Peter Below s UseNet Post with PrintLineToGeneric procedure to print a line to the generic text printer without formfeed GetDeviceCaps Getting Printer Capabilities printing graphics large bitmaps DIBs Borland FAQ 1475D How can I determine my printer s resolution For pixels inch use the GetDeviceCaps API call with a LOGPIXELSX or LOGPIXELSY parameter You might also find Printer Canvas Font PixelsPerInch useful For total pixels in the horizontal or vertical dimension use Printer PageWidth Printer PageHeight or GetDeviceCaps with HORZRES or VERTES parameters What other useful information can I get using the GetDeviceCaps API call Horizontal size HORZSIZE or vertical size VERTSIZE in millimeters bits pixel BITSPIXEL color planes PLANES various capabilities e g CURVECAPS LINECAPS POLYGONALCAPS TEXTCAPS CLIPCAPS RASTERCAPS SHADEBLENDCAPS aspect ratio ASPECTX ASPECTY ASPECTXY physical page size PHYSICALWIDTH PHYSICALHEIGHT printable area offset PHYSICALOFFSETX PHYSICALOFFSETY These values and others are printed by efg s Printer Demo 1 GetDeviceCaps and DeviceCapabilities Delphi 5 Developer s Guide by Teixeira and Pacheco in Online CD Chapters pp 191 207 Passing TPrinter handle to GetDeviceCaps in Borland FAQ 2610D Also see DeviceCapabilities GetPrinter SetPrinter ChangePrinter Stephen Brown s UseNet Post with ChangePrinter procedure Changing the Printer Port in Code Borland FAQ 2921D Changing the Papersize of a Print Job Borland FAQ 603D See Reset below Installed Printers Finn Tolderlund s UseNet Post with AnyPrintersInstalled routine MPrtInfo This component let you access to Windows95 98 and NT structures containing virtually any information provided by the system about installed printers and their pending jobs Structures available are PRINTER INFO 1 2 3 4 and 5 DEVMODE JOB INFO 1 and 2 see Win32 online help for details plus some obvious properties installed printer names list selected printer name and index in the list and so on Methods to pause resume and clear printers and jobs some printer configuration dialogs Events to monitor printer and printer jobs status changes http delphi icm edu pl ftp d30free mprtinfo zip List of Printers EnumPrinters API call to enumerate available printers print servers domains or print providers Margins Marginal Printing Your printer knows its own limitations all you have to do is ask March April 1999 Visual Developer pp 96 97 Getting the Printing Margin of the Page Borland FAQ 1115D NT Tips Jeff Hamblin s UseNet Post with solution for some NT printing problems Direct Commands to Printer Passthrough Escape Borland TI 1497D See EnumPrinterData under Printer Properties Online Checking if Printer is Online Peter Below s UseNet Post showing how to capture WMSpoolerStatus messages Peter Below s UseNet Post about checking whether printer is on Peter Below s UseNet Post about EnumJobs for printer status in WinNT Detecting Printer Status www undu com Articles 990228a html Testing Printer Status Chris UseNet Post Q160129 HOWTO Get the Status of a Printer and a Print Job http support microsoft com support kb articles Q160 1 29 asp Orientation How can I tell what direction a printer will rotate output on a landscape page See Joe Hecht s UseNet Post Detecting what direction a printer will rotate for a portrait Borland FAQ 902D Packages StatPlot TP 4 or later plotting software for HP LaserJet 2 or later StatUnit at www math ku dk ims software index html TExcellent FormPrinter Prints Delphi forms reliably to most any graphics capable printing device Allows you to print your complete form even the portions that are scrolled out of view Allows you to print your form to any size even enlarged to span across multiple pages up to 2 billion pixels high and wide The multi page capability is excellent for creating presentations enginering drawings and even billboards Allows you to print forms that are hidden from view by opening the form off the screen by Joe C Hecht www code4sale com joehecht prnform htm TExcellent ImagePrinter Prints Windows device independent bitmaps reliably to most any graphics capable printing device Allows you to print your image to any size even enlarged to span across multiple pages up to 2 billion pixels high and wide The multi page capability is excellent for creating presentations engineering drawings and even billboards Handles all Windows bitmap formats Can work with bitmaps up to 2 billion pixels high and wide FAST as reliably possible with a very small memory footprint by Joe C Hecht www code4sale com joehecht prndib htm GmPrintSuite Professional is a set of print print preview components which provide Full page preview with zooming page panning Page Thumbnails component String grid printing RichEdit RichEdit98 and RxRichEdit with embedded graphics support Portrait and Landscape pages in the same report Multipage and Duplex printing Includes Rotated text TextBox functionallity TTreeView printing Avery label printing www murtsoft com Downloads GmPrintSuite GmPrintSuite 2 54 Lite exe Paper Bins See Bins Paper Names Paper Formats for Default Printer www gnomehome demon nl uddf pages printer htm printer12 OFF Macro to Obtain a List of Paper Names Supported by the Active Printer http support microsoft com support kb articles Q229 7 18 ASP Paper Size Changing the Papersize of a Print Job Borland FAQ 603D Peter Below s UseNet Post about setting printer paper size Peter Below s UseNet Post with example of changing DEVMODE when new page printer form added Also see TDeviceMode Pen Styles What line styles and brushes are available with my printer See efg s Printer Demo 2 Line Styles and Colors Steve Schafer s Team B UseNet Post GDI drivers are not required to support line styles other than psSolid and psClear if the line width is anything more than 1 pixel Some drivers do support wide styled lines but most do not The only sure fire fix that I know of is to draw all of the dashes and dots yourself Postscript Determining if a given printer is capable of printing a PostScript file Borland FAQ 914D Print Preview Print preview of TRichEdit www howtodothings com showarticle asp article 432 Greatis Print Suite Components for Print and Preview An extremely convenient set of components which provides advanced print and preview features into Delphi and C Builder applications http www greatis com printsuite htm In an E mail Adirano Urbano suggests using Quick Reports for a print preview 19 Jan 2001 For example QRPrinter Title Example QRPrinter BeginDoc QRPrinter Canvas TextOut put your code here QRPrinter EndDoc QRPrinter PreviewModal GmPrintSuite is collection of 6 components based around the GmPreview print preview component www murtsoft com Downloads GmPrintSuite GmPrintSuite 2 54 Lite exe Add Print Preview to Your Applications www undu com Articles 000207f html SPRINT Print Preview Engine for Delphi It has never been easier to create multi column multi grouped reports with FULL control of every little printer pixel http delphi icm edu pl ftp d40share Sprint11 zip Component by Ben Ziegler www radix net bziegler Delphi pprev zip Requires Ben s Library PrintDrv Print preview component that allows you to code your own reports without the need for visual report writers or complicated printer calculations This component wraps the device independent methods used to ensure good print outs regardless of printer and provides a scalable preview form allowing users to preview any report before printing http delphi icm edu pl ftp d20free printdrv zip Print preview the MS Access s report www scalabium com faq dct0083 htm Printer Queue How can I show the Printer Queue Download efg s translation to Delphi of most of the C code in Microsoft s Knowledge Base Article Q153751 Using Printers with Windows 95 Shell SHPrinters ZIP Printer Properties How can I display the Windows 95 Printer Properties dialog Download efg s translation to Delphi of most of the C code in Microsoft s Knowledge Base Article Q153751 Using Printers with Windows 95 Shell SHPrinters ZIP EDSprint component This component allows Delphi developers to programmatically get set the various properties of the current printer www onedomain com edsprint htm Property changes in same print http www gnomehome demon nl uddf pages printer htm printer11 EnumPrinterData API call to enumerate configuration data for a specified printer New in Windows NT From the Win32 Developer s References A printer s configuration data consists of a set of named and typed values The EnumPrinterData function obtains one of these values and its name and a type code each time you call it Call the EnumPrinterData function several times in succession to obtain all of a printer s configuration data values Printer configuration data is stored in the registry While enumerating printer configuration data you should avoid calling registry functions that might change that data Printer Settings Setup How can I get a printer s settings www scalabium com faq dct0019 htm How can I set a printer settings www scalabium com faq dct0020 htm TPrinterSetupDialog This non visual Delphi component that can be used to change the default Windows printer but it does not provide persistence for the next time a program is run TPBPrinterSetupDialog is a TPrinterSetupDialog component with capability of getting setting printer setup values orientation paper size etc at design time and runtime Settings can be saved so users don t have to setup the printer every time they run your program http delphi icm edu pl ftp d20free PBPrintS zip How can I read a printer settings page sizes and margins http www scalabium com faq dct0017 htm Changing the Printer Setup between Printed Pages Borland FAQ 1545D and Joe Hecht s UseNet Post Borland s FAQ 2618D and FAQ 1109D give clues about how to implement persistence for Windows 95 98 but are missing details and do not provide a complete example For a complete D3 D4 example of how to change the Windows 95 98 default printer WITH persistence see PrinterDefault ZIP Printers I m not getting the same printouts on different printers What am I doing wrong Getting the same printout on a wide variety of Windows printers is almost impossible See efg s Printer Demo 1 HP Printers Steve Philipp s Heuristic Research Report About Problems with HP Printers and Drivers Printing graphics to a HP LaserJet using HP PCL Borland TI 71D D1 only Epson Printers E mail comments from Armindo Da Silva I have noticed a few weeks ago that if you don t set printer title you won t be able to print on Epson Stylus Color x60 series Another bug is that if you use the ICC mode with big pictures you will get false color compared to small pictures Try getting the latest printer drivers to solve these problems Printing Graphics to an Epson Compatible Borland TI 80D D1 only Printers Multiple Simultaneously Printing to Multiple Printers Borland FAQ 1367D Printers Unit www doit com delphi undu dn0524i htm Printing Bitmaps How can I print a bitmap 1 A good and free method Use the StretchDIBits API call Make sure you have a DIB by setting PixelFormat to pf24bit or setting HandleType to bmDIB Look at the StretchDIBits code fragment example Complete Delphi D3 D5 Project D1 Solution Builder C Example See Rodney E Geraghty s UseNet Post about How do I print a bitmap with code for D1 D2 D3 How to print a JPEG displayed in a TImage How to print a GIF displayed in a TImage efg s UseNet Post explaining how to print a TPanel object Chris Rorden s version of how to print a JPEG with these improvements 1 checks whether the image is taller or wider and selects landscape or portrait to suit 2 checks the image aspect ratio versus the printer aspect ratio to see whether height or width is the constraint on scaling Why is StretchDIBits necessary See Blitting Between DCs for Different Devices Is Unsupported MS Q195830 IF GetDeviceCaps Printer Canvas Handle RASTERCAPS AND RC STRETCHDIB RC STRETCHDIB THEN printer directly supports the StretchDIBits ELSE Windows will simulate StretchDIBits Joe C Hecht s 14 May 99 comments from UseNet Post to borland public codecentral The only way to print an image form or otherwise reliably is to use StretchDIBits You are much better off not calling GetDIBits to get the image bits as the palette is often neglected in the process The best thing to do is to manufacture a really good DIB header and color table If the image is coming from a res file disk file or other reliable DIB source then the job is easy providing you do not mind retrieving the DIB directly from the source with no VCL code sitting in between you and the image Note that building a good bitmap reader is not exactly easy as evidenced in the VCL Getting a good color table from a screen image is more difficult since you must take into account the correct palette should the device be a palette device That includes 1 4 and 8 bit images as they all have a color table Finally should the printer be a palette device rare you must make a palette available to the printer Under NT just about every printer has at least palette structure under the hood even if it is internally bypassed not that that info is actually valuable here Which VCL methods can I use while printing images Any the VCL methods for drawing raster images should never be used to a printer Problems are caused by sending a bitmap based on another device to the printer and you should never do that Joe Hecht pioneered the workaround for this problem at driver level Some drivers are now able to detect this error and work around it but you cannot rely on all drivers to do this The damage that can be done includes bringing down the entire NT system Thanks to Joe Hecht for E mailing me this information 19 Jan 99 See efg s Printer Demo 1 for a complete example and a comparison of using Draw and StretchDraw instead of StretchDIBits You re very lucky if Draw and StretchDraw work for you Delphi 4 5 Books are still WRONG about printing bitmaps Mastering Delphi 5 by Marco Cantù still incorrectly shows to use Printer Canvas StretchDraw on p 867 to print a bitmap I sent an E mail to Marco and he says this will be shown in the bug list and corrected in future editions Printing a Bitmap in Delphi 5 Developer s Guide by Teixeira and Pacheco in Online CD Chapters p 158 still incorrectly shows to use StretchDraw I sent an E mail to the publisher and the authors about this issue 2 Better free method Use StretchDIBits but don t ignore palettes which may be needed on some printers A Better Way to Print A Form by Joe Hecht Borland s TI 1412D 3 Best method but not free See links to Joe Hecht s TExcellent products below Print Matrix of images on a single page See efg s Slide Show Lab Report Printing Files College Student Guide to Reading and Writing Files Borland TI 641D Printing to a File Borland FAQ 2394D Printing Graphics To print a graphics file convert to a TBitmap and use StretchDIBits See Printing Bitmap How can I print a TMetaFile to the printer UseNet Post by Mat Ballard Sending an Image to the Printer Borland FAQ 1211D Formerly Q A 821 There is a missing NOT in the second sentence but I can t get anyone at Borland to fix this The statement should read This means you should NOT use the VCL canvas methods Draw StretchDraw CopyRect BrushCopy and the like to transfer a bitmap to the printer Better Way to Print A Form Borland TI 1412D Interesting approach www drdelphi com delphi right tips printform htm PrintScreen See Screen Capture Raw printer access RawPrint Delphi unit that allows sending raw data including control characters to a Windows printer The data is sent to the printer in the approved Windows manner

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Printing/index.html (2016-02-14)
    Open archived version from archive

  • efg's Delphi Strings
    t W i t h S pa c e s rfreplaceAll gives you TextWithSpaces without any space characters They Were There All Along Fun with SysUtils Delphi Informant Feb 1999 Optimizing String Searches in Delphi in Delphi Developer Trim D2 function Trim const S string string TrimLeft D2 TrimRight D2 UpCase FUNCTION UpCase c CHAR CHAR Converts a character to upper case Charcter values not in the range a z are not affected TP UpperCase function UpperCase const S string string WrapText function WrapText const Line BreakStr string nBreakChars TSysCharSet MaxCol Integer string overload function WrapText const Line MaxCol Integer 45 string overload WrapText scans a string for occurrences of any of the characters specified by nBreakChars and inserts a line break specified by BreakStr at the last occurrence of a character in nBreakChars before MaxCol Line is the text WrapText scans MaxCol is the maximum line length If the BreakStr and nBreakChars parameters are omitted WrapText searches for space hyphen or tab characters on which to break the line and inserts a carriage return line feed pair at the break points WrapText does not insert a break into an embedded quoted string both single quotes and double quotes are supported For example the following call wraps the text into two lines at the last space character WrapText The rain in Spain falls mainly on the plain 13 10 9 42 The result The rain in Spain falls mainly on the plain 1B Conversion Formating Numeric Conversion in Delphi in a Nutshell pp 515 523 Conversions and Formatting in efg s General Math Functions Format Left and right justification of strings Format 10 10s 10 10s Left Right Result Left Right Padding or chopping a string to given length Format 10 10s s 2 2d results in zero fill for single digit months and days RESULT Format 4 4d 2 2d 2 2d year month day Convert 24 to 0024 Format 4d 24 Concatenating strings Format s s s a b c Index Specifiers 0 origin Format 2 s 1 s 0 s First Second Third Result Third Second First Variable width and precision specifiers Format f 12 4 100 PI Result 314 1593 Use Variable Width to Center String VAR pad INTEGER s STRING width INTEGER s Center width 16 pad width LENGTH s DIV 2 Format s s s pad s pad Result Center FormatBuf FormatStr HexDisplayPrefix D4 Normally SysUtils IntToHex IntToStr IsValidIdent Str PROCEDURE Str x width decimals VAR s STRING Converts a numeric value to its string representation TP StrFmt StrPas StrToColor StrToDateTime StrToInt StrToInt64 StrToIntDef StrToIntDef64 Val PROCEDURE VAL s STRING VAR v VAR code INTEGER Converts the string value to is numeric representation TP 2A C like Routines pChars null terminated strings Strings Unit Descriptions from Delphi 2 Unleashed AnsiLastChar AnsiStrComp AnsiStrIComp AnsiStrLComp AnsiStrLIComp AnsiStrLastChar AnsiStrLower AnsiStrUpper SysUtils sscanf Translation of sscanf C Utility Library Project JEDI Converted Tool by Clinton Johnson www delphi jedi org Jedi API TOOLS 236830434 ftp delphi jedi org tools sscanf zip StrAlloc Allocates a buffer for null terminated string with specified maximum length StrBufSize Returns the maximun number of characters that can be stored in a buffer allocated by StrAlloc StrCat Appends a copy of one string to the end of another and returns the concatenated string StrComp Compares two strings StrCopy Copies one string to another StrDispose Disposes a string on the heap StrECopy Copies one string to another and returns a pointer to the end of the resulting string StrEnd Returns a pointer to the end of a string StrFmt Formats a series of arguments StrLFmt Formats a series of arguments the result contains a pointer to the destination buffer StrLCat Appends characters from one string to the end of another and returns the concatenated string StrIComp Compares two strings without case sensitivity StrLComp Compares two strings up to a maximum length StrLCopy Copies characters from one string to another StrLen Returns the number of characters in Str StrLIComp Compares two strings up to a maximum length without case sensitivity StrLower Converts a string to lowercase StrMove Copies characters from one string to another StrNew Allocates a string on the heap StrPas Converts a null terminated string to a Pascal style string StrPCopy Copies a Pascal style string to a null terminated string StrPLCopy Copies a maximum of MaxLen characters from the Pascal style string Source into the null terminated string Dest StrPos Returns a pointer to the first occurence of a string in another string StrScan Returns a pointer to the first occurence of a character in a string StrRScan Returns a pointer to the last occurence of a character in a string StrUpper Converts a string to uppercase 2B Windows API Calls Windows Unit AnsiCompareStr AnsiCompareText AnsiLowerCase AnsiToNative AnsiUpperCase CharToOEM charToOem pchar myString pChar myString Converts myString from Ansi to Dos CopyMemory procedure ZeroMemory Destination Pointer Length DWORD FillChar PROCEDURE FillChar VAR x Count WORD Value Byte Example FillChar x SizeOf x 0 FillMemory and ZeroMemory are calls to FillChar VAR s STRING SetLength s N FillChar s 1 N FillMemory procedure FillMemory Destination Pointer Length DWORD Fill Byte D5 GetEnvironmentVariable Example of fetching PATH envionrment variable VAR EnvVarLength INTEGER EnvVarString STRING EnvVarString Determine size of buffer needed including NULL terminator EnvVarLength GetEnvironmentVariable PATH NIL 0 IF EnvVarLength 0 THEN BEGIN Set dynamic length of string to needed buffer size SetLength EnvVarString EnvVarLength Get PATH environment variable GetEnvironmentVariable PATH pChar EnvVarString EnvVarLength Get rid of NULL Terminator SetLength EnvVarString EnvVarLength 1 END GetWindowsDirectory VAR Path STRING PathLength DWORD PathLength GetWindowsDirectory NIL 0 SetLength Path PathLength GetWindowsDirectory pChar Path PathLength SetLength Path PathLength 1 get rid of null terminator ShowMessage Path Move PROCEDURE Move VAR Source Dest Count WORD Example Move s1 16 s2 1 8 MoveMemory and CopyMemory are calls to Move MoveMemory procedure MoveMemory Destination Pointer Source Pointer Length DWORD MultiByteToWideChar WideCharToMultiByte ZeroMemory procedure ZeroMemory Destination Pointer Length DWORD D5 3 Visual Component Library VCL Strings property TLabel See Neil Rubenking s WrapLabel function in the AllFuncs pas unit in his ColorClue PC Magazine utility WrapLabel sets the label s caption to the specified string with sensible word wrap even if the string contains no spaces TMemo Windows 95 98 imposes a size limit of about 32 KB on what can be put in a TMemo This size limit does not affect Windows NT One way arround this problem is to use a TRichEdit object with PlainText TRUE since it does not have this size limitation According to Guido Festraets in a 27 Aug 99 UseNet Post In D4 the size limit is 64K but this strangely seems to depend on the MaxLength setting If you leave it at 0 which should mean no limit the limit is in fact 32K under Win95 Set it to a higher level and you can go up to 64K While Borland cannot be faulted for this limitation blame Microsoft they can be faulted for not mentioning this limitation in any online or printed documentation To avoid size limit of TMemo use the TRichEdit control TRichEdit To use TRichEdit as a replacment for a TMemo just set the PlainText property to TRUE efg s RichEditResourceInit example for initializing TRichEdit from RTF in resource file Unlike the TMemo the TRichEdit does not automatically scroll down Here are two alternatives to make the control scroll 1 RichEdit Perform EM SCROLL SB LINEDOWN 0 2 To view the last line after adding a line RichEdit SelStart 1 RichEdit Perform EM SCROLLCARET 0 0 or Set the caret to the last character RichEdit1 SelStart RichEdit1 GetTextLen Scroll the caret into view RichEdit1 Perform EM SCROLLCARET 0 0 Example that implements Find and Replace capabilities with a TRichEdit www ecnet net users gsmpati delphi TStringGrid object TI 1045D Different colored characters in a string grid FAQ 2068D Resizing StringGrid Columns FAQ 2434D Custom InPlace Editor in StringGrid FAQ 2681D How do I Print a TStringGrid TDBGrid FAQ 1337D Controlling shortcut keys in a string grid TStringGrid Example www govst edu users gsmpati delphi Advanced string grid techniques www bridgespublishing com articles issues 0011 Advanced string grid techniques htm Peter Below s UseNet Post about Word Wrap in TStringGrid A Generic Way to Print a String Grid www undu com Articles 990618c html Printing a StringGrid www gw ro pascal PrintStringGrid html Example of how to use a string grid to display a matrix of ICOs and optionally the name of the ICO IconMapDemo ZIP Bitmaps in String Grids www undu com DN970601 00000013 htm Bitmaps on String Grids www undu com DN970501 00000027 htm Displaying Multi Colored Text in a String Grid www undu com DN970301 00000066 htm Mauro Patiño s UseNet Post explaining how to use an OnDrawCell to make the fixed row font and text centering different than the remainder of the rows in a TStringGrid component Text Alignment in StringGrid USES Classes TAlignment Use half width of X as left margin FUNCTION XLeft rect TRect canvas TCanvas s STRING INTEGER BEGIN RESULT rect Left canvas TextWidth X DIV 2 END XRight FUNCTION XCenter rect TRect canvas TCanvas s STRING INTEGER BEGIN RESULT rect Left rect Right canvas TextWidth s DIV 2 END XCenter Use half width of X as right margin FUNCTION XRight rect TRect canvas TCanvas s STRING INTEGER BEGIN RESULT rect Right canvas TextWidth s canvas TextWidth X DIV 2 END XRight Top of text is its origin so adjust by half height of text to center FUNCTION YCenter rect TRect canvas TCanvas s STRING INTEGER BEGIN RESULT rect Top rect Bottom canvas TextHeight s DIV 2 END YCenter PROCEDURE AlignText CONST Canvas TCanvas CONST Rect TRect CONST alignment TAlignment CONST s STRING BEGIN CASE alignment OF taLeftJustify Canvas TextRect Rect XLeft Rect Canvas s YCenter Rect Canvas s s taCenter Canvas TextRect Rect XCenter Rect Canvas s YCenter Rect Canvas s s taRightJustify Canvas TextRect Rect XRight Rect Canvas s YCenter Rect Canvas s s END END AlignText CONST ColumnAlignment ARRAY 0 7 OF TAlignment taLeftJustify taLeftJustify taLeftJustify taLeftJustify taLeftJustify taCenter taCenter taCenter procedure TFormList StringGridList DrawCell Sender TObject Col Row Longint Rect TRect State TGridDrawState VAR s STRING begin s StringGridList Cells Col Row StringGridList Canvas Font Color clBlack IF Col StringGridList FixedCols THEN StringGridList Canvas Brush Color clBtnFace ELSE IF Row StringGridList FixedRows THEN StringGridPatientList Canvas Brush Color clBtnFace ELSE IF Row StringGridList Selection Top AND Row StringGridList Selection Bottom THEN StringGridList Canvas Brush Color clYellow ELSE StringGridList Canvas Brush Color clWindow StringGridList Canvas FillRect Rect IF Row 0 THEN AlignText StringGridList Canvas Rect taCenter s ELSE AlignText StringGridList Canvas Rect ColumnAlignment Col s end TStringList object Converting Label Collections to String Lists www undu com Articles 991117b html TStrings object 4 Specialty Abbrev FUNCTION Abbrev CONST information info STRING CONST nMatch TStrIndex BOOLEAN efg s REXX like function AddBackSlash Delphi Developer s Guide p 775 AllSame FUNCTION AllSame CONST s STRING CONST c CHAR BOOLEAN VAR i INTEGER BEGIN RESULT TRUE i 1 WHILE RESULT AND i LENGTH s DO BEGIN RESULT RESULT AND s i c INC i END END AllSame BinStringToLongInt FAQ 2834D Covert sic string of zeros and ones to binary Capitalize also see Proper Capitalizing first characters of every word http members xoom com XOOM jescott DelphiCodeTips1 html Capitalize FUNCTION Capitalize CONST s STRING STRING efg s REXX like function Center FUNCTION Center CONST s STRING CONST sLength TStrIndex STRING efg s REXX like function CharEntity Neil Rubenking s CharEntity in the AllFuncs pas unit of his ColorClue utility For example given 034 returns quot or 060 returns lt ClearString Possibly FillChar could be used here if speed were more important PROCEDURE ClearString VAR s STRING VAR i INTEGER BEGIN IF LENGTH s 0 THEN BEGIN FOR i 1 TO LENGTH s DO s i 00 END END ClearString Clipboard Copying large amounts of Text to the Clipboard www innotts co uk zephyr copyclip html Copies FUNCTION Copies CONST s STRING CONST n TStrIndex STRING efg s REXX like function CountChar FUNCTION CountChar CONST s STRING CONST c CHAR TStrIndex efg s REXX like function Also see CharCnt utility to form frequency distribution of characters in a file CRC efg s CRC Lab Report Also see CheckDigit below Cross Reference Cross Reference Tool Marco Cantù describes a clever utility which cross references the variables functions procedures and more from all your source code files then presents the results as HTML files he also shows how the same techniques can be used to publish databases on the web Delphi Magazine Issue 30 February 1998 ExcludeTrailingBackslash D5 FUNCTION ExcludeTrailingBackslash CONST S STRING STRING Use ExcludeTrailingBackslash to modify a path name specified by the S parameter so that it does not end with a backslash character If S does not end in a backslash character ExcludeTrailingBackslash returns a copy of S ExpandEnvironment Strings Neil Rubenking s EE function in the AllFuncs pas unit of his ColorClue utility is a wrapper for ExpandEnviornmentStrings so it works properly in both WinNTx and Win9x Filters TEdit Hex digit filter procedure TFormSample EditKeyKeyPress Sender TObject var Key Char CONST BackSpace 08 begin IF NOT Key IN 0 9 a f A F BackSpace THEN Key 00 end IsBlankField FUNCTION IsBlankField CONST s STRING BOOLEAN BEGIN RESULT LENGTH s 0 OR AllSame s END BlankField IsNumValue How to Program Delphi 3 pp 317 318 IsPrintable FUNCTION IsPrintable CONST c CHAR BOOLEAN BEGIN RESULT c IN 20 7E END IsPrintable IncludeTrailingBackSlash D5 FUNCTION IncludeTrailingBackslash CONST S STRING STRING Use IncludeTrailingBackslash to modify a path name specified by the S parameter so that it ends with a backslash character If S already ends in a backslash character IncludeTrailingBackslash returns a copy of S IsWhiteSpace Ray Lischner s String Unit to help write portable code for Delphi 1 0 2 0 Secrets of Delphi 2 p 11 LeftJustify FUNCTION Left CONST s STRING CONST sLength TStrIndex STRING efg s REXX like function note rename LeftJustify to avoid Delphi name conflicts LTrim UDDF Strings Item 1 MatchesMask Masks unit function MatchesMask const Filename Mask string Boolean Call MatchesMask to check the Filename parameter using the Mask parameter to describe valid values A valid mask consists of literal characters sets and wildcards Each literal character must match a single character in the string The comparison to literal characters is case insensitive Each set begins with an opening bracket and ends with a closing bracket Between the brackets are the elements of the set Each element is a literal character or a range Ranges are specified by an initial value a dash and a final value Do not use spaces or commas to separate the elements of the set A set must match a single character in the string The character matches the set if it is the same as one of the literal characters in the set or if it is in one of the ranges in the set A character is in a range if it matches the initial value the final value or falls between the two values All comparisons are case insensitive If the first character after the opening bracket of a set is an exclamation point then the set matches any character that is not in the set Wildcards are asterisks or question marks An asterisk matches any number of characters A question mark matches a single arbitrary character MatchesMask returns True if the string matches the mask MatchesMask returns false if the string does not match the mask MatchesMask raises an exception if the mask is syntactically invalid Note The Filename parameter does not need to be a file name MatchesMask can be used to check strings against any syntactically correct mask MatchStrings UDDF Strings Item 2 Overlay FUNCTION Overlay CONST ovly target STRING CONST n TStrIndex STRING efg s REXX like function Parsers UDDF Strings Item 10 Peter Below s UseNet Post with SplitString Example Also see Tokens below Plural FUNCTION Plural CONST n LongInt CONST singularform pluralform STRING STRING efg s REXX like function Proper also see Capitalize Capitalize the first letter of each word UDDF Item 5 Regular Expressions UDDF Strings Item 11 This unit implements searching strings for UNIX style regular expressions as supported by the vi and grep tools http ourworld compuserve com homepages neil butterworth delphiunits htm RemoveChar Used mostly to get rid of in user interface strings FUNCTION RemoveChar CONST s STRING CONST c CHAR STRING VAR i INTEGER BEGIN RESULT FOR i 1 TO LENGTH s DO BEGIN IF s i c THEN RESULT RESULT s i END END RemoveChar RemoveCommas Volker W Walter s UseNet Post ReplaceInFile Peter Below s UseNet Post RemoveInvalid UDDF Strings Item 9 ReplaceSub UDDF Strings Item 4 Reverse FUNCTION Reverse CONST s STRING STRING efg s REXX like function ReverseString How to reverse a string www preview org q q1003 shtml Right FUNCTION Right CONST s STRING CONST sLength TStrIndex STRING efg s REXX like function note rename RightJustify to avoid Delphi name conflicts ScanFile Peter Below s UseNet Post to search file for a specified text Search Threaded text search example Delphi in a Nutshell pp 123 126 Fastest way to search a string in a file www preview org q q1024 shtml SearchAndReplace www chami com tips delphi 010197D html Space FUNCTION Space CONST s STRING CONST n TStrIndex STRING efg s REXX like function Spelling A Simple Spelling Checker Bob Swart describes the implementation of a spelling checker using minimal resources ideal for when the Full Monty would be over the top Delphi Magazine Issue 31 March 1998 StripBackSlash Delphi Developer s Guide p 775 Strip FUNCTION Strip CONST s STRING CONST option STRING STRING efg s REXX like function StripChar Philippe Ranger s UseNet Post StrCenter How to Program Delphi 3 pp 318 319 StrDeleteAll How to Program Delphi 3 pp 320 321 StrExtractCmd How to Program Delphi 3 pp 321 322 StrLen Finding the length of a PChar string StrLen optimized code example www optimalcode com exstrlen htm

    Original URL path: http://www.efg2.com/Lab/Library/Delphi/Strings/index.html (2016-02-14)
    Open archived version from archive



  •