How can i make a picture exacly the same display as the textbox?

Posted on 2003-03-07
Medium Priority
Last Modified: 2010-05-01
I want to save a picture as the textbox (text,font,fontsize, font colour)!
The user will input multi-line string in the textbox!

Can i put the text1 image into picture.image?????????????

So i can save the picture into the file as picture.picture = picture.image!

Question by:tonyleung
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 53

Expert Comment

by:Ryan Chong
ID: 8086723
Private Declare Function BitBlt Lib "gdi32" _
  (ByVal hDCDest As Long, ByVal XDest As Long, _
   ByVal YDest As Long, ByVal nWidth As Long, _
   ByVal nHeight As Long, ByVal hDCSrc As Long, _
   ByVal xSrc As Long, ByVal ySrc As Long, _
   ByVal dwRop As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long

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 Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Private Type POINTAPI
   X As Long
   Y As Long
End Type

        Length As Long
        flags As Long
        showCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPosition As RECT
End Type

Private Sub PrintHwnd(ByRef hwnd As Long, ByRef pic As PictureBox)
    Dim hDCDesk As Long
    Dim LeftDesk As Long
    Dim TopDesk As Long
    Dim WidthDesk As Long
    Dim HeightDesk As Long
    Dim rtn As Long
    Dim Rectan As RECT
    Dim newWidth As Long, newHeight As Long
    Dim MyStr As String
    WinEst.Length = Len(WinEst)
    'get the current window placement
    rtn = GetWindowPlacement(hwnd, WinEst)
    Rectan = WinEst.rcNormalPosition
    LeftDesk = 0
    TopDesk = 0
    WidthDesk = Rectan.Right - Rectan.Left
    HeightDesk = Rectan.Bottom - Rectan.Top
    hDCDesk = GetWindowDC(hwnd)
    newWidth = WidthDesk * Screen.TwipsPerPixelX
    newHeight = HeightDesk * Screen.TwipsPerPixelY
    pic.Width = IIf(pic.Width < newWidth, newWidth, pic.Width)
    pic.Height = IIf(pic.Height < newHeight, newHeight, pic.Height)
    picW = pic.Width
    picH = pic.Height
    Debug.Print "WidthDesk:newWidth:pic.Width: " & WidthDesk & ": " & newWidth & ": " & pic.Width
    Debug.Print "HeightDesk:newHeight:pic.Height: " & HeightDesk & ": " & newHeight & ": " & pic.Height
    i = BitBlt(pic.hdc, 0, 0, WidthDesk, HeightDesk, hDCDesk, LeftDesk, TopDesk, vbSrcCopy)
    pic.Tag = "PrintHwnd"
    Call ReleaseDC(hwnd, hDCDesk)
End Sub

Try like:

PrintHwnd Text1.hwnd, Picture1

Accepted Solution

tonyleung earned 0 total points
ID: 8087056
I found that it is work when the form scalemode set as 1-trip!
However, i must set the scalemode of form and the picturebox as 3-resolution!
Is there any method on it?
Or, is there any method for convert the scalemode value from 3 to 1 and 1 to 3?

Expert Comment

ID: 8900535
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 9074281
tonyleung, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question