|
According to the source code, it sets things up so DDE can
be used by the shell to pass an open command to your app if it's
already running.
See CWinApp::OnDDECommand()
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey y'all,
How would I make a DialogBox a child window of the main View window in an SDI project?, or am I going about this wrong?
By the way I'm using C++ 6.0
Mike
|
|
|
|
|
Mike Hankey wrote: How would I make a DialogBox a child window...
The CDialog constructor takes a parent as one of its arguments.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
David,
You are right...is my thinking right;
CCeDBTestView::CCeDBTestView()
{
poutputDlg = new COutputDlg;
poutputDlg->ShowWindow(SW_SHOW);
}
I get an ASSET failed in winocc.cpp
I show be able to create it then show it? I'm obviously missing something?
Mike
|
|
|
|
|
You need to call Create with the pointer created by new.
Try this:
CCeDBTestView::CCeDBTestView()
{
poutputDlg = new COutputDlg;
if (poutputDlg != NULL)
{
if (poutputDlg->Create(COutputDlg::IDD,this))
poutputDlg->ShowWindow(SW_SHOW);
}
else
AfxMessageBox("Error creating OutputDlg!");
}
|
|
|
|
|
NO still no luck...Thats basically what I had to begin with but tried to narrow things down, same error goes south on the ShowWindow staement?
Thanks for your help
Mike
|
|
|
|
|
Does your child dialog include an ActiveX control?
|
|
|
|
|
No right now it doesn't contain anything. What I wanted to use it for is a container for controls and have several where I could switch views.
Mike
|
|
|
|
|
Come to think of it, creating the child dialog in the view constructor is not the right place. The view window has not been created yet.
Try creating the child dialog in the OnInitialUpdate handler for the view. Alternatively you can create your child dialog in the OnCreate handler (after you have called CView::OnCreate).
I just created a simple SDI app and tried creating a child dialog in the constructor and saw the same ASSERT you are getting. I then moved the child creation code into OnInitialUpdate and the child dialog was created successfully.
|
|
|
|
|
Your right my bleary mind didn't pick up it til you mentioned it. )
Thanks,
Mike
|
|
|
|
|
For a modal dialog box, try:
CCeDBTestView::CCeDBTestView()
{
COutputDlg poutputDlg(this);
poutputDlg.DoModal();
}
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
the below function tokenize the string "ram,red,orange,,blue,,yellow,white" as
ram
red
orange
blue
yellow
white
but I want a "sapce" if no value is present between commas. So that result should be
ram
red
orange
blue
yellow
white
- Nandu
void Tokenize(const string& str, vector<string>& tokens, const string& delimiters )
{
// Skip delimiters at beginning.
string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
string::size_type pos = str.find_first_of(delimiters, lastPos);
while (string::npos != pos || string::npos != lastPos)
{
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
// Find next "non-delimiter"
pos = str.find_first_of(delimiters, lastPos);
}
}
int main(int argc, char* argv[])
{
vector<string> tokens;
vector<string>::iterator it;
string str = "ram,red,orange,,blue,,yellow,white";
Tokenize(str,tokens,",");
cout<<str;
for (it = tokens.begin(); it <tokens.end(); it++)
cout<<*it<<'\n';
getch();
return 0;
}
|
|
|
|
|
|
|
Hi,
Below code shows how to get the last occurrence of a string. But in this case string::rfind reads the string from the starting and gives the last occurrence.
string str ("The sixth sick sheik's sixth sheep's sick.");
string key ("sixth");
size_t found;
found=str.rfind(key);
if (found!=string::npos)
str.replace (found,key.length(),"seventh");
cout << str << endl;
(EXAMPLE:1)
But I need a code to find the last occurrence of a string reading it from the last rather than reading it from starting. Using only string operations.
This is because I have a requirement where I need to read a string from the end, improve the performance as below shown scenario
#STAR
Data…
Data..
…………
……….
Data……
#END
We will receive a huge string (about 10mb) of data from server as show above (in the above format). To confirm that we have received the whole set of data, just check for #START and #END tag. As of now I am reading the #END using string::rfind(), which takes some time to give the result. So is there any to find a word in a string reading from end. Reading from the end will reduce the time for finding the #EDN tag.
So please proved a solution to read a string from the end.
-Nandu
|
|
|
|
|
Hi,
how about searching only the last part of the string, by getting its length, then adding say len-20
to the string pointer, then do a "find last occurence"? And as a safety net (if one is needed) if
no match, try the normal approach.
However, if the length has to be obtained by scanning for a NULL (as strlen would do), not much
may be gained!
|
|
|
|
|
Thanks for your reply,
But this approach will not help, boz some tags may also present at the end as show below.
#START
data
....
....
#END
#DATE
#TIME
That's why I need an approach to find a word in a string from end.
-Nandu
|
|
|
|
|
Hi,
assuming you get the length in an inexpensive way, search the last N1, on failure the last N2,
on failure the last N3 characters, where it is up to you to decide what appropriate values for
N1, N2, N3 are. You might go for 10%, 20%, 30% or something similar. The basic idea is to
have more than 50% chance N1 will find a match.
if the length is as expensive as strlen, IMO there is nothing you can do once all the data is
in a single string.
Whatever the case be, I would tend to avoid having such big strings to begin with.
There must be better ways to store the data. If, before being turned into a big string, it
comes in in buckets, why not search the last bucket, or possibly the last two?
|
|
|
|
|
above suggestion will not help.
Can help me in this regard. Is there any other solution.?
|
|
|
|
|
Is there any external data available that indicates the length of the string.
I would consider it sort of nasty to send anyone a \0 terminated string of upto 10 MByte.( A bit Error prone too) If it comes to that type of size, an extra 4 bytes to indicate the length of the string at the start would help, (i.e. Make it a Pascal String) and will hardly hit performance.)
But, How does your Receiving Software know to allocate buffer of sufficient size to hold the data in the first place. Drill into that with your debugger, and you might find your answer.
Regards,
Bram van Kampen
|
|
|
|
|
How do I do that?
Man, I feel like such a noob.
For example, strlen, strcmp, etc., all want a const char* or const wchar_t*. How do I cast the CString to that type?
[edit] Never mind, I changed to multi-char instead of unicode and simply dereferencing the CString object converts it correctly. Sigh [/edit]
Marc
modified on Saturday, July 12, 2008 12:14 PM
|
|
|
|
|
Hi Marc,
Remember, you don't have to abandon Unicode.
CString has methods to do most of the things those old char functions do,
but CString is generic.
If you truly need the char character type in a Unicode build, you can use
CStringA.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
http://www.cplusplus.com/reference/string/string/c_str.html
Check the above link, hope it will help you.
-Nandu
|
|
|
|
|
Mark Salsbery wrote: If you truly need the char character type in a Unicode build, you can use
CStringA.
Ah, thanks!
Marc
|
|
|
|
|
My C++ is rusty, about the last time I did C++ stuff was with VS7. So here I am with VS9, doing pure MFC/C++ (none of the CLR crap).
So, I've got a "lib" project and a console "test" project. The linker can only find functions that are inline'd in the header file. It can't find functions defined in the lib.cpp class!
What happened? And actually, why can't I find the lib.dll file? It creates lib.dll.embed.manifest, but no foo.dll!
In fact, I think I just answered my first question: I'm not referencing lib.dll in my test project, so it's only resolving inline functions. Why am I not getting a lib.dll lib? How do I get one?
Do I add a path to the Linker\General "Additional Library Directories" or do I add it under Common Properties "Framework and References"?
This used to be so much easier.
[edit] Ummm. Why is the output going to a project in my solution that is excluded from the build and not even referencing the lib project? Why isn't it going to the folder specific to the project itself? WTF has MS done!!! [/edit]
[edit2]The output file property in the Librarian was using (OutDir) rather than (IntDir). WTF? Why would it do that? [/edit2]
Marc
modified on Saturday, July 12, 2008 11:45 AM
|
|
|
|
|