Results 1 to 5 of 5

Thread: How to Repaint client area of a MDI form ? [Resolved]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Question How to Repaint client area of a MDI form ? [Resolved]

    I'm making a multithreaded client server program, and on the server side I have a MDI form where I want to draw on the client area of the form the connection status of all clients.

    I added a picture box in the MDI, with the Visible = False, I paint on the picturebox what I need, then I set the picture's Image to the MDI form Picture (see code).

    The problem is that after I do that, there is no method for MDI do refresh the form !

    I'm using the following code:
    VB Code:
    1. Private Sub CConnection_StateChanged(Index As Integer, ByVal NewSckState As Integer)
    2.     Dim TmpStr As String, K As Long, TextHeight As Single
    3.    
    4.     Debug.Print "CConnection_StateChanged: " & Index, NewSckState
    5.    
    6.     picDrawClientState.Cls
    7.     picDrawClientState.AutoRedraw = True
    8.    
    9.     For K = 0 To CConnection.UBound
    10.         With picDrawClientState
    11.             .CurrentX = 25
    12.             .CurrentY = K * TextHeight + 50
    13.            
    14.             picDrawClientState.Print K
    15.             If K = 0 Then TextHeight = .CurrentY - 50
    16.            
    17.             .CurrentX = 500
    18.             .CurrentY = K * TextHeight + 50
    19.            
    20.             TmpStr = Choose(CConnection(K).ClientState + 1, _
    21.                            "Closed", "Open", "Listening", "Connection pending", _
    22.                            "Resolving host", "Host resolved", "Connecting", _
    23.                            "Connected", "Disconnecting", "Error")
    24.             picDrawClientState.Print TmpStr
    25.            
    26.             picDrawClientState.Line (0, .CurrentY)-(5000, .CurrentY)
    27.         End With
    28.     Next K
    29.    
    30.     picDrawClientState.Line (450, 0)-(450, 10000)
    31.     Set frmMain.Picture = picDrawClientState.Image
    32.    
    33.     ' HAVE TO REDRAW THE MDI HERE !!!
    34. End Sub

    Thanks in advance...
    Last edited by CVMichael; Apr 21st, 2005 at 10:24 AM. Reason: Resolved

  2. #2

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: How to Repaint client area of a MDI form ?

    Thanks, it is quite simple...
    This is all I needed (from the MdiBack class):
    VB Code:
    1. Const swpFlags As Long = _
    2.       SWP_FRAMECHANGED Or SWP_NOMOVE Or _
    3.       SWP_NOZORDER Or SWP_NOSIZE
    4.  
    5. Call SetWindowPos(Me.hWnd, 0, 0, 0, 0, 0, swpFlags)

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: How to Repaint client area of a MDI form ? [Resolved]

    I'd try these as another couple of methods:
    Code:
    Public Const RDW_UPDATENOW                  As Long = &H100
    
    Public Declare Function RedrawWindow Lib "user32" _
        (ByVal hWnd As Long, _
         ByRef lprcUpdate As Any, _
         ByVal hrgnUpdate As Long, _
         ByVal fuRedraw As Long) _
    As Long
    
    Public Declare Function UpdateWindow Lib "user32" _
        (ByVal hWnd As Long) _
    As Boolean
    Call them like this
    VB Code:
    1. RedrawWindow Me.hWnd, ByVal 0&, 0, RDW_UPDATENOW
    2. ' or
    3. UpdateWindow Me.hWnd
    Both should have the same effect.

  5. #5

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