yyuubum2
asked on
How can I save contents of a TEXT BOX to a BITMAP?
I am having a user enter text into a TEXTBOX control.
I then want to have them press a button and the contents will be saved to a BITMAP'd version of the contents, same dimentions as the text box.
Can someone show me code that will do that?
I then want to have them press a button and the contents will be saved to a BITMAP'd version of the contents, same dimentions as the text box.
Can someone show me code that will do that?
ASKER
that is sweet...very nice.
thanks !
thanks !
ASKER
Just another question...would there be a lot for you to ammend it to work
with a Rich Text Box?
with a Rich Text Box?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Option Explicit
Private Declare Function GetWindowDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" _
(ByVal hwnd As Long, ByVal hdc As Long) As Long
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
Private Sub Command1_Click()
Me.ScaleMode = vbPixels
Picture1.Width = Text1.Width
Picture1.Height = Text1.Height
Picture1.BorderStyle = 0 ' none
Picture1.Appearance = 0 ' flat
Picture1.AutoRedraw = True
Dim textDC As Long
textDC = GetWindowDC(Text1.hwnd)
BitBlt Picture1.hdc, 0, 0, Picture1.Width, Picture1.Height, textDC, 0, 0, vbSrcCopy
ReleaseDC Text1.hwnd, textDC
SavePicture Picture1.Image, "c:\someImage.bmp"
End Sub