C# :: Managing Multiple Button Events Using Array
Apr 19, 2014
I'am creating a 10x10 graph of nodes. Each node is a button object.
Instead of coding the click event procedure for each (As each button will do the same thing when clicked), how would I implement a single click event method for all of the buttons within a Button array.
Picture of the 10x10 grid
EDIT: Each button would return its location (x,y) to the node class.
I'm attempting to write a basic Dijkstra's algorithm using a 10x10 grid.
View 1 Replies
ADVERTISEMENT
May 23, 2012
How to use button with right click events in mfc?
View 1 Replies
View Related
Apr 15, 2013
Is it a common thing to do? Does this tutorial seem legit .... [URL] .....
View 9 Replies
View Related
Feb 16, 2014
How do I detect left mouse button down and up events on the 'Close' option of the system menu that appears when the mouse is clicked on the top left corner of a form?
View 1 Replies
View Related
Oct 24, 2014
For now the app creates a new DateTime property which is binded to a label and shows the user the current time. Eventually I want to have the ability to select the timezone you are in, change font/background colors/etc etc... But that is all in time. My current step that I am trying to implement is having a button click (Binded to an event method) change screens. I find it hard to explain in words, but I would like the same Window to be used, just have different functions on the other when the button is clicked. So for example...
The only way I have found to do this so far is to create a whole new form or create tabs. While those are all good and have their place. I know that I need to start breaking up my code into classes, I am developing a bad habit throwing everything into the MainWindow Class...
Here is the code if needed:
XAML:
<Window x:Class="ClockApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="MyWindow"
Title="Alarm Clock App" Height="180" Width="360" Visibility="Visible" ResizeMode="NoResize" WindowStyle="ToolWindow">
[Code] ....
View 6 Replies
View Related
Feb 27, 2014
Organizing and managing a large database of words building semantic relationships between them.
Questions:
1. Is C++ a good language to manage large databases
2. Is there a better language/software solution that can easily manage my database but return output that I could use in C++
3. Is C++ a good language for securing and encryption? If not, where should I look?
View 2 Replies
View Related
Jul 28, 2013
My assignment is to write a system for managing a radio station. The code is composed of four classes:
Song: each song has a name, a composer and a singer, and has a few segments: INTRO,VERSE,CHORUS,TRANSITION, while each represents a different length string of chars.
Playlist: a multiset of songs, and a pointer to a RadioStatistics instance (see below).
RadioStation: a set of Songs (will represent the station database), and a list of Playlists, each playlist holds a few songs from the database.
RadioStatistics: can only be instantiate once, this object gather statistics; it has two maps: one that counts how many times a song was played, and second that counts how many times each singer was played. (the key is the song/singer name, and the value is the counter).
The RadioStation has a constant that defines a limit to how many times a song is allowed to be played. whenever a song reaches this limit (meaning, it was played too much), the program needs to skip to the next song in the database.
so, I run this test from main, and the program crashes (or more accuratly get stuck, since the console stays open and the program keeps working until I stop it).
I made a few changes and run the debugger a few times, and was able to focus on the problem.
Song.h:
Code:
#ifndef SONG_H_
#define SONG_H_
#include<iostream>
#include<string>
[Code] ....
I ran a step by step debugger, and found out the problem lays with line 90 in RadioManager.cpp, when the while loop runs its fourth iteration. It crashes when it tries to dereference the iterator, while it points to the fourth playlist in the list.
And here's some more weird stuff: when I comment out line 73 in main.cpp - it works perfectly fine! (line 73 in particular! commenting out any other line in main.cpp didn't worked around the bug!)
View 13 Replies
View Related
Jun 10, 2014
I have an code that makes form window + button bet bigger when pressed each time, but it runs endless till out of screen,
code:
{
int S1 = 300;
int S2 = 0;
[Code]...
make it so it runs only each time i press the button?
View 2 Replies
View Related
Feb 24, 2014
I have a program that has been broken into View/Model/Control plus another class to handle RS232 output.
When the View requests something to be sent via RS232, an event is sent to the control, which then raises an event for the serial class.
Is there a way of using only one event without the serial knowing anything about the view?
If there was, I'd imagine it would be something with Lamdas.
View 2 Replies
View Related
Mar 16, 2014
I want to build a library using c++ which will serve as an abstraction layer between applications and low-level process. The library will provide some APIs for the applications for some purposes.
For example the low-level process, may send an indication to the library i.e. raise an event, and the library in turns send it to all the applications, which have their registered callbacks to this library.
Any example for the previous scenario in c++ using boost library or the standard library will be perfect in Linux environment? The example that I want is: Generate event from a process and pass it to the library, then let an application register callback to the library.
Initially I know in Linux, I may use signal to send events, but my plan is to have a something more general not tighten to a specific OS.
View 1 Replies
View Related
Sep 28, 2013
class test {
private:
string name="";
public:
event void changedname();
void setname(string value)
[code]....
i get error about 'a' and 'b' not be a class. but using a template can i validate these code?
my problem is that i don't know how to use objects outside of functions / these is polymorphism, but not accepted by C++
View 12 Replies
View Related
Dec 28, 2014
In my week long quest to understand delegates/events, all the contrived examples have made my understanding worse. I've been trying to make this simple console project work, where you have a Person, Phone and Switchboard class. My thinking was, that the Phone object would broadcast to any SwitchBoard that's listening, the SwitchBoard would broadcast to the proper phone on the other end and the phone would do the same for any person that's listening.
This is what I have so far, and after adding the SwitchBoard.
class Phone {
public delegate void IncomingCallHandler();
public event IncomingCallHandler IncomingCallEvent;
public delegate void OutGoingCallHandler(Phone p);
public event OutGoingCallHandler OutGoingCallEvent;
[Code] ....
View 8 Replies
View Related
Mar 28, 2012
I have looked on this website and stumbled across this link: [URL] .....
My question is can how do I use that code when im console programming?
When I try this code I get errors.
" line |14|error: initializer expression list treated as compound expression|"
" line |17|error: a function-definition is not allowed here before '{' token|"
"line |40|error: expected '}' at end of input|"
Code:
#include <iostream>
using namespace std;
int main() {
int MouseMove(100,100);
void MouseMove (int x, int y ) {
[Code] .....
View 4 Replies
View Related
Apr 20, 2012
I have written ( using VS2008 c++ ) a windows service which sends information about PC usage to a central database, as part of a PC availability setup. I have been asked to add the following functionality to it:
1) What applications are most used, when and how long for, and
2) What web sites are being accessed, again to find the most popular etc.
My main question is, what functionality is there to trap application start / close events from within my service ( just need the application name ), and secondly I am already using sockets to send information to a PHP script on a server, the best way to see what web pages are being accessed is to build in a packet sniffer, and extract the information from that.
View 6 Replies
View Related
Jun 17, 2013
I have a main CWnd class called CMainWnd which is created like this:
Code:
DWORD dwStyle = WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN ;
...
CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS), L"", dwStyle, rect, parent, NULL, NULL);
And I draw smaller windows on this main window with a CWnd-dervied class called CClientWnd, which is created like this:
Code:
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER;
...
CWnd::Create(AfxRegisterWndClass(CS_DBLCLKS), L"", dwStyle, rect, parent, NULL, NULL);
In the main window I draw lots of background stuff using a memoryDC and BitBlt(). In the child window, I actually am not drawing anything, I just created it to have events like mouse over, etc. In the child window when the mouse is over the window I bring up a pop-up window. This works unless my mouse is over any parts where something is drawn in the main window, then the popup just flickers constantly. Why is the main window affecting my mouse over events if I am not handling any such events for it?
View 1 Replies
View Related
Jan 16, 2015
I am trying to do this:
Read a text file which is like:
2
2 10 1 2 7
3 8 3 7 7 10 7
The first line indicates how many paths exist in my design.
The second and third lines are those lines(the first number indicates 2 pairs, so 10,1 and 2,7 are 2 pairs)
The first element in the third line indicates 3 pairs and the pairs are 8,3 and 7,7 and 10,7.
I have been able to read the text file and store these into ONE array. However, I need to divide them up and have each line in a seperate array.
So for example
array alpha to contain 10,1 and 2,7
array beta to contain 8,3 and 7,7, and 10,7
How would you do this?
View 4 Replies
View Related
Oct 13, 2013
int statarray[] = {61, 66, 47, 50, 372,
62, 66, 47, 50, 372, 50, 54, 64, 45, 331, 49, 52, 58 69, 356,
58, 80, 50, 48, 389, 76, 64, 60, 59, 401, 76, 59, 57, 54, 422,
53, 45, 45, 52, 253};
I'm getting a bunch of different errors with this, how do we do this?
View 2 Replies
View Related
May 29, 2014
I am trying to create n number of files (n being an integer), by passing the name through a character array (and obviously changing its value at each iteration). But the problem is that the program compiles and executes but not a single file is created.
Here is my code snippet.
void file_phipsi(int m)
{
int a=0,n=0;
char *str1;
[Code].....
View 4 Replies
View Related
Jan 11, 2015
I have array of 100 elements and I'm trying to write elements which index is smaller than the index of the maximum element of the array. My problem is that I can't determine how big this array should be . I found which is my biggest index.
Code:
#include <visual_2013.h>
#include <stdio.h>
#include <stdlib.h>
#define DIM 10
void enterArray(int x[]);
void array2(int x[]);
int maxAndIndex(int x[], int n, int *index);
int main()
[Code]...
View 3 Replies
View Related
Dec 17, 2014
Write a program using inheritance allow user to enter grades of his students 5~8 students as a base class and compute the sums for each students in derived class and compute the average of sums in another derived class. I created 3 classes in 1 header file and 1 cpp file how ever i cant seem to get the sum or the average to show up on execution time
header file
#ifndef GRADES_H_INCLUDED
#define GRADES_H_INCLUDED
class Grades {
public:
Grades()
[Code] .....
View 2 Replies
View Related
Oct 9, 2014
My function "MatrixMul" returns an int array with multiple values Let's say, res[0] and res[1]
When I'm calling the array in a for loop for multiple times, and when I'm storing the results in another array, in each iteration the results are over-written with the new results.
If the first call returns [0,1] the array will store [0,1] at index [0] and [1], which is fine, but when I'm calling the function again, the new results are stored at the same indexes [0] and [1] How can I avoid that?
The code is:
class Hill_Cipher
{
string AtoZ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public string Hill_Cipher_Enc(string input, int[,] key)
[Code].....
For example, my outPut contains the following: "TH","IS","AT" when I'm calling the function with the first element of array "TH", it converts "T" to its equivalent number and apply some calculations and same with "H". Let's say the final answer is 20 for "T" and 30 for "H". The problem is that every time, encChars will store the values at index 0 and 1: encChars[0]=20 encChars[1]=30 When I call the function again it will store the new values at 0 and 1.... That's because I'm not changing the index value for encChars on each call, so how do I do that?
View 1 Replies
View Related
Feb 16, 2014
I am having issues getting this working. This is a simple program that is designed to ask a user if he would like to enter a string, if yes, the user is prompted to enter it and its stored in a char array. User is then asked if he wants to enter another string... Once user responds no, the program outputs the strings and the program ends...
Note: I'm using in.getline(myarray[i], MAX, ' '), to avoid white space problems if user enters a space. Lastly I would like the option of letting user enter any number of strings, but how would you do this when declaring the 2 dimensional char array?
#include <iostream>
#include <string>
using namespace std;
const int MAX = 81; //max char is sting is 80
int main(){
string y_n;
bool go = true;
[Code] ....
View 2 Replies
View Related
Jul 31, 2014
I want to develop an application which can host multiple views of explorer (window), where as each window is totally separate from others. So that I can have multiple desktop views through my single explorer. Any built in feature in .NET ?
View 11 Replies
View Related
Aug 17, 2014
how to make subroutines and return multiple arrays.Before that, i wrote my program on matlab. could my program to be structured as following?
<header>
initial value of program;
subroutine1() {
calculating the first work;
return 2 or 3 arrays;
[code].....
View 14 Replies
View Related
Mar 21, 2014
I've been working on a function that works like a pipeline of a shell but receives a directory, go over it an search for every file to send it to a filter, something like this in bash "cat dir/* | cmd_1 | cmd_2 | ... | cmd_N", The only problem i have with the code is the redirection of the pipe descriptors.
Code:
int main(int argc, char* argv[]){
char** cmd;
int Number_cmd;
cmd = &(argv[2]); /*list of cmds*/
Number_cmd = argc-2; /*number of cmds*/
}
[code]....
The code is seems to work fine except when i run it with more than one command in example ("./filter DIR wc rev") in this case it returns
wc: standard input: Bad file descriptor
wc: -: Bad file descriptor
0 0 0
View 2 Replies
View Related
Jul 15, 2013
I'm using multiple C++ files in one project for the first time. Both have need to include a protected (#ifndef) header file. However, when I do that, I get a multiple definition error.
From what I found from research, adding the word inline before the function fixes the error. Is this the right way to do this, and why does it work? Should I make a habbit of just declaring any function that might be used in two .cpp files as inline?
View 5 Replies
View Related