Results 1 to 4 of 4

Thread: Find ActiveX

  1. #1

    Thread Starter
    Addicted Member Rohan_Powle's Avatar
    Join Date
    Mar 2000
    Location
    Mumbai,maharashtra.India
    Posts
    173

    Post Find ActiveX

    I am making a find active x control. for connecting to the database I want to make 3 Properties

    1.ConnectionString
    2.Table
    3.DisplayField

    but due to I am unaware abt below mentioned thing I am not able to carry on.. pls help out.

    1.How to get ellipses while defining a ConnectionString property and then UDL Box? How to retrive the connection string from the UDL?
    2.How to get the list of Tables from a particular Database in a List Box?

    Any more suggestions will be appreciated
    "Trouble Gives Experience & Experience Gives Wisdom."
    (accept troubles as they come to become more wise in life)
    - Regards Rohan

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    You can't directly get the ellipse button to come up for a custom property, dunno why!

    You can specify a special colour or font return type for a property & vb will create a specific entry with an ellipse button in the properties window, but I looked for ages too trying to find how to create this yourself & the final answer I came to was that it can't be done!

    However.... You could create a property page & have the user to press a button to create & show the udl option screen...

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Wow, okay that was quite hard & took a lot of code, but this'll sort the udl issue.

    VB Code:
    1. [size="1"]Private Declare Function ShellExecute Lib "shell32.dll" Alias _
    2. "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    3. ByVal lpFile As String, ByVal lpParameters As String, _
    4. ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    5.  
    6. Private Const SW_SHOWNORMAL = 1
    7.  
    8. Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
    9. (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, _
    10. ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, _
    11. ByVal dwCreationDisposition As Long, _
    12. ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
    13.  
    14. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    15. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    16.  
    17. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    18.  
    19. Private strUDLFile As String
    20.  
    21. Private Sub Command1_Click()
    22.  
    23.     Dim blnUDLFileOpen As Boolean
    24.     Dim strReturnedConnStr As String
    25.  
    26.     strUDLFile = "C:\tempudlfile.udl"
    27.     blnUDLFileOpen = True
    28.  
    29.     ' The open statement creates a file if it doesn't exist. Other than
    30.     ' this, you could use the CreateFile API call to create the UDL file.
    31.     Open strUDLFile For Output As #1
    32.     Close #1
    33.    
    34.     ' Put a temporary pause in here giving the file a chance to close
    35.     ' properly before attempting the next line.
    36.     Sleep 600
    37.    
    38.     ' Use the shellexecute api call to open the file up. You might want to
    39.     ' look at the SetWindowPos api call to keep this the topmost window also
    40.     ShellExecute Me.hwnd, vbNullString, strUDLFile, _
    41.     vbNullString, "C:\", SW_SHOWNORMAL
    42.  
    43.     ' Temporarily pause excecution of this code until the user has setup the
    44.     ' connection string & closed the udl options file. The findwindow Api call
    45.     ' looks for an open instance of the udl file window.
    46.     Do While blnUDLFileOpen = True
    47.         DoEvents
    48.    
    49.         blnUDLFileOpen = CBool(FindWindow(vbNullString, _
    50.         "Data Link Properties") <> 0)
    51.     Loop
    52.    
    53.     ' Rename the udl file to a text file, I noticed that this fails if a text
    54.     ' with this path & name exists, so I've put a check in to delete this first.
    55.     If (Len(CStr(Dir("C:\tempconnstr.txt"))) > 0) Then
    56.         Kill "C:\tempconnstr.txt"
    57.         Sleep 600
    58.     End If
    59.    
    60.     Name strUDLFile As "C:\tempconnstr.txt"
    61.    
    62.     ' Open the file again, this time reading the last line (i.e. the line
    63.     ' with the connection string in), into a string variable.
    64.     Open "C:\tempconnstr.txt" For Input As #1
    65.         Do Until EOF(1)
    66.             Line Input #1, strReturnedConnStr
    67.         Loop
    68.     Close #1
    69.    
    70. End Sub[/size]

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    For the last bit you could just search the forums as this is bound to be asked before...

    http://www.vbforums.com/showthread.p...se+and+listbox

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

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