• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

managing picture control

i have some questions related to picture control

1. how can i open two photos or more using the same picture control (overlaying)?

2. how can i do zoom in and zoom out and pan?

0
aft
Asked:
aft
1 Solution
 
Ryan ChongCommented:
1. To overlay the picture, you may use the AlphaBlend API:

Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long

2. for zoom in and zoom out, try StretchBlt API:

Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
0
 
aftAuthor Commented:
u do not have any examples about the using of these 2 functions?

and how to pan the map?
0
 
aelatikCommented:
if you want examples, download api-guide 3.7 from http://www.student.kuleuven.ac.be/~m0116986/3.7/agsetup.exe
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Ryan ChongCommented:
or you can download the API-guide from its official website at: http://www.allapi.net/
0
 
aftAuthor Commented:
also there is one thing happen. i draw some rectangles and lines in the picture control. after that i want to load the photo. when i did that all the rectangle deleted and the photo added.
how can i prevent the drawing from being removed after i add a photo?
0
 
aftAuthor Commented:
both versions of this two files of the API guide are the same version?
0
 
Ryan ChongCommented:
>>also there is one thing happen. i draw some rectangles and lines in the picture control. after that i want to load the photo. when i did that all the rectangle deleted and the photo added.
Try set the AutoRedraw property to false, and try again.

>>both versions of this two files of the API guide are the same version?
if not wrong, 3.7 is the latest one.
0
 
aftAuthor Commented:
i want more details about unsing these 2 functions
0
 
aftAuthor Commented:
>>Try set the AutoRedraw property to false, and try again.

i tried it it is not working too
i still have the same problem
0
 
Ryan ChongCommented:
>>Try set the AutoRedraw property to false, and try again.
Sorry, it's actually try set the AutoRedraw property to True..

ok, here are the example:

Const NEWFRAME = 1
Private Declare Function Escape Lib "gdi32" (ByVal hdc As Long, ByVal nEscape As Long, ByVal nCount As Long, ByVal lpInData As String, lpOutData As Any) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Dim hMemoryDC As Long

Dim m_cVSplitter As New cVSplitter
Dim frmWidth As Long, frmHeight As Long

Const AC_SRC_OVER = &H0
Private Type BLENDFUNCTION
  BlendOp As Byte
  BlendFlags As Byte
  SourceConstantAlpha As Byte
  AlphaFormat As Byte
End Type
Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
Private Declare Sub RtlMoveMemory Lib "Kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
    x As Long
    y As Long
End Type

Dim myX As Long, myY As Long, fX As Long, fY As Long, sX As Long, sY As Long
Dim CurPos As POINTAPI, isReset As Boolean

Private Sub ApplyBlend(ByRef PicSource As PictureBox, ByRef PicTarget As PictureBox)
    Dim BF As BLENDFUNCTION, lBF As Long
   
    Dim OriginalScaleMode(1) As Integer
   
    'Set the graphics mode to persistent
    PicSource.AutoRedraw = True
    PicTarget.AutoRedraw = True
    'Store the Original ScaleMode
    OriginalScaleMode(0) = PicSource.ScaleMode
    OriginalScaleMode(1) = PicTarget.ScaleMode
    'API uses pixels
    PicSource.ScaleMode = vbPixels
    PicTarget.ScaleMode = vbPixels
    'set the parameters
    With BF
        .BlendOp = AC_SRC_OVER
        .BlendFlags = 0
        .SourceConstantAlpha = 128
        .AlphaFormat = 0
    End With
    'copy the BLENDFUNCTION-structure to a Long
    RtlMoveMemory lBF, BF, 4
    'AlphaBlend the picture from PicSource over the picture of PicTarget
    AlphaBlend PicTarget.hdc, 0, 0, PicTarget.ScaleWidth, PicTarget.ScaleHeight, PicSource.hdc, 0, 0, PicSource.ScaleWidth, PicSource.ScaleHeight, lBF
    PicTarget.Refresh
   
    'Restore to Original ScaleMode
    PicSource.ScaleMode = OriginalScaleMode(0) 'vbTwips
    PicTarget.ScaleMode = OriginalScaleMode(1) 'vbTwips
   
End Sub

Private Sub RemoveBlend(ByRef PicSource As PictureBox, ByRef PicTarget As PictureBox)
    PicTarget.Picture = PicSource.Picture
    PicTarget.Refresh
End Sub

Private Sub Command1o_Click()
    If Picture2.AutoRedraw = False Then Picture2.AutoRedraw = True
    Picture2.ScaleMode = vbTwips
    Picture2.Cls
    DoEvents
    StretchBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, ScrCopy
    Picture2.Refresh
End Sub

0
 
aftAuthor Commented:
can u explain to me this source code?
0
 
aftAuthor Commented:
can u explain to me this source code?
0
 
aftAuthor Commented:
>>Sorry, it's actually try set the AutoRedraw property to True..

i already set the autoredraw to true but still after loading a photo all the drawing is deleted
0
 
aftAuthor Commented:
there is no solution for this problem?
0
 
aftAuthor Commented:
i load the picture using:
map1.Picture = LoadPicture(LayerFull)

but when i use map1.cls
all the graphics is deleted and the photo remaining
0
 
Ryan ChongCommented:
>>all the graphics is deleted and the photo remaining
What is the photo you mean? Graphic or Object?
0
 
aftAuthor Commented:
the photo that i loaded it using the following command

map1.Picture = LoadPicture(LayerFull)

0
 
aftAuthor Commented:
can open one reply me?
0
 
CleanupPingCommented:
Hi aft,
This old question (QID 20569930) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
GrahamSkanRetiredCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept ryancys' comment as answer

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GrahamSkan
EE Cleanup Volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now