PDA

View Full Version : معادل hdc در VB.NET



مطهر
پنج شنبه 19 آذر 1383, 10:11 صبح
با سلام
معادل hdc در VB.NET چیست
Form1.hdc
همچنین معادل Hwnd
با سپاس

Farhad.B.S
پنج شنبه 19 آذر 1383, 13:59 عصر
معادل Hwnd :

FormName.Handle
برای بدست آوردن hdc ابتدا باید یک سطح گرافیکی با استفاده از متد CreateGraphics ایجاد کنید :

FormName.CreateGraphics().GetHdc()

علیرضا مداح
پنج شنبه 19 آذر 1383, 14:31 عصر
سلام .


معادل hdc در VB.NET چیست

مثالی از MSDN :


<System.Runtime.InteropServices.DllImportAttribute ("gdi32.dll")> _
Private Shared Function Rectangle(hdc As IntPtr, _
ulCornerX As Integer, ulCornerY As Integer, lrCornerX As Integer, _
lrCornerY As Integer) As Boolean
End Function
Public Sub GetHdcForGDI(e As PaintEventArgs)
' Create pen.
Dim redPen As New Pen(Color.Red, 1)
' Draw rectangle with GDI+.
e.Graphics.DrawRectangle(redPen, 10, 10, 100, 50)
' Get handle to device context.
Dim hdc As IntPtr = e.Graphics.GetHdc()
' Draw rectangle with GDI using default pen.
Rectangle(hdc, 10, 70, 110, 120)
' Release handle to device context.
e.Graphics.ReleaseHdc(hdc)
End Sub