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


ADVERTISEMENT

C Sharp :: Create Instance Of Form Into Non Form Class To Access Button / Label

Nov 23, 2014

I have a non form class. I want to update label/ check status of check box etc.. in non form class ( here resides functions that contains logic). How can i do that ?

View 4 Replies View Related

Visual C++ :: Const Char Returned By Various Functions

May 13, 2013

What is the programmers responsibility with respect to const char * returned by various functions, like the C++ string class c_str() function which returns a const char * to an c style string array? In VC++ I cannot delete a const char * which holds a string literal. Take the following code for example:

Code:
void func() //a useless function with illustrative code {
string s1("abcd");
string s2("efgh");
const char * cc1 = s1.c_str(); //c_str() returns a const char * c style string pointer
s2.c_str(); //this returns a const char *, which must be allocated on the heap right?
delete cc1; //produces run time error in Release mode in VC++
}

The problem with the above code snip is that space is allocated on the heap (or so I believe) for the const char *'s returned by the 2 calls to c_str(). The delete attempt fails and there is no opportunity to delete the space allocated by const char * because its not assigned to anything (however I see c_str() used this way extensively)

So, if I cannot delete a const char *, how does the memory get recovered? Perhaps the string objects s1 and s2 themselves have pointers to the items on the heap made by c_str() calls and they get deleted by the destructors of s1 and s2 when the function ends?

View 3 Replies View Related

C :: Getting Const Char Array From Function

Jun 7, 2013

Now I am stuck with getting const char* array from function to main.

Code:

const char* values[3];
strings_to_array()
printf("%s
", values[1]);
printf("%s
", values[2]); function: Code:
const char* strings_to_array()
}

[code]....

First, I cant get strings printed out in main.

Second, is here way to get number of such elements which array contains like higher languages have "count" or "ubound" or such?

Third, next function which need that array assumes that array of const chars* is 1 based. Can that be set in C or here are allways zero based arrays?

View 1 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

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 View Related

C# :: Update A Label On Another Form?

Jun 29, 2014

I have a label on my main form. When I menu select my settings form, I make a change to the label text on the main form but the label text does not update with the new text.

So here is my code in my settings form:

MainForm frm = new MainForm();
frm.paintMainFormThemeTitle(logoText); // updates the main form label

I may not fully understand the new instantiate key word, but doesn't this create another, new copy of my main form to operate on? And isn't that why I can't see my label text change on my main form that is previously in view?

All of the examples that I have been able to find show using this new key word to be able to access a component on another form. But to my understanding, I'm creating another, new form.

View 5 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

C++ ::  How Do Windows (or Any Other OS) Get Its Label Names Back

Feb 17, 2015

With the LoadLibrary function (followed by GetProcAddress) you can get a function or any other thing that is on DLL export. AFAIK, when you assemble one program, it loses all user-reading data (names in general). How do the OS's get them?

View 3 Replies View Related

C Sharp :: Unable To Change Label Text For Certain Location On Web Form

Dec 7, 2012

I am trying to change label text on button click, the way label.text = "string" work well before but not in this case. I tried to put this on other method and it work..it is just not working on the button that I would like to fire..

C# code :

protected void btnTotalGroupMember_Click(object sender, EventArgs e) {
string s = "there";
string[] words = s.Split(' ');
foreach (string word in words) {
Label1.Text = s;

[Code] ...

View 4 Replies View Related

C/C++ :: Why To Use Return Type For String Function As Char

Oct 6, 2012

If we are using strcpy() for copying the string. As we are passing pointers to it It will copy the string & no need to return the string .This function will finely work with return type as void then why Ritchie has used it as char* strcpy()?

View 4 Replies View Related

C++ :: How To Convert Char To Const Char

Jun 3, 2013

I have a file which contains a year and the name of an associated file to be read. I need to extract the data in the txt file and perform some calculations.

( year data file)
2004 2004data.txt
2005 2005data.txt
2006 2006data.txt

Here is what I do. I first declare "char yeardata" and then pass "2004data.txt" to it. Then I call yeardata in ifstream to extract the data inside the file "2004data.txt". The problem is that char yeardata is not constant so I cannot pass the file to it. It doesn't work if I change "char yeardata" to "const char yeardata".

Code:
int oldnewcomp_temp(char* lcfile) {
using namespace std;

int year;
char yeardata;

[Code] ....

View 12 Replies View Related

C++ :: Use Const Char As Buffer?

Feb 5, 2014

I want to use a const char* as a buffer. I am reading values from a file and adding them to a buffer. How to extract the values is simple enough. I am reading through a filestream, reading each character into a char pointer and progressing that char pointer every time. I have another char pointer marking the start positon

eg.

char *mychar = new char;
char *char1 = new char;
char *char2 = new char;
const char *constchar ;
char2 = char1;
while(filestream.read(mychar,1) {
*char1 = *mychar;
++char1;
}

Then I get this problem: constchar = mychar; // const char* = char*.

Constchar does not catch all the data in other words. At some stage some data is lost due to zeros in the data.. How can I put values into a const char and get around this problem? The const char* will //only record everything up until the first zero.

View 6 Replies View Related

C++ :: String To Const Char Error

Jan 15, 2013

I'm currently finishing up an assignment that was half written by my professor. Below in the testGrades section of code there are two errors both are the same message.

Error: no matching function for call to Grades:: Grades(const char [15])

Test Grades

//Purpose: Test program for the class Grades
// Create stu1 Grades object
// Add 5 grades to stu1 - only 3 can be stored in stu1 - other 2 discarded
// Create stu2 Grades object
// Add only 2 grades

#include <iostream>
#include <string>
#include <iomanip>
#include "Grades.h"

using namespace std;

[Code] .....

View 5 Replies View Related

C++ :: Convert Int To Const Char (for A File Name)

Jan 20, 2014

i found a lot about how to convert int to const char * but non of them explain correctly or sometimes dont even work.

Here is my code:

#include <stdio.h>
#include <cstdlib>
using namespace std;
int main () {
int i =0;
char c1 =0;
char c2 =0;

[code]....

View 15 Replies View Related

C++ :: Wild Output From Const Char Array

Nov 20, 2014

I have data that is coming into my buffer via popen (process data, not a file). Every seven records is a new set [0-6]. I am trying to 'print out the array line/element value' and 'change the value of element [2] to 0', but my loop appears to be looping through every character and not just every line?

code:

char* Data(){
char buff[BUFSIZ];
FILE *fp = popen("php order.php 155", "r");
std::string::size_type sz;
while(fgets(buff, sizeof buff, fp) != NULL)
}

[code]....

View 2 Replies View Related

C++ :: Wild Output From A Const Char Array?

Nov 20, 2014

I have data that is coming into my buffer via popen (process data, not a file). Every seven records is a new set [0-6]. I am trying to 'print out the array line/element value' and 'change the value of element [2] to 0', but my loop appears to be looping through every character and not just every line?

Code:

char* Data(){
char buff[BUFSIZ];
FILE *fp = popen("php order.php 155", "r");
std::string::size_type sz;
while(fgets(buff, sizeof buff, fp) != NULL) {
const char * cstr2 = buff;
for(int i = 0; i < 6; ++i){

[code]...

expected output:

199729173
2014-11-16 10:09:34
Found String!
198397652
2014-11-14 15:10:10
Found String!
198397685
2014-11-14 15:10:13
Found String!
198398295
2014-11-14 15:11:14
Found String!

raw inbound data [URL]

View 4 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

Visual C++ :: Create Window Form Function Using MFC Or Win32 API?

Jan 7, 2013

My setup is as follows:

There is function written C++, that must be compiled to DLL. This DLL is linked to some CAD (computer aded design) tool, that has special interface for it.

I want to add to this function some GUI (graphical user interface). So the creation of a window is necessary.

I've tried already with Win32, but without success.

The problem is that CreateWindow function requires application instance handle, that is provided by Windows itself when window is created in "normal conditions".

View 14 Replies View Related

C++ ::  Initializing Const Char Member Variable In Constructor?

Jan 23, 2015

I have a class that defines a window (a popup dialog of sorts), and I want the name of that window to be constant. The only problem is that the name of the popup needs to match the title of the parent window, and I get the name of the parent in the constructor. So how do I go about defining this member variable to be constant and initializing it with a value in the constructor?

I want to do something like this, but I know this isn't allowed:

/* class.h */
class foo {
public:
foo(*parentWindowPtr);

[Code] .....

I should mention that yes the name of the parent window is const char *, and I would like to keep it this way.

View 4 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







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