Any one plz tell me Can I fit my own dialog box in to frame or picture box of another VB form?or any other feasible way?Thanking you!
Can I fit my own dialog box in to frame?
Collapse
X
-
Need more info to understand the problem
Can you please elaborate on your specific requirements? -
Originally posted by mailforanuCan you please elaborate on your specific requirements?
Actually I want to build inbuilt Browse control which can browse My Network Places.inbuilt means it should not open separate dialog box.Just something like FileListBox in VB.Now my problem is that,I am not getting any thing like this,but I wrote code to browse in separate dialogbox.I am posting it as bellow.So I want to put the dialogbox on form may be in frame or picturebox.So that it should look like FileListBox.Tha nking you!
In module:
Option Explicit
'API Declares
Private Declare Function SendMessage Lib "USER32" Alias "SendMessag eA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SHBrowseForFold er Lib "shell32.dl l" Alias "SHBrowseForFol derA" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromID List Lib "shell32.dl l" Alias "SHGetPathFromI DListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
'API Constants
Private Const MAX_PATH = 260
Private Const BIF_RETURNONLYF SDIRS = 1
Private Const BIF_STATUSTEXT = 4
Private Const WM_USER = &H400
Private Const BFFM_INITIALIZE D = 1
Private Const BFFM_SELCHANGED = 2
Private Const BFFM_SETSTATUST EXTA = (WM_USER + 100)
Private Const BFFM_SETSELECTI ONA = (WM_USER + 102)
'BrowseInfo Type
Private Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
'Private Variables
Private m_sDefaultFolde r As String
'Displays the Windows 95 BrowseForFolder dialog box
Public Function BrowseForFolder (DefaultFolder As String, Optional Parent As Long = 0, Optional Caption As String = "") As String
Dim bi As BrowseInfo
Dim sResult As String, nResult As Long
bi.hwndOwner = Parent
bi.pIDLRoot = 0
bi.pszDisplayNa me = String$(MAX_PAT H, Chr$(0))
If Len(Caption) > 0 Then
bi.lpszTitle = Caption
End If
bi.ulFlags = BIF_RETURNONLYF SDIRS 'Or BIF_STATUSTEXT
bi.lpfn = GetAddress(Addr essOf BrowseCallbackP roc)
bi.lParam = 0
bi.iImage = 0
'Call API
nResult = SHBrowseForFold er(bi)
'Get result if successful
If nResult <> 0 Then
sResult = String(MAX_PATH , 0)
If SHGetPathFromID List(nResult, sResult) Then
BrowseForFolder = Left$(sResult, InStr(sResult, Chr$(0)) - 1)
End If
'Free memory allocated by SHBrowseForFold er
'' CoTaskMemFree nResult
End If
End Function
'CAUTION: This function is called by the system to intialize the SHBrowseForFold er
'dialog box. Attempting to set breakpoints or adding other debugging code to this
'routine may cause unexpected problems.
Private Function BrowseCallbackP roc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal lParam As Long, ByVal lpData As Long) As Long
Select Case uMsg
Case BFFM_INITIALIZE D
'Note: This code was crashing VB when the default folder was empty
If Len(m_sDefaultF older) > 0 Then
'Set default folder when dialog has initialized
SendMessage hwnd, BFFM_SETSELECTI ONA, True, ByVal m_sDefaultFolde r
End If
End Select
End Function
'Return the argument to workaround limitations of AddressOf operator
Private Function GetAddress(nAdd ress As Long) As Long
GetAddress = nAddress
End Function
in form:
Option Explicit
Private Sub cmdBrowse_Click ()
txtDirectory = BrowseForFolder (txtDirectory, Me.hwnd, "&Select a directory:")
End Sub
Private Sub cmdClose_Click( )
Unload Me
End SubComment
Comment