Taskbar Code small problem
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
I am trying to use a sender.text to read and show a form here is the code for the button click
with the sender in it
and here is the code for bringinig it to front and adding the button in the first place :P
with the sender in it
Code: Select all
Private Sub btnpress(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
Dim procArray() As System.Diagnostics.Process
procArray = System.Diagnostics.Process.GetProcessesByName(sender.text)
If procArray.Length > 0 Then
ShowPreviousInstance(procArray(0).MainWindowHandle)
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
and here is the code for bringinig it to front and adding the button in the first place :P
Code: Select all
Private Sub BackTrackBrowserButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackTrackBrowserButton1.Click
BackTrackListBox1.Items.Clear()
For Each p As Process In Process.GetProcesses
If p.MainWindowTitle <> "" Then BackTrackListBox1.Items.Add(p.MainWindowTitle)
Next
BackTrackMenuStrip1.Items.Clear()
Dim btnTop As Integer = 0
For i As Integer = 0 To BackTrackListBox1.Items.Count - 1
Dim btn As New ToolStripButton
btn.Text = BackTrackListBox1.Items(i).ToString()
btn.Tag = i
AddHandler btn.Click, AddressOf btnpress
BackTrackMenuStrip1.Items.Add(btn)
btnTop += 30
Next
End Sub
Private SW_RESTORE As Integer = 9
Private Declare Auto Function IsIconic Lib "user32" (ByVal hWnd As IntPtr) As Boolean
Private Declare Auto Function SetForegroundWindow Lib "user32" (ByVal hwnd As IntPtr) As Long
Private Declare Auto Function ShowWindow Lib "user32" (ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As IntPtr
Private Function ShowPreviousInstance(ByVal handle As IntPtr) As Boolean
If handle.ToInt32 <> IntPtr.Zero.ToInt32 Then
Try
If IsIconic(handle) Then
ShowWindow(handle, SW_RESTORE)
End If
SetForegroundWindow(handle)
ShowPreviousInstance = True
Catch ex As System.Exception
ShowPreviousInstance = False
End Try
Else
ShowPreviousInstance = False
End If
End Function
oh so lucky..! you've found the answer in your previous question on
bringing the form to front.. i'll will take note of that code as well..! thanks.!
bringing the form to front.. i'll will take note of that code as well..! thanks.!
i did yes if you replace the
procArray = System.Diagnostics.Process.GetProcessesByName(sender.text)
with something like
procArray = System.Diagnostics.Process.GetProcessesByName("notepad")
then it will work i need to find a way to make it a sender or something were it will know what it is as the controls will be added programtically
procArray = System.Diagnostics.Process.GetProcessesByName(sender.text)
with something like
procArray = System.Diagnostics.Process.GetProcessesByName("notepad")
then it will work i need to find a way to make it a sender or something were it will know what it is as the controls will be added programtically
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023