Results 1 to 4 of 4

Thread: HAHA better NOT change it!

  1. #1

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    HAHA better NOT change it!

    Open / Save file dialog BOX.

    Is there a way to NOT allow users to change the text that I store in the save text box of the dialog box pop up that the API uses. Meaning I pop this file save dialog box and through my application it assigns the name for this file...but it also allows users to modify it. Is there a way to lock this field??

    Jon

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Just hard code the filename you want.
    Then grab the file path they selected and
    change the filename they entered and replace it with
    the hardcoded filename! HA.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Try using a "Folder" Dialog as opposed to a "File" dialog, i.e.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type BROWSEINFO
    4.     hwndOwner As Long
    5.     pIDLRoot As Long
    6.     pszDisplayName As Long
    7.     lpszTitle As Long
    8.     ulFlags As Long
    9.     lpfnCallback As Long
    10.     lParam As Long
    11.     iImage As Long
    12. End Type
    13.  
    14. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    15. Private Declare Function lStrCat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    16. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BROWSEINFO) As Long
    17. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    18.  
    19. Private Const BIF_RETURNONLYFSDIRS = 1
    20.  
    21. Public Function BrowseForFolder(ByVal lHwnd As Long, ByVal sPrompt As String) As String
    22.     Dim tBI As BROWSEINFO
    23.     Dim lList As Long
    24.     Dim lResult As Long
    25.     Dim sPath As String
    26.     Dim sString As String
    27.    
    28.     sString = Space(260)
    29.     With tBI
    30.         .hwndOwner = lHwnd
    31.         .lpszTitle = lStrCat(sPrompt, Chr(0))
    32.         .pszDisplayName = StrPtr(sString)
    33.         .ulFlags = BIF_RETURNONLYFSDIRS
    34.     End With
    35.     lList = SHBrowseForFolder(tBI)
    36.     sString = StrConv(sString, vbUnicode)
    37.     If lList Then
    38.         sPath = Space(260)
    39.         lResult = SHGetPathFromIDList(lList, sPath)
    40.         Call CoTaskMemFree(lList)
    41.         sPath = Left$(sPath, InStr(sPath, Chr(0)) - 1)
    42.     End If
    43.     BrowseForFolder = sPath
    44. End Function
    Example Usage:
    VB Code:
    1. sFolder = BrowseForFolder(hWnd, "Select Destination:")

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Much better way. I forgot about the folder browse.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width