[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

Question for lakshman_ce - How to implement static functions

Asked by John500 in Microsoft Visual C++.Net

Tags: checkbox1_checkedchanged, static

lakshman_ce,

The following code will allow you to create my Form application.  The project is called Form1DataApp.  Just to prove the project would compile for you - I created a new .Net Form Application and pasted these existing .h and .cpp files into the project.  It compiled fine.  You will see exactly what I'm attempting.  Take note of menuItem6_Click() because this is where I call Form1::ListBox5Msg().  This menu item would call existing cpps but you don't need them to demonstrate the problem:

===============================================================================

#pragma once
#include <string>


namespace Form1DataApp
{

      using namespace std;
      using namespace System;
    using namespace System::ComponentModel;
      using namespace System::ComponentModel::Design;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
      using namespace System::IO;
      using namespace System::Threading;
      using namespace System::Runtime::InteropServices;

    /// <summary>
    /// Summary for Form1
    ///
    /// WARNING: If you change the name of this class, you will need to change the
    ///          'Resource File Name' property for the managed resource compiler tool
    ///          associated with all .resx files this class depends on.  Otherwise,
    ///          the designers will not be able to interact properly with localized
    ///          resources associated with this form.
    /// </summary>
      //[DllImport("user32.dll", SetLastError = true, CharSet = Auto)]
      //Int32 RegisterWindowMessage(string lpString);
    public __gc class Form1 : public System::Windows::Forms::Form
    {


            private:

            public:

                  // Create a main menu object
                  MainMenu* mainMenu1;

                  // Create empty menu item objects.
                  MenuItem* menuItem1;
                  MenuItem* menuItem2;
                  MenuItem* menuItem3;
                  MenuItem* menuItem4;
                  MenuItem* menuItem5;
                  MenuItem* menuItem6;
                  MenuItem* menuItem7;
                  MenuItem* menuItem8;
                  MenuItem* menuItem9;
                  MenuItem* menuItem10;
                  MenuItem* menuItem11;
                  MenuItem* menuItem12;
                  MenuItem* menuItem13;

                  Form1(void){

                        InitializeComponent();

                        // Create empty menu object
                        mainMenu1 = new MainMenu();

                        // Create empty menu item objects.
                        menuItem1 = new MenuItem();
                        menuItem2 = new MenuItem();
                        menuItem3 = new MenuItem();
                        menuItem4 = new MenuItem();
                        menuItem5 = new MenuItem();
                        menuItem6 = new MenuItem();
                        menuItem7 = new MenuItem();
                        menuItem8 = new MenuItem();
                        menuItem9 = new MenuItem();
                        menuItem10 = new MenuItem();
                        menuItem11 = new MenuItem();
                        menuItem12 = new MenuItem();
                        menuItem13 = new MenuItem();

                        // Set the caption of the menu items.
                        menuItem1->Text = S"&File";
                        menuItem2->Text = S"&View";
                        menuItem3->Text = S"&Open File";
                        menuItem4->Text = S"&Exit";
                        menuItem5->Text = S"&System_1";
                        menuItem6->Text = S"&System_2";
                        menuItem7->Text = S"&System_3";
                        menuItem8->Text = S"&System_4";
                        menuItem9->Text = S"&System_5";
                        menuItem10->Text = S"&System_6";
                        menuItem11->Text = S"&All";
                        menuItem12->Text = S"&Reconnect";
                        menuItem13->Text = S"&Start Socket";

                        menuItem1->MenuItems->Add(menuItem3);
                        menuItem1->MenuItems->Add(menuItem4);
                        menuItem2->MenuItems->Add(menuItem5);
                        menuItem2->MenuItems->Add(menuItem6);
                        menuItem2->MenuItems->Add(menuItem7);
                        menuItem2->MenuItems->Add(menuItem8);
                        menuItem2->MenuItems->Add(menuItem9);
                        menuItem2->MenuItems->Add(menuItem10);
                        menuItem2->MenuItems->Add(menuItem11);
                        menuItem12->MenuItems->Add(menuItem13);

                        // Add the menu items to the main menu.
                        mainMenu1->MenuItems->Add(menuItem1);
                        mainMenu1->MenuItems->Add(menuItem2);
                        mainMenu1->MenuItems->Add(menuItem12);
      
                        // Add functionality to the menu items.                        
                        menuItem1->Click += new System::EventHandler(this, &Form1::menuItem1_Click);
                        menuItem2->Click += new System::EventHandler(this, &Form1::menuItem2_Click);
                        menuItem12->Click += new System::EventHandler(this, &Form1::menuItem2_Click);

                        // Add functionality to the menu items.
                        menuItem3->Click += new System::EventHandler(this, &Form1::menuItem3_Click);
                        menuItem4->Click += new System::EventHandler(this, &Form1::menuItem4_Click);
                        menuItem5->Click += new System::EventHandler(this, &Form1::menuItem5_Click);
                        menuItem6->Click += new System::EventHandler(this, &Form1::menuItem6_Click);
                        menuItem7->Click += new System::EventHandler(this, &Form1::menuItem7_Click);
                        menuItem8->Click += new System::EventHandler(this, &Form1::menuItem8_Click);
                        menuItem9->Click += new System::EventHandler(this, &Form1::menuItem9_Click);
                        menuItem10->Click += new System::EventHandler(this, &Form1::menuItem10_Click);
                        menuItem11->Click += new System::EventHandler(this, &Form1::menuItem11_Click);
                        menuItem12->Click += new System::EventHandler(this, &Form1::menuItem12_Click);
                        menuItem13->Click += new System::EventHandler(this, &Form1::menuItem13_Click);

                        // Assign mainMenu1 to the form.
                        this->Menu=mainMenu1;

                  }
      
                  static System::Windows::Forms::ListBox *  listBox5;
            static void ListBox5Msg(string strValue);
                  void menuItem6_Click(Object* /*sender*/, System::EventArgs* /*e*/);


            private:
           
                  Thread      *Sys1Thread;

                  void Sys1ThreadProc();

                  void menuItem1_Click(Object* /*sender*/, System::EventArgs* /*e*/){};
                  void menuItem2_Click(Object* /*sender*/, System::EventArgs* /*e*/){};
                  void menuItem3_Click(Object* /*sender*/, System::EventArgs* /*e*/);
                  void menuItem4_Click(Object* /*sender*/, System::EventArgs* /*e*/);
                  void menuItem5_Click(Object* /*sender*/, System::EventArgs* /*e*/);
                  //void menuItem6_Click(Object* /*sender*/, System::EventArgs* /*e*/);
                  void menuItem7_Click(Object* /*sender*/, System::EventArgs* /*e*/);      
                  void menuItem8_Click(Object* /*sender*/, System::EventArgs* /*e*/);      
                  void menuItem9_Click(Object* /*sender*/, System::EventArgs* /*e*/);      
                  void menuItem10_Click(Object* /*sender*/, System::EventArgs* /*e*/);      
                  void menuItem11_Click(Object* /*sender*/, System::EventArgs* /*e*/);      
                  void menuItem12_Click(Object* /*sender*/, System::EventArgs* /*e*/){};      
                  void menuItem13_Click(Object* /*sender*/, System::EventArgs* /*e*/);      

            protected:

                  [System::Security::Permissions::PermissionSet(System::Security::Permissions::SecurityAction::Demand, Name="FullTrust")]
                  void WndProc(Message* m);
                  
                  // ********************************************************************
                  void Dispose(Boolean disposing)
                  {
                        if (disposing && components)
                        {
                              components->Dispose();
                        }
                        __super::Dispose(disposing);
                  }

            private: System::Windows::Forms::Button *  button1;
            private: System::Windows::Forms::Label *  label5;
            //private: System::Windows::Forms::ListBox *  listBox5;
            private: System::Windows::Forms::CheckBox *  checkBox1;
            private: System::Windows::Forms::CheckBox *  checkBox2;
            private: System::Windows::Forms::CheckBox *  checkBox3;

            private: System::Windows::Forms::GroupBox *  groupBox1;
             private: System::Windows::Forms::GroupBox *  groupBox2;
             private: System::Windows::Forms::GroupBox *  groupBox3;
            private: System::Windows::Forms::GroupBox *  groupBox4;
            private: System::Windows::Forms::GroupBox *  groupBox5;
            private: System::Windows::Forms::GroupBox *  groupBox6;

            private:
                  /// <summary>
                        /// Required designer variable.
                        /// </summary>
                  System::ComponentModel::Container * components;

                  /// <summary>
                        /// Required method for Designer support - do not modify
                        /// the contents of this method with the code editor.
                        /// </summary>
                  void InitializeComponent(void)
                        {
                              System::Resources::ResourceManager *  resources = new System::Resources::ResourceManager(__typeof(Form1DataApp::Form1));
                              this->groupBox1 = new System::Windows::Forms::GroupBox();
                              this->listBox5 = new System::Windows::Forms::ListBox();
                              this->label5 = new System::Windows::Forms::Label();
                              this->groupBox2 = new System::Windows::Forms::GroupBox();
                              this->button1 = new System::Windows::Forms::Button();
                              this->checkBox3 = new System::Windows::Forms::CheckBox();
                              this->checkBox2 = new System::Windows::Forms::CheckBox();
                              this->checkBox1 = new System::Windows::Forms::CheckBox();
                              this->groupBox3 = new System::Windows::Forms::GroupBox();
                              this->groupBox4 = new System::Windows::Forms::GroupBox();
                              this->groupBox5 = new System::Windows::Forms::GroupBox();
                              this->groupBox6 = new System::Windows::Forms::GroupBox();
                              this->groupBox2->SuspendLayout();
                              this->SuspendLayout();
                              //
                              // groupBox1
                              //
                              this->groupBox1->Enabled = false;
                              this->groupBox1->Location = System::Drawing::Point(40, 88);
                              this->groupBox1->Name = S"groupBox1";
                              this->groupBox1->Size = System::Drawing::Size(184, 144);
                              this->groupBox1->TabIndex = 1;
                              this->groupBox1->TabStop = false;
                              this->groupBox1->Text = S"Group 1";
                              this->groupBox1->Enter += new System::EventHandler(this, groupBox1_Enter);
                              //
                              // listBox5
                              //
                              this->listBox5->Location = System::Drawing::Point(8, 96);
                              this->listBox5->Name = S"listBox5";
                              this->listBox5->Size = System::Drawing::Size(168, 43);
                              this->listBox5->TabIndex = 4;
                              this->listBox5->SelectedIndexChanged += new System::EventHandler(this, listBox5_SelectedIndexChanged);
                              //
                              // label5
                              //
                              this->label5->BackColor = System::Drawing::SystemColors::ControlDarkDark;
                              this->label5->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
                              this->label5->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
                              this->label5->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
                              this->label5->ForeColor = System::Drawing::SystemColors::ControlLightLight;
                              this->label5->Location = System::Drawing::Point(40, 24);
                              this->label5->Name = S"label5";
                              this->label5->Size = System::Drawing::Size(600, 48);
                              this->label5->TabIndex = 2;
                              this->label5->Text = S" SYSTEMS  DATA  PANNEL";
                              this->label5->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
                              this->label5->Click += new System::EventHandler(this, label5_Click);
                              //
                              // groupBox2
                              //
                              this->groupBox2->Controls->Add(this->button1);
                              this->groupBox2->Controls->Add(this->checkBox3);
                              this->groupBox2->Controls->Add(this->listBox5);
                              this->groupBox2->Controls->Add(this->checkBox2);
                              this->groupBox2->Controls->Add(this->checkBox1);
                              this->groupBox2->Location = System::Drawing::Point(248, 88);
                              this->groupBox2->Name = S"groupBox2";
                              this->groupBox2->Size = System::Drawing::Size(184, 144);
                              this->groupBox2->TabIndex = 3;
                              this->groupBox2->TabStop = false;
                              this->groupBox2->Text = S"Group 2";
                              this->groupBox2->Enter += new System::EventHandler(this, groupBox2_Enter);
                              //
                              // button1
                              //
                              this->button1->BackColor = System::Drawing::SystemColors::ControlDarkDark;
                              this->button1->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
                              this->button1->Font = new System::Drawing::Font(S"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, (System::Byte)0);
                              this->button1->ForeColor = System::Drawing::SystemColors::HighlightText;
                              this->button1->Location = System::Drawing::Point(8, 24);
                              this->button1->Name = S"button1";
                              this->button1->Size = System::Drawing::Size(168, 18);
                              this->button1->TabIndex = 0;
                              this->button1->Text = S" Manually Register";
                              this->button1->Click += new System::EventHandler(this, button1_Click);
                              //
                              // checkBox3
                              //
                              this->checkBox3->BackColor = System::Drawing::SystemColors::ControlDarkDark;
                              this->checkBox3->ForeColor = System::Drawing::SystemColors::HighlightText;
                              this->checkBox3->Location = System::Drawing::Point(8, 48);
                              this->checkBox3->Name = S"checkBox3";
                              this->checkBox3->Size = System::Drawing::Size(168, 15);
                              this->checkBox3->TabIndex = 1;
                              this->checkBox3->Text = S"         Auto Register";
                              this->checkBox3->CheckedChanged += new System::EventHandler(this, checkBox3_CheckedChanged_1);
                              //
                              // checkBox2
                              //
                              this->checkBox2->BackColor = System::Drawing::SystemColors::ControlDarkDark;
                              this->checkBox2->ForeColor = System::Drawing::SystemColors::HighlightText;
                              this->checkBox2->Location = System::Drawing::Point(8, 64);
                              this->checkBox2->Name = S"checkBox2";
                              this->checkBox2->Size = System::Drawing::Size(168, 15);
                              this->checkBox2->TabIndex = 2;
                              this->checkBox2->Text = S"            Task 1";
                              this->checkBox2->CheckedChanged += new System::EventHandler(this, checkBox2_CheckedChanged);
                              //
                              // checkBox1
                              //
                              this->checkBox1->BackColor = System::Drawing::SystemColors::ControlDarkDark;
                              this->checkBox1->ForeColor = System::Drawing::SystemColors::HighlightText;
                              this->checkBox1->Location = System::Drawing::Point(8, 80);
                              this->checkBox1->Name = S"checkBox1";
                              this->checkBox1->Size = System::Drawing::Size(168, 15);
                              this->checkBox1->TabIndex = 3;
                              this->checkBox1->Text = S"            Task 2";
                              this->checkBox1->CheckedChanged += new System::EventHandler(this, checkBox1_CheckedChanged);
                              //
                              // groupBox3
                              //
                              this->groupBox3->Location = System::Drawing::Point(456, 88);
                              this->groupBox3->Name = S"groupBox3";
                              this->groupBox3->Size = System::Drawing::Size(184, 144);
                              this->groupBox3->TabIndex = 4;
                              this->groupBox3->TabStop = false;
                              this->groupBox3->Text = S"Group 3";
                              this->groupBox3->Enter += new System::EventHandler(this, groupBox3_Enter);
                              //
                              // groupBox4
                              //
                              this->groupBox4->Location = System::Drawing::Point(40, 248);
                              this->groupBox4->Name = S"groupBox4";
                              this->groupBox4->Size = System::Drawing::Size(184, 144);
                              this->groupBox4->TabIndex = 5;
                              this->groupBox4->TabStop = false;
                              this->groupBox4->Text = S"Group 4";
                              this->groupBox4->Enter += new System::EventHandler(this, groupBox4_Enter);
                              //
                              // groupBox5
                              //
                              this->groupBox5->Location = System::Drawing::Point(248, 248);
                              this->groupBox5->Name = S"groupBox5";
                              this->groupBox5->Size = System::Drawing::Size(184, 144);
                              this->groupBox5->TabIndex = 6;
                              this->groupBox5->TabStop = false;
                              this->groupBox5->Text = S"Group 5";
                              this->groupBox5->Enter += new System::EventHandler(this, groupBox5_Enter);
                              //
                              // groupBox6
                              //
                              this->groupBox6->Location = System::Drawing::Point(456, 248);
                              this->groupBox6->Name = S"groupBox6";
                              this->groupBox6->Size = System::Drawing::Size(184, 144);
                              this->groupBox6->TabIndex = 7;
                              this->groupBox6->TabStop = false;
                              this->groupBox6->Text = S"Group 6";
                              this->groupBox6->Enter += new System::EventHandler(this, groupBox6_Enter);
                              //
                              // Form1
                              //
                              this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
                              this->ClientSize = System::Drawing::Size(680, 413);
                              this->Controls->Add(this->groupBox6);
                              this->Controls->Add(this->groupBox5);
                              this->Controls->Add(this->groupBox4);
                              this->Controls->Add(this->groupBox3);
                              this->Controls->Add(this->groupBox2);
                              this->Controls->Add(this->label5);
                              this->Controls->Add(this->groupBox1);
                              this->Icon = (__try_cast<System::Drawing::Icon *  >(resources->GetObject(S"$this.Icon")));
                              this->Location = System::Drawing::Point(456, 88);
                              this->Name = S"Form1";
                              this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
                              this->Text = S"Systems Data Application";
                              this->Closing += new System::ComponentModel::CancelEventHandler(this, Form1_Closing);
                              this->Load += new System::EventHandler(this, Form1_Load);
                              this->groupBox2->ResumeLayout(false);
                              this->ResumeLayout(false);

                        }    






            private: System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void Form1_Closing(System::Object *  sender, System::ComponentModel::CancelEventArgs *  e)
                         {
                              // terminate all threads
                               if(Sys1Thread)
                                    Sys1Thread->Abort();
                         }

            private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e);

            private: System::Void checkBox1_CheckedChanged(System::Object *  sender, System::EventArgs *  e);
            private: System::Void checkBox2_CheckedChanged(System::Object *  sender, System::EventArgs *  e);            
            private: System::Void checkBox3_CheckedChanged(System::Object *  sender, System::EventArgs *  e){}            

            private: System::Void label2_Click(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void label4_Click(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void label5_Click(System::Object *  sender, System::EventArgs *  e){}

            private: System::Void listBox1_SelectedIndexChanged(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void listBox5_SelectedIndexChanged(System::Object *  sender, System::EventArgs *  e){}

            private: System::Void groupBox1_Enter(System::Object *  sender, System::EventArgs *  e){}
             private: System::Void groupBox2_Enter(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void groupBox3_Enter(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void groupBox4_Enter(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void groupBox5_Enter(System::Object *  sender, System::EventArgs *  e){}
            private: System::Void groupBox6_Enter(System::Object *  sender, System::EventArgs *  e){}

private: System::Void checkBox3_CheckedChanged_1(System::Object *  sender, System::EventArgs *  e)
             {
             }

};
}

===============================================================================

#include <string>
using namespace std;

// log routine for all panel display data
void WriteToFile(string , string);

===============================================================================

#include "stdafx.h"
#include "resource.h"
#include "Form1.h"
#include "write_util.h"
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <float.h>
#include <string.h>
#include <process.h>
#include <time.h>
#include <fstream>
#include <string>
//#using <mscorlib.dll>

using namespace std;
using namespace System;
using namespace Form1DataApp;

#ifdef MessageBox
#undef MessageBox
#endif


// LOCAL GLOBALS
int                              SocketDlls = 0;                  // reflects status of socket dlls
int                              SystemPanelAll      = 0;      // reflects status of pannel request
int                              SelfReg;

// PROJECT GLOBALS
UINT RECEIVED_HB;



/********************************   WndProc  **************************************
*
* desc    :
*          
* input   :
*          
* output  :
*          
* returns : -
*/

void Form1::WndProc(Message* m)
{
      int            i;                                    // used as an index for 'buffer' array below
      int            wmId, lParm;
      char      IntBuffer1[50];
      char      IntBuffer2[50];
      char      IntBuffer3[50];
      char      datebuf[9];                        // stores the date obtained from _strdate()
      char      timebuf[9];                        // stores the time obtained from _strtime()            
      char      LogBuffer[1024];            // holds the message which is converted into a string
      string      LogMessage;
      UINT      MsgParam;



    _strdate(datebuf);                        // get current date
      _strtime(timebuf);                        // get current time
      i =  sprintf(LogBuffer, "**********   WinProck()   ********** \t  %s %s", datebuf, timebuf);
      LogMessage = LogBuffer;            
      WriteToFile("C:\\debug.txt", LogMessage + "\n");

      //hWnd            = (HWND)Form1::Handle();
      MsgParam      = m->Msg;
      wmId            = (int)m->WParam;
      lParm            = (int)m->LParam;

      //wmEvent = m->Msg.MaxValue.ToInt16;

      sprintf(IntBuffer1," %d ", m->Msg);
      string message1 = IntBuffer1;
      sprintf(IntBuffer2," %d ", m->WParam);
      string message2 = IntBuffer2;
      sprintf(IntBuffer3," %d ", m->LParam);
      string message3 = IntBuffer3;
      WriteToFile("C:\\debug.txt", "WndProc message = \t" + message1 + "\n");
      WriteToFile("C:\\debug.txt", "WndProc wParam = \t" + message2 + "\n");
      WriteToFile("C:\\debug.txt", "WndProc lParam = \t" + message3 + "\n");

      if(MsgParam == RECEIVED_HB){  //hbReceivedMessage){
            WriteToFile("C:\\debug.txt", "\n**************  BINGO " + message1 + " ************** \n");
      }
    Form::WndProc(m);
}


void GetSocketHandles()
{

      WriteToFile("C:\\output.txt", "anything");

      return;
}


/**************************   ExecuteAndWaitForCompletion  **************************
*
* desc    :
*          
* input   :
*          
* output  :
*          
* returns : -
*/


bool ExecuteAndWaitForCompletion(char *pszCmd)
{
      bool bRes;
      int i = 0;
      int SpawnError;
      char buffer[400];                        // holds the message which is converted into a string
      string LogMessage;                        // holds the converted message to be written in the log

      STARTUPINFO si;
      PROCESS_INFORMATION ProcessInfo;

      ZeroMemory( &si, sizeof(si) );
      si.cb = sizeof(si);
      ZeroMemory( &ProcessInfo, sizeof(ProcessInfo) );


      // Start the child process.
      if( !CreateProcess( NULL,   // No module name (use command line).
            pszCmd, // Command line - TEXT(pszCmd), // Command line.
            NULL,             // Process handle not inheritable.
            NULL,             // Thread handle not inheritable.
            FALSE,            // Set handle inheritance to FALSE.
            0,                // No creation flags.
            NULL,             // Use parent's environment block.
            NULL,             // Use parent's starting directory.
            &si,              // Pointer to STARTUPINFO structure.
            &ProcessInfo )){             // Pointer to PROCESS_INFORMATION structure.

            SpawnError = GetLastError();
            i =  sprintf(buffer, "Last error code: %d\n",GetLastError() );
            LogMessage =  buffer;
            //WriteToFile("C:\\GetLastError.txt", LogMessage);
            return 1;
      }

      // Wait until child process exits.
      WaitForSingleObject( ProcessInfo.hProcess, INFINITE );

      // Close process and thread handles.
      CloseHandle( ProcessInfo.hProcess );
      CloseHandle( ProcessInfo.hThread );

      return ( bRes);
}


void Form1::ListBox5Msg(string strValue)
{
      Form1::listBox5->BeginUpdate();
      String *ListBoxStr = __gc new String(strValue.c_str());
      Form1::listBox5->Items->Add(ListBoxStr);
      Form1::listBox5->EndUpdate();
      return;
}

void Form1::Sys1ThreadProc()
{
      /*
      for (;;)
    {
            retstat = readsocket();
            update list boxes

    }
      */
      return;
}


/*******************************   Form1::button1_Click()  *******************************
*
* desc    :
*          
* input   :
*          
* output  :
*          
* returns : -
*/
void Form1::button1_Click(System::Object *  sender, System::EventArgs *  e)
{
      WriteToFile("C:\\output.txt", "anything");
      return;
}

void Form1::checkBox1_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
{
      if(checkBox1->Checked)
            WriteToFile("C:\\output.txt", "anything");
      else
            WriteToFile("C:\\output.txt", "anything");

      return;
}
void Form1::checkBox2_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
{
      if(checkBox1->Checked)
            WriteToFile("C:\\output.txt", "anything");
      else
            WriteToFile("C:\\output.txt", "anything");

      return;
}



void Form1::menuItem3_Click(Object* /*sender*/, System::EventArgs* /*e*/)
{
      
      return;
}

void Form1::menuItem4_Click(Object* /*sender*/, System::EventArgs* /*e*/)
{
      //Dispose(true);
      Application::Exit();
      this->Close();
}
void Form1::menuItem5_Click(Object* sender, System::EventArgs* e)
{
      int rc = 1;

      if(menuItem5->Checked){
            menuItem5->Checked = false;
            /* terminate the thread
            if(Sys1Thread)
                  Sys1Thread->Abort();
            groupBox1->Enabled = false;
            */
      }
      else{
            menuItem5->Checked = true;
            groupBox1->Enabled = true;
            /* Start the multicast socket to listen for packets
            if(StartSocket(true)){
                  Sys1Thread = new Thread(new ThreadStart(this, Sys1ThreadProc));
                  Sys1Thread->Start();
            }
            else
                  MessageBox::Show(S"startUDPSocket unable to start socket!", S"Socket Information");
            */
      }
      return;
}

void Form1::menuItem6_Click(Object* sender, System::EventArgs* e)
{
      int rc = 1;
      HWND                        *hWnd;
      void                        *FormHwndPtr;
      Form1                        *Form1Ptr = new Form1();
      System::IntPtr __gc      *hWndPtr;
      FormHwndPtr                  = &Form1Ptr->get_Handle();
      hWnd                        = (HWND *)FormHwndPtr;      

      if(menuItem6->Checked){
            menuItem6->Checked = false;
            //groupBox2->Enabled = false;
      }
      else{
            menuItem6->Checked = true;
            //groupBox2->Enabled = true;
            //Getini();
            // open connection to socket dlls
            if(!SelfReg){
                  WriteToFile("C:\\debug.txt", "AutoDiscovery Status = 0 \n");
                  // Start the multicast socket to listen for the heart beat.
                  Form1::ListBox5Msg("Ready to register ISIS boards.");
            }
            else{
                  Form1::ListBox5Msg("Registering 'RECIEVED_HB' ");                  
                  //rc = RegisterMsg(hWnd);
                  if(rc == -1){
                        Form1::ListBox5Msg("Unable to start socket !");
                        WriteToFile("C:\\debug.txt", "AutoDiscovery Status = 0 \n");
                  }
            }
      }
      return;
}
void Form1::menuItem7_Click(Object* sender, System::EventArgs* e)
{
      if(menuItem7->Checked){
            menuItem7->Checked = false;
            MessageBox::Show(S"Turning off System 3 Data", S"The Event Information");
      }
      else{
            menuItem7->Checked = true;
            MessageBox::Show(S"Displaying System 3 Data", S"The Event Information");
      }
      return;
}
      
void Form1::menuItem8_Click(Object* sender, System::EventArgs* e)
{
      if(menuItem8->Checked){
            menuItem8->Checked = false;
            MessageBox::Show(S"Turning off System 4 Data", S"The Event Information");
      }      
      else{
            menuItem8->Checked = true;
            MessageBox::Show(S"Displaying System 4 Data", S"The Event Information");
      }
      return;
}

void Form1::menuItem9_Click(Object* sender, System::EventArgs* e)
{
      if(menuItem9->Checked){
            menuItem9->Checked = false;
            MessageBox::Show(S"Turning off System 5 Data", S"The Event Information");
      }      
      else{
            menuItem9->Checked = true;
            MessageBox::Show(S"Displaying System 5 Data", S"The Event Information");
      }
      return;
}

void Form1::menuItem10_Click(Object* sender, System::EventArgs* e)
{
      if(menuItem10->Checked){
            menuItem10->Checked = false;
            MessageBox::Show(S"Turning off System 6 Data", S"The Event Information");
      }      
      else{
            menuItem10->Checked = true;
            MessageBox::Show(S"Displaying System 6 Data", S"The Event Information");
      }
      return;
}

void Form1::menuItem11_Click(Object* sender, System::EventArgs* e)
{
      if(menuItem11->Checked){

            SystemPanelAll = 0;
            menuItem11->Checked = false;
            menuItem5_Click(sender,e);
            menuItem6_Click(sender,e);
            menuItem7_Click(sender,e);
            menuItem8_Click(sender,e);
            menuItem9_Click(sender,e);
            menuItem10_Click(sender,e);
      }
      else{
            SystemPanelAll = 1;
            menuItem11->Checked = true;
            menuItem5_Click(sender,e);
            menuItem6_Click(sender,e);
            menuItem7_Click(sender,e);
            menuItem8_Click(sender,e);
            menuItem9_Click(sender,e);
            menuItem10_Click(sender,e);
      }
      return;
}

void Form1::menuItem13_Click(Object* /*sender*/, System::EventArgs* /*e*/)
{
      //GetSocketHandles();
      //return;
}


int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{

      System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
      
      // establish application socket connections - necessary dependent dlls
      GetSocketHandles();

      // Start the application
      Application::Run(new Form1());

      // terminate sockets
      //WSACleanup();

      // Application ended - free socket libraries
      //if (PackLib) FreeLibrary(PackLib);
      //if (SockLib) FreeLibrary(SockLib);
      //if (ParseLib) FreeLibrary(ParseLib);


      return 0;
}

===============================================================================


#include "stdafx.h"
#include "WriteUtil.h"

#include <fstream>





/******************************   Write To File  ******************************
*
* desc    : This procedure is used to pass all error messages to the designated
*                  error log.  An output stream object is created and opened for the
*           designated file name.  If the file is unable to be opened, a message
*                  box informs the user of the problem.  Otherwise the message is
*                  written to the log and the file is closed.
*          
* input   : One string parameter is taken.  The calling function must first convert
*                  any formatted text into a string before calling this procedure.
*          
* output  : If the file fails to be opened, a message box alerts the user.  This
*                  message must be acknowledged by clicking the 'OK' button.
*          
* returns : -
*/      

void WriteToFile(string FileName, string Message)
{                                                      

      int i = 0;                                    // used as an index for the 'buffer' array
      char buffer[100];                        // an array used by sprintf to create a MessageBox string
      string ErrorMessage;                  // assigned the value of 'buffer' for use in the MessageBox

      ofstream WriteFile;                        // create a ouput stream object called WriteFile

      WriteFile.open(FileName.c_str(), ios::app);

      // create error message for possible use
      i =  sprintf(buffer, "Error writing to %s!  Contact OMS Support.", FileName.c_str());
      ErrorMessage = buffer;                  // store message as a string rather than in an array

      if(WriteFile.fail()){
            WriteFile.close();      
            //MessageBox(NULL,ErrorMessage.c_str(), "OMS Database Utility", MB_OK | MB_ICONERROR);
      }            
             
      else
            WriteFile << Message;
            WriteFile.close();                  
            
      return;
}
[+][-]12/09/05 12:52 PM, ID: 15455769Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/09/05 01:01 PM, ID: 15455831Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/09/05 01:02 PM, ID: 15455837Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/10/05 07:50 AM, ID: 15458847Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 05:43 AM, ID: 15466004Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Visual C++.Net
Tags: checkbox1_checkedchanged, static
Sign Up Now!
Solution Provided By: lakshman_ce
Participating Experts: 1
Solution Grade: A
 
[+][-]12/12/05 10:00 AM, ID: 15468130Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 11:54 AM, ID: 15468949Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/12/05 12:03 PM, ID: 15469021Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/12/05 12:35 PM, ID: 15469272Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/05 09:07 AM, ID: 15475425Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/13/05 11:12 AM, ID: 15476430Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/13/05 02:17 PM, ID: 15477994Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/13/05 06:03 PM, ID: 15479144Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/14/05 09:39 AM, ID: 15483852Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/14/05 10:49 AM, ID: 15484526Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/14/05 11:29 AM, ID: 15484927Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/14/05 02:33 PM, ID: 15486462Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 05:23 AM, ID: 15489835Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/15/05 06:14 AM, ID: 15490221Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 06:29 AM, ID: 15490334Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/15/05 07:31 AM, ID: 15490811Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 08:05 AM, ID: 15491141Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 08:25 AM, ID: 15491350Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 10:31 AM, ID: 15492361Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/15/05 10:50 AM, ID: 15492530Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 11:01 AM, ID: 15492620Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 04:20 PM, ID: 15494991Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 04:49 PM, ID: 15495112Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/15/05 04:49 PM, ID: 15495113Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/15/05 05:25 PM, ID: 15495266Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/15/05 06:36 PM, ID: 15495447Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81