|
-
Apr 20th, 2005, 05:48 PM
#1
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:
Private Sub CConnection_StateChanged(Index As Integer, ByVal NewSckState As Integer)
Dim TmpStr As String, K As Long, TextHeight As Single
Debug.Print "CConnection_StateChanged: " & Index, NewSckState
picDrawClientState.Cls
picDrawClientState.AutoRedraw = True
For K = 0 To CConnection.UBound
With picDrawClientState
.CurrentX = 25
.CurrentY = K * TextHeight + 50
picDrawClientState.Print K
If K = 0 Then TextHeight = .CurrentY - 50
.CurrentX = 500
.CurrentY = K * TextHeight + 50
TmpStr = Choose(CConnection(K).ClientState + 1, _
"Closed", "Open", "Listening", "Connection pending", _
"Resolving host", "Host resolved", "Connecting", _
"Connected", "Disconnecting", "Error")
picDrawClientState.Print TmpStr
picDrawClientState.Line (0, .CurrentY)-(5000, .CurrentY)
End With
Next K
picDrawClientState.Line (450, 0)-(450, 10000)
Set frmMain.Picture = picDrawClientState.Image
' HAVE TO REDRAW THE MDI HERE !!!
End Sub
Thanks in advance...
Last edited by CVMichael; Apr 21st, 2005 at 10:24 AM.
Reason: Resolved
-
Apr 20th, 2005, 07:33 PM
#2
Re: How to Repaint client area of a MDI form ?
I would recommend to visit Karl E. Peterson's site and download his nicely wrapped (in the class) MdiBack sample project.
-
Apr 21st, 2005, 10:23 AM
#3
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:
Const swpFlags As Long = _
SWP_FRAMECHANGED Or SWP_NOMOVE Or _
SWP_NOZORDER Or SWP_NOSIZE
Call SetWindowPos(Me.hWnd, 0, 0, 0, 0, 0, swpFlags)
-
Apr 21st, 2005, 10:29 AM
#4
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:
RedrawWindow Me.hWnd, ByVal 0&, 0, RDW_UPDATENOW
' or
UpdateWindow Me.hWnd
Both should have the same effect.
-
Apr 21st, 2005, 10:30 AM
#5
Re: How to Repaint client area of a MDI form ?
 Originally Posted by CVMichael
Thanks, it is quite simple...
... once we know what to use ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|