Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ctooltip class tooltip baLloon in msflexgrid 2

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
425
IT
If the cursor is on row 1 and col 9 the baloon appear...
But if i move the cursor on row 1 col 10 the new value dont change!!!!

note:
i need only if is present a picture in cell

Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)

With MSFlexGrid1
.Row = .MouseRow
.Col = .MouseCol
If .CellPicture <> 0 Then
If Not m_bInLable Then
m_bInLable = True
TT.Title = "TEST"
TT.TipText = "RIGA: " & .MouseRow & " COLONNA: " & .MouseCol
TT.Create Me.MSFlexGrid1.hwnd
End If
Else
m_bInLable = False
TT.Title = ""
TT.TipText = ""
TT.Destroy
End If
End With

End Sub
 
 https://files.engineering.com/getfile.aspx?folder=696a7535-6c96-42d9-8207-44739e378695&file=SCO.jpg
Wow....
Is a boolean variabile.
Can you modify the code?
Tks.
 
I'd anticipate, given the code you haver shown us, that you have declared m_bInLable as a global/public variable. Thus will be the underlying cause of the issue you are seeing as it means that m_bInLable retains its value between calls to MSFlexGrid1_MouseMove. Let's strip your code down to the bare minimum:

Code:
Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)

With MSFlexGrid1
	.Row = .MouseRow
	.Col = .MouseCol
	If .CellPicture <> 0 Then
		If Not m_bInLable Then
			m_bInLable = True
			[COLOR=green]' Set tooltip[/color]
		End If
	Else
		m_bInLable = False
                [COLOR=green]' Clear tooltip[/color]
	End If
End With

End Sub

So, look at what happens if you move immediately from one cell with a picture in it to another cell with a picture in it - nothing. Your logic flow is horribly wrong. I am sure, since you are a programmer, you can now correct that logic ...

(suffice it to say I probably wouldn't do it quite the way you are, and remove the requirement for m_bInLable completely)



 
Hi strong is this correct?:

Code:
Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)

With MSFlexGrid1
	.Row = .MouseRow
	.Col = .MouseCol
	If .CellPicture <> 0 Then
		If Not m_bInLable Then
			m_bInLable = True
			' Set tooltip
TT.Title = "TEST"
TT.TipText = "RIGA: " & .MouseRow & " COLONNA: " & .MouseCol
TT.Create .hwnd
		End If
	Else
		m_bInLable = False
                ' Clear tooltip
TT.Title = ""
TT.TipText = ""
TT.Destroy

	End If
End With

End Sub
 
No, you have misunderstood my post. My post was your code stripped down to the bare minimum to allow you to more easily spot where your logic error lies. It is not a solution.

Suffice it to say that "if i move the cursor on row 1 col 10 [from an adjacent cell that has a picture] the new value dont change!!!!" this is because that is exactly how you have coded it to work
 
Strongm,
I'm going crazy.
Please have a godd solution, please?
 
How about simply:

Code:
Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, _
X As Single, Y As Single)

[green]' Clear tooltip[/green]
TT.Title = ""
TT.TipText = ""
TT.Destroy

With MSFlexGrid1
    .Row = .MouseRow
    .Col = .MouseCol
    If .CellPicture <> 0 Then[green]
        ' Set tooltip[/green]
        TT.Title = "TEST"
        TT.TipText = "RIGA: " & .MouseRow & " COLONNA: " & .MouseCol
        TT.Create .hwnd
    End If
End With

End Sub

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I'll help by being more specific: if you are in a cell with a picture set, then moving to an adjacent cell with the picture set never gives any opportunity for [tt]m_bInLable[/tt] to be set to false (or, consequently, the tooltip to be cleared), as the [tt]Else[/tt] is not triggered. Since that is the case, the conditional [tt]If Not m_bInLable Then[/tt] always fails, and thus the tooltip is never set to the new value

Not trying to be difficult here, just trying to get you to help ypurself.
 
Andy, that works slightly differently. For some reason sal21 only wants the code that sets the tooltip triggered once for each cell, hence the attempted use of m_bInLable, whilst your code will trigger it for every movement within the cell. (I suspect that setting a tooltip is not all sal21 intends to do)
 
I see.
Easy fix - keep the last Row/Col and compare to the current/selected cell, and - if different - run the code for the ToolTip just once.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
friend suggestion...
tell me to use Static var (i never used! and i dont know the use)
see...

Private Sub MSFlexGrid1_MouseMove(Button As Integer, _
Shift As Integer, _
X As Single, Y As Single)

Static F As Long
Static C As Long

With MSFlexGrid1

If F <> .MouseRow Or C <> .MouseCol Then

If .TextMatrix(.MouseRow, .MouseCol) = "." Then

F = .MouseRow
C = .MouseCol

SCHIAVE = F & "-" & C & "-" & IDAZN & "-" & DXSX & "-" & GIORNO
TROVATO = DIC.Item(SCHIAVE)

TT.Title = "INFO"
TT.TipText = "FILA : " & F & " OMBRELLONE: " & C & " - NOME: " & TROVATO
TT.Create .hwnd

Else

TT.Title = ""
TT.TipText = ""
TT.Destroy

End If

End If

End With

End Sub
 
C loser, but still contains a logic flaw (if you go into a cell with a "." then into one without, and thence to one with ... no tooltip will show for that final cell. Why? essentially because of the same logic flaw as in your original version.

And adding static variables isn't the answer ...


This is how I'd do it (assuming I've managed to interpret your unstated requirements from your original post correctly), using built-in tooltips rather than a 3rd party control that I don't have.

Code:
[COLOR=blue]Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    With MSFlexGrid1
        If .Row <> .MouseRow Or .Col <> .MouseCol Then
            .Row = .MouseRow
            .Col = .MouseCol
    
            If .CellPicture <> 0 Then
                .ToolTipText = "RIGA: " & .Row & " COLONNA: " & .Col
            Else
                .ToolTipText = ""
            End If
    
        End If
    End With

End Sub[/color]
 
strongm said:
if you go into a cell with a "." then into one without, and thence to one with ... no tooltip will show for that final cell.

Of course not, because we do not know the requirements of when the tooltip should be triggered.

We have:[tt]
If .CellPicture <> 0 Then[/tt]
and later we have[tt]
If .TextMatrix(.MouseRow, .MouseCol) = "." Then[/tt] (single period in a cell)
so, I assume [tt]"..."[/tt] should never trigger tooltip, or should it?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
>we do not know the requirements of when the tooltip should be triggered

I beg to differ!

You just have to look at this in the context of sal21's various other posts on this subject of parasol availability.

It is reasonably clear from sal21's original post that they want something to happen each time they enter a cell that displays a picture of an parasol. In the OP this 'something' just happens to be tooltip simply showing the row and column which, from the Title for the tooltip, I'd imagine is just for testing purposes, to make sure the correct row and column are being captured. Which they are not. Sal21's later post shows that they are trying to build a key using the row and column to search a dictionary for an item.

Given this it is fair to say they need the their code to trigger for every cell in which there is a parasol, no matter how we got to it. And again, the second code example from sal21 does not achieve this (I'd suspect that the '.' was actually part of sal21's attempt to get this working the way they want by using a simple text check instead of the picture check).

It is worth pointing out now that the code I presented (albeit without the tooltips bit) was originally written back on 17th Feb as a possible solution to sal21's thread222-1813837, but they never answered my question in that thread, which was specifically aimed at teasing out the idea that they only wanted a single event when moving in a given cell.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top