473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Emulate Picture Box double click

I have the following code

Private Sub PictureBox_DoubleClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Try
Dim p As PictureBox = CType(sender, PictureBox)
Dim filetemp As String
filetemp = Replace(p.Tag, "Thumb", "jpg")
If Me.UseEditor = True Then
System.Diagnostics.Process.Start(filetemp)
Else

End If

_Image = Image.FromFile(filetemp)

Catch ex As Exception
Throw New Exception("PictureBox_DoubleClick", ex)
End Try

End Sub

Is there a way to emulate this functionality by single clicking the
image to select and and then click a button on the form to perform the
same action as the above code? If so, please could you provide sample
code.

Thanks.
Oct 7 '08 #1
2 3259
wkaibigan wrote:
Private Sub PictureBox_DoubleClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Try
Dim p As PictureBox = CType(sender, PictureBox)
Dim filetemp As String
filetemp = Replace(p.Tag, "Thumb", "jpg")
If Me.UseEditor = True Then
System.Diagnostics.Process.Start(filetemp)
Else

End If

_Image = Image.FromFile(filetemp)

Catch ex As Exception
Throw New Exception("PictureBox_DoubleClick", ex)
End Try

End Sub

Is there a way to emulate this functionality by single clicking the
image to select and and then click a button on the form to perform the
same action as the above code? If so, please could you provide sample
code.
Extract the code into a separate routine and call it wherever you want
to call it from.

Private Sub EditPicture( ByVal sender as PictureBox )
'Try
Dim p As PictureBox = CType(sender, PictureBox)
Dim filetemp As String _
= Replace(p.Tag, "Thumb", "jpg")
If Me.UseEditor = True Then
System.Diagnostics.Process.Start(filetemp)
Else
???
End If

_Image = Image.FromFile(filetemp)

'Catch ex As Exception
' Throw New Exception("PictureBox_DoubleClick", ex)
'End Try
End Sub

.... then ...

Private m_CurrentPicture as PictureBox = Nothing

Private Sub PictureBox_Click(ByVal sender As System.Object _
, ByVal e As System.EventArgs)

m_CurrentPictureBox = DirectCast( sender, PictureBox )

End Sub

Private Sub Button7_Click(ByVal sender As System.Object _
, ByVal e As System.EventArgs)

EditPicture( m_CurrentPictureBox )

End Sub

You'll note I've commented out your Exception Handling in EditPicture -
there's no point catching an Exception unless you're going to do
something /useful/ with it (and, IMHO, wrapping a nice, specific
Exception in a System.Exception isn't).

HTH,
Phill W.
Oct 7 '08 #2
On Oct 7, 2:23*pm, wkaibigan <wkaibi...@gmail.comwrote:
I have the following code

Private Sub PictureBox_DoubleClick(ByVal sender As System.Object,
ByVal e As System.EventArgs)
* * * * Try
* * * * * * Dim p As PictureBox = CType(sender, PictureBox)
* * * * * * Dim filetemp As String
* * * * * * filetemp = Replace(p.Tag, "Thumb", "jpg")
* * * * * * If Me.UseEditor = True Then
* * * * * * * * System.Diagnostics.Process.Start(filetemp)
* * * * * * Else

* * * * * * End If

* * * * * * _Image = Image.FromFile(filetemp)

* * * * Catch ex As Exception
* * * * * * Throw New Exception("PictureBox_DoubleClick", ex)
* * * * End Try

* * End Sub

Is there a way to emulate this functionality by single clicking the
image to select and and then click a button on the form to perform the
same action as the above code? If so, please could you provide sample
code.

Thanks.
Hi,
As Picturebox is a control, and control class has OnDoubleClick method
to raise DoubleClick event. So you can directly call it from anywhere
and you'd better look at that method:
http://msdn.microsoft.com/en-us/libr...ubleclick.aspx

Hope this helps,

Onur Güzel
Oct 7 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Trevor Fairchild | last post by:
I am making a program that categorizes pictures. The picture paths are stored in an Access Database, vb6 connects using adodc controls. This program works specifically with .jpg files. It will be...
1
by: Dennis | last post by:
Hello, Ive to draw a line on a picture i used this code: Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) x1 = z.X y1 = z.Y lbl3 = "x1: " & x1 lbl4...
6
by: Richard A. Lowe | last post by:
I'm using P/Invoke to call SendInput (using code culled from these newsgroups!) to send mouse events to a window. But I'm unsure how to send double-clicks. A VB6 article I saw on SendInput...
2
by: madhuri.eerupula | last post by:
HI I had a bitmap image(textimage) on a picturebox, i want to do double click operation on it, if i double click on some part(particular text) of the pic box then i want to show that particular part...
0
by: Sin Jeong-hun | last post by:
The term 'system-wide' just means that click is dealt in whole-screen wide level. Just like the real mouse pointer. What I'd like to do is to emulate mouse move and click. For example, the...
4
by: =?Utf-8?B?Q2FybGFKYWRl?= | last post by:
Can anyone help me? I need to use picture it 2000 every day and use to use it on Windows XP and had NO problems at all. If I would open up windows explorer i could be in my folder that has all of...
1
by: rajeev deep | last post by:
Hello Everyone, When I use properties window of image then one picture call easily, even no need to write the code for calling any jpg picture or bmp picture, just double click on picture option on...
17
by: merrily | last post by:
Read in one forum the question someone asked after successfully (sort of) installing Picture It 2000 on new computer with Vista. Will this person or any other help me accomplish this install on...
14
by: Eugeny Myunster | last post by:
Hello all, How can i emulate sizeof() only for integers?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.