Print full page delphi - delphi

Whenever I print a from in delphi, it does not print to the entire page. It uses all the page horizontally, but it only uses about 3/4 of the page vertically.
My code is :
printer.Orientation:=poLandscape;
form1.PrintScale:=poPrintToFit;
printer.Copies:=spinedit1.Value;
form1.Print;
Any suggestions ? Thanks
I have tried changing form sizes and trying other printers will no result, it prints exactly the same thing.

You are getting exactly what you want. The printer is producing an image of the screen that is 1963 by 1056 which should map nicely on to the top 3/4 of your 11.7 x 8.3 paper. The top 3/4 would be about 11.7 x 6.2. (1963/1056 is approximately equal to 11.7/6.2) You are printing an image with the aspect ration of about 2 to 1; the printed image has the same aspect ratio. If the printed image filled the entire page, it would be distorted in such a way that it looked either too tall or too narrow, depending on your perspective. You would see this more clearly if you were to throw some other controls onto the form near the corners. They will show up on the printed page.

Related

Adapt the display of a form to the screen resolution (Delphi XE8)

I'm having trouble solving the problem of adapting the display of a form according to the resolution of the screen.
I wrote my code in a 15 inch laptop, I'm using 1366X 768 resolution, The form fills the screen perfectly, and the display is as expected
but when I open my application in another computer with a larger screen (1920x1080 resolution), the shape takes up the whole screen, but the display of objects is not as expected, , there is too much space..
I am looking for a way to adapt the appearance of the form according to the screen, i.e. to make the display look like photo 1 whatever the screen resolution
I tried to play on the properties of the form (Align,Anchors Autosize..), but it did not work

Form.Left is offset by 7 pixels compared to the screen coordinates [duplicate]

I'm coding in c++ on windows 10 - straight win32 API.
I wanted to make a window show up in the top right of the screen.
As I was doing this, I noticed that screen coordinates for a maximized window are left=-8, top=-8, right=1936, bottom=1088.
Also, when I position a window so right=1920 and top=0, there's about an 8 pixel gap on the right. I tried moving the window around to see what screen coordinates I got.
rect.left for a nonmaximized window can go from -7 to 1912.
so things are slid by 7 pixels ? WTF microsoft ??
How am I supposed to come up with the rec.right=1913 value to position my window aligned to right side of screen without that dang gap ?
But rect.right of 1920 leaves a gap. So rect.right of 1912 would leave MORE of a gap...
And I need a solution that'll work back to Vista.
Pre win10, that rect.right should be 1920 like ya expect.
Whaaaaat is going on here? I'm about to start throwing knives around !!
Code wise, this is just what GetWindowRect is reporting...
(excuse my weird debugging function)
::GetWindowRect (_wndo, r);
DBG("ExtRc l=`d r=`d t=`d b=`d w=`d h=`d",
r->left, r->right, r->top, r->bottom, r->right-r->left, r->bottom-r->top);
Well thanks to #ChristopherOicles
This is really his answer. Duplicate this as your own (or tweak it, whatever) and I'll accept your's.
What's going on is microsoft wrecking border widths in windows 10.
GetWindowRect returns the outside window coordinates as screen coordinates.
GetClientRect returns the inside the window coordinates.
Up until Windows 10 (F U Win10 !!),
The difference in width and height between them was the width and height of the borders.
Upon win10, the border width reports 16 pixels, so 8 pixels a side.
However, only 1 of those pixels are visible. 7 of them are transparent.
So your window has a transparent 7 pixels to the left, right, and bottom.
So you need to take those transparent 7 pixels into account if you're going to line up the window on the screen programmatically. The user doesn't want that 7 pixel gap next to the screen border !
DwmGetWindowAttribute with the attribute DWMWA_EXTENDED_FRAME_BOUNDS will get you the width and height of the ACTUALLY SHOWING part of the border in screen coordinates. So similar to GetWindowRect, but the rect does not include the invisible-ness.
You're still going to need GetWindowRect most of the time to set the width and height of your window and those 7 pixels per side of invisible-ness are needed to size the window properly programmatically.
So use the difference between the .left of the rect GetWindowRect returns and .left of what DwmTerribleName returns to get that 7 pixels of offset.
In my opinion, whoever did this at Microsoft should be immediately shot.
This is a hoop I didn't need to jump through.
This breaks compatibility with the past.
This is because of the width of the window border and other factors, which vary depending on OS version, user preference, and DPI settings. See the GetSystemMetrics function.

How many pixels of an image can iphone display horizontally without scrolling?

OK, so I've been reading iphone 4's screen resolution is "640x960".
So I created a web page with an image sized 600x300 inside.
Now, when I access the web page, it just shows around half of the image and I have to scroll to the right to see it all. During my search I read that iphone 4's pixels count 2 for 1 CSS pixel blah blah.
Can someone clarify this for me? So iphone 4 cannot display an image sized less than 640 pixels wide "normally" ?
Yes, the 'correct' resolution is 320x480. The Retina display doubles the resolution, but adds the notion of 'points', so developers don't have to make two versions of same application.
Here you can read more about it.

iOS webview scaling to match retina display

I'm using a full screen UIWebView to house/render an HTML5 application under iOS. Very much like Cordova/phonegap although I'm not using those. I try to make my webview size match the underlying display. Unfortunately, on retina displays, the value returned by self.view.bounds relies on the UIScreen scaling factor. So I get 1024x768 instead of 2048x1536. Not a huge problem except I then instantiate the UIWebView using the smaller bounds (after adjusting for the status bar) and some things get a bit jaggy. In particular, I use canvas at a couple of points and also rounded borders appear thick. To be clear, this isn't a case of scaled raster resources.
I'm not getting the full resolution of the screen using that UIWebView. Ideally, I'd like to set the screen scale to 1.0 but that doesn't appear to be supported. Any suggestions on how best to get full advantage of the screen?
The problem is most noticeable on the iPhone 5 simulator. I don't have that hardware to test on. iPad/new iPad I think has the problem but the jaggies aren't as noticeable.
Update: The more I look at this, the more I think it may be restricted to canvas.
Solution: In case anyone else gets here. Based on the answer below, I created all of my canvas elements with width and height multiplied by window.devicePixelRatio and then set their style attribute to have the original (device independent) size.
See https://stackoverflow.com/a/7736803/341994. Basically you need to detect that you've got double resolution and effectively double the resolution of the canvas.

Converting between pt and pixels

My netbook has a monitor with 10.1 inch length and 1024*600 solution. I think 1pt is about 1/72inch - is the following computation right?
Since the resolution is 1024*600, the
diagonal has about 1186.83 pixels,
thus 1 inch is about 1186.83/10.1 =
117.51 pixels, and thus 1pt is about 117.51/72 = 1.63 pixels, or 1 pixel is about 0.6127 pt.
Using this relationship, I've inserted an image into a LaTeX document, converting pixels to pt, and take the result as a parameter to includegraphics, but the figure in the resulting document is rather blurred.
Is the computation correct? if
not, how or
where am I wrong?
How can I insert an image into a LaTeX document
with precisely the same dimensions as the
original?
Updated:
I'm using pdflatex to compile the document and the image is a png file, and the reason why I do such a stupid computation is that with no width parameter set, the image shown in the document is larger than the actual size, and I can't work out why.
LaTeX is for creating paper documents. The units it uses refer to distance on the paper output, not on the screen. So if you ask for a distance of 72pts in LaTeX, you'll get 1 inch on your printout, but the distance you get on your screen depends on the zoom-level of your pdf or ps reader, which probably doesn't know how big your screen is.
If you simply want to get the raster grid of your image to fit to the screen grid, I'd say the best thing to do is get a higher-quality graphic if you can.
(PS there's a TeX stack exchange site where you could ask your question too...)
I don't know if it will make any difference, but TeX actually uses 72.27 points to the inch (as it predates PostScript, which set the standard 72 points to the inch).

Resources