CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2000
    Location
    CA, USA
    Posts
    88

    MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )

    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


  2. #2
    Join Date
    Mar 2001
    Posts
    91

    Re: MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )

    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


  3. #3
    Join Date
    Jul 2000
    Location
    CA, USA
    Posts
    88

    Re: MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )

    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


  4. #4
    Join Date
    Mar 2001
    Posts
    91

    Re: MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )

    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


  5. #5
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )

    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

  6. #6
    Join Date
    Jul 2000
    Location
    CA, USA
    Posts
    88

    Re: MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )

    Very cool, works just like a charm.... thanks


  7. #7
    Join Date
    Jul 2000
    Location
    CA, USA
    Posts
    88

    Re: MSHFlexGrid and PictureBox ( two questions: Alignment and Cursor type )

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured