大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net打印分辨率的简单介绍

vb.net屏幕分辨率的单位是什么?

默认单位是像素

创新互联公司专注于利辛企业网站建设,成都响应式网站建设,商城建设。利辛网站建设公司,为利辛等地区提供建站服务。全流程按需策划,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务

96是系统的一种设定,每英寸的点数,是系统界面用小字体时的设置

用像素数除以DPI没有意义

用VB.Net 编程时如何获得打印机的物理边距

网络上找到这个比较全面,你试一下,我记得以前也是这么设置的。

int GetDeviceCaps( HDC hdc, int nIndex);

其中,hdc用来指定设备环境句柄,nIndex用来指定要获取的参量索引,对于打印机而言,它常常需要下列的预定义值:

LOGPIXELSX 打印机水平分辨率

LOGPIXELSY 打印机垂直分辨率

PHYSICALWIDTH 打印纸的实际宽度

PHYSICALHEIGHT 打印纸的实际高度

PHYSICALOFFSETX 实际可打印区域的物理左边距

PHYSICALOFFSETY 实际可打印区域的物理上边距

下面的函数代码就是用来设置页边距,并且还计算页面的物理边距:

void CEx_Prn1View::SetPageMargin(CDC *pDC, CPrintInfo *pInfo, int l, int t, int r, int b)

// l, t, r, b分别表示左上右下边距, 单位为0.1mm

{

int nOldMode = pDC- GetMapMode();

pDC- SetMapMode(MM_LOMETRIC);

// 计算一个设备单位等于多少0.1mm

double scaleX = 254.0 / (double)GetDeviceCaps(

pDC- m_hAttribDC, LOGPIXELSX);

double scaleY = 254.0 / (double)GetDeviceCaps(

pDC- m_hAttribDC, LOGPIXELSY);

int x = GetDeviceCaps(pDC- m_hAttribDC,

PHYSICALOFFSETX);

int y = GetDeviceCaps(pDC- m_hAttribDC,

PHYSICALOFFSETY);

int w = GetDeviceCaps(pDC- m_hAttribDC,

PHYSICALWIDTH);

int h = GetDeviceCaps(pDC- m_hAttribDC,

PHYSICALHEIGHT);

int nPageWidth = (int)((double)w*scaleX + 0.5);

// 纸宽,单位0.1mm

int nPageHeight = (int)((double)h*scaleY + 0.5);

// 纸高,单位0.1mm

m_nPhyLeft = (int)((double)x*scaleX + 0.5);

// 物理左边距,单位0.1mm

m_nPhyTop = (int)((double)y*scaleY + 0.5);

// 物理上边距,单位0.1mm

pDC- DPtoLP(pInfo- m_rectDraw);

CRect rcTemp = pInfo- m_rectDraw;

rcTemp.NormalizeRect();

m_nPhyRight = nPageWidth - rcTemp.Width() -

m_nPhyLeft; // 物理右边距,单位0.1mm

m_nPhyBottom = nPageHeight - rcTemp.Height() -

m_nPhyTop; // 物理下边距,单位0.1mm

// 若边距小于物理边距,则调整它们

if (l m_nPhyLeft) l = m_nPhyLeft;

if (t m_nPhyTop) t = m_nPhyTop;

if (r m_nPhyRight) r = m_nPhyRight;

if (b m_nPhyBottom) b = m_nPhyBottom;

// 计算并调整pInfo- m_rectDraw的大小

pInfo- m_rectDraw.left = l - m_nPhyLeft;

pInfo- m_rectDraw.top = - t + m_nPhyTop;

pInfo- m_rectDraw.right -= r - m_nPhyRight;

pInfo- m_rectDraw.bottom += b - m_nPhyBottom;

pDC- LPtoDP(pInfo- m_rectDraw);

pDC- SetMapMode(nOldMode);

// 恢复原来的映射模式

}

在VB.NET中通过那个函数可以获取当前屏幕的分辨率?

您可以用下面给出这一小段代码检测当前屏幕分辨率,然后根据结果作出反应──例如,重新调整窗体大小以适应用程序户分辨率。

Public Function CheckRez(pixelWidth As Long, pixelHeight As Long) As Boolean

'

Dim lngTwipsX As Long

Dim lngTwipsY As Long

'

' convert pixels to twips

lngTwipsX = pixelWidth * 15

lngTwipsY = pixelHeight * 15

'

' check against current settings

If lngTwipsX Screen.Width Then

CheckRez = False

Else

If lngTwipsY Screen.Height Then

CheckRez = False

Else

CheckRez = True

End If

End If

'

End Function

Next, run the following code at the start of the program:

If CheckRez(640, 480) = False Then

MsgBox "Incorrect screen size!"

Else

MsgBox "Screen Resolution Matches!"

End If

VB.NET设置屏幕分辨率、颜色位数、刷新率 实例代码

这篇文章介绍了VB.NET设置屏幕分辨率、颜色位数、刷新率

实例代码,有需要的朋友可以参考一下

复制代码

代码如下:

Private

Declare

Function

GetDeviceCaps

Lib

"gdi32"

(ByVal

hdc

As

Long,

ByVal

nIndex

As

Long)

As

Long

Private

Declare

Function

ChangeDisplaySettings

Lib

"user32"

Alias

"ChangeDisplaySettingsA"

(lpDevMode

As

Any,

ByVal

dwflags

As

Long)

As

Long

Private

Const

CCDEVICENAME

As

Long

=

32

Private

Const

CCFORMNAME

As

Long

=

32

Private

Const

DM_BITSPERPEL

As

Long

=

H40000

Private

Const

DM_PELSWIDTH

As

Long

=

H80000

Private

Const

DM_PELSHEIGHT

As

Long

=

H100000

Private

Const

DM_DISPLAYFLAGS

As

Long

=

H200000

Private

Const

DM_DISPLAYFREQUENCY

=

H400000

Private

Const

CDS_FORCE

As

Long

=

H80000000

Private

Const

BITSPIXEL

As

Long

=

12

Private

Const

HORZRES

As

Long

=

8

Private

Const

VERTRES

As

Long

=

10

Private

Const

VREFRESH

=

116

Private

Type

DEVMODE

dmDeviceName

As

String

*

CCDEVICENAME

dmSpecVersion

As

Integer

dmDriverVersion

As

Integer

dmSize

As

Integer

dmDriverExtra

As

Integer

dmFields

As

Long

dmOrientation

As

Integer

dmPaperSize

As

Integer

dmPaperLength

As

Integer

dmPaperWidth

As

Integer

dmScale

As

Integer

dmCopies

As

Integer

dmDefaultSource

As

Integer

dmPrintQuality

As

Integer

dmColor

As

Integer

dmDuplex

As

Integer

dmYResolution

As

Integer

dmTTOption

As

Integer

dmCollate

As

Integer

dmFormName

As

String

*

CCFORMNAME

dmUnusedPadding

As

Integer

dmBitsPerPel

As

Integer

dmPelsWidth

As

Long

dmPelsHeight

As

Long

dmDisplayFlags

As

Long

dmDisplayFrequency

As

Long

End

Type

Private

Sub

cmdChangeDesktopMode_Click()

Dim

DM

As

DEVMODE

With

DM

.dmPelsWidth

=

CInt(txtNewWidth.Text)

.dmPelsHeight

=

CInt(txtNewHeight.Text)

.dmBitsPerPel

=

CInt(txtNewColor.Text)

.dmDisplayFrequency

=

CInt(txtNewFreq.Text)

.dmFields

=

DM_PELSWIDTH

Or

DM_PELSHEIGHT

Or

DM_BITSPERPEL

Or

DM_DISPLAYFREQUENCY

.dmSize

=

LenB(DM)

End

With

If

ChangeDisplaySettings(DM,

CDS_FORCE)

Then

MsgBox

"错误!不支持此模式!"

End

If

End

Sub

Private

Sub

Form_Load()

txtOldWidth.Text

=

GetDeviceCaps(Me.hdc,

HORZRES)

txtOldHeight.Text

=

GetDeviceCaps(Me.hdc,

VERTRES)

txtOldColor.Text

=

GetDeviceCaps(Me.hdc,

BITSPIXEL)

txtOldFreq.Text

=

GetDeviceCaps(Me.hdc,

VREFRESH)

End

Sub

vb.net保存图片时如何调整其分辨率

保存前加一句 myImage2.SetResolution(300, 300) 你设置的bMape不是保存的主画布 所以无效,设置分辨率就是 SetResolution(X,Y)


分享文章:vb.net打印分辨率的简单介绍
转载来于:http://dzwzjz.com/article/docgoid.html
在线咨询
服务热线
服务热线:028-86922220
TOP