.net Form Problems...

Started by
7 comments, last by jeffzi 18 years, 3 months ago
I have a problem, I need to send a message in a text box whenever a statement is true. I activate the variable of this statement using a button. However, I can't seem to find a place to put the if statement. Form code example: http://www.developer.com/net/net/article.php/1378751 Scroll to bottom.
Dave G.http://www.higstudios.comProjects:Project BU - Fast action pvp MOG
Advertisement
When you say send a message in a text box, so you mean set it to something?

if(statement)
{
textBox1.Text = "Variable is true";
}

I'm not sure I understand your problem enough to help, sorry.
Basically I need to send the same message over and over and over until a button is clicked to tell it to stop. One button activates a variable, isbutton1down = true... Now I need a loop to put an if statement in it to send the message over and over again.
Dave G.http://www.higstudios.comProjects:Project BU - Fast action pvp MOG
I dont see the problem?

while(blah)
{
if(variable != true)
{
display some form of message
}
else
{
break;
}
}
You don't understand. Using the following code:

// This is the main project file for VC++ application project // generated using an Application Wizard.#include "stdafx.h"#using <mscorlib.dll>#include <tchar.h>#using <System.dll>#using <System.Drawing.dll>#using <System.Windows.Forms.dll>#using <System.Data.dll>using namespace System;using namespace System::Drawing;using namespace System::Collections;using namespace System::ComponentModel;using namespace System::Windows::Forms;using namespace System::Data;namespace cs1{   /// <summary>   /// Summary description for Form1.   /// </summary>public __gc class Form1 : public System::Windows::Forms::Form   {   private:      Button* button1;      Label* label1;      /// <summary>      /// Required designer variable.      /// </summary>      System::ComponentModel::Container* components;   public:      Form1()      {         //         // Required for Windows Form Designer support         //         components = NULL;         InitializeComponent();         //         // TODO: Add any constructor code after          // InitializeComponent call         //      }      /// <summary>      /// Clean up any resources being used.      /// </summary>   protected:      void Dispose( bool disposing )      {         if( disposing )         {            if (components != NULL)             {               components->Dispose();            }         }         Form::Dispose( disposing );      }      /// <summary>      /// Required method for Designer support - do not modify      /// the contents of this method with the code editor.      /// </summary>   private:      void InitializeComponent()      {         button1 = new Button();         label1 = new Label();         SuspendLayout();         //          // button1         //          button1->Location = Point(48, 96);         button1->Name = "button1";         button1->TabIndex = 0;         button1->Text = "Greet Me";         button1->Click += new System::EventHandler(this,                                    &Form1::button1_Click);         //          // label1         //          label1->Location = Point(184, 96);         label1->Name = "label1";         label1->TabIndex = 1;         //          // Form1         //          AutoScaleBaseSize =  System::Drawing::Size(5, 13);         ClientSize =  System::Drawing::Size(292, 273);         Controls->Add(label1);         Controls->Add(button1);         Name = "Form1";         Text = "Form1";         ResumeLayout(false);      }   private:      void button1_Click(Object* sender, System::EventArgs* e)      {         label1->Text = "Hello from C++!";      }   };}// This is the entry point for this applicationint __stdcall WinMain(){   Application::Run(new cs1::Form1());    return 0;}


Follow the code structure, Form1 runs, InitializeComponent(); initializes, where would the if statement go? I've attempted it myself, after InitializeComponent(), the application displays. While application is executing I need to check if statement handlers are met and act on it.

[Edited by - Dave84311 on January 3, 2006 8:48:43 PM]
Dave G.http://www.higstudios.comProjects:Project BU - Fast action pvp MOG
Is there some way that I could set the button down using .net forms? Not too much experience with them... buttonname->?
Dave G.http://www.higstudios.comProjects:Project BU - Fast action pvp MOG
Please use source tags.

Look up the class for w/e your using, command button or w/e it is on MSDN. That should answer your question.
Already did, didn't find much.
Dave G.http://www.higstudios.comProjects:Project BU - Fast action pvp MOG
If I understand you right you want to do something like this:

user clicks a button (button1)
send a message repeatedly
don't stop until user clicks another button (button2)

to do this you'll need to create another thread in the click handler of button1. the thread proc will send the message and check a variable to see if it should continue or stop sending the message. in button 2's click handler you can set the variable that the thread proc is looking for.

hope this helps.

This topic is closed to new replies.

Advertisement