Click here to Skip to main content
15,902,112 members
Home / Discussions / C#
   

C#

 
GeneralRe: small problem Pin
IamJunk21-Jun-05 19:30
IamJunk21-Jun-05 19:30 
Generalflow chart generator Pin
bobballi@usa.net21-Jun-05 8:23
bobballi@usa.net21-Jun-05 8:23 
QuestionSocket.Select() Bug? Pin
obelisk2921-Jun-05 7:46
obelisk2921-Jun-05 7:46 
AnswerRe: Socket.Select() Bug? Pin
leppie21-Jun-05 10:45
leppie21-Jun-05 10:45 
GeneralWritting to a ListBox from another class Pin
cmacgowan21-Jun-05 7:45
cmacgowan21-Jun-05 7:45 
GeneralRe: Writting to a ListBox from another class Pin
S. Senthil Kumar21-Jun-05 8:34
S. Senthil Kumar21-Jun-05 8:34 
GeneralRe: Writting to a ListBox from another class Pin
IamJunk21-Jun-05 17:36
IamJunk21-Jun-05 17:36 
GeneralRe: Writting to a ListBox from another class Pin
cmacgowan22-Jun-05 7:17
cmacgowan22-Jun-05 7:17 
Thanks IAMJUNK ...

The following is the solution to the ListBox Issue
Thanks also to Andy Tacker (CodeGuru)

Note that we added a reference to the form in the Video Class (m_ParentForm1). Then when we create the Video Object in the Form1 Object we will set the Video.m_ParentForm1 attribute to be <this> to set the reference back to the Form1 Object. Then when we want to use the Form1::WriteStatusMessage() method we can used the reference to Form1 from m_ParentForm1.


<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace TestBlueRayon<br />
{<br />
    /// <summary><br />
    /// Summary description for Form1.<br />
    /// </summary><br />
    public class Form1 : System.Windows.Forms.Form<br />
    {<br />
        private System.Windows.Forms.MenuItem menuItemVideo;<br />
        private System.Windows.Forms.ListBox ListBoxStatus;<br />
<br />
        private System.ComponentModel.Container components = null;<br />
<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
            WriteStatusMessage("TestBlueRayon Application Started.");<br />
            WriteStatusMessage("Good to have you with us.  ");<br />
<br />
        }<br />
<br />
<br />
        #region Windows Form Designer generated code<br />
        private void InitializeComponent()<br />
        {<br />
            this.mainMenu1 = new System.Windows.Forms.MainMenu();<br />
            // took out code<br />
            this.ResumeLayout(false);<br />
        }<br />
        #endregion<br />
<br />
        [STAThread]<br />
        static void Main()<br />
        {<br />
            Application.Run(new Form1());<br />
        }<br />
<br />
<br />
<br />
        private void menuItemVideo_Click(object sender, System.EventArgs e)<br />
        {<br />
            //string strTemp;<br />
            string strMessage;<br />
<br />
            // Tell the user what is happening<br />
            strMessage = "Create Video Object";<br />
            WriteStatusMessage(strMessage);<br />
<br />
            // Create the Video object<br />
            Video GreenVideo = new Video();<br />
<br />
            // Set the parent object<br />
            GreenVideo.m_ParentForm1 = this;<br />
<br />
            // Set video contrast<br />
            GreenVideo.SetVideoContrast(0);<br />
        }<br />
<br />
<br />
<br />
<br />
        public void WriteStatusMessage(string strMessage)<br />
        {<br />
            // You have pressed ???<br />
            string strDisplayMessage;<br />
<br />
            DateTime dtCurrent = DateTime.Now;<br />
<br />
            int nYear        = dtCurrent.Year;<br />
            int nMonth       = dtCurrent.Month;<br />
            int nDay         = dtCurrent.Day;<br />
            int nHour        = dtCurrent.Hour;<br />
            int nMinute      = dtCurrent.Minute;<br />
            int nSecond      = dtCurrent.Second;<br />
            int nMillisecond = dtCurrent.Millisecond;<br />
<br />
            string strTemp;<br />
<br />
            strDisplayMessage = String.Format("{0,0:D4}.{1,0:D2}.{2,0:D2} {3,0:D2}:{4,0:D2}:{5,0:D2}.{6,0:D3}  {7}",<br />
                                              nYear,<br />
                                              nMonth,<br />
                                              nDay,<br />
                                              nHour,<br />
                                              nMinute,<br />
                                              nSecond,<br />
                                              nMillisecond,<br />
                                              strMessage);<br />
<br />
            // Shutdown the painting of the ListBox as items are added.<br />
            // this.ListBoxStatus.BeginUpdate();<br />
            this.ListBoxStatus.Items.Add(strDisplayMessage);<br />
            // this.ListBoxStatus.EndUpdate();<br />
<br />
            // this.ListBoxStatus.Invalidate();<br />
            this.ListBoxStatus.Update();<br />
        }<br />
    }<br />
}<br />
<br />
<br />
<br />
<br />
<br />
using System;<br />
<br />
namespace TestBlueRayon<br />
{<br />
    public class Video<br />
    {<br />
<br />
        // Public attributes<br />
        public int nColor;<br />
        public int nHue;<br />
        public string strComment;<br />
        public Form1 m_ParentForm1;<br />
<br />
        // Default constructor<br />
        public Video()<br />
        {<br />
            nColor = 0;<br />
            nHue = 0;<br />
            m_ParentForm1 = null;<br />
        }<br />
<br />
        public void SetVideoContrast(int nIndex)<br />
        {<br />
            // Set some values for the color and hue<br />
            nColor = 12;<br />
            nHue = 34;<br />
            strComment = "Contrast has been set";<br />
<br />
            if (m_ParentForm1 != null)<br />
            {<br />
                m_ParentForm1.WriteStatusMessage("SetVideoContrast() called");<br />
            }<br />
        }<br />
    }<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />

Generaltelnetting to a router Pin
reveal21-Jun-05 7:06
reveal21-Jun-05 7:06 
GeneralRe: telnetting to a router Pin
reveal21-Jun-05 7:07
reveal21-Jun-05 7:07 
GeneralRemoting thru firewalls Pin
Judah Gabriel Himango21-Jun-05 6:21
sponsorJudah Gabriel Himango21-Jun-05 6:21 
GeneralRe: Remoting thru firewalls Pin
DeepToot21-Jun-05 14:55
DeepToot21-Jun-05 14:55 
GeneralPassing special characters in a string Pin
CheckDude21-Jun-05 5:49
CheckDude21-Jun-05 5:49 
GeneralRe: Passing special characters in a string Pin
IamJunk21-Jun-05 6:02
IamJunk21-Jun-05 6:02 
GeneralRe: Passing special characters in a string Pin
mav.northwind21-Jun-05 6:58
mav.northwind21-Jun-05 6:58 
GeneralRe: Passing special characters in a string Pin
CheckDude21-Jun-05 16:08
CheckDude21-Jun-05 16:08 
QuestionHow do i create a savestate? Pin
Anthony Mushrow21-Jun-05 5:48
professionalAnthony Mushrow21-Jun-05 5:48 
AnswerRe: How do i create a savestate? Pin
IamJunk21-Jun-05 6:05
IamJunk21-Jun-05 6:05 
GeneralSecure Conversation doesn't work with second web service Pin
Member 186329021-Jun-05 5:07
Member 186329021-Jun-05 5:07 
GeneralMultiple connections Pin
Micu Radu21-Jun-05 4:53
Micu Radu21-Jun-05 4:53 
GeneralRe: Multiple connections Pin
CheckDude21-Jun-05 5:36
CheckDude21-Jun-05 5:36 
GeneralRe: Multiple connections Pin
Luis Alonso Ramos21-Jun-05 17:16
Luis Alonso Ramos21-Jun-05 17:16 
GeneralRe: Multiple connections Pin
Micu Radu24-Jun-05 0:29
Micu Radu24-Jun-05 0:29 
GeneralRe: Multiple connections Pin
Luis Alonso Ramos24-Jun-05 6:17
Luis Alonso Ramos24-Jun-05 6:17 
GeneralCrystal Reports / Data horizontally &amp; vertically Pin
V.21-Jun-05 3:53
professionalV.21-Jun-05 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.