Перейти к содержанию
СофтФорум - всё о компьютерах и не только

Размер экранного пикселя


Рекомендуемые сообщения

Как программно (Delphi) определить физический размер пикселя, в зависимости от диагонали монитора и разрешения? Ответ хотелось бы увидеть в виде проги... Простите, please, за наглость :-)

Ссылка на комментарий
Поделиться на другие сайты

Сразу оговорюсь, что на Delphi не пишу, поэтому программу не выкладываю. Это первое. Второе - физический размер пикселя может быть только у ЖК монитора, в ЭЛТ мониторах он завист от разрешения, но если тебя это не волнует, тогда третье - если хочешь определять используя диагональ, то всё равно будет погрешность. Обычно у 15'' ЖК - 0.297 у 17'' - 0.264, 19'' я видел с разным разрешением с 1280х1024 и с 1800x1440, так, что у них тоже соответственно размер пикселя разный. Но если тебе по барабану всё, что я сказал выше, тогда вспоминаем теорему Пифагора, зная диагональ, получаем высоту и ширину, определяем разрешение экрана, затем простым делением определяем размеры пикселя.

Ссылка на комментарий
Поделиться на другие сайты

Так мне и нужна программа, которая, получая данные о диагонали монитора и разрешении (причем сама), считает размер пикселя, например, в дюймах!!!

Ссылка на комментарий
Поделиться на другие сайты

Ну насчёт диагонали незнаю, ниразу не слышал, что бы её можно было бы программно получать, а разрешение получить можно без проблем, правда как это в Delphi сделать я незнаю (снаю как С++ :( ). А если не секрет, для чего это нужно? На ум приходит только одна идея - программа для определения технических данных компа (типа SiSoftSandra) или это для чего-то другого?

Ссылка на комментарий
Поделиться на другие сайты

Не секрет. Это нужно для одинаковых масштабных соотношений всех элементов на экране любого монитора.

Ссылка на комментарий
Поделиться на другие сайты

Тогда я думаю, ты себе только усложняешь жизнь. Тебе достаточно только разрешения экрана. А размер например кнопки делаешь исходя из разрешения экрана (если тебе надо, что бы кнопка была равна 1/20 размеров экрана, то при разрешении 1024x768 размеры кнопки будут 51х38, а при разрешении 1280х1024 она будет 64х51). Если я правильно понял условия поставленной задачи, лично я бы делал так. Теперь тебе осталось узнать, как в Delphi определить разрешение монитора, я думаю тебе на этом форуме кто-то поможет.

Ссылка на комментарий
Поделиться на другие сайты

ИМХО, Кока прав. Если же тебе нужно, к примеру, нужно, чтобы изначально форма была по центру, это будет так:

form.top=screen.height/2-form.height/2form.left=screen.width/2-form.width/2

Если нужно что-нибудь ещё как-нибудь расположить, спрашивай! :)

Ссылка на комментарий
Поделиться на другие сайты

Народ!!! Во-первых, спасибо. Во-вторых, простите за каламбур, я сам толком не знаю, что мне надо. У меня отец - программист, а я ему помогаю. Выглядит это так: он поручает мне делать небольшие проги, которые потом юзает в только ему известных целях. Потом часть денег уходит мне. Так вот он мне и поручил именно такую дрянь написать. А зачем, и что она должна делать...

Ссылка на комментарий
Поделиться на другие сайты

Stolik

Да что ты ругаешься, взял бы уже давно книжку по WinAPI и нашел то, что тебе надо...

Есть такая функция - GetDeviceCaps(), читай:

The GetDeviceCaps function retrieves device-specific information about a specified device. int GetDeviceCaps(   HDC hdc,	// device-context handle    int nIndex  // index of capability to query    );	ParametershdcIdentifies the device context. nIndexSpecifies the item to return. This parameter can be one of the following values: Index	MeaningDRIVERVERSION	The device driver version.TECHNOLOGY	Device technology. It can be any one of the following values:Value	MeaningDT_PLOTTER	Vector plotterDT_RASDISPLAY	Raster displayDT_RASPRINTER	Raster printerDT_RASCAMERA	Raster cameraDT_CHARSTREAM	Character streamDT_METAFILE	MetafileDT_DISPFILE	Display file If the hdc parameter identifies the device context of an enhanced metafile, the device technology is that of the referenced device as given to the CreateEnhMetaFile function. To determine whether it is an enhanced metafile device context, use the GetObjectType function.HORZSIZE	Width, in millimeters, of the physical screen.VERTSIZE	Height, in millimeters, of the physical screen.HORZRES	Width, in pixels, of the screen.VERTRES	Height, in raster lines, of the screen.LOGPIXELSX	Number of pixels per logical inch along the screen width.LOGPIXELSY	Number of pixels per logical inch along the screen height.BITSPIXEL	Number of adjacent color bits for each pixel.PLANES	Number of color planes.NUMBRUSHES	Number of device-specific brushes.NUMPENS	Number of device-specific pens.NUMFONTS	Number of device-specific fonts.NUMCOLORS	Number of entries in the device's color table, if the device has a color depth of no more than 8 bits per pixel. For devices with greater color depths, -1 is returned.ASPECTX	Relative width of a device pixel used for line drawing.ASPECTY	Relative height of a device pixel used for line drawing.ASPECTXY	Diagonal width of the device pixel used for line drawing.PDEVICESIZE	Reserved.CLIPCAPS	Flag that indicates the clipping capabilities of the device. If the device can clip to a rectangle, it is 1. Otherwise, it is 0.SIZEPALETTE	Number of entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with Windows version 3.0 or later.NUMRESERVED	Number of reserved entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with Windows version 3.0 or later.COLORRES	Actual color resolution of the device, in bits per pixel. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with Windows version 3.0 or later.PHYSICALWIDTH	For printing devices: the width of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical width value of 5100 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller. PHYSICALHEIGHT	For printing devices: the height of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical height value of 6600 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller. PHYSICALOFFSETX	For printing devices: the distance  from the left edge of the physical page to the left edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the leftmost 0.25" of paper, has a horizontal physical offset of 150 device units. PHYSICALOFFSETY	For printing devices: the distance  from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the topmost 0.5" of paper, has a vertical physical offset of 300 device units. VREFRESH	Windows NT only: For display devices: the current vertical refresh rate of the device, in cycles per second (Hz).A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use Win32 display functions such as ChangeDisplaySettings. DESKTOPHORZRES	Windows NT only: Width, in pixels, of the virtual desktop. This value may be larger than HORZRES if the device supports a virtual desktop or multiple displays.DESKTOPVERTRES	Windows NT only: Height, in pixels, of the virtual desktop. This value may be larger than VERTRES if the device supports a virtual desktop or multiple displays.BLTALIGNMENT	Windows NT only: Preferred horizontal drawing alignment, expressed as a multiple of pixels. For best drawing performance, windows should be horizontally aligned to a multiple of this value. A value of zero indicates that the device is accelerated, and any alignment may be used.RASTERCAPS	Value that indicates the raster capabilities of the device, as shown in the following table:Capability	MeaningRC_BANDING	Requires banding support.RC_BITBLT	Capable of transferring bitmaps.RC_BITMAP64	Capable of supporting bitmaps larger than 64K.RC_DI_BITMAP	Capable of supporting the SetDIBits and GetDIBits functions.RC_DIBTODEV	Capable of supporting the SetDIBitsToDevice function.RC_FLOODFILL	Capable of performing flood fills.RC_GDI20_OUTPUT	Capable of supporting features of Windows 2.0.RC_PALETTE	Specifies a palette-based device.RC_SCALING	Capable of scaling.RC_STRETCHBLT	Capable of performing the StretchBlt function.RC_STRETCHDIB	Capable of performing the StretchDIBits function.CURVECAPS	Value that indicates the curve capabilities of the device, as shown in the following table:Value	MeaningCC_NONE	Device does not support curves.CC_CIRCLES	Device can draw circles.CC_PIE	Device can draw pie wedges.CC_CHORD	Device can draw chord arcs.CC_ELLIPSES	Device can draw ellipses.CC_WIDE	Device can draw wide borders.CC_STYLED	Device can draw styled borders.CC_WIDESTYLED	Device can draw borders that are wide and styled.CC_INTERIORS	Device can draw interiors.CC_ROUNDRECT	Device can draw rounded rectangles.LINECAPS	Value that indicates the line capabilities of the device, as shown in the following table:Value	MeaningLC_NONE	Device does not support lines.LC_POLYLINE	Device can draw a polyline.LC_MARKER	Device can draw a marker.LC_POLYMARKER	Device can draw multiple markers.LC_WIDE	Device can draw wide lines.LC_STYLED	Device can draw styled lines.LC_WIDESTYLED	Device can draw lines that are wide and styled.LC_INTERIORS	Device can draw interiors.POLYGONALCAPS	Value that indicates the polygon capabilities of the device, as shown in the following table:Value	MeaningPC_NONE	Device does not support polygons.PC_POLYGON	Device can draw alternate-fill polygons.PC_RECTANGLE	Device can draw rectangles.PC_WINDPOLYGON	Device can draw winding-fill polygons.PC_SCANLINE	Device can draw a single scanline.PC_WIDE	Device can draw wide borders.PC_STYLED	Device can draw styled borders.PC_WIDESTYLED	Device can draw borders that are wide and styled.PC_INTERIORS	Device can draw interiors.TEXTCAPS	Value that indicates the text capabilities of the device, as shown in the following table:Bit	MeaningTC_OP_CHARACTER	Device is capable of character output precision.TC_OP_STROKE	Device is capable of stroke output precision.TC_CP_STROKE	Device is capable of stroke clip precision.TC_CR_90	Device is capable of 90-degree character rotation.TC_CR_ANY	Device is capable of any character rotation.TC_SF_X_YINDEP	Device can scale independently in the x- and y-directions.TC_SA_DOUBLE	Device is capable of doubled character for scaling.TC_SA_INTEGER	Device uses integer multiples only for character scaling.TC_SA_CONTIN	Device uses any multiples for exact character scaling.TC_EA_DOUBLE	Device can draw double-weight characters.TC_IA_ABLE	Device can italicize.TC_UA_ABLE	Device can underline.TC_SO_ABLE	Device can draw strikeouts.TC_RA_ABLE	Device can draw raster fonts.TC_VA_ABLE	Device can draw vector fonts.TC_RESERVED	Reserved; must be zero.TC_SCROLLBLT	Device cannot scroll using a bit-block transfer. Note that this meaning may be the opposite of what you expect.Return ValuesThe return value specifies the value of the desired item. 

Ежели хошь, я тебе прогу пришлю, которая с помощью этой функции определяет ширину и высоту монитора.

Ссылка на комментарий
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

  • Последние посетители   0 пользователей онлайн

    • Ни одного зарегистрированного пользователя не просматривает данную страницу
×
×
  • Создать...