Managed C++ And C++/CLI :: Opening Forms With Buttons From Form 1 (With Conditions)

Jun 12, 2014

I'm pretty much newbie in creating a successful GUI in C++. Although, i managed to create 4 buttons that should show a certain form. Lets say, Form1 is my main form, therefore - Button 1 will open Form2, and Button 2 will open Form3..... But the conditions is - If there is a form that is already open, clicking again on the Button that should open it, will Close it, but all the forms (form1,2,3,4,5) can be enabled together.

Also, a very important note is that whenever i close a form, in any way of closing it (Not the main form) It will "save" the changes i made (Such as ticking checkboxes and so..) and won't reopen it, it will just use "Visible" i guess ?

Notes :

If i use Form2 ^form2show = gcnew Form2;

and then Form2->Show();

I will be able to simply ATTACK the button and open Billions of form2 ^_^

Although, when i use Form2->ShowDialog();

It won't let me open the form3,4,5.

Which isn't so bad, but when i exit from the form2, it won't save my changes (Such as checkboxes..)

View 6 Replies


ADVERTISEMENT

Managed C++ And C++/CLI :: Message Loop In Windows Forms

May 13, 2014

I'm trying to port a Win32 application over to Windows Forms so that I can have better graphical control over the interface. The program itself is pretty simple; in the main message loop it listens for a WM_CopyData containing a certain char array, and occasionally sends WM_CopyData itself after the user clicks a certain sequence of buttons.

I found a couple of pages discussing how to completely override the Windows Forms WndProc, but I rather like having the framework do all of the control and would prefer to only latch onto it, rather than replace it. So, what would be the best way to have a Win Forms application listen for Windows Messages continuously and execute a function upon receiving them?

If I do need to override WndProc, what is the syntax? I found the following code:

Code:

protected override void WndProc(ref Message m) {
base.WndProc (ref m);
if (m.Msg==0x4a) // WM_COPYDATA {
// do your stuff here...
}
}

But when I stick that into my main.cpp file right after int main function, "protected" gets highlighted as a syntax error with the message "IntelliSense: expected a declaration".

View 8 Replies View Related

C# :: Opening A Second Form Project Within A Project

Jan 22, 2014

I have a project which does a specific thing, like an open file dialog.

I would like to open it in a different project on a click of a button.

Also, It has a different namespace.

I'm guessing that it would involve a "using" statement to add the namespace And I will have to add reference to an *.exe or *.dll -> I'll have to look up how to make a *.dll, I know where the *.exe file is.

I have searched for a different things on Google, but I don't think that I am looking for the correct phrase (which is always frustrating...)

View 12 Replies View Related

Managed C++ And C++/CLI :: How To Create EXE File To Run It On Any Window

May 11, 2014

I have created a MFC application on Visual c++ 2012. My computer work in Win 7 - 64bits. When I see many tutorial about making the executable file which is independent on .dll library (by changing Configuration Properties ->C/C++->Code Generation->Runtime Library ->Multi Threaded Deburg (MT/d)) the compiler becomes error then I can not get the result as tutorial on internet.

Is there any other way to make the .exe file for this?

View 4 Replies View Related

Managed C++ And C++/CLI :: Class Of String Collections?

Nov 25, 2014

Is it legal in VC++ to create a class composed only of string colections. If it is how can I create it in VC++ and add it to my project?

View 6 Replies View Related

Managed C++ And C++/CLI :: Designing GUI - Ambiguous Symbol String Used

Jan 10, 2014

I am working on my project of gesture recognition using c++ and open cv and i am also designing GUI simultaneously. I am using system namespace for GUI part and cv namespace for gestures.

After compiling i am getting error as Ambiguous symbol String is used.

This the link for msdn error support : [URL] .....

View 5 Replies View Related

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

Managed C++ And C++/CLI :: How To Use Open File Dialog With Multiple Files

Dec 21, 2014

Right now, I have and application that opens a multi file dialog box. I want to take all of the files I highlight when the dialog box shows up and display a messsage box with the path and file names. This is what I have right now:

Code:
private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
String^ folderName;
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->Multiselect = true;

[Code] ....

Currently, it only shows the first file that I choose. I want to make it so that the message box shows all of the files that I select when the open file dialog shows up.

View 2 Replies View Related

C# :: How To Access User Control Form One Of The Child Form

Apr 22, 2014

I hav created mdi parent form that contain one user control. I want to access that user control from one of the child form

View 4 Replies View Related

C# :: Login Then Close Form And Open Main Form

Aug 25, 2014

This is more of a Application Design question, Let's say I have Form1(Login), this is opened from Program.cs, when the user enters details, the Event Handler makes a instance of a class, adds the data and stores the instance within Program.cs class.

So the best thing to do here, is to close the Form1(Login) and open Form2(Main) via Program.cs so that I can send the List<Login> object with my Login instance objects to said form. This form will remain open throughout the applications use as it's like the main GUI for all the programs functions.

When I close this form, I may want to save some information before the application is terminated, so I may as well store the Login instances in Program.cs anyway.

Main stepping stone: Multiple (usually around 3 max) users can login this system if need be, which will mean closing Form2(Main) and then opening Form1(Login) so that once Form1 is closed it can recreate the From2(Main) form and pass the new List<Login> to that form.

What's the best way to do this, at the moment i'm creating the Form2 instance like so:

//....
//Detect the Login form being closed
loginForm.Closed += new EventHandler(OnLoginClosed);
//...
//Open the main form when the login is closed
private void OnLoginClosed(object sender, EventArgs e)

[Code] .....

This seems like it will work and do the job, but is there a better and cleaner way? The List<Login> will be passed to Forms which are created via Form2(Main) as this information will be needed. It's just that ive been told not to use Forms for too much data containment.

View 2 Replies View Related

C :: If Statement With Multiple Conditions

Feb 26, 2013

I have tried writing a code and come across an issue where I'm not getting the desired result. It is to design a program that tells whether gas emissions from a car are too high, or permissible. The instructions are to design a code where there are four possible choices of pollutant, whether the emitted pollutant ratio is greater or less then a certain value, and the mileage on the car. All of these are supposed to determine whether the emissions are permissible or not, which would be displayed with printf. (The actual conditions of the assignment are described perfectly by the code below, so I didn't think it would be necessary to write it out. The problem is that I'm getting a logical error.) Here's the code:

Code:
#include <stdio.h>
int main() {
int poln, odr;
double gpm;
printf ("(1) Carbon Monoxide

[Code] ....

My error is that the program will proceed with the first four if/else statements, but once the 'poln' value changes to something other then one, it will not display the expected quotation.

View 3 Replies View Related

C++ :: Testing Conditions For Consistency

Dec 1, 2013

In the below program, when we have 4 consecutive spaces, the following comparison will not be equal: (x / tabstop != (x + spaces) / tabstop). If we have, let's say, only 2 consecutive spaces, then the comparison will be equal. So we know to print a tab with 4 consecutive spaces and not print a tab otherwise. How do we know this kind of division comparison would work in every case?

#include <stdio.h>
#define TABSTOP 4
int main(void) {
size_t spaces = 0;
int ch;
size_t x = 0; /* position in the line */
size_t tabstop = TABSTOP; /* get this from the command-line

[Code] .....

View 3 Replies View Related

C++ :: Best Way To Prompt User Again After Some Conditions Have Met

Mar 9, 2013

Here is a simple drinks machine programm. It basically consists in the user selecting a drink that it's presented, if the user selects correctly the number representing a certain drink, the machine shows the user what was the drink he selected, after his choise the machine asks for money insertion, if the user inserts the incorrect amount of money, the machine shows an error saying that user need to insert the correct amount of money.

My problem is that, if the user selects a different number other than those presentend, the machine displays an error saying that he needs to choose a valid drink, but i can't find a way to reprompt the user again after the error has been displayed. here's the code.

// ***Drinkins Machine*** by Roxmate
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
// initializes the variables coca, fanta, iced and drink to be used in switch function,so that the user can choose what drink he wants.
int coca = 1;

[code]....

View 5 Replies View Related

C++ ::  ascending Integer Conditions Not Always Met

Dec 4, 2013

I wrote a code to ascend any three integers. Problem is the code does not output the numbers in ascending order all the time. What am I doing wrong? here is my code :

// This program will prompt user to enter any three integers and then out integers in ascending order
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int num1,num2,num3;
cout << "Enter the first number: " << endl;

[code]....

View 2 Replies View Related

Managed C++ And C++/CLI :: Breaking Up Large Class Into Manageable Source Files?

Feb 9, 2015

I'm trying to make sure my code is written in smaller modules, so my first step is to create my initialization process in and external file to load the necessary data from external sources and set up things like the content of drop down list boxes.

My first attempt failed to give me access to the combobox items add function so I moved that code back into the form1.h file:

Code:
public:
Form1(void) {
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
void AddDate(char *date, int ID)
{
this->comboBox1->Items->Add("line 1");
}

It compiles fine, but the call to it in my Initialize.cpp file

Code:
MarketView::Form1::AddDate("abs",1);
Gives error C2352: 'MarketView::Form1::AddDate' : illegal call of non-static member function

OK, so I change "void AddDate" to "static void AddDate" and now get the error that "static member functions do not have 'this' pointers" so I go back to the "MarketView::Form1::comboBox1" situation where there is no legal syntax after "Box1 to get me to Items->Add

I've been an old fashion programmer for over 47 years. It seems as is the concept of programming computers has changed from the concepts of logic to memorization of complex syntax.

There has to be a simple answer to do this other than to write thousands of lines of code in one Form1.h file. I refuse to believe that the new programming concepts will not allow you to write code in smaller more manageable modules.

What is the proper syntax for breaking up the larger file into more manageable chucks?

View 12 Replies View Related

Managed C++ And C++/CLI :: App That Shows Pixelated Picture In Window - Reference Image On Screen?

Jan 11, 2014

I am developing an app that shows a pixelated picture in a window. I am trying to capture the image, which is composed of a number of tiles processed from a mother image, but I am having difficulty since I can't reference the image on the screen. I have placed a rectangle around the image and my understanding is that I have get the window handle for the rectangle in order to save the Image as a jpg file. In the literature there is something about a Device Context and a window handle but my compiler throws out HWND and I don't really understand the device context. I am using Windows Forms, not native code.

View 6 Replies View Related

C :: Do While Loop Fails When More Conditions Are Added

Mar 29, 2014

I'm trying to write a piece of code that calculates the difference in days between two manually input dates. The part of my code that's causing problems is:

xxx

When running the code and prompted to enter the date, if I input for example 31/12/2014, it'll be rejected and send me back to the beginning of the loop. Any date with 31 days involving months 1, 3, 5, 7, 8, 10 or 12 causes this problem. All other valid dates however work perfectly fine (e.g. 30/4/2014).

Something possibly worth mentioning is that, when I take out all other conditions from the loop, i.e.

xxx

it works fine (31/12/2014 is accepted), but of course I need all of the other conditions in there too.

View 1 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++ :: Using Enumerations Types In Loops And Conditions - Ignored In Program

Jan 22, 2014

I am trying to use enumeration types in my conditions to make a simple program that calculates area of a square or circle depending on users choice then updates the total area and outputs the total area.

The program builds fine. But it ignores all of my loop conditions and i'm not sure why.

Code:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <fstream>
#include <string>
using namespace std;

[Code] ....

View 4 Replies View Related

C# :: Switch To End Or Start Of Array Depending On Conditions?

Apr 1, 2015

I have a seat allocation algorithm for an airplane 30 x 6 seats. The plane is 'split' front (1 - 15) and back (16 -30), right (A,B,C) and left (D,E,F). I am placing passengers in window seats front right centre (15A) first then back left centre (16F) followed by (15F) followed by (16A). This will continue for single passengers middle seats then aisle.

Another part of the algorithm is to ensure parties >2 or <=6 to sit together in an empty row, if not possible the party will be split as to not have a person in the party sitting alone firstly. i.e. 6 is 3 + 3 or 2 + 2 + 2 or 4 + 2 or 3 + 2 + 1 or 4 + 1 + 1 or 3 + 1 + 1 + 1 and so.

I have got it working for one person but seating two people is a bit more difficult. I am trying to get 15A,15B then 16E,16F then 16A,16B then 15E,15F then 16C 16D and 15C 15D.

This code only allocates passengers 15 A 15B then 15C 15D then 15E 15F

//seat allocation for two people
public bool[,] seatTwoPerson(bool[,] seatArray, int startCol, int endCol, int directionX, int startRow, int endRow, int directionY)
{ //loop through seatArray section determined by parameters
//for (int col = startCol; directionX < 0 ? col >= endCol : col < endCol; col += directionX)

[code].....

View 3 Replies View Related

C++ :: Glass Rod - Get Triangle Variable To Increase When Conditions Met

Jun 25, 2012

I'm working on a project, and can't seem to get the project to get the triangle variable to increase when the conditions are met. I need this number to be accurate so I can work out the probability.

Experiments that are either too expensive or too dangerous to perform are often simulated on a computer when the computer is able to provide a good representation of the experiment. Find out how to call the random-number generator (usually a function returning a floating point value in the range 0 to 1) for your C++ system. (Look up the functions rand and srand in the library cstdlib on the website cplusplus.com). Write a program that uses the random-number generator to simulate the dropping of glass rods that break into three pieces.

The purpose of the experiment is to estimate the probability that the lengths of the three pieces are such that they might form the sides of a triangle. For the purposes of this experiment, you may assume that the glass rod always breaks into three pieces. If you use the line segment 0 to 1 (on the real number line) as a mathematical model of the glass rod, a random-number generator (function) can be used to generate two numbers between 0 and 1 representing the coordinates of the breaks. The triangle inequality (the sum of the lengths of two sides of a triangle are always greater than the length of the third side) may be used to test the length of each piece against the lengths of the other two pieces.

To estimate the probability that the pieces of the rod form a triangle, you'll need to repeat the experiment many times and count the number of times a triangle can be formed from the pieces. The probability estimate is the number of successes divided by the total number of rods dropped. Your program should prompt the user for the number of rods to drop and allow the experiment to be repeated. Use a sentinel value of 21 to hale execution of the program.

Code:
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cfloat>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
using namespace std;
float doBreak (float, float);
float doProbability (float, float);

[Code] ....

View 11 Replies View Related

C++ ::  String Subscript Out Of Range / For Loop Conditions All Look Good

Apr 4, 2014

Im having a problem with my sneaky hangman game I feel like im really close just getting an error I can't fix. When I run it, it says something like string subscript out of range when I goggled it. it says im searching past the bounds of what it should be or something.

Also a dictionary.txt file is needed to run the program

code: [URL]

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int guessesUsed = 0;
int wordlength;

[code]....

View 3 Replies View Related

C++ :: Random Number Generator Isn't Working Correctly - Ignoring Conditions

Apr 12, 2014

My random number generator isn't working properly. It seems to be ignoring my conditions when it compiles and I enter the input. The program is supposed to accomplish the following.

1. Let the user input how many digits he or she would like to have in the random numbers.

2. Let the user type in how many of the numbers that he or she wants.

3. It will then generate the numbers.

4. It will display the minimum or maximum number it can be with the number of digits the user entered. And display the number of numbers that the user wanted. It also is supposed to check and output only up to the max of that digit range.

so if someone entered they wanted a digit of 1(1-9) but said they wanted 300 numbers it would only output 9

Example:
the user says that she would like 3 digits to be in the numbers generated. So it will output numbers between 100 and 999. then the user says that they would like only 3 random numbers. So it will output three random numbers in between 100 and 999. Also all of the numbers need to be unique so they can't output more then one of the same number.

I am not sure why but it ignores my conditions. Ill type that I want 7 but it just outputs a bunch of random numbers. it dosen't stay in the ranges.

Class file.

Code:
#include "stdafx.h"
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
#include <conio.h>
#include "TargetGen.h"
using namespace std;

[Code] .....

View 6 Replies View Related

C# :: Calling Method In One Form From Another Form?

Dec 6, 2014

I have a program which when a button is clicked on Form1 it runs a vision system operation on an image in a window on a Form1. There are also other buttons on the Form1 which can change things like threshold levels so the inspection can be run again with different settings. It all works fine but I want to change it to remove the buttons from Form1 so that when the user clicks on a button on Form1 it opens up another form, Form2, and all the buttons which were on Form1 are now on Form2 and the image analysis should run on Form1 when the buttons are used on Form2. I have taken over all the code from Form1 to Form2 and I'm trying to make this happen by creating a new oject on Form1 which calls a method on Form2 which contains the code which was in Form1 and called when the button was clicked on Form1 - not working!! I have a constructor in Form2 but I think I have become monumentally confused.

This was the code which was on Form1 when the inspection button was clicked.

private void cmdInspectOnce_Click(object sender, EventArgs e)
{
iReturn = VisionSystem.InvModeSet(IpeEngCtrlLib.I_MODE.I_EXE_MODE_ONCE);
if (_imgEngines!=null && _imgEngines[0]!=null)
_imgEngines[0].cmdInspectOnce();//InvModeSet(IpeEngCtrlLib.I_MODE.I_EXE_MODE_ONCE);
}

View 1 Replies View Related

C# :: Selection From 1 Form DatagridView On Second Form

Sep 5, 2014

I have 3 Windows Form: frmMain, frmFirstForm, and frmSecondForm.

frmMain is the form that will load when the application is started with 2 tabs to access frmFirstForm and frmSecondForm.

Here's my problem:

After making a selection from a combobox on frmFirstForm, I would like a datagridview header to change based on the selection made. Here is a list of items on one combobox: Item1, Item2, Item3, Item4. When somebody chooses Item one, the header on the datagridview on frmSecondForm should display: JohnItem1, PaulItem1, BradItem1 and so on. Those items are not part of the comboboxes, but they will be shown as header text on the datagridview on the second form either automatically or after clicking OK from frmMain. There's no OK button on frmFirstForm, but on frmMain.

The only code I have right now is the if statement on the form load on frmSecondForm. Here's what I have:

private void HeaderTextLoad() {
if(comboboxonfirstform.text = "Item1") {
datagridview1.Columns[0].HeaderText = "ItemJohn";
datagridview1.Columns[1].HeaderText = "ItemPaul";
... And so on.
}
}

View 1 Replies View Related

C# :: How To Get AI To Look For Specific Buttons

May 5, 2014

Basically I am creating a game and I need the ai to look for specific buttons. At the moment this is the code I have, and what it does is it makes the ai look for any random button that has't already been clicked.

Code:

private Button look_for_spaces() {
Console.WriteLine("Looking for spaces");
Button b = null;
foreach (Control c in Controls) {
b = c as Button; // performs a cast

[Code] .....

Now what I'm trying to do is make the ai go through 4 searches in steps instead of looking for any button. I want it first to look for buttons 1, 2 and 3, if there's a space in any then it will be clicked but if all of them are already clicked it will look for spaces in buttons 4, 5 and 6 and so on if that makes sense. But i'm not too sure how I would do it.

View 3 Replies View Related







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