Click to See Complete Forum and Search --> : MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )


mrhicks
March 5th, 2001, 01:28 PM
Hello all,

I am using a MSHFlexGrid to display some data after performing a serach. The problem is that I can not change the alignment for the cells within this grid. Is there a way to do this? Sometimes the text within the cells appear to be Left aligned while others appear to be Right aligned. Is there a way to force either one?

The second question is that I have a PictureBox which I would like to change the cursor while over the PictureBox. I use the MouseMove event to change the cursor while it is within the PictureBox, but I run into problems when the cursor leaves the PictureBox. There is not event that I know of that tells me that is left the PictureBox. I have tried to use the LostFocus, but that doesn't work. I would subclass the PictureBox and maybe intercept a message, but I am already subclassing the Main form so i don't know if subclassing an additional Control would be a good idea or not. Any thoughts or ideas?

Mark

Srikanth_hlp
March 5th, 2001, 03:03 PM
try displaying the values of the current cell in a text box over the current cell. (ie) explicitly move the values to text box , change the left , right , alignment , zorder properties of text box in such a way that it occupies the current cell of the MSHFlexGrid and hide it when the cursor leaves that cell.

- Srikanth

mrhicks
March 5th, 2001, 03:58 PM
I follow you to a certain degree, are you saying that I have a text box for each cell in the grid? Right now I have 10 columns with up to 100 rows so that would be a lot of text boxes?! The end user doesn't directly edit the cells either, they are present data after they enter specific search criteria.

Mark

Srikanth_hlp
March 5th, 2001, 04:03 PM
Ay,
Its not that u need n*n textboxes for n columns and for n rows. I said to use 1 (one) textbox whose left , right , alignment , zorder property has to be changed whenever the focus goes into the cell substituting that cell.

- Srikanth

John G Duffy
March 5th, 2001, 06:28 PM
Your Mouse_Over _Not Over problem can be solved using the SetCapture API. Below is a working sample.
Start a new project, Add a command button. Paste this code into the General declarations section. Run the program. Move the mouse over then not over the command button

option Explicit

private Declare Function SetCapture Lib "user32" (byval hwnd as Long) as Long
private Declare Function ReleaseCapture Lib "user32" () as Long


'Code:
'Put this code in MouseMove event. In this example, I put a
'CommandButton on a
'form with the name Command1

private Sub Command1_MouseMove(Button as Integer, Shift as Integer, X _
as Single, Y as Single)
static CtrMov as Boolean
static Counter as Long
Counter = Counter + 1
With Command1 'Change this 'Command1' to your control name
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) then
ReleaseCapture
CtrMov = false
Command1.BackColor = &HFF&
Command1.Caption = " Not Over " & Counter
Command1.Refresh
'Put here your code to LostMouseFocus
'for example:
me.print "LostMouseFocus"

else
SetCapture .hwnd
If CtrMov = false then ' do this only once per "over"
CtrMov = true
Command1.BackColor = &HFFFFFF
Command1.Caption = " Over " & Counter
Command1.Refresh
'Put here your code to GetMouseFocus
'for example:
me.print "GetMouseFocus"

End If
End If
End With
End Sub




John G

mrhicks
March 5th, 2001, 07:07 PM
Very cool, works just like a charm.... thanks

mrhicks
March 5th, 2001, 09:08 PM
Hello again,

I was searching the KB for alignment and MSHFlexGrid and found that they do have a way to align the cells. The FormatString is the ticket to solve this, though I don't like the way it is implemented though. I would rather use use some sort of constant other than using "< ^ and >" for this.

Mark