Results 1 to 3 of 3

Thread: VB IDE like interface [PARTLY RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Resolved VB IDE like interface [PARTLY RESOLVED]

    Hi, how would I go about creating a VB-like IDE, with a combobox popping up displaying possible code?

    I know how to get the caret position in the box, but I need to know the X and Y coordinates so I can give the combobox its correct position. Can anybody help me with this?
    Attached Images Attached Images  
    Last edited by TheVader; Sep 22nd, 2004 at 01:04 PM.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here is an example from allapi.net
    VB Code:
    1. Private Type POINTAPI
    2.     X As Long
    3.     Y As Long
    4. End Type
    5. Private Type RECT
    6.     Left As Long
    7.     Top As Long
    8.     Right As Long
    9.     Bottom As Long
    10. End Type
    11. Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    12. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    13. Private Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal wOptions As Long, ByVal lpRect As Any, ByVal lpString As String, ByVal nCount As Long, lpDx As Long) As Long
    14. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    15. Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As POINTAPI) As Long
    16. Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    17. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    18.     'KPD-Team 1998
    19.     'URL: [url]http://www.allapi.net/[/url]
    20.     'E-Mail: [email][email protected][/email]
    21.     Dim Pt As POINTAPI, mWnd As Long, WR As RECT, nDC As Long
    22.     Dim TextSize As POINTAPI, CX As Long, CY As Long
    23.     'Get the current cursor position
    24.     GetCursorPos Pt
    25.     'Get the window under the cursor
    26.     mWnd = WindowFromPoint(Pt.X, Pt.Y)
    27.     'Get the window's position
    28.     GetWindowRect mWnd, WR
    29.     'Get the window'zs device context
    30.     nDC = GetWindowDC(mWnd)
    31.     'Get the height and width of our text
    32.     GetTextExtentPoint32 nDC, "Hello !", Len("Hello !"), TextSize
    33.     For CX = 1 To WR.Right - WR.Left Step TextSize.X
    34.         For CY = 1 To WR.Bottom - WR.Top Step TextSize.Y
    35.             'Draw the text on the window
    36.             ExtTextOut nDC, CX, CY, 0, ByVal 0&, "Hello !", Len("Hello !"), ByVal 0&
    37.         Next
    38.     Next
    39. End Sub
    40. Private Sub Form_Paint()
    41.     Me.CurrentX = 0
    42.     Me.CurrentY = 0
    43.     Me.Print "Click on this form," + vbCrLf + "Hold the mouse button," + vbCrLf + "drag the mouse over another window," + vbCrLf + "release the mouse button" + vbCrLf + "and see what happens!"
    44. 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

  3. #3

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Thanks for the reply. I couldn't really get that GetTextExtentPoint32 code to work properly. It doesn't seem to return usable values, though (the X value increases just by one with every character). However, by setting the ScaleMode of the form to Character, I can simply use the Len method to measure the length. It's not an ideal solution since it only supports 'standard' fonts (Courier New, 10pt), but for now it works.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

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