Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy and paste picture box

sal21

Programmer
Apr 26, 2004
493
IT
ho to copy and paste picture1 from one postion into new postion but rename it in pictutre2
 
HI strongm, really my prob is other.....

based the value in a label LARRAY1how to cover the related number in a red square o the image(SK1.GIF), with the little black square named NERO_12.GIF

TKS

NOTE:
- The number in the label are alway six, but naturally with a dinamic value
- Assign to the button MOVE the code
- At the and of code i need the image in attached image
a the and of code i need that in immagine.jpg
 

Attachments

  • TEST.zip
    299.7 KB · Views: 3
  • Immagine.jpg
    Immagine.jpg
    71.3 KB · Views: 2
Last edited:
So you already have an alternative solution to displaying the lotto selections. You are just missing the bit to save the modified image? In which case, Add a module, then copy and paste this code

Rich (BB code):
Option Explicit

' API Declarations
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 Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long

' Type for window rectangle
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

' Constant for BitBlt
Private Const SRCCOPY = &HCC0020

' Function to capture the area of a specific control and save it
' Note that this captures all graphics within the area outlined by the control, not just the
' control itself.
Public Sub CaptureControlArea(frm As Form, ctl As Control, ByVal FilePath As String)
    Dim hDCForm As Long
    Dim picBox As PictureBox
    Dim frmRect As RECT
    Dim ctlRect As RECT
    Dim xSrcPixels As Long
    Dim ySrcPixels As Long
    Dim nWidthPixels As Long
    Dim nHeightPixels As Long
    
    ' Get the control's rectangle in screen coordinates
    GetWindowRect ctl.hwnd, ctlRect
    
    ' Get the form's rectangle in screen coordinates
    GetWindowRect frm.hwnd, frmRect
    
    ' Calculate control's position relative to form's client area in pixels
    xSrcPixels = ctlRect.Left - frmRect.Left
    ySrcPixels = ctlRect.Top - frmRect.Top
    nWidthPixels = (ctlRect.Right - ctlRect.Left)
    nHeightPixels = (ctlRect.Bottom - ctlRect.Top)
    
    ' Create a temporary picture box to hold the captured image
    Set picBox = frm.Controls.Add("VB.PictureBox", "TempPicBox")
    With picBox
        .Visible = False
        .AutoRedraw = True
        .Width = nWidthPixels * Screen.TwipsPerPixelX
        .Height = nHeightPixels * Screen.TwipsPerPixelY
    End With
    
    ' Get the form's device context
    hDCForm = GetWindowDC(frm.hwnd)
    
    ' Capture the control's area to the picture box
    BitBlt picBox.hDC, 0, 0, nWidthPixels, nHeightPixels, hDCForm, xSrcPixels, ySrcPixels, SRCCOPY
    
    ' Refresh the picture box to ensure the image is drawn
    picBox.Refresh
    
    ' Save the captured image
    SavePicture picBox.Image, FilePath
    
    ' Clean up
    ReleaseDC frm.hwnd, hDCForm
    frm.Controls.Remove "TempPicBox"
End Sub

This could then be called from the form by adding another button with ther following:
Rich (BB code):
Private Sub Command3_Click()
    CaptureControlArea Form1, Picture1, "c:\downloads\sal21.bmp" 'your filepath goes here
End Sub

Note that code assumes form's scalemode is twips
 
STRONGM i'm very sorry, tks for code, in other case. But i have post a wrong gif image, here is the correct image SK1.GIF
and i can re- explain my prob..

in the form SKEDINA are a label LARRAY1 with a value in my case 1 12 33 48 66 90.
now i need to loop all value in the label LARRAY1 one to one and cover with the NERO_12.gif the related number in SK1.GIF

at the and of code i I should have the image final result.gif
note:

- the label LARRAY1 may contain only max six numbers
- at the first moment work only on the first rose panell

tell me if you have understand now, sorry for my bad napolitain/english language
 

Attachments

  • final result.gif
    final result.gif
    138.2 KB · Views: 4
  • SK1.gif
    SK1.gif
    136.1 KB · Views: 4
Last edited:
I understand fine. But the reason I am confused is that I saw you had a solution to the lotto card on eileen's lounge, and assumed that was what you were posting here. Why twould you revert to a non-working, poor version?
 
because I was sure that you have more experience and then I don't like the use of flexgrid, naturally other solution is welcome.

and I have doubts if I take the betting slip to the tobacconist it will not be read correctly, I think that the solution with the numbers covered by picturebox works better, please write something for me
tks
 
Last edited:
> I don't like the use of flexgrid

It's the MSHFlexgrid, which is a slightly later contyrol - but why don't you like it? For this challenge it is ideal. Does ALL the heavy lifting.

>I have doubts if I take the betting slip to the tobacconist it will not be read correctly
Why?

>I think that the solution with the numbers covered by picturebox works better
Why?

Both of the last two are honest questions - is there something specific about Superenalotto lottery playslip readers that can tell the difference between a gif black box and a unicode black box. In the UK the optical mark recognition systems simply care that the mark is (roughly) within the alignment markers.

And on the mshflewxgrid solution they pretty much are, so should work.

But, as I say, perhaps there is something special about Superenalotto that I am not aware.
 

Part and Inventory Search

Sponsor

Back
Top