Wrox Programmer Forums
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2005, 01:47 PM
Registered User
 
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to clowns119
Default GDI+ in 2 forms

I am having a strange problem that is driving me crazy. I am drawing rectangles to a picturebox in my main form based on values entered in text boxes in a second form. It is working however if I change teh values in form 2 the changes do not show up in form 1 until I minimize and maximize form 1 or until I click another application to move my app to the background then click my ap to make it active. I think the problom has to do with redrawing the screen on an event but I cannot find any documentation on it. Here is some of my code if it helps. Thanks in advance for any help

Code:
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
           me.Refresh()

           Dim MEF As bitmap= new Bitmap(MEFBOX.Width,MEFBOX.Height)

        Me.MEFBOX.Image=MEF

           'Defines your graphics holder
           Dim g As Graphics = Graphics.FromImage(MEF)

        'Defines your 4 line colors
        Dim fillcol As Color

             'assigns variables to the text boxes

           Dim WXTEXT As String="LGT RME ICG"

        'Defines array for the SZL row
        Dim x as integer
        Dim SZLBOXES(23) As rectangle

       'Set values for boxes
        Dim SZLNUMS(23) As Integer
        Dim Vals(23) As Integer

        'Defines cases for colors of your lines
           If szlwxval1=1 Then
               fillcol=color.Green
           ElseIf szlwxval1<5 Then
               fillcol=color.Yellow
        else fillcol=color.Red
        End If


       'Defines pens and brushes
           Dim NPN As pen=new Pen(color.Red,3)
        Dim BXBS As Solidbrush=new SolidBrush(fillcol)         
        Dim TXBS As Solidbrush=new SolidBrush(color.black)
           Dim fnt as Font = new Font("Times New Roman", 10)

           If SZLDLG.Visible=True Then 
            Me.ClientSize = New System.Drawing.Size(0, 0)
        Else Me.ClientSize = New System.Drawing.Size(800, 600)
           End If


       'Defines SZL rectangle sizes
           For x = box1val To box2val : szlboxes(x) = New Rectangle( (30*(x+1)), 10, 30, 20)  
           Next x

        'Draw boxes
       g.FillRectangles(bxbs,szlboxes)
       g.DrawString(WXTEXT,fnt,TXBS,x,10)

        'save drawing to picturebox
        MEFBOX.Image.Save("C:\MISSION TRACKING\MEF\TEST.BMP")
      End Sub

       Private Sub KSZLBUTClick(sender As System.Object, e As System.EventArgs)

        'Show SZL form
        Me.ref
        SZLDLg.Visible=true
             End Sub


and form2
Code:
    Private Sub SZLOKClick(sender As System.Object, e As System.EventArgs)

        Dim MFM as new MainForm()

        Dim SZLST1 As Integer
        Dim SZLST2 As Integer
        Dim SZLWeX1 as Integer

        SZLST1=Me.SZLS1.text
        SZLST2=Me.SZLE1.text
        SZLWeX1=Me.SZLW1.Text

        MFM.Box1Val=SZLST1
        MFM.Box2Val=SZLST2
        MFM.szlwxval1=SZLWex1

        me.visible=False

        MFM.Refresh()
        MFM.
        End Sub







Similar Threads
Thread Thread Starter Forum Replies Last Post
GDI+ Problem -- Any Insight? dparsons ASP.NET 1.0 and 1.1 Professional 5 July 23rd, 2007 07:24 AM
GDI+ Help Dienzo General .NET 0 April 1st, 2007 02:50 PM
Device Independence in GDI+ Shujaat .NET Framework 2.0 0 November 24th, 2006 09:05 AM
GDI+ problem pravo_u_raj C# 4 February 16th, 2006 05:27 PM
GDI frame image nbryson Pro VB.NET 2002/2003 0 December 4th, 2003 11:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.