|
I'm not entirely sure what you mean. If you're just talking about being able to switch the focused button by using the Tab button; the operating system should handle that itself.
If you're making the window from a resource, make sure the button has "Tab Stop" checked. If you're making the window from from code, or on-the-fly I believe it's called, there may be a Style flag for "Tab Stop." "Tab Stop" is what tells the OS that the button (or other control) is a valid target to set focus to when the user cycles with the Tab key.
If you're talking about changing the order that they get focus in, in Visual C++ 6.0 I know you can hit Ctrl+D to do that. (in the resource editor)
|
|
|
|
|
when i press tab key ,nothing happen.onone button have a focus.i am crete a button with check on tabstop option.
|
|
|
|
|
If you have the buttons set up with the Tab Stop option, but pressing tab does not cycle the focus, it may be part of your code intercepting the Tab key's message. Do you have any pretranslatemessage functions that may be throwing off the key press messages?
|
|
|
|
|
i wrote the following in pretranslatemessage()
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN)
pMsg->wParam=VK_TAB;
if(pMsg->wParam==VK_ESCAPE)
return false;
}
return CDialog::PreTranslateMessage(pMsg);
tab key is working but i cant view the changes.i used cxSkinbutton
|
|
|
|
|
I do not understand why you have your pretranslate message converting the VK_RETURN messages into VK_TAB, However, if that is necessary, you may have to do the same for WM_KEYUP
|
|
|
|
|
tab is working.am move to button using tab after i place tab on one button, and press enter key that show error what is a problem.
|
|
|
|
|
janpoo wrote: and press enter key that show error what is a problem.
And whats that ?
|
|
|
|
|
I made a simple programme and there is a single compilation error. i am new to inheritance technicalities so, plz anyone can interpret this error for me.
the orror is ->> cannot find default constructor to initialize base class 'baby' in function mybaby::mybaby(int,int).
i am also enclosing the code for your reference -->>
# include "iostream.h"
# include "conio.h"
class baby
{
private:
int weight,age;
char name[20];
public :
int standard;
baby(int age, int weight, int standard):age(age),weight(weight),standard(standard)
{ }
baby(int age, int weight):age(age),weight(weight)
{ }
void get_name()
{
cout<<"\n \n Enter the name of the baby -> ";
cin>>name;
}
void show_data()
{
cout<<"\n \n The name of the baby is -> "<<name;
cout<<"\n \n="" the="" age="" and="" weight="" of="" baby="" is="" -=""> "<<age<<" &="" "<<weight<<"="" respectively";
}
};
class="" mybaby="" :="" baby
{
private:
int="" mybaby_age,mybaby_weight;
char="" mybaby_name;
public:
mybaby(int="" mybaby_age,="" int="" mybaby_weight):mybaby_age(mybaby_age),mybaby_weight(mybaby_weight)
{="" }
void="" get_mybabyname()
{
cout<<"\n="" \n="" the="" name="" of="" my="" baby="" -=""> ";
cin>>mybaby_name;
}
void show_mybabyname()
{
cout<<"\n \n The name of my baby is -> "<<mybaby_name;
cout<<"\n \n="" the="" standard="" of="" my="" baby="" is="" -=""> "<
|
|
|
|
|
I may be wrong, but I would interpret the problem as a lack of default constructor in the class Baby.
You should make a function in Baby that's just Baby() without any parameters.
I believe when you make a new class, like MyBaby, that is based off another class, Baby, that it needs the base class, Baby, to have a default constructor.
This is because when you construct MyBaby, it will inherit all of Baby, and initialize using Baby().
-----
Your code is hard to follow, because I don't quite get what you're trying to do. When you initialize mybaby obj0(7,25); the variable standard is not initialized anywhere in the code. this would make obj0.show_mybabyname(); to print out garbage for "The standard of my baby is -> "
-----
also note the char mybaby_name; is not initialized as an array, and will not store a name.
I think you fail to see the usefulness in inheritance, as you have mybaby_age and mybaby_weight. When you declare a mybaby object, you can use age and weight that is inherited from the baby class to store the same values.
|
|
|
|
|
Firstly, you're using private inheritance (the default for class es); you probably intended this:
class mybaby : public baby
Secondly, the class baby has no default constructor (a constructor that can be called with no arguments). To fix this the derived class needs to explicitly call a constructor, like this:
mybaby(int mybaby_age, int mybaby_weight)
: baby(mybaby_age, mybaby_weight)
{}
Thirdly why has the class mybaby got the members mybaby_age , mybaby_weight and mybaby_name when the members weight , age and name will be inherited from the base and look like they serve the same purpose?
There are other problems but this should point you in the right direction.
Steve
|
|
|
|
|
for the second time :
please respect the forum posting guildelines[^] and use the appropriate <pre></pre> tags when posting code samples.
moreover, a huge piece of code is generaly useless if you sink the lines that really matter into a ocean of code lines that don't bring much infos to the problem.
|
|
|
|
|
i posted the code along with the problem so that someone trying to figure out the problem may understand the issue clearly by running or analysing the code himself/herself over his/her machine.
and regarding the
, i'll take care of that next time i post anything like a code.
|
|
|
|
|
I program on occasion as a past time. I'm very familiar with Visual C++ 6.0 and all my apps are made on it. Soon I will be upgrading to Vista and I am worried about compatibility. Vista says it is not supporting any C++ before 2005. I know I won't be able to take advantage of any new Vista API if I continue using Visual C++ 6.0, my question is will it run at all?
Basically, if I do get Vista installed, can I use Visual C++ 6.0 and still make applications using the XP/98 API that I've been using. Or has Microsoft basically forced an upgrade?
Thanks
|
|
|
|
|
x87Bliss wrote: Basically, if I do get Vista installed, can I use Visual C++ 6.0 and still make applications using the XP/98 API that I've been using.
Yes. You can use VC6 on Vista.
x87Bliss wrote: Or has Microsoft basically forced an upgrade?
VC 6 is no longer supported, so its other way to ask for upgrade.
|
|
|
|
|
VC6 runs fine on Vista, just make sure you install SP6.
|
|
|
|
|
Thanks for both of your responses
|
|
|
|
|
Hi
after freeing a pointer using free() is it required to set it to NULL ?
thanks
|
|
|
|
|
You should set it to NULL, freeing it doesn't do that for you.
-Sean
|
|
|
|
|
No, setting it to NULL is not required. Many people do it because it can help track down dangling pointer problems.
Steve
|
|
|
|
|
Its is not required, but its good practice to set pointer to NULL after deleting.
|
|
|
|
|
Ayman Mashal wrote: after freeing a pointer using free() is it required to set it to NULL ?
it will good programming practice if you set it NULL, it may save you many trouble
|
|
|
|
|
Hey guys,
I guess I need to brush up on my pointers a bit. How do I keep the value of a spot in a pointer from changing when the object it was set with changes? my code looks something like this:
<br />
Node someNode;<br />
Node * nodeArray = new Node[40];<br />
<br />
.<br />
.<br />
.<br />
<br />
for(int i = 0; i < 40; i++)<br />
{<br />
<br />
nodeArray[i] = someNode;<br />
}<br />
I'm looking for a way to keep my array values from all ending up as the final value of someNode.
I know this has something to do with dereferencers and stuff here and there, but it's been quite a while. I checked google and a few other places, but no luck.
Thanks,
Sean
|
|
|
|
|
Write a copy constructor in Node that makes a deep copy. That way, each assignment in
nodeArray[i] = someNode; will make a separate copy of the data.
|
|
|
|
|
That's a really handy little trick . Thanks for the help (I don't think I would have ever remembered that one).
|
|
|
|
|
Hi, I am a total beginner - first time using this forum.
I need to write a fraction calculator program that can do +,-,*,and /. The output format required is like this:
> 1/2 + 3/4
> 5/4
>2 1/2 - 3/4
>1 3/4
Essentially, I need to ask the user to input a valid expression, and be able to output the result on the screen. Notice that I have to be able to do mixed fractions. This is a huge challenge for me. I don't know how to extract key data from user's inputs.
This is an example given in class - but my professor said that we can't have the program menu driven. It means I can't ask the user numerator and denominator separately, for example. A good method/strategy to write this program is appreciated.
Note: something with me posting header files - so the ones really needed: stdlib.h, iostream, math.h, conio.h, string
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <conio.h>
#include <time.h>
#include <string>
using namespace std;
class Fraction
{
public:
Fraction()
{
num = 0;
denom = 1;
}
Fraction(int a, int b) : num(a), denom(b)
{
int div = gcd(num, denom);
num /= div;
denom /= div;
}
Fraction(const Fraction &x)
{
num = x.num;
denom = x.denom;
}
Fraction operator =(const Fraction &x)
{
num = x.num;
denom = x.denom;
return Fraction(num,denom);
}
friend ostream& operator <<(ostream& out, const Fraction &x);
friend istream& operator >>(istream& in, Fraction &x);
friend Fraction operator +(const Fraction &x, const Fraction &y);
friend Fraction operator -(const Fraction &x, const Fraction &y);
friend Fraction operator *(const Fraction &x, const Fraction &y);
friend Fraction operator /(const Fraction &x, const Fraction &y);
private:
int num, denom;
int gcd(int p, int q)
{
return (q==0)? p : gcd(q, p%q);
}
};
Fraction operator +(const Fraction &x, const Fraction &y)
{
int num, denom;
num = x.num*y.denom + y.num*x.denom;
denom = x.denom * y.denom;
return Fraction(num,denom);
}
Fraction operator *(const Fraction &x, const Fraction &y)
{
int num, denom;
num = x.num*y.num;
denom = x.denom * y.denom;
return Fraction(num,denom);
}
Fraction operator -(const Fraction &x, const Fraction &y)
{
int num, denom;
num = x.num*y.denom - y.num*x.denom;
denom = x.denom * y.denom;
return Fraction(num,denom);
}
Fraction operator /(const Fraction &x, const Fraction &y)
{
int num, denom;
num = x.num*y.denom;
denom = x.denom * y.num;
return Fraction(num,denom);
}
ostream& operator <<(ostream& out, const Fraction &x)
{
out<<x.num<<' '<<x.denom;
="" return="" out;
}
istream&="" operator="">>(istream& in, Fraction &x)
{
char junk;
in>>x.num>>junk>>x.denom;
return in;
}
char menu()
{
cout<<"Please make a selection: "<<endl
<<"="" a="" input="" the="" fraction="" a"<<endl
="" b="" b"<<endl
="" +="" add="" and="" -="" subtract="" from="" divide="" by="" *="" multiply="" c="" print="" answer="" c"<<endl
="" 1="" move="" to="" 2="" q="" quit"<<endl
="" <<"your="" selection:="" ";
="" char="" ans;
="" cin="">>ans;
cin.ignore(1000,'\n');
return ans;
}
void operation(char choice, Fraction &a, Fraction &b, Fraction &c)
{
switch(toupper(choice))
{
case 'A' : cout<<"Please enter the fraction A: ";
cin>>a;
break;
case 'B' : cout<<"Please enter the fraction B: ";
cin>>b;
break;
case 'C' : cout<<"The fraction C is: "<
|
|
|
|
|