?
Solved

managing picture control

Posted on 2003-04-01
20
Medium Priority
?
221 Views
Last Modified: 2012-05-04
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
Comment
Question by:aft
[X]
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
20 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8244782
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
 

Author Comment

by:aft
ID: 8245331
u do not have any examples about the using of these 2 functions?

and how to pan the map?
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8245408
if you want examples, download api-guide 3.7 from http://www.student.kuleuven.ac.be/~m0116986/3.7/agsetup.exe
0
Industry Leaders: 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!

 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8250339
or you can download the API-guide from its official website at: http://www.allapi.net/
0
 

Author Comment

by:aft
ID: 8251775
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
 

Author Comment

by:aft
ID: 8251779
both versions of this two files of the API guide are the same version?
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8251797
>>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
 

Author Comment

by:aft
ID: 8253302
i want more details about unsing these 2 functions
0
 

Author Comment

by:aft
ID: 8253410
>>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
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 300 total points
ID: 8258757
>>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
 

Author Comment

by:aft
ID: 8269439
can u explain to me this source code?
0
 

Author Comment

by:aft
ID: 8269456
can u explain to me this source code?
0
 

Author Comment

by:aft
ID: 8269465
>>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
 

Author Comment

by:aft
ID: 8301315
there is no solution for this problem?
0
 

Author Comment

by:aft
ID: 8301359
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
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8304046
>>all the graphics is deleted and the photo remaining
What is the photo you mean? Graphic or Object?
0
 

Author Comment

by:aft
ID: 8305402
the photo that i loaded it using the following command

map1.Picture = LoadPicture(LayerFull)

0
 

Author Comment

by:aft
ID: 8312238
can open one reply me?
0
 

Expert Comment

by:CleanupPing
ID: 8531201
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9046626
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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
Course of the Month15 days, 8 hours left to enroll

743 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