Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Forms sample source codes
Creating a textbox which displays different MRU lists (like IE address bar)
Creating a textbox which displays different MRU lists (like IE address bar) The following code makes a textbox auto complete and shows a drop down which displays a specified MRU list (i.e. like the IE "Address bar"). Option Explicit Private Declare Function SHAutoComplete Lib "Shlwapi.dll" (ByVal hWndEdit As Long, ByVal dwFlags As Long) As Long Public Enum SHAC_Constants SHACF_AUTOAPPEND_FORCE_OFF = &H80000000 'Ignore the registry default and force the autoappend feature off. This flag must be used in combination with one or more of the SHACF_FILESYSXXX or SHACF_URLXXX flags. SHACF_AUTOAPPEND_FORCE_ON = &H40000000 'Ignore the registry value and force the autoappend feature on. The completed string will be displayed in the edit box with the added characters highlighted. This flag must be used in combination with one or more of the SHACF_FILESYSXXX or SHACF_URLXXX flags. SHACF_AUTOSUGGEST_FORCE_OFF = &H20000000 'Ignore the registry default and force the autosuggest feature off. This flag must be used in combination with one or more of the SHACF_FILESYSXXX or SHACF_URLXXX flags. SHACF_AUTOSUGGEST_FORCE_ON = &H10000000 'Ignore the registry value and force the autosuggest feature on. A selection of possible completed strings will be displayed as a dropdown list, below the edit box. This flag must be used in combination with one or more of the SHACF_FILESYSXXX or SHACF_URLXXX flags. SHACF_DEFAULT = &H0 'The default setting, equivalent to SHACF_FILESYSTEM | SHACF_URLALL. SHACF_DEFAULT cannot be combined with any other flags. SHACF_FILESYSTEM = &H1 'Include the file system. SHACF_URLALL = (&H2 Or &H4) 'Include the URLs in the users History and Recently Used lists. Equivalent to SHACF_URLHISTORY | SHACF_URLMRU. SHACF_URLHISTORY = &H2 'Include the URLs in the user's History list. SHACF_URLMRU = &H4 'Include the URLs in the user's Recently Used list. End Enum 'Purpose : Makes a textbox display an MRU (most recently used) list (behaves like ' the "Address" combo in internet explorer). 'Inputs : txtMRU The textbox to make an MRU textbox. ' [eMRUType] The type of the MRU list to display i.e. MRU files, MRU internet addresses etc. 'Outputs : Returns True in success 'Notes : Public Function TextBoxToMRUBox(txtMRU As TextBox, Optional eMRUType As SHAC_Constants = SHACF_URLALL) As Boolean On Error GoTo ErrHandler Const S_OK = 0 If S_OK = SHAutoComplete(txtMRU.hWnd, eMRUType) Then TextBoxToMRUBox = True End If Exit Function ErrHandler: Debug.Print "Error in TextBoxToMRUBox: " & Err.Description TextBoxToMRUBox = False End Function 'Demonstration routine Private Sub Form_Load() TextBoxToMRUBox Me.Text1 End Sub
Privacy Policy
|
Link to Us
|
Links