473,671 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Emulate Picture Box double click

I have the following code

Private Sub PictureBox_Doub leClick(ByVal sender As System.Object,
ByVal e As System.EventArg s)
Try
Dim p As PictureBox = CType(sender, PictureBox)
Dim filetemp As String
filetemp = Replace(p.Tag, "Thumb", "jpg")
If Me.UseEditor = True Then
System.Diagnost ics.Process.Sta rt(filetemp)
Else

End If

_Image = Image.FromFile( filetemp)

Catch ex As Exception
Throw New Exception("Pict ureBox_DoubleCl ick", 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 3271
wkaibigan wrote:
Private Sub PictureBox_Doub leClick(ByVal sender As System.Object,
ByVal e As System.EventArg s)
Try
Dim p As PictureBox = CType(sender, PictureBox)
Dim filetemp As String
filetemp = Replace(p.Tag, "Thumb", "jpg")
If Me.UseEditor = True Then
System.Diagnost ics.Process.Sta rt(filetemp)
Else

End If

_Image = Image.FromFile( filetemp)

Catch ex As Exception
Throw New Exception("Pict ureBox_DoubleCl ick", 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.Diagnost ics.Process.Sta rt(filetemp)
Else
???
End If

_Image = Image.FromFile( filetemp)

'Catch ex As Exception
' Throw New Exception("Pict ureBox_DoubleCl ick", ex)
'End Try
End Sub

.... then ...

Private m_CurrentPictur e as PictureBox = Nothing

Private Sub PictureBox_Clic k(ByVal sender As System.Object _
, ByVal e As System.EventArg s)

m_CurrentPictur eBox = DirectCast( sender, PictureBox )

End Sub

Private Sub Button7_Click(B yVal sender As System.Object _
, ByVal e As System.EventArg s)

EditPicture( m_CurrentPictur eBox )

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.Exceptio n isn't).

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

Private Sub PictureBox_Doub leClick(ByVal sender As System.Object,
ByVal e As System.EventArg s)
* * * * Try
* * * * * * Dim p As PictureBox = CType(sender, PictureBox)
* * * * * * Dim filetemp As String
* * * * * * filetemp = Replace(p.Tag, "Thumb", "jpg")
* * * * * * If Me.UseEditor = True Then
* * * * * * * * System.Diagnost ics.Process.Sta rt(filetemp)
* * * * * * Else

* * * * * * End If

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

* * * * Catch ex As Exception
* * * * * * Throw New Exception("Pict ureBox_DoubleCl ick", 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
13871
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 used by people categorizing thousands of images. The problem I have is that both the picture control, and the image control seem unable to open certain jpg images for an unknown reason. The error message simply states "Invalid Picture". I can...
1
9700
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 = "y1: " & y1
6
15638
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 suggested simply queueing two click events, but this is not working for me, regardless of the delay I put between clicks. So give this as a click (where INPUT is an appropriate structure for sending the SendInput data): public static void Click()
2
4421
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 somewhere else may be in another form or notepad, or anything.in c#, how can i know the limit of pixels on four sides of text, when i double click on it(some particular text) n get only exactly that particular text. hope u get bck to me asap....
0
2011
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 command is something like "Move the mouse to the 300,400 of the screen and click." I know that I can send mouse clcik message to a specific window using WinAPI. But can't I just emulate 300,400 click of the real screen? I thought that I might need to...
4
5823
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 my picture it files in there, .mix files and even though they were not jpegs etc.. windows explorer would show the thumbnail of all of these projects saved so i could quickly look for something and double click to open. Since installing...
1
2076
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 the properties window of specified image and give exact path of picture file, but I don’t want to call any picture like jpg picture through above mentioned way, I want to call picture in image through the coding. So please suggest me with the...
17
12057
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 Vista, please. I tried installing Picture It and it seemed to do so. I got no error messages but it sure took a long time. Then when I tried to open the program it said "access denied" adding that I needed 30 meg of disk space (implying I didn't)...
14
1706
by: Eugeny Myunster | last post by:
Hello all, How can i emulate sizeof() only for integers?
0
8403
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.