Solved

Move ListBox into RTF, 1 line under.

Posted on 1998-11-02
2
170 Views
Last Modified: 2010-04-30
Fellow VB Programmers,

I am using the RichTextBox control and would like to know
how to move the a ListBox underneath the current line,
like in VB when you dim a value as, a ComboBox or ListBox appears.

For the sake of this question,
Please insert the RTF Control and a ListBox onto a form.
Let the Listbox.Visisble = False and insert the Following code
into your sample...

Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)

Select Case Chr$(KeyAscii)
case "!"
      List1.Visible = True
      ' And the Code to move it here...
case else
end select
end sub

When you press the ! key, it will show you the ListBox.

Now, in order to properly answer this Question,
have the ListBox popup right underneath your current position
in the RichTextBox control. Left & Top.

Thank you.
0
Comment
Question by:s_mccolgan
  • 2
2 Comments
 
LVL 2

Expert Comment

by:Poddy
ID: 1442796
Have you considered using the right-click context menu?
0
 
LVL 2

Accepted Solution

by:
Poddy earned 200 total points
ID: 1442797
Private Type POINTAPI
        x As Long
        y As Long
End Type

Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long

  Dim ptX As POINTAPI
  Dim lngRet As Long  
    If KeyAscii = 33 Then
      List1.Visible = True
      lngRet = GetCaretPos(ptX)
      List1.Top = Screen.TwipsPerPixelY * ptX.y + RichTextBox1.Top
      List1.Left = Screen.TwipsPerPixelX * ptX.x + RichTextBox1.Left
    end if
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question