powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / VB.NET and WinAPI GDI and Printer ???????
2 сообщений из 2, страница 1 из 1
VB.NET and WinAPI GDI and Printer ???????
    #32907477
Фотография DoctorM
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Please, Help...
What is wrong ?????
Why returned value of StartDoc = -1 AND GetLastWin32Error = 0 ????????

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
 
Dim lhPrinter As IntPtr
Dim pd As PRINTER_DEFAULTS
OpenPrinter("Microsoft Office Document Image Writer", lhPrinter, Nothing)

Dim di As New DOCINFO()
di.lpszDocName = "MyDocument"
di.lpszOutput = ""
di.cbSize = Marshal.SizeOf(di)

Debug.WriteLine(StartDoc(lhPrinter, di))
Debug.WriteLine(Marshal.GetLastWin32Error)


'---------DECLARATIONS------------------


<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> Public Structure DOCINFO
	<MarshalAs(UnmanagedType.I4)> Public cbSize As Integer
	<MarshalAs(UnmanagedType.LPStr)> Public lpszDocName As String
	<MarshalAs(UnmanagedType.LPStr)> Public lpszOutput As String
	<MarshalAs(UnmanagedType.LPStr)> Public lpszDatatype As String = "EMF"
            <MarshalAs(UnmanagedType.I4)> Public fwType As Integer =  0 
End Structure 




Public Const CCHDEVICENAME =  32 
Public Const CCHFORMNAME =  32 


<StructLayout(LayoutKind.Sequential)> Public Structure DEVMODE
	<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCHDEVICENAME)> Public dmDeviceName As String
	Public dmSpecVersion As Integer
	Public dmDriverVersion As Integer
	Public dmSize As Integer
	Public dmDriverExtra As Integer
	Public dmFields As Integer
	Public dmOrientation As Integer
	Public dmPaperSize As Integer
	Public dmPaperLength As Integer
	Public dmPaperWidth As Integer
	Public dmScale As Integer
	Public dmCopies As Integer
	Public dmDefaultSource As Integer
	Public dmPrintQuality As Integer
	Public dmColor As Integer
	Public dmDuplex As Integer
	Public dmYResolution As Integer
	Public dmTTOption As Integer
	Public dmCollate As Integer
	<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCHFORMNAME)> Public dmFormName As String
	Public dmUnusedPadding As Integer
	Public dmBitsPerPel As Integer
	Public dmPelsWidth As Integer
	Public dmPelsHeight As Integer
	Public dmDisplayFlags As Integer
	Public dmDisplayFrequency As Integer
End Structure

    


<StructLayout(LayoutKind.Sequential)> Public Structure PRINTER_DEFAULTS
	Public pDatatype As String
	Public pDevMode As DEVMODE
	Public DesiredAccess As Integer
End Structure


<DllImport("gdi32.dll", CharSet:=CharSet.Auto, EntryPoint:="StartDocW", CallingConvention:=CallingConvention.StdCall)> _
Public Function StartDoc(ByRef hDC As IntPtr, <MarshalAs(UnmanagedType.Struct)> ByRef di As DOCINFO) As Integer
End Function

<DllImport("winspool.drv", CharSet:=CharSet.Unicode, ExactSpelling:=False, CallingConvention:=CallingConvention.StdCall)> _
Public Function OpenPrinter(ByVal pPrinterName As String, ByRef phPrinter As IntPtr, <MarshalAs(UnmanagedType.Struct)> ByRef pDefault As PRINTER_DEFAULTS) As Boolean
End Function


...
Рейтинг: 0 / 0
VB.NET and WinAPI GDI and Printer ???????
    #32932866
Непонятно — зачем из-под .NET делать печать вручную, когда есть PrintDocument, PrintPreviewDialog, PrintPreviewControl?
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / VB.NET and WinAPI GDI and Printer ???????
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]