Click here to Skip to main content
15,892,746 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questionlistbox not visible in thread Pin
Thilek25-Mar-09 6:53
Thilek25-Mar-09 6:53 
AnswerRe: listbox not visible in thread Pin
Thilek25-Mar-09 9:09
Thilek25-Mar-09 9:09 
Questionhelp with C++ pragraming Pin
mimikoyan25-Mar-09 0:56
mimikoyan25-Mar-09 0:56 
QuestionForm refresh... and accept click on button while performing other task... Pin
Thilek24-Mar-09 23:31
Thilek24-Mar-09 23:31 
AnswerRe: Form refresh... and accept click on button while performing other task... Pin
N a v a n e e t h25-Mar-09 1:14
N a v a n e e t h25-Mar-09 1:14 
AnswerRe: Form refresh... and accept click on button while performing other task... Pin
erfi25-Mar-09 2:10
erfi25-Mar-09 2:10 
GeneralRe: Form refresh... and accept click on button while performing other task... Pin
Thilek25-Mar-09 3:29
Thilek25-Mar-09 3:29 
GeneralRe: Form refresh... and accept click on button while performing other task... Pin
Thilek25-Mar-09 4:04
Thilek25-Mar-09 4:04 
Below is my coding.. i not sure where to put the thread....

#pragma once

#include "QUARANTINE.h"


using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;


namespace Enhan_GUI {

	/// <summary>
	/// Summary for manscan
	///
	/// 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>
	public ref class manscan : public System::Windows::Forms::Form
	{
	public:
		manscan(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~manscan()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::PictureBox^  pictureBox1;
	protected: 
	private: System::Windows::Forms::GroupBox^  gbxfunction;
	private: System::Windows::Forms::Button^  cmdPause;
	private: System::Windows::Forms::Button^  cmdStart;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Button^  cmdClose;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::Label^  label3;

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

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(manscan::typeid));
			this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
			this->gbxfunction = (gcnew System::Windows::Forms::GroupBox());
			this->cmdPause = (gcnew System::Windows::Forms::Button());
			this->cmdStart = (gcnew System::Windows::Forms::Button());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->cmdClose = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->label3 = (gcnew System::Windows::Forms::Label());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
			this->gbxfunction->SuspendLayout();
			this->SuspendLayout();
			// 
			// pictureBox1
			// 
			this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
			this->pictureBox1->Location = System::Drawing::Point(47, 222);
			this->pictureBox1->Name = L"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(75, 75);
			this->pictureBox1->TabIndex = 18;
			this->pictureBox1->TabStop = false;
			// 
			// gbxfunction
			// 
			this->gbxfunction->Controls->Add(this->cmdPause);
			this->gbxfunction->Controls->Add(this->cmdStart);
			this->gbxfunction->Location = System::Drawing::Point(31, 76);
			this->gbxfunction->Name = L"gbxfunction";
			this->gbxfunction->Size = System::Drawing::Size(118, 107);
			this->gbxfunction->TabIndex = 14;
			this->gbxfunction->TabStop = false;
			this->gbxfunction->Text = L"Functions";
			// 
			// cmdPause
			// 
			this->cmdPause->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
			this->cmdPause->Location = System::Drawing::Point(19, 66);
			this->cmdPause->Name = L"cmdPause";
			this->cmdPause->Size = System::Drawing::Size(75, 23);
			this->cmdPause->TabIndex = 2;
			this->cmdPause->Text = L"Pause";
			this->cmdPause->UseVisualStyleBackColor = true;
			this->cmdPause->Click += gcnew System::EventHandler(this, &manscan::cmdPause_Click);
			// 
			// cmdStart
			// 
			this->cmdStart->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
			this->cmdStart->Location = System::Drawing::Point(19, 37);
			this->cmdStart->Name = L"cmdStart";
			this->cmdStart->Size = System::Drawing::Size(75, 23);
			this->cmdStart->TabIndex = 1;
			this->cmdStart->Text = L"Start";
			this->cmdStart->UseVisualStyleBackColor = true;
			this->cmdStart->Click += gcnew System::EventHandler(this, &manscan::cmdStart_Click);
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label2->Location = System::Drawing::Point(259, 50);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(165, 16);
			this->label2->TabIndex = 16;
			this->label2->Text = L"Number of Files Scanned :";
			// 
			// cmdClose
			// 
			this->cmdClose->Location = System::Drawing::Point(491, 408);
			this->cmdClose->Name = L"cmdClose";
			this->cmdClose->Size = System::Drawing::Size(75, 23);
			this->cmdClose->TabIndex = 15;
			this->cmdClose->Text = L"Close";
			this->cmdClose->UseVisualStyleBackColor = true;
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Font = (gcnew System::Drawing::Font(L"Bodoni MT Poster Compressed", 15.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label1->Location = System::Drawing::Point(27, 16);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(123, 26);
			this->label1->TabIndex = 13;
			this->label1->Text = L"Click \'Start\' to Scan";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(426, 52);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(13, 13);
			this->label3->TabIndex = 17;
			this->label3->Text = L"0";
			// 
			// manscan
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(592, 447);
			this->Controls->Add(this->pictureBox1);
			this->Controls->Add(this->gbxfunction);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->cmdClose);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->label3);
			this->Name = L"manscan";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"Sparta AV : Manual Scan";
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
			this->gbxfunction->ResumeLayout(false);
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void cmdStart_Click(System::Object^  sender, System::EventArgs^  e) {

   int count =0;
   int t=0;
   int refre=0;
   int refres=0;
   string namefile[100];
   keeper=0;
   ListBox^ listBox1 = gcnew ListBox;



   
	SQLiteConnection ^connection = gcnew SQLiteConnection("Data Source=test.db3;Pooling=True");
	connection->Open();// connect to databse
	SQLiteCommand ^cmd = gcnew SQLiteCommand(connection);
    cmd->CommandText = ("select * from keep");// select signature column
	SQLiteDataReader ^reader = cmd->ExecuteReader();
    while (reader->Read())
     {
      String^ namekeep1 = gcnew String(reader->GetString(0));// get value from database
	  MarshalString(namekeep1,namefile[t]);// convert from String^ to std::string
      t++;
      }
     reader->Close();

	cmd->CommandText = ("drop table keep");// creating temp table
	cmd->ExecuteNonQuery();
	//cmd->CommandText = ("drop table temp");// creating temp table
	//cmd->ExecuteNonQuery();

	cmd->CommandText = ("create table temp(scanid DATETIME,filename VARCHAR(250),wormname VARCHAR(50),wormtype VARCHAR(50))");// creating temp table
	cmd->ExecuteNonQuery();
	




   // Set the size and location of the ListBox.
   listBox1->Size = System::Drawing::Size( 392, 319 );
   listBox1->Location = System::Drawing::Point( 174, 76 );

   // Add the ListBox to the form.
   this->Controls->Add( listBox1 );

   // Set the ListBox to display items in multiple columns.
   listBox1->MultiColumn = false;

   // Set the selection mode to multiple and extended.
   listBox1->SelectionMode = SelectionMode::MultiExtended;

   for(int v=0;v<=t;v++)
   {
   	vector<wstring> files;
    std::wstring str2(namefile[v].length(), L' '); // Make room for characters
	std::copy(namefile[v].begin(), namefile[v].end(), str2.begin());
	wstring directory = str2;		
	if (ListFiles(directory, L"*", files)) 
	{    
		for (vector<wstring>::iterator it = files.begin(); it != files.end(); ++it)     
		{        
            keepname  = WStringToString(it->c_str());
			searchkmp();
			int index = listBox1->Items->Add(String::Concat(gcnew String(it->c_str())));        
			listBox1->SelectedIndex = index; 
			count++;
			listBox1->Update();
			//refres=refre%5;
			//if(refres == 4)
			//Form::Focus();
			label3->Text =count.ToString();
			label3->Update();
			refre++;
		}
	}
   }

   if (keeper==0)
   {
    System::Windows::Forms::MessageBox::Show("  No Virus is Found \n\n Your Drive is Clean");//this close's the file if it fails to open
   }

   if(keeper != 0)
   {
   System::Windows::Forms::MessageBox::Show("Number Of Virus Found :  " + keeper);//this close's the file if it fails to open
   }   



	connection->Close();
#if defined(DEBUG)
   // Display the second selected item in the ListBox to the console.
   System::Diagnostics::Debug::WriteLine( listBox1->SelectedItems[ 1 ] );

   // Display the index of the first selected item in the ListBox.
   System::Diagnostics::Debug::WriteLine( listBox1->SelectedIndices[ 0 ] );
   #endif
   		 	 Form^ form3 = gcnew QUARANTINE();
			 Form::Close();
			 form3->Show();
	 }
			 
private: System::Void cmdPause_Click(System::Object^  sender, System::EventArgs^  e) {
			system("PAUSE");
		 }
};
}

GeneralRe: Form refresh... and accept click on button while performing other task... [modified] Pin
erfi25-Mar-09 11:21
erfi25-Mar-09 11:21 
QuestionProblem calling C++ DLL from Excel Pin
gvanto24-Mar-09 16:12
gvanto24-Mar-09 16:12 
QuestionDebug Assertion failed error while using an mfc dll via import library in an managed console application Pin
Muhammad.Ahmad.Malik24-Mar-09 10:02
professionalMuhammad.Ahmad.Malik24-Mar-09 10:02 
QuestionRe: Debug Assertion failed error while using an mfc dll via import library in an managed console application Pin
paxal31-Mar-09 4:02
paxal31-Mar-09 4:02 
AnswerRe: Debug Assertion failed error while using an mfc dll via import library in an managed console application Pin
Muhammad.Ahmad.Malik31-Mar-09 6:55
professionalMuhammad.Ahmad.Malik31-Mar-09 6:55 
QuestionCircular Form Reference Pin
thenutz7224-Mar-09 4:28
thenutz7224-Mar-09 4:28 
AnswerRe: Circular Form Reference [modified] Pin
led mike24-Mar-09 5:20
led mike24-Mar-09 5:20 
GeneralRe: Circular Form Reference Pin
thenutz7224-Mar-09 5:47
thenutz7224-Mar-09 5:47 
GeneralRe: Circular Form Reference Pin
led mike24-Mar-09 7:07
led mike24-Mar-09 7:07 
GeneralRe: Circular Form Reference Pin
thenutz7224-Mar-09 7:10
thenutz7224-Mar-09 7:10 
GeneralRe: Circular Form Reference Pin
led mike24-Mar-09 7:12
led mike24-Mar-09 7:12 
GeneralRe: Circular Form Reference Pin
Trollslayer4-May-09 4:26
mentorTrollslayer4-May-09 4:26 
AnswerRe: Circular Form Reference Pin
erfi25-Mar-09 1:47
erfi25-Mar-09 1:47 
QuestionCannot load 64bit CLI/C++ dll in C# project when running in Vista 64bit, .NET 3.5 Pin
ndkit24-Mar-09 3:40
ndkit24-Mar-09 3:40 
AnswerRe: Cannot load 64bit CLI/C++ dll in C# project when running in Vista 64bit, .NET 3.5 Pin
ndkit24-Mar-09 18:10
ndkit24-Mar-09 18:10 
QuestionHow to write an event handler which will be continiously looking for existence of a file Pin
naveen_bij24-Mar-09 2:25
naveen_bij24-Mar-09 2:25 
AnswerRe: How to write an event handler which will be continiously looking for existence of a file Pin
Giorgi Dalakishvili24-Mar-09 2:34
mentorGiorgi Dalakishvili24-Mar-09 2:34 

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.