C :: How To Create Menu Selection With Arrow Key
Jun 22, 2014I'm looking for an example of menu selection with arrow key i'dont know how to create one o think i should use CODE ASCI but what method I should follow
View 1 RepliesI'm looking for an example of menu selection with arrow key i'dont know how to create one o think i should use CODE ASCI but what method I should follow
View 1 RepliesThis is what I have so far, it gives me a nice menu to select from and it all works but after I make a selection it closes the program. I tried to return to it but it won't work for me
#include <stdio.h>
int main() {
int choice;
int deposit;
int balance = 500; {
printf(" CHOOSE FROM THE FOLLOWING
[code]....
My program uses a menu that easily facilitates a person to navigate trough out it but im stuck on a part and I cant go to menu3 with the arrows (only use c code not c++)
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
void sleep(long int interval) {
for(int i=0;i<interval*1000;i++);}
[Code]...
I am working on a database project, which can store (initially) 10,000 marksheets with following capabilities
1) new entry
2) edit/modification of entry
3)delete entry
4) separate Departements ( BBA, BCS, M.Phil, Phd., etc.)
5) can store data on files ( initially, all data is stored in a single file)
Now, I want to create a menu, in which i can use arrow keys to navigate through the menu and use Enter key fo selection.
What should i use in it?? The project is only on C language.
Basically we have to create a system for loan amortization for vehicle company. The code is still in its development stage and I am having problems with one of the menu selections. all the other menu selections work fine except for menu selection 3. I'm quite stuck on it. When I run the program everything goes well except when I enter 3 at the main menu, it just exits the program instead of going to the screen for the menu selection.
#include<stdio.h>
#include<conio.h>
#include<string.h>
main() {
char un, /*username*/
name, /*customer name*/
[Code] ....
So, I was trying to code a menu for a personal movie database. But I'm having some problems.So, this is what I did,
Code:
#include<stdio.h>
int main();
{
do
{printf("Menu
[Code]...
But this is not working.Furthermore I would also like add a sub menu.
I'm trying to make a selection process using roulette wheel selection. To do this I created two matrix, one random probabilities and one increasing probabilities. The idea is to choose a number according to the random probabilities. Here is the code I've written.
#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
int main (){
float select [5], prob [10], mat [5];
int c, r, z;
cout.precision (2);
cout << "Random Number:" << endl;
[Code]...
The result I got is as follows:
Random Number:
0.0013 0.56 0.19 0.81 0.59
Increasing Probabilities:
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Selected Column:
0
5
6
8
9
The evaluation doesnt seem to start from c=0 again. The selected column should be 0, 5, 1, 8, 5.
I am trying to write a menu program that will be broken down into a series of calls to function for each of the menu items. Two of the menu items will be simple programs which I wrote.
I want two of the functions to run one of the two programs I am trying to include as items in the menu.
So far I am only familiar with variables, loops, if statements, and I just learned how to write functions.
The problem I am have is that I don't quite understand how to write a function that will run one of the two programs. Also I am having a hard time writing the program in away that would allow the user to select the menu items.
I'm creating a program that is based on a menu system. Basically each menu is its own user-defined function. The problem is at each menu you can input 'b' to go to the previous menu. I just have it call the function of that menu.
However, do the functions need to complete themselves eventually? If I just keep calling functions will I just keep going further and further deeper into ever running functions?
If so how do I avoid this and yet keep the option to go back to a previous menu/function?
I understand that the dot operator is:
Code: a.b "a"
is the actual object (not a memory location) and "b" is the member. I also understand the arrow to mean:
Code: a->b "a"
is a pointer to a struct and "b" is it's member so "a" is dereferenced then "b" is given.
Here is where I get a little confused. I have a class:
exampleclass.h
Code:
#ifndef EXAMPLECLASS_H_INCLUDED
#define EXAMPLECLASS_H_INCLUDED
class exampleclass{
[Code].....
Also if ec1 had a public variable and I wanted to access it would it be referenced the same way as the method I call in ec1?
I have created plane as floor and sphere as ball. I used physics equations to it and ball falls under gravity. Now i want to attach visual arrow to this ball which moves with it according to velocity direction. If ball bounces then direction of velocity is changed so does arrow.
View 1 Replies View RelatedSo I have assigned this method to each TextBox. It works fine pressing the left arrow and right arrow, but for some reason will not work using the up and down arrows. I have tested the string, using MessageBox and it is correct...the loop even proves it finds a matching TextBox. It is correct as in it displays the TextBox name it should be selecting but doesn't. I have no clue! Now the first select method is the one I want to use, I used the loop to check to see if it was even finding a match. It does find it but doesn't select it. The naming convention for my text boxes is r1c1 where the first number indicates the row and the second number is the column. There are 9 rows and 9 columns. This SHOULD be working but for whatever reason it is not. I've even put a message box inside the if statement for the up and down keypress check and it pops up when i press up or down.
private void Navigate(object sender, KeyEventArgs e) {
TextBox input = (TextBox)sender;
string nextBox = input.Name.ToString();
if (e.KeyCode == Keys.Left) {
if (int.Parse(nextBox.Substring(1, 1)) > 1 && int.Parse(nextBox.Substring(3, 1)) == 1)
[Code] ....
So, I've been working on a project recently, and the only thing remaining to do is a detector to whenever down arrow key is pressed. The down arrow key can only trigger when a certain check box is checked and this will have to work with a timer either. The problem is that how to make the down arrow key press detector(I've got the check box and timer ready tho).
View 10 Replies View RelatedI'm trying to implement this on ubuntu, to compile and run only under ubuntu.
I found 100s of other attempts at answering the general question of arrow key press in c++. Nothing solid.
Some recommend using the Readline for the functionality I am trying to implement, but I need to stay clear of GNU licences if I can for this project. And some tips only work on projects for windows machines... for example the conio library.
For linux there may be the option of using the ncurses library which I will take a look at, but I am stubborn and want to implement this myself. It should be an easy straight forward thing to do, which is why I am a bit frustrated at the moment.
Here is my test code so far.
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;
[Code] ....
So! This works... 80% of the problem is solved. If you compile this, g++ under linux, ubuntu in my case, and run. Each keystroke reveals the correct key numbers.
q=113
w=119
when I click on the up key I get,
up = 279165
I thought, I can use this number is a if(int == '279165') to detect the up key.
I was not so lucky... this int is not behaving like an int!
So I modified the code to see it I could carry out an int operation on this number.
I added a 100000 to int i.
cout<< i + 100000;
Code:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;
[Code] .....
Compiling and running this, and pressing the UP key gives the following number.
100027100091100065
Some some sort of array, something like, [27][91][65].
I tried all ways to access these individual numbers, actually the third one for comparison purposes, but no luck.
For completeness sake I list the other arrows.
UP = [27][91][65]
DOWN = [27][91][66]
LEFT = [27][91][68]
RIGHT = [27][91][67]
A little further digging shows that these numbers are derived from the representation of a "multi-char" constant, the data type given when pressing special characters...
Now here is the main problem I have, I can find ANY decent documentation on how to handle and play with "multi-char" .
I have recently come across a function call that I do not understand. It uses the arrow operator for a function call, twice, and I don't understand.
Code:
static inline void b43_write32(struct b43_wldev *dev, u16 offset, u32 value)
{
dev->dev->write32(dev->dev, offset, value);
}
I see that the function itself does not return anything but calls another function. The main difficulty I have is with the "dev->dev->" operator, where dev, I expect is a pointer to a structure.
I am doing a project for a class which involves making a game where there is an arrray that holds a player (you) and a zombie (comp). The player is suppose to be able to turn clockwise or counter clockwise, move forward, and backward and shoot. Im having trouble trying to rotate the char in an array. I am also trying to switch from using the W,S,D,A to the arrow keys but doesnt seem to work.
#include <iostream>
#include <windows.h>
#include "color.h"
using namespace std;
using namespace Petter;
const int COL = 15;
void initBoard(char[][COL], int, int);
[Code] ....
I have two menu items. When item 1 is disabled, I want item 2 to be disabled as well. In the OnUpdate handler of menu item 1, I have tried to use "t_pMenu = pCmdUI->m_pMenu;", "t_pMenu = pCmdUI->m_pSubMenu;" and "t_pMenu = pCmdUI->m_pParentMenu;" but I always get NULL t_pMenu. How can I achieve this purpose?
Code:
void CDummyView::OnUpdateMenuItem1(CCmdUI* pCmdUI)
{
if(m_bShowMenuItem1) {
pCmdUI->Enable(TRUE);
[Code]....
#include <iostream>
using namespace std;
int main(){
return 0;
}
this is my main functions. I have problem making a program that prints in asterisks an oval, arrow and a diamond using for loop and if statements.
Selection sorting a 2D array . Let's say i have an array like
1 2 3 4 //4 elements
1 2 // 2 elements
1 2 3 4 5 //5 elements
1 2 3 //3 elements
1 //1 element
And I want to do a selection sort it in descending order which the row with 5 elements will come first then 4 then 3 and so on. So that it would look like this
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Code:
void selectionSortDescending(int list[MAX_ROW], int size){
int temp;
int walk;
int curr;
int large; // index of the largest element
for (walk = 0; walk < size - 1; walk++)
[Code] ....
I have my ListBox working and I'm able to select the items I want to keep. I'm trying to now get the Invert of the current selection for the items to delete.
I tried using:
if (lstLinePatterns == null) return;
for (int i = 0; i < lstLinePatterns.Items.Count; i++)
lstLinePatterns.Items[i].Selected = !lstLinePatterns.Items[i].Selected;
But
.Selected
is giving me an object error.
Is there an easy way to just inverse current selection?
Current Code:
private void btnSelectNonRvt_Click(object sender, EventArgs e)
{
// Unselects any Items to Prevent Infinite Loop
lstLinePatterns.SelectedIndex = -1;
[Code]....
So i'm trying to implement the selection sort algorithm and it seems that the code is fine but...
Code:
#include <cs50.h>
#include "helpers.h"
void
sort(int values[], int n) {
// TODO: implement an O(n^2) sort
[Code] ....
I keep getting these errors and i don't understand why:
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
How can you tell what button(yes/no) on a message box is clicked? Below is what I have right now but I am getting errors.
if (MessageBox(NULL,"The Message", "The Title", MB_YESNO) == IDYES){
do something
}
I'm trying to transfer the font parameters from a richtextbox to a label but the label doesn't support .SelectionFont.
System.Drawing.Font currentFont = richTextBox.SelectionFont;
System.Drawing.FontStyle newFontStyle;
newFontStyle = FontStyle.Regular;
expanderLabel.SelectionFont = new Font(
currentFont.FontFamily,
currentFont.Size,
newFontStyle
);
I need to select a random item from an array but I am going to have more than 1 such array so I created the random value selector as different function. Right now I am getting a correct value for random function but when I try to access the array value associated with that index I get 2 digits which does not make any sense.
#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int randFunction(int size);
int main() {
int heapsize;
[code]....
How to sort the last name instead of first name. Everything works so far and sorting is done on the first character.
#include <iostream>
#include <cstring>
using namespace std;
void sort(int, char[10][40]);
int main() {
char twoD[10][40];
int input = 0;
[Code] .....
I have a comboBox that I created in XAML using using binding and I'm unable to get the selection. I've tried everything I could think of or find on, but no luck.
Here's the relevant XAML and C# code for the comboBox:
<ComboBox Name="projSelected" Selectionchanged="projSelected_Selectionchanged" HorizontalAlignment="Left" Margin="424,27,0,0" VerticalAlignment="Top" Width="199" DisplayMemberPath="proj"/>
projSelected.ItemsSource = DAL.projectList;
Then here is where I try to check the selected value:
private void projSelected_Selectionchanged(object sender, SelectionchangedEventArgs e) {
projectDataList.ItemsSource = null;
projectDataList.Items.Clear();
[Code] ....
And here is my output in the MessageBox that I'm using to test the code:
Quote
project=Website selected=employeeProjects.project