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::De
sign;
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::InteropSe
rvices;
/// <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(stri
ng lpString);
public __gc class Form1 : public System::Windows::Forms::Fo
rm
{
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
(menuItem1
3);
// 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::Li
stBox * 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::Permiss
ions::Perm
issionSet(
System::Se
curity::Pe
rmissions:
:SecurityA
ction::Dem
and, Name="FullTrust")]
void WndProc(Message* m);
// **************************
**********
**********
**********
**********
**
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing
);
}
private: System::Windows::Forms::Bu
tton * button1;
private: System::Windows::Forms::La
bel * label5;
//private: System::Windows::Forms::Li
stBox * listBox5;
private: System::Windows::Forms::Ch
eckBox * checkBox1;
private: System::Windows::Forms::Ch
eckBox * checkBox2;
private: System::Windows::Forms::Ch
eckBox * checkBox3;
private: System::Windows::Forms::Gr
oupBox * groupBox1;
private: System::Windows::Forms::Gr
oupBox * groupBox2;
private: System::Windows::Forms::Gr
oupBox * groupBox3;
private: System::Windows::Forms::Gr
oupBox * groupBox4;
private: System::Windows::Forms::Gr
oupBox * groupBox5;
private: System::Windows::Forms::Gr
oupBox * groupBox6;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Co
ntainer * 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::Resourc
eManager * resources = new System::Resources::Resourc
eManager(_
_typeof(Fo
rm1DataApp
::Form1));
this->groupBox1 = new System::Windows::Forms::Gr
oupBox();
this->listBox5 = new System::Windows::Forms::Li
stBox();
this->label5 = new System::Windows::Forms::La
bel();
this->groupBox2 = new System::Windows::Forms::Gr
oupBox();
this->button1 = new System::Windows::Forms::Bu
tton();
this->checkBox3 = new System::Windows::Forms::Ch
eckBox();
this->checkBox2 = new System::Windows::Forms::Ch
eckBox();
this->checkBox1 = new System::Windows::Forms::Ch
eckBox();
this->groupBox3 = new System::Windows::Forms::Gr
oupBox();
this->groupBox4 = new System::Windows::Forms::Gr
oupBox();
this->groupBox5 = new System::Windows::Forms::Gr
oupBox();
this->groupBox6 = new System::Windows::Forms::Gr
oupBox();
this->groupBox2->SuspendLa
yout();
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->SelectedIn
dexChanged
+= new System::EventHandler(this,
listBox5_SelectedIndexChan
ged);
//
// label5
//
this->label5->BackColor = System::Drawing::SystemCol
ors::Contr
olDarkDark
;
this->label5->BorderStyle = System::Windows::Forms::Bo
rderStyle:
:Fixed3D;
this->label5->FlatStyle = System::Windows::Forms::Fl
atStyle::P
opup;
this->label5->Font = new System::Drawing::Font(S"Mi
crosoft Sans Serif", 12, System::Drawing::FontStyle
::Bold, System::Drawing::GraphicsU
nit::Point
, (System::Byte)0);
this->label5->ForeColor = System::Drawing::SystemCol
ors::Contr
olLightLig
ht;
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::ContentAl
ignment::M
iddleCente
r;
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::SystemCol
ors::Contr
olDarkDark
;
this->button1->FlatStyle = System::Windows::Forms::Fl
atStyle::P
opup;
this->button1->Font = new System::Drawing::Font(S"Mi
crosoft Sans Serif", 8.25F, System::Drawing::FontStyle
::Regular,
System::Drawing::GraphicsU
nit::Point
, (System::Byte)0);
this->button1->ForeColor = System::Drawing::SystemCol
ors::Highl
ightText;
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::SystemCol
ors::Contr
olDarkDark
;
this->checkBox3->ForeColor
= System::Drawing::SystemCol
ors::Highl
ightText;
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->CheckedCh
anged += new System::EventHandler(this,
checkBox3_CheckedChanged_1
);
//
// checkBox2
//
this->checkBox2->BackColor
= System::Drawing::SystemCol
ors::Contr
olDarkDark
;
this->checkBox2->ForeColor
= System::Drawing::SystemCol
ors::Highl
ightText;
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->CheckedCh
anged += new System::EventHandler(this,
checkBox2_CheckedChanged);
//
// checkBox1
//
this->checkBox1->BackColor
= System::Drawing::SystemCol
ors::Contr
olDarkDark
;
this->checkBox1->ForeColor
= System::Drawing::SystemCol
ors::Highl
ightText;
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->CheckedCh
anged += 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::Drawin
g::Icon * >(resources->GetObject(S"$
this.Icon"
)));
this->Location = System::Drawing::Point(456
, 88);
this->Name = S"Form1";
this->StartPosition = System::Windows::Forms::Fo
rmStartPos
ition::Cen
terScreen;
this->Text = S"Systems Data Application";
this->Closing += new System::ComponentModel::Ca
ncelEventH
andler(thi
s, Form1_Closing);
this->Load += new System::EventHandler(this,
Form1_Load);
this->groupBox2->ResumeLay
out(false)
;
this->ResumeLayout(false);
}
private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e){}
private: System::Void Form1_Closing(System::Obje
ct * sender, System::ComponentModel::Ca
ncelEventA
rgs * e)
{
// terminate all threads
if(Sys1Thread)
Sys1Thread->Abort();
}
private: System::Void button1_Click(System::Obje
ct * sender, System::EventArgs * e);
private: System::Void checkBox1_CheckedChanged(S
ystem::Obj
ect * sender, System::EventArgs * e);
private: System::Void checkBox2_CheckedChanged(S
ystem::Obj
ect * sender, System::EventArgs * e);
private: System::Void checkBox3_CheckedChanged(S
ystem::Obj
ect * sender, System::EventArgs * e){}
private: System::Void label2_Click(System::Objec
t * sender, System::EventArgs * e){}
private: System::Void label4_Click(System::Objec
t * sender, System::EventArgs * e){}
private: System::Void label5_Click(System::Objec
t * sender, System::EventArgs * e){}
private: System::Void listBox1_SelectedIndexChan
ged(System
::Object * sender, System::EventArgs * e){}
private: System::Void listBox5_SelectedIndexChan
ged(System
::Object * sender, System::EventArgs * e){}
private: System::Void groupBox1_Enter(System::Ob
ject * sender, System::EventArgs * e){}
private: System::Void groupBox2_Enter(System::Ob
ject * sender, System::EventArgs * e){}
private: System::Void groupBox3_Enter(System::Ob
ject * sender, System::EventArgs * e){}
private: System::Void groupBox4_Enter(System::Ob
ject * sender, System::EventArgs * e){}
private: System::Void groupBox5_Enter(System::Ob
ject * sender, System::EventArgs * e){}
private: System::Void groupBox6_Enter(System::Ob
ject * sender, System::EventArgs * e){}
private: System::Void checkBox3_CheckedChanged_1
(System::O
bject * 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.tx
t", "anything");
return;
}
/*************************
* ExecuteAndWaitForCompletio
n **************************
*
* desc :
*
* input :
*
* output :
*
* returns : -
*/
bool ExecuteAndWaitForCompletio
n(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:\\GetLast
Error.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->BeginUpda
te();
String *ListBoxStr = __gc new String(strValue.c_str());
Form1::listBox5->Items->Ad
d(ListBoxS
tr);
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(Syste
m::Object * sender, System::EventArgs * e)
{
WriteToFile("C:\\output.tx
t", "anything");
return;
}
void Form1::checkBox1_CheckedCh
anged(Syst
em::Object
* sender, System::EventArgs * e)
{
if(checkBox1->Checked)
WriteToFile("C:\\output.tx
t", "anything");
else
WriteToFile("C:\\output.tx
t", "anything");
return;
}
void Form1::checkBox2_CheckedCh
anged(Syst
em::Object
* sender, System::EventArgs * e)
{
if(checkBox1->Checked)
WriteToFile("C:\\output.tx
t", "anything");
else
WriteToFile("C:\\output.tx
t", "anything");
return;
}
void Form1::menuItem3_Click(Obj
ect* /*sender*/, System::EventArgs* /*e*/)
{
return;
}
void Form1::menuItem4_Click(Obj
ect* /*sender*/, System::EventArgs* /*e*/)
{
//Dispose(true);
Application::Exit();
this->Close();
}
void Form1::menuItem5_Click(Obj
ect* 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"startUD
PSocket unable to start socket!", S"Socket Information");
*/
}
return;
}
void Form1::menuItem6_Click(Obj
ect* 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("Regist
ering '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(Obj
ect* 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"Display
ing System 3 Data", S"The Event Information");
}
return;
}
void Form1::menuItem8_Click(Obj
ect* 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"Display
ing System 4 Data", S"The Event Information");
}
return;
}
void Form1::menuItem9_Click(Obj
ect* 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"Display
ing System 5 Data", S"The Event Information");
}
return;
}
void Form1::menuItem10_Click(Ob
ject* 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"Display
ing System 6 Data", S"The Event Information");
}
return;
}
void Form1::menuItem11_Click(Ob
ject* 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(Ob
ject* /*sender*/, System::EventArgs* /*e*/)
{
//GetSocketHandles();
//return;
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread:
:CurrentTh
read->Apar
tmentState
= System::Threading::Apartme
ntState::S
TA;
// 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,ErrorMes
sage.c_str
(), "OMS Database Utility", MB_OK | MB_ICONERROR);
}
else
WriteFile << Message;
WriteFile.close();
return;
}