Results 1 to 2 of 2

Thread: Combo Box Inside Textbox

  1. #1

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193

    Combo Box Inside Textbox

    Does anyone know how to put a combo box into a text box like
    how VB has when u press ctl + space i also want it to appear
    where the cursor is (like vb)

    is it possible in VB 6 ?

    thanks for help all

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Try the SetParent API.
    Here is an example from allapi.net
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
    4. Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
    5. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    6. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    7. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    8. Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
    9. Private Declare Function GetDesktopWindow Lib "user32" () As Long
    10. Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    11. Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
    12. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
    13. Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
    14. Const GW_HWNDNEXT = 2
    15. Dim mWnd As Long
    16. Function InstanceToWnd(ByVal target_pid As Long) As Long
    17.     Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
    18.     'Find the first window
    19.     test_hwnd = FindWindow(ByVal 0&, ByVal 0& )
    20.     Do While test_hwnd <> 0
    21.         'Check if the window isn't a child
    22.         If GetParent(test_hwnd) = 0 Then
    23.             'Get the window's thread
    24.             test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
    25.             If test_pid = target_pid Then
    26.                 InstanceToWnd = test_hwnd
    27.                 Exit Do
    28.             End If
    29.         End If
    30.         'retrieve the next window
    31.         test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    32.     Loop
    33. End Function
    34. Private Sub Form_Load()
    35.     'KPD-Team 1999
    36.     'URL: [url]http://www.allapi.net/[/url]
    37.     'E-Mail: [email][email protected][/email]
    38.     Dim Pid As Long
    39.     'Lock the window update
    40.     LockWindowUpdate GetDesktopWindow
    41.     'Execute notepad.Exe
    42.     Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
    43.     If Pid = 0 Then MsgBox "Error starting the app"
    44.     'retrieve the handle of the window
    45.     mWnd = InstanceToWnd(Pid)
    46.     'Set the notepad's parent
    47.     SetParent mWnd, Me.hwnd
    48.     'Put the focus on notepad
    49.     Putfocus mWnd
    50.     'Unlock windowupdate
    51.     LockWindowUpdate False
    52. End Sub
    53. Private Sub Form_Unload(Cancel As Integer)
    54.     'Unload notepad
    55.     DestroyWindow mWnd
    56.     'End this program
    57.     TerminateProcess GetCurrentProcess, 0
    58. End Sub
    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