PDA

View Full Version : چرخش متن در یک PICTURE BOX



noorsoft
شنبه 19 خرداد 1386, 21:51 عصر
این هم کد مربوط به چرخش متن درون یک پیکچر باکس


ByVal txt As String, _
ByVal X As Single, ByVal Y As Single, _
ByVal font_name As String, ByVal size As Long, _
ByVal weight As Long, ByVal escapement As Long, _
ByVal use_italic As Boolean, ByVal use_underline As _
Boolean, _
ByVal use_strikethrough As Boolean)

Const CLIP_LH_ANGLES = 16 ' Needed for tilted fonts.
Const PI = 3.14159625
Const PI_180 = PI / 180#

Dim newfont As Long
Dim oldfont As Long

newfont = CreateFont(size, 0, _
escapement, escapement, weight, _
use_italic, use_underline, _
use_strikethrough, 0, 0, _
CLIP_LH_ANGLES, 0, 0, font_name)

' Select the new font.
oldfont = SelectObject(target.hdc, newfont)

' Display the text.
target.CurrentX = X
target.CurrentY = Y
target.Print txt

' Restore the original font.
newfont = SelectObject(target.hdc, oldfont)

' Free font resources (important!)
DeleteObject newfont
End Sub

When the form loads, the program calls DrawRotatedText to draw some text on its PictureBox.


Private Sub Form_Load()
Const PI = 3.14159265
Dim angle As Long

' Make the form fit the picture.
Width = Width - ScaleWidth + Picture1.Width
Height = Height - ScaleHeight + Picture1.Height
Picture1.Move 0, 0

' Get the angle from the upper left to
' lower right corner.
angle = 100 * 180 / PI * Atn(Picture1.ScaleHeight / _
Picture1.ScaleWidth)

' Draw the angled text.
Picture1.AutoRedraw = True
Picture1.ForeColor = vbRed
DrawRotatedText Picture1, _
"My Dog Snortimer", _
1000, 500, _
"Times New Roman", 40, 700, _
angle, False, False, False

' Make the result permanent.
Picture1.Picture = Picture1.Image
End Sub

m_zargarnia
یک شنبه 20 خرداد 1386, 09:12 صبح
اگه ممکنه برنامه رو ارسال کنید

noorsoft
یک شنبه 20 خرداد 1386, 12:43 عصر
این هم نمونه برنامه امیدوارم خوشتون بیاد
:چشمک: