Jump to content
Sign in to follow this  
Getz

Visual C++ .net, Camne Nak Hide Bila Load Form?

Recommended Posts

Assalamualaikum...

Saya baru nak belajar Visual C++ .NET, bhgn Windows Form Application .NET.

Saya nak buat satu program yg bila program tu load aje, dia akan menyembunyikan dirinya.

Maka, saya letak this.Hide() dalam dia punya Form Load Event seperti dibawah:-

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

{

this->Hide();

}

Tapi malangnya tak menjadi, tapi bila aku add satu Button nama Button1 dekat form tu dan letak this.Hide() kat dia punya Click Event, dan bila aku klik button, form hilang plak!

So, perlukan khidmat nasihat para sifu2 semua..TQ

Code penuh dia dalam file Form1.h sperti di bawah

---------------------------------Form1.h------------------------------------------------

#pragma once

#include "resource.h"

#include "AviFile.h"

//Global variable

//CAviFile avi;

namespace cctv

{

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

/// <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>

public __gc class Form1 : public System::Windows::Forms::Form

{

public:

Form1(void)

{

InitializeComponent();

}

protected:

void Dispose(Boolean disposing)

{

if (disposing && components)

{

components->Dispose();

}

__super::Dispose(disposing);

}

private: System::Windows::Forms::Button * button1;

private: System::ComponentModel::IContainer * components;

private:

/// <summary>

/// Required designer variable.

/// </summary>

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

void InitializeComponent(void)

{

this->button1 = new System::Windows::Forms::Button();

this->SuspendLayout();

//

// button1

//

this->button1->Location = System::Drawing::Point(208, 40);

this->button1->Name = S"button1";

this->button1->Size = System::Drawing::Size(48, 24);

this->button1->TabIndex = 0;

this->button1->Text = S"button1";

this->button1->Click += new System::EventHandler(this, button1_Click);

//

// Form1

//

this->AutoScaleBaseSize = System::Drawing::Size(5, 13);

this->ClientSize = System::Drawing::Size(292, 266);

this->Controls->Add(this->button1);

this->Name = S"Form1";

this->Text = S"Form1";

this->Load += new System::EventHandler(this, Form1_Load);

this->ResumeLayout(false);

}

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

{

this->Hide();

}

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

{

this->Hide();

}

};

}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...