Visual C++ :: Declaring Member Variables In Windows Form App

Sep 30, 2014

I have created a windows form project in visual studio so that I can use a windows form to interact with the game class that I'm creating, but I'm running into some problems.

For one thing, I would like to be able to call Image::FromFile() one time only during initialization, and store the result in a member variable (called mBGImage). From what I can tell, the variable needs to be of type String^ (this caret symbol is new to me, but I understand it is the "managed code" version of the standard pointer, which would look like String*).

When I try to compile the following code (located in my header file) I get the error :

"error C3265: cannot declare a managed 'mBGImage' in an unmanaged 'BSG::BSGame'".

How can I store the result of Image::FromFile() permanently in my class?

When I try to declare a global variable of type "Image^", I get "error C3145: global or static variable may not have managed type System:rawing::Image ^"

#include "stdafx.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;

[Code] ......

View 2 Replies


ADVERTISEMENT

C++ :: Using Variables To Access Objects In Windows Form

Dec 4, 2014

Alright, so I'm making a windows form with a few hundred buttons, and one button will change color based on data the program receives over a socket. This is what I have, and it kind of works, but I don't want to have to make another if statement for all 260 buttons.

void hitmiss(std::string u){
std::string^ ind = reccdata2();
if (u == "button6"){
if (ind == "1"){
this->button6->BackColor = System::Drawing::Color::Red;
this->textBox2->Text = L"hit";

[Code] .....

What I want to do is make it more like

void hitmiss(System::String^ u){
std::string^ ind = reccdata2();
if (ind == "1"){
this->u->BackColor = System::Drawing::Color::Red;
this->textBox2->Text = L"hit";

[Code] ....

But it returns the error that u is not a part of Form1.

View 3 Replies View Related

Visual C++ :: Windows Form - Create Method With Parameters

May 16, 2013

I am wanting to separate the logic from the visual, but I'm having problems when calling the method that controls the actions of the progress bar timer.

Code:

ifndef PROGRESS_BAR
define PROGRESS_BAR
class Progress_bar{
public:
void set_Progress(ToolStripStatusLabel^ label,Timer^ time){

[Code] ....

The way that I'm calling this method on Form1.h

void set_Progress(toolStripStatusLabel1 ,timer1);

Errors:

Error1error C2182: 'set_Progress' : illegal use of type 'void'h:cry_devprogrammingc++school_mediaschool_mediaForm1.h277
Error2error C2078: too many initializersh:cry_devprogrammingc++school_mediaschool_mediaForm1.h277
Error3error C2440: 'initializing' : cannot convert from 'System::Windows::Forms::Timer ^' to 'int'h:cry_devprogrammingc++school_mediaschool_mediaForm1.h277

View 3 Replies View Related

C# :: Windows Form Application Using Visual Studio To Fetch Data From Web?

Aug 19, 2014

I want to write my own application which would fetch some data from a web site. I need to parse the HTML code of the web site and get the data.

About the application:A form (main form) that will contain data arranged in rows. Some of the data comes from a web site and some of it comes from a database.The data that comes from the web site needs to be updated every few seconds so I need to keep fetching the data from the web site.The main form will contain a button "add" which when clicked will add a new row. New data can be added to this row by the user.

I am not sure what to use for this. I have been writing the application as a Windows Form Application (Visual C#) but I do not know whether this is the best choice. Should it be a windows form application or web application? Should I use something else?

View 6 Replies View Related

C Sharp :: How To Code Array In Windows Form Using Listview In Visual Studio 2008

Oct 5, 2013

This is my problem in my subject programming but i dont how to use Array in windows form ... If i run my code i want my Data in listview would not be disappear if i close the form ...?

View 1 Replies View Related

Visual C++ :: How To Assign Const Char Return Value Of A Function To Label In Windows Form

Sep 30, 2013

I am a newbie to C++ and VS ++. I have created a windows form application by dragging and dropping button, label..etc. i wish label text to be appeared as return value from a function. The function returns ' const char* '.how this returned string pointer can be used to display label text.?

View 9 Replies View Related

Visual C++ :: Triangle Class With Member Variables

Apr 8, 2015

C++
Create a Triangle class that has the following member variables:
side1 - a double
side2 - a double
side 3 - a double perimeter area

The class should have the following member functions:

- default constructor that sets the value of all 3 sides of a triangle to 0.0

- a constructor with arguments that accepts values for the three sides of a triangle (member variables) as arguments

- setDimensions - a function that allows the value of the three sides to be entered by the user through the keyboard

- testSides - a function that determines if the 3 values entered can actually be the sides of a triangle. If they do not create a triangle, print the values entered and an appropriate message
--The sum of any two side lengths of a triangle must always be greater than the length of the third side: so side 1 + side 2 > side 3 and side 1 + side 3 > side 2 and side 2 + side 3 > side 1 ( all three must be true for the 3 values to make a triangle)

- getSide1 - a function that returns the value of side 1, getSide2 - a function that returns the value of side 2, getSide3 - a function that returns the value of side 3

- getArea - a function that returns the area of a triangle: The formula for the area of a triangle (when the height is not known) is: A = sqrt (p(p-side1)(p-side2)(p-side3)) where p = (side1+side2+side3)/2

- getPerimeter - a function that returns the perimeter of a triangle: Perimeter = side1 + side2+ Side 3

- A displayTriangleInfo function that displays side1, side2, side3, area, and perimeter for a triangle object.

After testing your code for a single object, create an array of 5 triangles. Use a for loop and the setDimensions function to allow the user to set the values for the 3 sides of a triangle, test the vales entered to determine if the 3 create a triangle. If they do create a triangle than use the getArea and getPerimeter functions to calculate the Area and Perimeter for the triangle and use the displayTriangleInfo function to display all of the data for that triangle. If the three values do not create a triangle then print the 3 numbers entered and an appropriate message. In either case the loop should then move on and get the data for the next triangle from the user.

View 7 Replies View Related

C# :: Sharing Variables From Login Form To Another Form

Mar 10, 2015

I have a form with 2 text boxes (Email and Password)

The user fills in the text boxes and clicks on the Log in button. The code behind the log in button does the following, First connects to a table (Users) in phpmyadmin. Next runs a SQL query (SELECT * FROM `users` WHERE Email = '" + sEmail + "' AND Password = '" + sPassword + "'") sEmail being the variable created from the text entered in Email text box and the same for password.

Next if the record count == to 1 it opens up the main menu form and if the record count == 0 it fails and the user does not get to the main menu.

All of the above is fine and working however what I want to do is take over a variable from the log in form to the other forms.

The code is below for the sign in button as all my code is behind that (I think this may be where I'm going wrong).

public partial class WelcomeForm : Form{
public static string connStr = "server = localhost; " +
"database = ppw5; " +
"uid = James; " +
"pwd = buster;";

[Code] .....

And the Main menu form where I'd like to take a variable over with me, lets assume the variable is the UserID from the database table that I pull from the dTable I created.

public partial class MenuForm : Form {
//Call the CloseProgram class and create a new method called ClassClose.
CloseProgram ClassClose = new CloseProgram();
WelcomeForm User = new WelcomeForm();
public MenuForm() {
InitializeComponent();

[Code] .....

View 7 Replies View Related

C++ :: Declaring Variables In A Function?

Nov 12, 2012

This is a c program that is failing to compile. The error occurs in the calcLabs() function. The error called out is (btw, I'm using VS 2010): Error4error C2143: syntax error : missing ';' before 'type'

I don't understand why the compiler is not letting me declare variables in the calcLabs() function!

Code:
#include<stdio.h>
#include<stdlib.h>
void calcPercent(double *);
double calcLabs();
double calcExams();
double calcFinal();
char calcLetter(float);

[code]...

View 5 Replies View Related

C++ :: Declaring Pointers Vs Regular Variables?

Aug 9, 2013

I really do not see the difference between these two declarations:

int myvariable;
int * mypointer;

It is said that when you define a pointer, instead of containing actual data, it contains a pointer to the memory location where information can be found.

But doesn't the other variable declaration do the same? It obviously doesn't have data either. And it must be stored in a memory location as well. So I do not see the difference.

View 6 Replies View Related

C++ :: Declaring Variables (Conditional) At Runtime?

Jan 22, 2014

I am looking for a way to declare variables at run time which being a static language shouldn't happen. I will explain my situation.

I am upgrading a legacy program that modifies executables (non malicious). I am trying to add 64bit support.

It is a huge project and I understand the majority of it but my issues with how it handles the input data.

It has a struct that certain parameters of the input file is loaded into:

Code:
typedef struct DATA {
DWORD Size;
IMAGE_NT_HEADERS32 Headers;
} _DATA; *PDATA
etc, etc its a huge list.

My problem lies in the fact that I need to change IMAGE_NT_HEADERS_32 to IMAGE_NT_HEADERS64 at runtime.

That DATA struct gets called at least 110 times during runtime.

How I might tackle this? Having a conditional statement repeated that many times seems ridiculous.

View 6 Replies View Related

C/C++ :: Declaring Constant Struct As A Member Of Class

Oct 2, 2014

I would like to have a unmodifiable standard of WAVEFORMATEX defined as a member of a class of mine. Something like:

class InputTest {
public:
const WAVEFORMATEX StandardWaveFormat;
public:
void TakeInput(WAVEFORMATEX pFormat);
};

Then in my cpp file to hard-code the values:

WAVEFORMATEX InputTest::StandardWaveFormat {
//Instantiate WaveFormat -- PCM standards
StandardWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
StandardWaveFormat.cbSize = 0; //extra information sent over stream. Usually ignored in PCM format.

[Code] ....

I get the following errors starting with the header file:

Error1error C2146: syntax error : missing ';' before identifier 'StandardWaveFormat'
Error2error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

both associated with the "const WAVEFORMATEX StandardWaveFormat; " line.

Here's a link to the WAVEFORMATEX struct: [URL] .....

Then the cpp source code is probably way off. Let me know if you'd like to see the errors associated with that.

View 11 Replies View Related

C++ :: Declaring Vector Of Pointer As Private Class Member

Mar 6, 2013

Below is a working program. Please note that the vector <int*> pointer is declared as a public member of the class A.

The problem arises when I try to make it a private (instead of public). First, let's look at the File 1 below. It compiles and works fine.

File 1: main.cpp (working fine)

#include <vector>
#include <iostream>
using namespace std;

[Code].....

View 19 Replies View Related

C# :: Keypad In Windows Form

Jan 7, 2015

How to make a keypad in my windows form? Need to finish my project at school...ATM machine app..

It is just the keypad part. Do i put 10 buttons and add a textbox...

View 2 Replies View Related

C++ :: Windows Form Display Error

Mar 20, 2014

I'm fairly new to visual C++ programming in a windows form and the code displayed below works fine. However my issue is as soon as the program is running it will display "failure" on label7 as soon as the button is clicked. I understand why it is doing this as "a" is not in the textbox at this time so it reads the else line and displays the message. When I enter "a" in the textbox everything works fine and label7 changes to the right message.

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
label1->Text = "Question 1: test";
label2->Text = "A. test";
label3->Text = "B. test";
label4->Text = "C. test";

[code].....

View 4 Replies View Related

C# :: Controls In Windows Form Won't Show

Feb 21, 2015

I created a simple calculator in Win App. When I played it, the form is displayed blank. Not a single control is shown.

The only thing I've done differently is adding a Coded UI Test in my test project. This is the first time I'm going to try to add a coded UI test so I wonder if that's the cause for this.

View 4 Replies View Related

C# :: Windows Form Applications Using Methods?

Sep 30, 2014

I need to write a windows form application that allows the user to enter a credit card number and credit card type and then determines whether it is a valid number using the following rules:

1.) the first number is:

a. 4 for visa
b. 5 for master card
c. 37 for american express
d. 6 for discover

2.) passes the mod 10/ luhn check, which is calculated as:

a. from right to left, multiply every other digit by 2. when doubling a digit results in a two digit number, add the numbers to get

a single digit. ( like 6 * 2 = 12 therefore 1 + 2 = 3).

b. add all the single digits from 2a

c. add all the odd places from right to left in the card number

d. sum the results fro steps 2b and 2c

e. if the resulting number in 2c is divisible by 10, the card number is valid otherwise it is invalid.

The chapter is introducing methods so that is the main thing i will be using for each step.

View 1 Replies View Related

C# :: Retrieve Geolocation In Windows Form

Feb 25, 2015

how would i recieve the latitude and longitude from this xml

XmlTextReader reader = new XmlTextReader
("http://maps.googleapis.com/maps/api/geocode/json?address=" + postcode);

it should reurn the array

the php code is :

$url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . $search_code . '&sensor=false';
$json = json_decode(file_get_contents($url));
$lat = $json->results[0]->geometry->location->lat;
$lng = $json->results[0]->geometry->location->lng;
return array($lat,$lng);

View 6 Replies View Related

C# :: Export Windows Form To Excel?

May 3, 2015

I want to export the windows form in which text box,label and gridview ,gridview export to excel is working fine,but i need to export the whole form as such to excel.Is there any option to select Panel : This is my code:

private void btnExport_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Excel Documents (*.xls)|*.xls";

[Code].....

View 2 Replies View Related

C Sharp :: How To Keep Windows Form On Top Of Other Programs

May 10, 2012

I am using a windows application to start other processes. I am looking for a way to keep the form itself as the topmost program until it is closed, allowing the other programs enough load time.

View 1 Replies View Related

C Sharp :: Loading OBJ In Windows Form

Nov 3, 2012

I'm animating a human hand made in blender, so I allredy the hand, but I don't know how can I load this .obj to a windows form aplication that I'm working on. I need to load this .obj and animated .....

View 4 Replies View Related

C++ :: How To Use String Variable In Windows Form Application

Jun 15, 2013

How to use string variable in windows form application?

I'm using Microsoft Visual C++ 2010 Express And where to include libraries?

View 7 Replies View Related

C# :: Create A Windows Form That Acts Like A Taskbar?

Apr 6, 2014

I am trying to create a windows form that acts like a windows taskbar. So i found this on the web Link so i have tried using it.

But when i try and edit the form in the form designer in visual studio none of the changes i have made appear when i debug the form. It just appears as a blank grey box at the top of my screen. What am i doing wrong?

View 8 Replies View Related

C/C++ :: Loading File In Windows Form - Richtextbox

Feb 7, 2015

I want to load a file to rich text box component. I have this line:

richTextBox1->LoadFile("StudentaiRez.txt", RichTextBoxStreamType->PlainText);

But I get an error when I try to pass second parameter. It says : type name is not allowed.

I probably write it wrong, but I can't remember the correct way. In examples I only see that instead of -> dot is used, but it doesn't work either.

View 1 Replies View Related

C# :: How To Apply XAML File In Windows Form

Dec 7, 2014

I need to apply theme file in windows form but I can't. When I use the code below I get error because there is no System.Windows.Application

StreamResourceInfo sri = System.Windows.Application.GetResourceStream(
new Uri("App.xaml", UriKind.Relative));
var resources = (System.Windows.ResourceDictionary)Load(sri.Stream); ;
var app = new System.Windows.Application();
app.Resources.MergedDictionaries.Add(resources);

View 2 Replies View Related

C Sharp :: Display Google Map In Windows Form

Jun 1, 2012

I have to display google maps in a windows form. I managed to display the map in the form like this link: [URL] ...

But i have to display only the frame with the map in the form..not the whole page.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved