باستخدام الدالة Windows API Escape() يمكن تطبيق تغيير حجم الورق في الطابعة ويكون للحصول على قائمة معايير الورق المتوفرة على الطابعة الافتراضية.

الحصول على قائمة معايير الورق المتوفرة, تجتاز ثابت الهروب الطابعة ENUMPAPERMETRICS الدالة Escape(). سيعود الدالة إما صفيف يحتوي على معايير الورق أو عدد قياسات الورق المتوفرة.

ملاحظة: ورق قياسات تختلف أحجام الورق الفعلي في ذلك delineate قياسات الورق الفعلي المنطقة التي يمكن طباعتها إلى بينما حجم الورق هو حجم الفعلي للورق بما في ذلك المناطق غير القابلة للطباعة.

تغيير حجم الورق " ، تجتاز ثابت الهروب الطابعة GETSETPAPERMETRICS مع معايير الورق إلى الدالة Escape().

يوضح برنامج المثال المذكور أدناه كيفية استخدام " كل ثوابت الهروب الطابعة (ENUMPAPERMETRICS و GETSETPAPERMETRICS) " مع الدالة Escape() API Windows

خطوات إنشاء مثال

  1. بدء تشغيل Visual Basic أو من القائمة " ملف " ، اختر " مشروع جديد ' " (ALT, F, N) إذا Visual Basic قيد التشغيل مسبقاً. تم إنشاء " Form1 " افتراضياً.
  2. من قائمة " ملف " ، اختر " وحدة نمطية جديدة " (M F، ALT). تم إنشاء " Module1 " افتراضياً.
  3. بإضافة التعليمة البرمجية التالية إلى مقطع declaration العامة من Module1: Type Rect Left As Integer Top As Integer Right As Integer Bottom As Integer End Type ' Enter each Declare as one, single line. Declare Function EnumPaperMetricsEscape% Lib "GDI" Alias "Escape" (ByVal hDC%, ByVal nEscape%, ByVal IntegerSize%, lpMode%, lpOutData As Rect) Declare Function SetPaperMetricsEscape% Lib "GDI" Alias "Escape" (ByVal hDC%, ByVal nEscape%, ByVal RectSize%, NewPaper As Rect, PrevPaper As Rect) Declare Function GetDeviceCaps% Lib "gdi" (ByVal hDC%, ByVal nIndex%) Global Const ENUMPAPERMETRICS = 34 Global Const GETSETPAPERMETRICS = 35 Global Const LOGPIXELSX = 88 ' Logical pixels/inch in X Global Const LOGPIXELSY = 90 ' Logical pixels/inch in Y
  4. قم بإضافة التعليمة البرمجية التالية إلى المقطع Declarations عام Form1:

    تبهيت RectArray() باسم Rect
  5. إضافة زر أمر (Command1) إلى Form1 ".
  6. قم بإضافة مربع قائمة (List1) إلى Form1 ".
  7. قم بإضافة التعليمة البرمجية التالية إلى إجراء الحدث Command1_Click. قراءة بعض الخطوط من التعليمات البرمجية يتم إظهار كـ سطرين ولكن يجب إدخال سطر فردي من التعليمات البرمجية. Sub Command1_Click () ReDim RectArray(1) mode% = 0 ' Enter the entire Result% statement as one, single line. Result% = EnumPaperMetricsEscape(Printer.hDC, ENUMPAPERMETRICS, 2, mode%, RectArray(0)) If Result% = 0 Then ' If Result = 0, the call failed MsgBox "Printer Driver does not Support EnumPaperMetrics", 48 Command1.Enabled = False Exit Sub End If ReDim RectArray(Result% - 1) ' Result% contains num paper sizes mode% = 1 ' Enter the entire Result2% statement as one, single line. Result2% = EnumPaperMetricsEscape(Printer.hDC, ENUMPAPERMETRICS, 2, mode%, RectArray(0)) HorzRatio% = GetDeviceCaps(Printer.hDC, LOGPIXELSX) VertRatio% = GetDeviceCaps(Printer.hDC, LOGPIXELSY) ' Add Paper Sizes (Listed by actual printing region) in inches ' to the list box. Enter each of the PWidth$ and PHeight$ statements ' as one, single line. For i% = 0 To Result% - 1 PWidth$ = Format$((RectArray(i%).Right - RectArray(i%).Left) / HorzRatio%) + Chr$(34) ' Enter as a single line PHeight$ = Format$((RectArray(i%).Bottom - RectArray(i%).Top) / VertRatio%) + Chr$(34) ' Enter as a single line List1.AddItem PWidth$ + " X " + PHeight$ Next i% End Sub
  8. بإضافة التعليمة البرمجية التالية إلى إجراء الحدث List1_Click: Sub List1_Click () Dim PrevPaperSize As Rect ' Enter the entire Result% statement as one, single line. Result% = SetPaperMetricsEscape(Printer.hDC, GETSETPAPERMETRICS, Len(PrevPaperSize), RectArray(List1.ListIndex), PrevPaperSize) If Result% = 0 Then MsgBox "Printer Driver does not support this Escape.", 48 ElseIf Result% < 0 Then MsgBox "Error in calling Escape with GETSETPAPERMETRICS." Else MsgBox "Paper size successfully changed!" End If End Sub
  9. من القائمة " تشغيل " ، اختر ابدأ (R، ALT S) لتشغيل البرنامج.
  10. اختر الزر " Command1 " لعرض قائمة مقاييس الورق المتوفرة في مربع List1. تمثل قياسات الورق حجم مناطق الطباعة المعتمدة من قبل الطابعة أحجام الورق الفعلي لا.
  11. حدد أحد مقاييس الورق تظهر في مربع List1. يظهر مربع رسالة تشير إلى حجم الورق الذي تم تغيير بنجاح باستخدام معايير الورق الذي حددته أم لا.
papersproducts

إيفا لايف

  • Currently 265/5 Stars.
  • 1 2 3 4 5
77 تصويتات / 678 مشاهدة

ساحة النقاش

شركة إيفا لايف

papersproducts
»

ابحث

تسجيل الدخول

عدد زيارات الموقع

471,509