Click here to Skip to main content
11,576,354 members (60,384 online)

Managed C++/CLI

 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
eakteam15-Apr-13 6:00
membereakteam15-Apr-13 6:00 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim26-Aug-13 23:07
memberkklim26-Aug-13 23:07 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan27-Aug-13 3:47
mvpRichard MacCutchan27-Aug-13 3:47 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim27-Aug-13 18:40
memberkklim27-Aug-13 18:40 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan27-Aug-13 20:51
mvpRichard MacCutchan27-Aug-13 20:51 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim27-Aug-13 22:47
memberkklim27-Aug-13 22:47 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan27-Aug-13 22:55
mvpRichard MacCutchan27-Aug-13 22:55 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim29-Aug-13 18:49
memberkklim29-Aug-13 18:49 
QuestionC++ and xaml connection to access database code Pin
juma owori10-Apr-13 23:34
memberjuma owori10-Apr-13 23:34 
AnswerRe: C++ and xaml connection to access database code Pin
Richard MacCutchan11-Apr-13 0:48
mvpRichard MacCutchan11-Apr-13 0:48 
Questionconversion from tchar* to string^ Pin
raghunath sahoo3-Apr-13 4:38
memberraghunath sahoo3-Apr-13 4:38 
AnswerRe: conversion from tchar* to string^ Pin
ThePhantomUpvoter3-Apr-13 5:13
memberThePhantomUpvoter3-Apr-13 5:13 
AnswerRe: conversion from tchar* to string^ Pin
Richard MacCutchan3-Apr-13 5:13
mvpRichard MacCutchan3-Apr-13 5:13 
QuestionCreating a global array of labels at runtime Pin
Douglas Kirk31-Mar-13 11:30
memberDouglas Kirk31-Mar-13 11:30 
I have an old Borland C++ project that displayed a 16 x 16 group of labels displaying 0x00 to 0xFF for the purpose of diagnostics.

I am now using MicroSoft Visual Studio 2010 C++

I am having a problem creating an array of labels at runtime that the labels are accessable by other routines such as a timer interval routine

 
#pragma once
#include <stdio.h>

namespace SerialTester {
 
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

int count;
int tindex;
    
 
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
        
    Form1(void)
    {
      InitializeComponent();
      count = 0;
      tindex = 0;
      char buffer[200];
      array< Label ^ > ^ labels;
      labels = gcnew array<Label^>(256);
 
      for (int index = 0; index < 256; ++index) 
      {
         Label ^ label = gcnew Label;
         label->Size = System::Drawing::Size(25, 25);
         label->Name = "C" + index;
         sprintf(buffer,"%2X",index);
         label->Text = Convert::ToString( index, 16 ); 
 
         String^ clistr = gcnew String(buffer);
         //label->Text = clistr; //buffer;
         Controls->Add(label);
         labels[index] = label;
      }
      //
      //TODO: Add the constructor code here
      //
    }
 
    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::Panel^  panel1;
    private: System::Windows::Forms::Timer^  timer1;
    private: System::ComponentModel::IContainer^  components;
    protected: 
 
    private:
    /// <summary>
    /// Required designer variable.
    /// </summary>

 
#pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method  do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
      this->components = (gcnew System::ComponentModel::Container());
      this->label1 = (gcnew System::Windows::Forms::Label());
      this->panel1 = (gcnew System::Windows::Forms::Panel());
      this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
      this->SuspendLayout();
      // 
      //
      this->Controls->Add(this->panel1);
      this->Controls->Add(this->label1);
      this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
      this->ResumeLayout(false);
   }
 
#pragma endregion
    private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
             }
    private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
                 count++;
                 label1->Text = Convert::ToString( count, 10 );
                
             }
    private: System::Void panel1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
             }
 

 
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) 
{
 labels[tindex++]->BackColor = System::Drawing::Color::SkyBlue;
 tindex%=256;
}
};
}
 

 


So when I create the form I created an array of 256 Labels at runtime, labels[x] but in the timer1_Tick I can not access them because the array is not global.

QUESTION: How can I do this, should my creation be somewheres else so that it is global.

QUESTION: in my Borland project I simply used sprintf to format the caption of each label to 00 .. FF, but can not seem to format the text simply in upper case.

Any help from anyone would be greatly appriciated.

Or a link to a tutorial on this.

Thank you in advance
Douglas
AnswerRe: Creating a global array of labels at runtime Pin
ThePhantomUpvoter31-Mar-13 14:10
memberThePhantomUpvoter31-Mar-13 14:10 
GeneralRe: Creating a global array of labels at runtime Pin
Douglas Kirk31-Mar-13 14:38
memberDouglas Kirk31-Mar-13 14:38 
GeneralRe: Creating a global array of labels at runtime Pin
ThePhantomUpvoter31-Mar-13 15:22
memberThePhantomUpvoter31-Mar-13 15:22 
GeneralRe: Creating a global array of labels at runtime Pin
Douglas Kirk31-Mar-13 15:56
memberDouglas Kirk31-Mar-13 15:56 
GeneralRe: Creating a global array of labels at runtime Pin
ThePhantomUpvoter31-Mar-13 16:26
memberThePhantomUpvoter31-Mar-13 16:26 
QuestionPassing a C# string to C++/CLI does not show up from a CPP program Pin
sujayg26-Mar-13 0:24
membersujayg26-Mar-13 0:24 
AnswerRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
David Knechtges26-Mar-13 8:50
memberDavid Knechtges26-Mar-13 8:50 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
sujayg26-Mar-13 21:33
membersujayg26-Mar-13 21:33 
AnswerRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
Richard MacCutchan26-Mar-13 22:59
mvpRichard MacCutchan26-Mar-13 22:59 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
sujayg27-Mar-13 3:54
membersujayg27-Mar-13 3:54 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
Richard MacCutchan27-Mar-13 3:58
mvpRichard MacCutchan27-Mar-13 3:58 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
sujayg27-Mar-13 4:11
membersujayg27-Mar-13 4:11 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
Richard MacCutchan27-Mar-13 4:19
mvpRichard MacCutchan27-Mar-13 4:19 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
sujayg27-Mar-13 4:52
membersujayg27-Mar-13 4:52 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
Richard MacCutchan27-Mar-13 5:03
mvpRichard MacCutchan27-Mar-13 5:03 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
sujayg29-Mar-13 19:09
membersujayg29-Mar-13 19:09 
GeneralRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
Richard MacCutchan29-Mar-13 23:00
mvpRichard MacCutchan29-Mar-13 23:00 
AnswerRe: Passing a C# string to C++/CLI does not show up from a CPP program Pin
jschell30-Mar-13 13:33
memberjschell30-Mar-13 13:33 
QuestionDidn't Understand to logic of calculation of this program.? Pin
Taqi_Shah11-Mar-13 7:26
memberTaqi_Shah11-Mar-13 7:26 
AnswerRe: Didn't Understand to logic of calculation of this program.? Pin
ThePhantomUpvoter11-Mar-13 7:55
memberThePhantomUpvoter11-Mar-13 7:55 
SuggestionRe: Didn't Understand to logic of calculation of this program.? Pin
MicroVirus13-Mar-13 12:16
memberMicroVirus13-Mar-13 12:16 
QuestionNeed Urgent Help!! Pin
Member 933160011-Mar-13 2:18
memberMember 933160011-Mar-13 2:18 
AnswerRe: Need Urgent Help!! Pin
Marco Bertschi14-Mar-13 10:36
memberMarco Bertschi14-Mar-13 10:36 
Questionhow to call vcvarsall.bat with Process::Start method? Pin
aupres8-Mar-13 23:43
memberaupres8-Mar-13 23:43 
AnswerRe: how to call vcvarsall.bat with Process::Start method? Pin
ThePhantomUpvoter9-Mar-13 3:06
memberThePhantomUpvoter9-Mar-13 3:06 
GeneralRe: how to call vcvarsall.bat with Process::Start method? Pin
aupres9-Mar-13 13:09
memberaupres9-Mar-13 13:09 
AnswerRe: how to call vcvarsall.bat with Process::Start method? Pin
Richard MacCutchan9-Mar-13 22:46
mvpRichard MacCutchan9-Mar-13 22:46 
Questioncandidate function not accessible Pin
bonosa1-Mar-13 17:35
memberbonosa1-Mar-13 17:35 
AnswerRe: candidate function not accessible Pin
Richard MacCutchan2-Mar-13 0:01
mvpRichard MacCutchan2-Mar-13 0:01 
GeneralRe: candidate function not accessible Pin
bonosa2-Mar-13 7:59
memberbonosa2-Mar-13 7:59 
GeneralRe: candidate function not accessible Pin
Richard MacCutchan2-Mar-13 9:13
mvpRichard MacCutchan2-Mar-13 9:13 
Questionsqrt() function strange behavouir Pin
Amrit Agr28-Feb-13 23:44
memberAmrit Agr28-Feb-13 23:44 
AnswerRe: sqrt() function strange behavouir Pin
Richard MacCutchan1-Mar-13 0:56
mvpRichard MacCutchan1-Mar-13 0:56 
Questionbatch files Pin
Member 981569020-Feb-13 22:42
memberMember 981569020-Feb-13 22:42 
AnswerRe: batch files Pin
Richard MacCutchan20-Feb-13 22:57
mvpRichard MacCutchan20-Feb-13 22:57 
GeneralRe: batch files Pin
Member 981569020-Feb-13 23:11
memberMember 981569020-Feb-13 23:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 29 Jun 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid