Results 1 to 4 of 4

Thread: can i transfer picture from picturebox to textbox?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Posts
    3

    Cool can i transfer picture from picturebox to textbox?

    can i transfer picture from picturebox to textbox?
    if can,what is the code?

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    is this what you want?

    VB Code:
    1. Option Explicit
    2. '// WIN32 API Function
    3. 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
    4. Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    5. Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    6.  
    7. '// WIN32 API Constant
    8. Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
    9.  
    10. Private Sub Command1_Click()
    11.     Dim hdc As Long
    12.    
    13.     hdc = GetDC(Text1.hwnd)
    14.     BitBlt hdc, 20, 20, ScaleX(Picture1.Width, vbTwips, vbPixels), _
    15.                         ScaleY(Picture1.Height, vbTwips, vbPixels), _
    16.                         Picture1.hdc, 0, 0, SRCCOPY
    17.     ReleaseDC Text1.hwnd, hdc
    18. End Sub

  3. #3
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183
    That code is clever, but it will only draw the picture over the top of the textbox. You'll be unable to move the picture up and down by pressing delete and return (like you can in msWord). The textbox that comes with VB isn't advances enough to incorporate pictures like word is. You can probably download a text box somewhere that lets you do this.

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    then you got to look into the RichTextBox control


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width