Solved

Move ListBox into RTF, 1 line under.

Posted on 1998-11-02
2
164 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
Comment Utility
Have you considered using the right-click context menu?
0
 
LVL 2

Accepted Solution

by:
Poddy earned 200 total points
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now