CreateDC

CreateDC, CreateDCBynum

VB声明

Declare Function CreateDC& Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE)

Declare Function CreateDCBynum& Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long)

说明

为专门设备创建设备场景

返回值

Long,新设备场景句柄,若出错则为零

参数表

参数

类型及说明

lpDriverName

String,用vbNullString传递null值给该参数,除非:1、用DISPLAY,是获取整个屏幕的设备场景;2、用WINSPOOL,则是访问打印驱动

lpDeviceName

String,所用专门设备的名称。该名由打印管理器分配显示

lpOutput

String,用vbNullString传递null值给该参数

lpInitData

DEVMODE,这个结构保存初始值。用CreateDCBynum传递0(NULL)值则适用默认设置

注解

在绘制之前,先要为该设备场景选定一个位图。不再需要时,该设备场景可用DeleteDC函数删除。删除前,其所有对象应回复初始状态。若有设备初始设置可用DocumentProperties API函数载入DEVMODE结构。使用屏幕设备场景(DISPLAY)时要小心,因为它会干扰其他应用程序的外观

示例:靠近屏幕左上角画一个矩形

dc& = CreateDCBynum("DISPLAY", vbNullString, vbNullString, 0)

dl& = Rectangle(dc&, 5, 5, 100, 100)

Top