|
Hi,
.NET does not expose the BROWSEINFO[^] structure for the shell's native FolderBrowser so you are stuck with the options chosen by Microsoft. I quite like the path autocomplete that's available in the native version when BIF_EDITBOX is included in BROWSEINFO.ulFlags but sadly .NET does not provide an enabling property for this.
There was an article posted just a few days ago on this topic and you may want to take a look at that. (FolderBrowserDialogEx: A C# customization of FolderBrowserDialog[^])
Alan
|
|
|
|
|
If it doesn't exist I rewrite the VBA api and use this in vb.net
Thanks all for thinking
|
|
|
|
|
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
<DllImport("User32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function EnumChildWindows(ByVal WindowHandle As IntPtr, ByVal Callback As EnumWindowProcess, ByVal lParam As IntPtr) As Boolean
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Sub GetClassName(ByVal hWnd As System.IntPtr, ByVal lpClassName As System.Text.StringBuilder, ByVal nMaxCount As Integer)
End Sub
<DllImport("USER32.DLL")> _
Private Shared Function GetShellWindow() As IntPtr
End Function
<DllImport("USER32.DLL")> _
Private Shared Function GetWindowText(ByVal hWnd As IntPtr, ByVal lpString As StringBuilder, ByVal nMaxCount As Integer) As Integer
End Function
<DllImport("USER32.DLL")> _
Private Shared Function GetWindowTextLength(ByVal hWnd As IntPtr) As Integer
End Function
<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetWindowThreadProcessId(ByVal hWnd As IntPtr, <Out()> ByRef lpdwProcessId As UInt32) As UInt32
End Function
<DllImport("USER32.DLL")> _
Private Shared Function IsWindowVisible(ByVal hWnd As IntPtr) As Boolean
End Function
Private Delegate Function EnumWindowsProc(ByVal hWnd As IntPtr, ByVal lParam As Integer) As Boolean
<DllImport("USER32.DLL")> _
Private Shared Function EnumWindows(ByVal enumFunc As EnumWindowsProc, ByVal lParam As Integer) As Boolean
End Function
<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetWindowRect(ByVal hWnd As IntPtr, <Out()> ByRef lpRect As RECT) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
Public Shared Function GetChildWindows(ByVal ParentHandle As IntPtr) As IntPtr()
Dim ChildrenList As New List(Of IntPtr)
Dim ListHandle As GCHandle = GCHandle.Alloc(ChildrenList)
Try
EnumChildWindows(ParentHandle, AddressOf EnumWindow, GCHandle.ToIntPtr(ListHandle))
Finally
If ListHandle.IsAllocated Then ListHandle.Free()
End Try
Return ChildrenList.ToArray
End Function
Private hShellWindow As IntPtr = GetShellWindow()
Private dictWindows As New Dictionary(Of IntPtr, String)
Private currentProcessID As Integer
Public Delegate Function EnumWindowProcess(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean
Private Shared Function EnumWindow(ByVal Handle As IntPtr, ByVal Parameter As IntPtr) As Boolean
Dim ChildrenList As List(Of IntPtr) = GCHandle.FromIntPtr(Parameter).Target
If ChildrenList Is Nothing Then Throw New Exception("GCHandle Target could not be cast as List(Of IntPtr)")
ChildrenList.Add(Handle)
Return True
End Function
Public Function GetOpenWindowsFromPID(ByVal processID As Integer) As IDictionary(Of IntPtr, String)
dictWindows.Clear()
currentProcessID = processID
EnumWindows(AddressOf enumWindowsInternal, 0)
Return dictWindows
End Function
Private Function enumWindowsInternal(ByVal hWnd As IntPtr, ByVal lParam As Integer) As Boolean
If (hWnd <> hShellWindow) Then
Dim windowPid As UInt32
If Not IsWindowVisible(hWnd) Then
Return True
End If
Dim length As Integer = GetWindowTextLength(hWnd)
If (length = 0) Then
Return True
End If
GetWindowThreadProcessId(hWnd, windowPid)
If (windowPid <> currentProcessID) Then
Return True
End If
Dim stringBuilder As New StringBuilder(length)
GetWindowText(hWnd, stringBuilder, (length + 1))
dictWindows.Add(hWnd, stringBuilder.ToString)
End If
Return True
End Function
Private Const WM_CHAR = &H102
What i need is to get all windows of an process...
I do it like this:
For Each P As Process In Process.GetProcessesByName("Notepad")
Dim windows As IDictionary(Of IntPtr, String) = GetOpenWindowsFromPID(P.Id)
For Each kvp As KeyValuePair(Of IntPtr, String) In windows
Next
Next
But now i am missing handles of that windows.
Could someone explain me a little!?
I want to know how to get all child windows (id,title,handle) of an process.
FeRtoll Software.net
------------
E-Mail me
WebPage
modified on Monday, February 21, 2011 3:09 AM
|
|
|
|
|
|
thank you but that not helping me.
i need handles of child windows of an process!
however i solved it so i dont need anymore
thanks man
|
|
|
|
|
Please pardon the lame subject. I could not think of anything more appropriate (because it's the answer to my question).
When you are calling a function and you type the open parenthesis, the IDE will then show a popup-type window containing the function's syntax and a brief description. How can this be done with your own code?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
When you type a triple single quote on the line above a sub/fun start, it will expand automatically; you can edit the result, then see it in intellisense.
''' <summary>
''' Performs some test.
''' </summary>
''' <param name="value">Input value</param>
''' <remarks></remarks>
Public Sub test(ByVal value As Long)
...
End Sub
FYI: it works the same in C#, with a triple slash.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Super.
I did not know that.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
You're welcome.
PS: Maybe you should read the fine manual, or a good book... (don't ask which, I mostly don't do VB!)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I found "Head First C#" to be the best possible introduction to VB.NET
|
|
|
|
|
This is a very help feature that is kind of hidden in VS. You should post it as a tip/trick to draw attention to it.
|
|
|
|
|
it is documented, e.g. here[^].
I tend to write articles or tips about stuff I feel is missing in the documentation, that is enough of a challenge already.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Need some advice in the best way to approach something.
I have a class library that processes Insurance Items, the class library has to return a list of potential advisories to the user for them to evaluate.
I thought of using a Module with a list of advisories (as constant variables), but am also not sure that this is the best way forward and would like the advice of others
Thanks
Simon
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
You would be better off storing your list in an external file or database, rather than hard-coding them into your program code. That way, if the list changes, you simply need to update the (external) data rather than having to modify your application.
|
|
|
|
|
Thanks that has given me some good ideas now
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
Modules aren't really that OOP so I tend to stay away from them. A nice way may be to create a class called InsuranceItems which inherits List<insuranceitem> and then create a function within the inherited class which returns a list of advisories.
Public Class InsuranceItems
Inherits List(Of InsuranceItem)
Public Function GetAdvisories() As List(Of Advisory)
'Do stuff and return list
End Function
End Class
"You get that on the big jobs."
|
|
|
|
|
Thanks that has given me good things to go on
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
I have googled, but would prefer advice or suggestions...
I want to just have a way of copying a folder ( and contents ) to a memory stick at the click of a mouse.
There is a manager who wants this made easy.
I am thinking For each Element in Files kind of thing.
But is there an easier way?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Dalek Dave wrote: is there an easier way?
There are plenty:
- Synchronization tools.
- Backup tools.
- Rentacoder.
...
and in the end they all use at least one loop and possibly some recursion.
just-a-link[^]
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks for all your help there Luc!
Invaluable.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
|
Try this link:
http://www.codeproject.com/Messages/3526402/Re-Is-it-the-right-approach-to-speed-up-the-copy-p.aspx[^]
Or try this code:
Public Class FileSearch
Inherits System.Collections.Generic.List(Of String)
#Region "-----------------------------------------------------Events"
Public Event NewFileList(ByVal Sender As Object, ByVal e As FSrcEventArgs)
Public Event CurrentFolder(ByVal Sender As Object, ByVal e As FSrcEventArgs)
Public Event CurrentEvent(ByVal Sender As Object, ByVal e As FSrcEventArgs)
#End Region
#Region "--------------------------------------------Public Variables"
Public AddOnObj As Object, Info As String = "", FolderCount As Long, StopSearching As Boolean, FolderList As New List(Of String)
Public Shared ExcludeFolder As String = "Unwanted Programs", ExcludeSignFile As String = "\info.inf", ExcludeSign As String = "simpledata"
#End Region
#Region "-------------------------------------------Local Variables"
Dim e As New FSrcEventArgs
Private G_FileTypes() As String
Private Parent As System.Windows.Forms.Control
#End Region
Sub Reset()
e = New FSrcEventArgs
Me.Clear()
StopSearching = False
G_FileTypes = Nothing
FolderCount = 0
AddOnObj = Nothing
Info = ""
End Sub
#Region "--------------------------------------------FSrcEventArgs Class"
Public Class FSrcEventArgs
Inherits System.EventArgs
Friend Enum EventTypes
None = 0
Dirs = 1
Files = 2
Informations = 3
End Enum
Public Directory As String = ""
Public CurrentList As New List(Of String)
Public Completed As Boolean = False
Public StopSearching As Boolean = False
Public FileCount As Integer = 0
Public DirCount As Integer = 0
Public Info As String = ""
Public Exclude_This_Folder As Boolean
Friend EventType As EventTypes = EventTypes.None
Friend Sub CopyArgs(ByVal Directory As String, _
ByVal CurrentList As List(Of String), _
ByVal Completed As Boolean, _
ByVal StopSearching As Boolean, _
ByVal FileCount As Integer, _
ByVal DirCount As Integer, _
ByVal Info As String, _
ByVal EventType As EventTypes, ByVal Exclude_This_Folder As String)
With Me
.Directory = Directory
.CurrentList = CurrentList
.Completed = Completed
.StopSearching = StopSearching
.FileCount = FileCount
.DirCount = DirCount
.Info = Info
.EventType = EventType
End With
End Sub
End Class
#End Region
Sub GetAllFiles(ByVal InFolder As String, Optional ByVal FileTypes As String = "*.*", Optional ByVal contains As String = "")
e.Directory = InFolder
FolderList.Add(InFolder)
e.CopyArgs(InFolder, Me, e.Completed, StopSearching, Me.Count, FolderCount, "Searching Completed", FSrcEventArgs.EventTypes.Dirs, False)
Dim DG As New DLG_SrcInfo_all(AddressOf SUB_SrcInfo_all)
Try
Me.Parent.Invoke(DG, Me, e)
Catch ex As Exception
End Try
FindInFolder(InFolder, FileTypes, contains)
e.Completed = True
e.CopyArgs(InFolder, Me, e.Completed, StopSearching, Me.Count, FolderCount, "Searching Completed. Total Files: " & Me.Count, FSrcEventArgs.EventTypes.Informations, False)
Try
Me.Parent.Invoke(DG, Me, e)
Catch ex As Exception
End Try
End Sub
Shadows Function ToString(ByVal Delimiter As String) As String
Me.ToArray()
Return Microsoft.VisualBasic.Strings.Join(Me.ToArray, Delimiter)
End Function
Function FindInFolder(ByVal InFolder As String, Optional ByVal FileTypes As String = "*.*", Optional ByVal contains As String = "") As System.Collections.Generic.IEnumerable(Of String)
Dim xx = InFolder
If IsNothing(G_FileTypes) Then
G_FileTypes = FileTypes.Split(New [Char]() {","c})
End If
Try
Dim ps As Integer = InStr(InFolder, ExcludeFolder, CompareMethod.Text)
If ps > 0 Then
Dim FD As String = My.Computer.FileSystem.ReadAllText(InFolder & ExcludeSignFile)
If FD.Length = ExcludeSign.Length Then
Return Me
End If
End If
Catch ex As Exception
End Try
Dim DG As New DLG_SrcInfo_all(AddressOf SUB_SrcInfo_all)
Try
Me.AddRange(FindFiles(InFolder, FileTypes, contains))
Catch ex As Exception
Return Me
End Try
FolderCount += 1
e.CopyArgs(InFolder, e.CurrentList, e.Completed, StopSearching, Me.Count, FolderCount, "Searching for folders in '" & InFolder & "'", FSrcEventArgs.EventTypes.Informations, False)
Try
Me.Parent.Invoke(DG, Me, e)
Catch ex As Exception
End Try
For Each Directory As String In My.Computer.FileSystem.GetDirectories(InFolder, FileIO.SearchOption.SearchTopLevelOnly)
If StopSearching Then
e.CopyArgs(Directory, e.CurrentList, e.Completed, StopSearching, Me.Count, FolderCount, "Searching Stopped", FSrcEventArgs.EventTypes.Informations, False)
If Not IsNothing(Parent) Then
Me.Parent.Invoke(DG, Me, e)
End If
Return Nothing
End If
e.CopyArgs(Directory, e.CurrentList, e.Completed, StopSearching, Me.Count, FolderCount, "Searching for folders in '" & InFolder & "'", FSrcEventArgs.EventTypes.Dirs, False)
If Not IsNothing(Parent) Then
If Parent.Disposing Then
Else
Me.Parent.Invoke(DG, Me, e)
End If
End If
If e.Exclude_This_Folder Then
e.Exclude_This_Folder = False
Continue For
Else
FolderList.Add(Directory)
End If
Try
FindInFolder(Directory, FileTypes, contains)
Catch ex As Exception
xx = ex.ToString()
Continue For
End Try
Next
Return Me
End Function
#Region " -------------------------------------------- Delegates"
Private Delegate Sub DLG_SrcInfo_all(ByVal Sender As Object, ByVal e As FSrcEventArgs)
Private Sub SUB_SrcInfo_all(ByVal Sender As Object, ByVal e As FSrcEventArgs)
If StopSearching = True Then
Return
End If
Select Case e.EventType
Case FSrcEventArgs.EventTypes.Dirs
RaiseEvent CurrentFolder(Sender, e)
Case FSrcEventArgs.EventTypes.Files
RaiseEvent NewFileList(Sender, e)
Case FSrcEventArgs.EventTypes.Informations
RaiseEvent CurrentEvent(Sender, e)
End Select
End Sub
#End Region
Function FindFiles(ByVal InFolder As String, Optional ByVal FileTypes As String = "*.*", Optional ByVal contains As String = "") As System.Collections.Generic.IEnumerable(Of String)
On Error GoTo Errr
If StopSearching Then
Return Nothing
End If
Dim la As ArrayList
If IsNothing(G_FileTypes) Then
G_FileTypes = FileTypes.Split(New [Char]() {","c})
End If
Dim lResult As New List(Of String)
Dim DG As New DLG_SrcInfo_all(AddressOf SUB_SrcInfo_all)
e.CopyArgs(InFolder, e.CurrentList, e.Completed, StopSearching, Me.Count, FolderCount, "Searching for files in '" & InFolder & "'", FSrcEventArgs.EventTypes.Informations, False)
On Error Resume Next
Me.Parent.Invoke(DG, Me, e)
On Error GoTo Errr
lResult.AddRange(My.Computer.FileSystem.FindInFiles(InFolder, _
contains, False, FileIO.SearchOption.SearchTopLevelOnly, _
G_FileTypes))
If lResult.Count > 0 Then
e.CurrentList = lResult
e.CopyArgs(InFolder, lResult, e.Completed, StopSearching, Me.Count, FolderCount, "Search Completed at folder '" & InFolder & "'", FSrcEventArgs.EventTypes.Files, False)
On Error Resume Next
Me.Parent.Invoke(DG, Me, e)
On Error GoTo Errr
End If
If IsNothing(AddOnObj) Then
Else
AddOnObj.AddRange(lResult.ToArray)
End If
Return lResult
Errr:
Return Nothing
End Function
Public Sub New()
End Sub
Public Sub New(ByVal Parent As System.Windows.Forms.Control)
Me.Parent = Parent
End Sub
End Class
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++****************
I’ll be pleased if you give me any bugs report & fix that.
Here is a sample form to call that.(bugs report are not needed for below code because I know that. Its a testing.)
Public Class Form1
Dim WithEvents FF As New System_Tools.Task_Explorer
Dim WithEvents CC As System_Tools.HOOK_
Dim di As New System_Tools.HOOK_
Dim WithEvents FS As System_Tools.FileSearch
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BackgroundWorker1.RunWorkerAsync(Me.ComboBox1.Text)
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
FS = New System_Tools.FileSearch(Me)
Dim xx As List(Of String)
FS.GetAllFiles(e.Argument.ToString)
End Sub
Private Sub FS_CurrentEvent(ByVal Sender As Object, ByVal e As System_Tools.FileSearch.FSrcEventArgs) Handles FS.CurrentEvent
Dim xx
Me.Text = e.Info
If e.Completed Then
Beep()
xx = EvList
xx = RefList
Me.Text = e.Info & " " & Sender.count
End If
End Sub
Private Sub FS_CurrentFolder(ByVal Sender As Object, ByVal e As System_Tools.FileSearch.FSrcEventArgs) Handles FS.CurrentFolder
Dim xx
Me.Text = e.Info
If e.Completed Then
Beep()
xx = EvList
xx = RefList
End If
End Sub
Private Sub FS_NewFileList(ByVal Sender As Object, ByVal e As System_Tools.FileSearch.FSrcEventArgs) Handles FS.NewFileList
EvList.AddRange(e.CurrentList)
Dim xx
Me.Text = e.Info
If e.Completed Then
Beep()
xx = EvList
xx = RefList
End If
TextBox1.Text = Join(e.CurrentList.ToArray, vbNewLine)
End Sub
Dim EvList, RefList As New List(Of String)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("C:\")
ComboBox1.Items.Add("d:\")
ComboBox1.Items.Add("e:\")
ComboBox1.Items.Add("f:\")
ComboBox1.Items.Add("g:\")
ComboBox1.Items.Add("h:\")
ComboBox1.Items.Add("i:\")
ComboBox1.Items.Add("j:\")
ComboBox1.Items.Add("k:\")
ComboBox1.Text = "C:\"
Debug.WriteLine("Leaving ExpTree ShDragDrop")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xx
CC.autocheck1time()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim xx
End Sub
Private Sub FF_Task_Explorer_Terminated() Handles FF.Task_Explorer_Terminated
FF.Dispose()
End Sub
Private Sub CC_
Dim addrem As String = ""
If e.
addrem = "Added: " & e.DriveInfo.Name & "-" & e.DriveInfo.VolumeLabel & vbNewLine
ElseIf e.
addrem = "Removed: " & e.DriveInfo.Name & vbNewLine
End If
Me.Text = e.
TextBox1.AppendText(addrem)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Text = System_Tools.FileAccess.FileLenStr("H:\PLangs.iso")
End Sub
End Class
Oh, I forgot to say that sample form could raise errors because some classes are not given. Just remove which raise error.
______________
Aslam Iqbal
|
|
|
|
|
Hi,
I am Using Slider control. I want Small changes value set in floating point. It is possible? I have move to slider control on 0.1, 0.2, 0.3..... to 1.
Pls help any idea? or url pls
Regards,
M.Mathivanan
|
|
|
|
|
This[^] CP Archive item may help.
But your question is somewhat ambiguous.
You want an actual value changed?
Or you want the figures shown to change?
Unclear, please post the code you have so far.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
I think one of the change properties will do what you need; see here[^] for more information.
I must get a clever new signature for 2011.
|
|
|
|
|