VB projects - Text-to-image converter
Description: saves typed text into bitmap
Minimum requirements: VB6
Download: source code
Screenshot:

Project: EXE
Controls: CommandButton cmdClear (located outside visible area), CommandButton cmdCapture, CommandButton cmdFont, CommandButton cmdColor, CommandButton cmdClear, PictureBox pic (Appearance = 0 'Flat, AutoRedraw = -1 'True, ScaleMode = 3 'Pixel, Visible = 0 'False), Label lbl (Appearance = 0 'Flat, AutoSize = -1 'True, BackColor = &H80000005&, BorderStyle = 1 'Fixed Single, ForeColor = &H80000008&), CommonDialog dlg
Additional references: none
Code:
Option Explicit
Private Const SRCCOPY = &HCC0020
Private Const MERGEPAINT = &HBB0226
Private Const SRCAND = &H8800C6
Private Const DIB_RGB_COLORS = 0
Private Const DIB_PAL_COLORS = 1
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Dim nRet As Long
Private Sub cmdColor_Click()
frmColor.Show vbModal
Command1.SetFocus
End Sub
Private Sub cmdFont_Click()
dlg.Flags = cdlCFScreenFonts
dlg.FontName = lbl.FontName
dlg.ShowFont
lbl.FontName = dlg.FontName
lbl.FontSize = dlg.FontSize
lbl.FontBold = dlg.FontBold
lbl.FontItalic = dlg.FontItalic
lbl.FontStrikethru = dlg.FontStrikethru
lbl.FontUnderline = dlg.FontUnderline
Command1.SetFocus
End Sub
Private Sub cmdCapture_Click()
pic.Visible = True
pic.Height = lbl.Height
pic.Width = lbl.Width
nRet = BitBlt(pic.hDC, 0, 0, lbl.Width - 2, lbl.Height - 2, Me.hDC, lbl.Left + 1, lbl.Top + 1, _
SRCCOPY)
pic.Picture = pic.Image
SavePicture pic.Image, "text.bmp"
pic.Visible = False
Command1.SetFocus
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
lbl.Caption = lbl.Caption & Chr(KeyAscii)
End Sub
Private Sub cmdClear_Click()
Me.Refresh
lbl.Caption = ""
End Sub
|