|
Thanks, Joaquín buddies!
George
|
|
|
|
|
I have what is probably a simple question, but I am stuck and need help. I am trying to create an Options dialog box for an app. I am using WTL to create the app. I have added the tab control, but I need a quick way to select the controls for each page. In VB I would create a group control and add the controls to the group, then show and hide the group as needed. I can't seem to make this work in WTL (probably doing something wrong with adding the controls to the group). I also, think that I might be able to use a dialog resource like a property sheet, but I am at a loss at how to get this added to the Tab Control. What is the best way to proceed?
Thanks for any help you can give.
Leo T. Smith
|
|
|
|
|
This is probably not the answer you’re looking for but, as far as I know, the way groups work in VB is just that, a VB thing. There is no parallel functionality in the rest of windows programming. The closest you could come would be to store a list of all the controls in the 'group' you want to modify and simply hide/shoe them when necessary.
Besides, the thing you probably want to be doing, as you mentioned, is create a property sheet. There are some samples of this on this site:
Using DDX and DDV with WTL[^]
It does concern itself with a more advance topic, but the code for using both property sheets and property pages is in there.
cheers,
-B
|
|
|
|
|
Hi, everyone!
Here are the sentences taken from my STL tutorial,
--------
Any value of an output iterator may have at most one active copy at any given time.
// i and j are output iterators
// a and b are values written to a iterator position
i = j;
*i++ = a;
*j = b;
is not a valid code sequence.
--------
I write a piece of code by myself tried the codes and
run it. I find it runs OK! So I doubted what is the tutorial
talking about. Can anyone explain it to me? (What means "at most one active copy at any given time" ?)
Here is my sample,
--------
#include <iterator>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
ofstream ofile ("c:\\file1.txt");
ostream_iterator<int> i (ofile);
ostream_iterator<int> j (ofile);
// i and j are output iterators
// a and b are values written to a iterator position
*i++ = 1;
*j = 2;
}
--------
Thanks in advance,
George
|
|
|
|
|
The semantics of output iterators are simple, and it reduces to the following rule: a given position has to be accessed once and only once. Let us examine why the following pieces of code are incorrect:
*i=5;
++i;
++i; This is incorrect as you're "skipping" a value.
*i=5;
*i=6; Wrong, as you're assigning to the same position twice.
j=i;
*i++=1;
*j=2; Wrong, for the same reason as before.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, Joaquín buddies!
In the last sample,
--------
j=i;
*i++=1;
*j=2;
--------
i and j are referencing to the same stream but
they are different iterators. I still doubted
why they are assigning to the same position twice?
Since they are different iterators and I think it
is like two pointers pointing to the same memory.
Can you give me an explanation?
Thanks in advance,
George
|
|
|
|
|
No, wait. I've reread the standard and now I think the above piece of code is correct. Sorry.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, Joaquín buddies!
Do you mean that the tutorial is
not correct? Since the tutorial says
that the piece of code is not correct.
Thanks in advance,
George
|
|
|
|
|
Hi, Joaquín buddies!
Have you found the answer?
Thanks in advance,
George
|
|
|
|
|
Hi, everyone!
Here is a simple STL program. It uses two input iterators
to use on the same input file. I do not understand why the
output is looking like this.
Here are the source codes,
--------
#include <iterator>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
// c:\\file1.txt: 0 1 2 3
ifstream ifile ("c:\\file1.txt");
istream_iterator<int> r (ifile);
istream_iterator<int> s (ifile);
(r==s) ? cout << "equal" : cout << "not equal";
cout << endl;
++r;
++s;
cout << *r << endl;
cout << *s << endl;
(r==s) ? cout << "equal" : cout << "not equal";
cout << endl;
}
--------
Here are the outputs,
--------
equal
2
3
equal
--------
Thanks in advance,
George
|
|
|
|
|
You're twisting the semantics of istream_iterator s: You only can do the following with such an iterator:Check for the end of stream with the expression it==istream_iterator<int>() .retrieve a value from the associated istream with an expression of the form x=*it; .
Increment the iterator with ++it or it++ .Moreover, after retrieving a value, you must increment the iterator previous to further retrievals. That's it, do not assume you can do much else with such iterators. Do no think these iterators are something like pointers to the data contained in the file, because they are not, hence the odd results when testing r and s for equality. istream_iterator is designed as a convenient adaptor to take advantage of generic algoritms, as such its functionality is strictly limitied to what these algorithms require.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, Joaquín buddies!
Such piece of codes are taken from a turorial
and it is a concept-proof sample.
It really doubted me. So, if you can explain it
to me, I will be really thankful. I am a newbie
of STL.
Cheers,
George
|
|
|
|
|
Hi, everyone!
Here is a simply STL program deals with copy
algorithm of STL. I do not understand what is the
meaning of the socond parameter of my case, i.e.
--------
istream_iterator<int> ()
--------
What does it mean? Here are the source codes
and related output.
Source codes,
--------
#include <iterator>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
//0 1 2 3 are in c:\\file1.txt
ifstream ifile ("c:\\file1.txt");
copy (istream_iterator <int> (ifile),
istream_iterator<int> (),
ostream_iterator<int> (cout) );
}
--------
Output,
--------
0123
--------
Thanks in advance,
George
|
|
|
|
|
istream_iterator() indicates end of a stream.
Kuphryn
|
|
|
|
|
Hi, Kuphryn buddies!
As you mentioned, istream_iterator<int> () is an "end-of-stream" iterator. But it is the end of which stream? Why it is assigned as
the end of the ifile stream? Since there are no parameter in istream_iterator<int> (), it really doubted me a lot. (If it has a parameter identifies the ifile, it would be clear, I think.)
Thank in advance,
George
|
|
|
|
|
Its the end of all istream_iterator<int>'s. Think of it as a constant.
Ryan.
They read good books, and quote, but never learn
a language other than the scream of rocket-burn.
Our straighter talk is drowned but ironclad;
elections, money, empire, oil and Dad.
|
|
|
|
|
Thanks, Ryan buddies!
George
|
|
|
|
|
First off: STL RULES!
Ok, now a confession...
the only reason I even use MFC is for CString. I've been searching for a decent stl replacement, and found a few, but I thought I'd ask some STL zealots for their respective opinions...
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
A quick & dirty replacement is:
typedef std::basic_string<TCHAR> tstring; although I think I've seen a true STL port here on CP.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
typedef std::basic_string<TCHAR> tstring;
That's not enough. CString uses reference counting remember?
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Well, depending on your application, reference counting can be slower. Herb Sutter did a study and found that reference counting based strings only benefit the application if you application is primarily copying the string from place to place without modification. But you also have to take into account any memory savings that you might get with a reference counting system.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Actually, to be even more specific, I use CString mainly for the method:
szMyString.Format("My unsigned int is 0x%.8X", uiMyInt);
...and for some reason sprintf() scares me
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
std::ostringstream oss;
oss << "My unsigned int is 0x" << std::uppercase << std::setw ( 8 )
<< std::setfill ( '0' ) << std::hex << n << std::endl;
std::cout << oss.str () << std::endl;
Is roughly the equivalent when using the STLs. It a bit of a mouth full, but some of the modifiers persist between calls--std::uppercase will, while std::setw must be called each time--so once you called them, you need not do so again untill you need a new option set.
cheers,
-B
|
|
|
|
|
Ben Burnett wrote:
It a bit of a mouth full,
I agree. Maybe I will have to attempt my own STL replacement for CString...
hmmm, possible article
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nitron wrote:
Maybe I will have to attempt my own STL replacement for CString...
Before you dig in, check out the Boost Format library[^]. It might just be what you're looking for.
cheers,
-B
|
|
|
|