|
Hello everyone:
i have a modal dialog which contains many controls for user to operate on so as to continue the work.Now i want to let it embed into the frame,not floating on the screen any more,just like a formview.some one told me to change the dialog as a formview,but there are quite a lot of code i have wrritten based on that dialog.
should i changed it in to a cformview?if that,how can i create it to fit the frame,because on the left side is a big dlgbar.
i am sooooo confused now.is there anyone who can help me?anhthing will be appreciated ,thankx in advance!!!!!!!!!!!
|
|
|
|
|
A formview is basically a surface that you can add controls to like a dialog box, but within a normal windows app, which means you can have tool bars, menus, etc. I'd say that the best thing to do is to make a new formview application, and see if you can copy and paste your control layout between projects. That may work. If not, I'd certainly suggest that a formview is what you need to do anyhow, painful as that may be. You should be able to copy a lot of the code though, just handle the same events, and copy and paste your code between them. If you know how to plumb the MFC message handlers yourself, you can probably do it all by hand.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks for your reply,Christian Graus
can you give me some samples or articles on how to create it ,especially on how to set it the proper size and position?
|
|
|
|
|
I'm not sure what the issue is ? Use SetWindowPos to change the size of your window, and it's position, if required. Why do you need to do this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thank you.just as i have referenced before,i want my modal dialog not to float on the screen any more,but to be a part of my frame,which can be resized like a formview. howerver, i don't know howto create it use a function like DoModal().Is there any one who can help me?Thanks in advance!
|
|
|
|
|
You can't, because it will be embedded in your frame. Your best bet would be to use a formview, and then resize the dialog when a button is pushed to show/hide the section that you're wanting to put in your dialog. To do this, either put the stuff you want to show/hide at the far bottom or far right of the form (so it's easy to size the form to hide it ), or put everything else onto a panel, so you can resize the panel to cover/show the controls in question at the top or left of the form. The second way is better, then you can get everything else to autosize on the panel, and only have to manually move one control.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I wrote a windows program using VISUAL C## and MFC, using CEditView.
I find I need to have a scrollable dialog box.
Is this possible in CEditView, or do I have to convert it to CFormView?
This program has multiple dialogs, and some of them are over a screen long.
Thanks...
|
|
|
|
|
I didn't know you could derive a dialog box from a view nowadays, I thought you created a windows app and used CFormView to do that.
If you could derive from CEditView then I assume you could derive from CScrollView instead, which will give you scrolling. CEditView gives you a big fat edit box though, I thought, which is surely not what you want for a dialog box ? I'd suggest you need to examine a more wizard type interface, having people scroll through dialog boxes seems pretty cluttered to me.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian...
I wrote a tax program in C under DOS years ago, and finally converted it to a windows program. So I created a separate dialog for each tax form. It was my first real attempt at VCPlus, so it is not ideal code. CEditView seemed to give me what I needed at the time, except scrollable dialogs. Now I would like to get rid of the 2 to 5 page dialogs and replace them with 1. I'll try CScrollView and see what happens.
Thanks..
|
|
|
|
|
bitron@islandnet.com wrote:
This program has multiple dialogs, and some of them are over a screen long.
Scrolling dialogs are evil. Split them up so the dialogs are smaller and fit on the screen.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi, I have an dialog based app that has an initialisation dialog and a main dialog (property sheet). I have to switch between these dialogs and keep the non active one hidden.
My problem is how do I put a minimize button on a Property Sheet dialog?
Thanks
---
|
|
|
|
|
aaah.....create a new class derived from the CPropertySheet,.....
then,override the virtual function OnInitDialog() OR the PreCreateWindow() function and add te following code......
ModifyStyle(0,WS_MINIMIZEBOX);
thatz it!!!!
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
hi
I have a floating data type precision question.
If I have an array of float (32bit) that cover a very large range of value (say FLT_MIN to FLT_MAX). Can i normalize this array into 0.0 to 0.1 without precision lost (and still maintain it as float)?
(ie i could later de-normalize these floats back into its orginal value)
Thanks in advance
|
|
|
|
|
not_happy0 wrote:
Can i normalize this array into 0.0 to 0.1 without precision lost (and still maintain it as float)?
No - quite obviously if you compress the numbers into a smaller range, you will lose precision. Floating point numbers suffer from precision problems anyhow, you should be using double if you want to improve precision, and a fixed point format if you want to be absolutelt precise.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
can someone please help me????
Implement the class bigNumber that allows one to perform basic arithmetic operations for positive integers with any number of digits. You should correctly overload the arithmetic operators +, - , and *, as well as stream operators << and >>. Your class interface may look as follows. However your are free to use any STL container in place of vector.
#include <vector>
using namespace std;
class bigNumber;
bigNumber operator+ (const bigNumber& lhs, const bigNumber& rhs);
bigNumber operator- (const bigNumber& lhs, const bigNumber& rhs);
bigNumber operator* (const bigNumber& lhs, const bigNumber& rhs);
ostream& operator<< (ostream& ostr, const bigNumber& t);
istream& operator>> (istream& istr, bigNumber& t);
class bigNumber {
public:
bigNumber ();
bigNumber (const string &s);
bigNumber (vector<int> v);
friend bigNumber operator+ (const bigNumber& lhs, const bigNumber& rhs);
friend bigNumber operator- (const bigNumber& lhs, const bigNumber& rhs);
friend bigNumber operator* (const bigNumber& lhs, const bigNumber& rhs);
friend ostream& operator<< (ostream& ostr, const bigNumber& t);
friend istream& operator>> (istream& istr, bigNumber& t);
private:
vector<int> digits;
void reverse ( );
};
|
|
|
|
|
Wow - good to see someone taking a class that requires you to use C++ properly, so many seem to use C with classes.
You need to do your own homework. We're happy to help if you get stuck, but you need to start it yourself. Do you know how to write a class ? A mathematical operator ? An iostream operator ? Where are you stuck here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i understand how to do the overloading part of the homework but i dont understand what the difference is between regular integers and the integers of any size
how do i distinguish between them when i am overloading the operators in the bignumber class?????
i do would like for some help and not the solution to the program because i need to skill for my final exams .... could you please maybe give me some insight as to how to even go about this or even let me know what i would have to do differently for overloading these operators.
|
|
|
|
|
Anonymous wrote:
but i dont understand what the difference is between regular integers and the integers of any size
An 'integer of any size' is obviously a construct you will come up with, and it won't just be a type like 'int', because they have limitations. You're obviously going to store the digits that make up your number in the vector called 'digits', and so any operations you make will have to walk that vector and apply the addition/subtraction one digit at a time, just like you did it in primary school.
Anonymous wrote:
how do i distinguish between them when i am overloading the operators in the bignumber class?????
I don't see any operators that require you to use any numeric format apart from your own bignumber type, so this is not an issue.
Anonymous wrote:
even let me know what i would have to do differently for overloading these operators.
It seems to me that if you pass in the number 27 to your operator=, your vector will contain two values, 2 and 7. So operator= could turn the number into a string, then turn each digit into a number, to add to the vector. Then your iostream operators become very easy to write, and operator== is also really simple. Just walk the vectors. Operator+ and operator- will be a little more challenging, but you'd just walk the vectors, adding or subtracting numbers until there's nothing more to work with.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
if i use the the class stack instead of vector can i just dispose of the function reverse()???
i am not sure why i would want to use the function reverse()....
also, i have implemented some code that will do what i need now i just need to convert it to the class file of bigNumber, i think.
maybe some pointers...??
#include<iostream>
#include<iomanip>
#include<stack>
using namespace std;
void main(){
stack<int> S1,S2,R;
int result = 0;
char d;
cout<<"please enter two large integers for me to add." << endl;
//Read the first digit of the first number and push it on S1
if(cin >> d && isdigit(d))
S1.push(d - '0');
cin >> noskipws;
//Read the remaining digits of the first number and push it on S1
while(cin >> d && isdigit(d))
S1.push(d - '0');
cin >> skipws;
//read the first digit of the second number and push it on S2
if(cin >> d >> noskipws && isdigit(d))
S2.push(d - '0');
//read the remaining numbers of the second number and push them on the stack
while(cin >> d && isdigit(d))
S2.push(d - '0');
//Add the two numbers
while (!S1.empty() || !S2.empty()){
if(!S1.empty()){
result += S1.top();
S1.pop();
}
if(!S2.empty()){
result += S2.top();
S2.pop();
}
R.push(result % 10);
result /= 10;
}
if(result)
R.push(result);
//display the result
cout << "the sum is " << endl;
while(!R.empty()){
cout << R.top();
R.pop();
}
cout << endl;
}
|
|
|
|
|
Anonymous wrote:
if i use the the class stack instead of vector can i just dispose of the function reverse()???
No.
Anonymous wrote:
i am not sure why i would want to use the function reverse()....
I assume so that you can create an iterator and go over the digits in reverse order for the sake of operators such as addition and subtraction. I thought you could create a reverse direction iterator though, although it's years since I used the STL. I imagine you'd call reverse before and after a mathematical operation. To me, that sounds more expensive than using array access instead of an iterator to move backwards through a container that's meant to be optimised for random access anyhow.
The problem with the code you've implimented is that it's not wrapped in a class. You should be doing all these operations within your class, using your own iostream inserters and extractors, instead of doing it all with a stack as you are here.
The general idea of what you're doing is a good start for your operator >>.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ok so my input operator (function) will look somewhat like this:
istream & operator >>(istream & istr, bigNumber t)
{
istr >> t.something ;
return istr;
}
now how would i go about setting the constructors to the string paramter and the vector<int> v parameters?
my test program will consist of asking for two numbers...
the user will enter the first number which will be set to the one of the constructors and then matched up with the correct constructor, right. would i have to use the (this) command?
|
|
|
|
|
I'd imagine it would iterate over the vector, and pass each item in the vector to the stream. There's other stuff you should do in setting up a stream operator, read my articles on the subject here on Code Project.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
if i use the the class stack instead of vector can i just dispose of the function reverse()???
i am not sure why i would want to use the function reverse()....
also, i have implemented some code that will do what i need now i just need to convert it to the class file of bigNumber, i think.
maybe some pointers...??
#include<iostream>
#include<iomanip>
#include<stack>
using namespace std;
void main(){
stack<int> S1,S2,R;
int result = 0;
char d;
cout<<"please enter two large integers for me to add." << endl;
//Read the first digit of the first number and push it on S1
if(cin >> d && isdigit(d))
S1.push(d - '0');
cin >> noskipws;
//Read the remaining digits of the first number and push it on S1
while(cin >> d && isdigit(d))
S1.push(d - '0');
cin >> skipws;
//read the first digit of the second number and push it on S2
if(cin >> d >> noskipws && isdigit(d))
S2.push(d - '0');
//read the remaining numbers of the second number and push them on the stack
while(cin >> d && isdigit(d))
S2.push(d - '0');
//Add the two numbers
while (!S1.empty() || !S2.empty()){
if(!S1.empty()){
result += S1.top();
S1.pop();
}
if(!S2.empty()){
result += S2.top();
S2.pop();
}
R.push(result % 10);
result /= 10;
}
if(result)
R.push(result);
//display the result
cout << "the sum is " << endl;
while(!R.empty()){
cout << R.top();
R.pop();
}
cout << endl;
}
|
|
|
|
|
you may use some class derived from CString class.
then you can perform arithmetic operations on them without using vectors, or arrays. ex:
CMyClass s1,s2;
s1="123434";
s2="654321";
//now add them like this
// 123434
// + 654321
// result : 777755
we add them simply like we do it on paper , we read symbols(from the end) from s1 and s2 , for example first we'd add 4 and 1 and get 5.next we'd add 3 and 2 and get 5 and so on...
programatically you can do it like this
CString Add(CString s1,CString s2)
{
CString result,m;
int l1,l2,l,k1,k2,k,temp,g1,g2;
k=temp=k1=k2=0;
m="";
if((s1=="0")&&(s2=="0")) return "0"; // 0+0 = 0
l1=s1.GetLength();
l2=s2.GetLength();
l=__max(l1,l2);
g1=convert(s1,l+1);
g2=convert(s2,l+1);
//convert means if you must add
//123 and 45555 it must convert 123 to 00123
//it's simple to write such function
for(int i=l;i>=0;i--)
{
k1=g1.GetAt(i)-'0';
k2=g2.GetAt(i)-'0';
k=k1+k2+temp;
if(k>=10){k=k-10;temp=1;}else temp=0;
m.Format("%d",k);
result=m+result;
}
return NoZero(result);
//NoZero means if the result is 00987 ir must return 987
}you can modify this function so that it will work with negative number also.
you'll have to do similatly with -,*,/ of course with division job will be harder.
Good luck.
m0n0
|
|
|
|
|
I am using a CRegistry to read the name of a server stored in a char variable
"char cbBuffer [250]"
What I am trying to do is ping the name stored in cbBuffer as follows:
system("ping localhost> C:\\Temp\\pingresult.txt");
how can I replace the name of the "localhost" by the name stored in cbBuffer
or a better way to do this.
thanX in advanced.
|
|
|
|
|