• Marc
  • Member Topic Starter
Hi Igor

May I ask two things about hTooltip?

  1. What is best practice if I'd like to show a hTooltip for every control on a MS Access form (of course with different title and text)? Do I have to create separate hTooltips for each control? Or can I assign a tooltip dynamically?
  2. I tried to create a tooltip with "CreateForVBCtrl" command; unfortunately this command seems to fail, perhaps due to some specific behaviour of Access. (see attachement)

Although I was able to create tooltips using "CreateForRect" command, this would force me to recreate tooltips whenever I resize the form, i.e. whenever a control with tooltip resizes or has another position on the form, else the "rect" parameters won't match anymore and the tooltip won't appear near the respective control.

Thanks very much for a feedback.

File Attachment(s): (95kb) downloaded 143 time(s).
Let's start from the 2nd question. As the name implies, CreateForVBCtrl is a method which helps to create tooltips for the so-called "classic" Visual Basic control (VB5/6). In fact, it automates the work you can do with other Create* methods like CreateForRect based on the internal VB form/controls infrastructure. It's not applicable for MS Access forms infrastructure, and I changed the status of the topic from "bug" to "question" because of this.

As for the 1st part, the best way to create tooltips for the built-in MS Access form controls is to define them with the CreateForRect method but use the HWND of the whole form and specify the coordinates of the control you create the tooltip for. As an example, here is real code used to create one tooltip for an Access text box and another tooltip for a button:

Dim objTT1 As New CTooltip
Dim objTT2 As New CTooltip

Private Sub Form_Load()
   DefaultTooltip.Style = httStyleBalloon
   DefaultTooltip.Title = "hTooltip"
   DefaultTooltip.Icon = httIconInfo

   objTT1.Text = "Sample tooltip for button"
   objTT1.CreateForRect Me.Hwnd, Command0.Left, Command0.Top, Command0.Width, Command0.Height

   objTT2.Text = "Sample tooltip for edit box"
   objTT2.CreateForRect Me.Hwnd, Text1.Left, Text1.Top, Text1.Width, Text1.Height
End Sub

Don't ask us why we should do so - this is a question for the MS Access developers 🙂. They use a very specific form package which is "enough far" from the native Windows form/controls ideology our hTooltip is a friendly wrapper for. Thank God that they use the same measurement units for control coordinates, i.e. twips, hTooltip expects to see (just FYI: you can change this to pixels using the ScaleMode property).

So, as you can see, every CTooltip object is used to create a tooltip for one dedicated rectangular area on a form. If you need say 5 tooltips for 5 different controls/areas, you need to create 5 different CTooltip objects personally for each area.