|
Karthika85 wrote: I am using m_ctrlEd.SetFocus()
from where are you calling that ?
|
|
|
|
|
Set the focus at the end of your WM_INITDIALOG handler, then return FALSE to prevent the system from setting focus to the default control.
L u n a t i c F r i n g e
|
|
|
|
|
In Dialog resource,
Tab numbers will be appear when you press Ctrl+D,
then you can set 1 to edit control. after run the application
automatically cursor will be appear on edit control.
Regards,
Srinivas
|
|
|
|
|
In addition to the comments about the OnInitDialog function, use the CDialog::GotoDlgCtrl[^] function to actually set the focus. See here[^] on why SetFocus should not generally be used in dialogs.
Steve
|
|
|
|
|
hi everybody, the C++ fstream's write operation is Sync or aSync?
|
|
|
|
|
it's buffered, so you might not see the data in the file until the buffer flushes.
|
|
|
|
|
so the fstream's write operation will not be blocked?
|
|
|
|
|
I currently program in C# and decided to make a move to C++. I am finding it a little more difficult than I thought. I mean I am having trouble even reading a file. I am using XCode on Mac OS X Snow:
#include <cstdio>
#include <fstream>
#include <istream>
#include <ostream>
#include <iostream>
int main () {
using namespace std;
ifstream in("/Users/Dixon/MyFile.rtf");
if (not in)
perror("/Users/Dixon/MyFile.rtf");
else {
int x(0);
while (in >> x)
{
cout << x << '\n';
}
cout << "Ending....";
in.close();
}
}
Output:
[Switching to process 16406]
Running…
Ending....
Debugger stopped.
Program exited with status value:0.
Ok, now I understand I am not getting any errors when opening this file. The problem is it isn't reading anything from it. I have put 5 lines in there (just one word on each line). Now according to my book (Exploring C++ by Apress), this hsould work. This code is pretty much exactly from their book. Except in their book they used a list1302.in file as I used a RTF file. Maybe that is the problem? I really don't know what an IN file is exactly (coming from Windows world)
|
|
|
|
|
Ok im back tracking on my reading.. so the point is to read integers from a file. So I changed the words in my rtf file to just numbers and I still get nothing?
|
|
|
|
|
An rtf file includes formatting - so there is more in the file than just what you typed. Try using a plain text file with several integers typed into it.
|
|
|
|
|
I still can't seem to get it to work. I saved that RTF file as TXT and I also coded this to try to get it to work:
ofstream out("/Users/Dixon/test1.txt");
if (not out)
perror("/Users/Dixon/test1.txt");
else {
out << "1" << "2" << "3" << "4" << "5" << "6";
out.close();
ifstream in("/Users/Dixon/test1.txt");
if (not in)
perror("/Users/Dixon/test1.txt");
else {
int x(0);
while (in >> x)
{
cout << x << '\n';
}
in.close();
}
}
So I made it create a file with the words 123456 in it, close it then open it to read.. but it doesn't read!
|
|
|
|
|
I have also tried this: (from: http://www.cplusplus.com/doc/tutorial/files/[^])
#include <iostream>
#include <fstream>
#include <string>
int main () {
using namespace std;
string line;
ifstream myfile("/Users/Dixon/test1.txt");
if (myfile.is_open())
{
while (! myfile.eof())
{
getline(myfile,line);
cout << line << endl;
}
myfile.close();
}
else {
cout << "Unable to open file";
}
return 0;
}
But I seem to get:
[Switching to process 17059]
Running…
Exploration 13(17059) malloc: *** error for object 0x10000a700: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal: “SIGABRT”.
sharedlibrary apply-load-rules all
(gdb)
If I change this:
while (! myfile.eof())
to:
while (myfile.eof() != false)
it runs but still does not read anything
|
|
|
|
|
Uhm... I tried something... I used NetBeans 6.8 instead of Xcode and the exact code compiled and ran just fine. It actually read the data. What could be the cause of that?
|
|
|
|
|
I don't know - I'm not familiar with either Xcode or NetBeans. Hopefully, someone else will have an idea for you.
|
|
|
|
|
Just being curious, but what do you use? I used Visual Studio for C#, but I wanted to try to find a program that would work on both windows and mac (thats where I found netbeans).
|
|
|
|
|
I've written code for a few different computers, but so far not the mac.
Lately I've been using:
Visual Studio for C++ on the PC,
CodeWarrior/Freescale for C cross compiled from the PC to a microcontroller, and
Visual C++ 1.52 plus some add-ons for C for an 80386EX embedded system.
None of this code is using iostreams & I have to consider myself weak in that area at the moment. I would have just looked at the responses you got to see what I could pick up, but seeing rtf rather than plain text was a glaring issue for me. In the last week I've had to deal with a couple of mismatched formatting issues.
modified on Thursday, January 21, 2010 12:31 AM
|
|
|
|
|
Jacob Dixon wrote: #include <cstdio>
#include <fstream>
#include <istream>
#include <ostream>
#include <iostream>
Of these, only fstream and iostream are needed.
Jacob Dixon wrote: if (not in)
Have you tried:
if (in.fail())
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I'm wondering if there is something else this book is talking about? It says C++. But the code above is exactly what the book put in. Interesting...
I take it you didn't see my post before this one but it seems it works fine in netbeans, but in xcode it wouldn't work. I got the code that I was having trouble with to work perfect in netbeans. What could cause this?
|
|
|
|
|
hello, i'm usig this spin control, it works fine, in my application i draw some lines when the spin control increases or decreases an edit box,nice, but when the control change the acceleration it seems like iDelta and iPos (from UDN_DELTAPOS) change their behavior, because in that moment the line plotted is wrong , but after and before that moment all works fine, and the variable shown in the buddy edit box is always well. I guess that in acceleration changes happens somethig that i dont know whith spin control. Any ideas ? i can`t find any good information about how this controls works, specially the acceleration thing.
|
|
|
|
|
Hi to all,
I have a small doubt.Is it possible to use arithmetic operators between two char* variables, like bellow
char* conc(const char* c1,const char* c2)
{
char* c3=c1+c2
return c3
}
Above code is giving error "adding two pointer variables is invalid". Please tell me how to concat(add) two char*.
To invent something, you need a mountain of junk in your mind.
---------------------Thomas alva edison
|
|
|
|
|
You could use strcat()[^] to concatenate strings.
Alternatively, you could use one of those string classes (such as CString) which will allow you to just use + (the addition operator) to add two strings.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Rajesh R Subramanian wrote: You could use strcat()[^] to concatenate strings.
Actually my requirement is "not use the strcat() function".
To invent something, you need a mountain of junk in your mind.
---------------------Thomas alva edison
|
|
|
|
|
If you have to stick to the two pointer of char in order to concat them.
You have to creat a new char * with the length of both. Then copy both to the one.
I would suggest using stings.
You could also create a string and use += to do it.
I guess that is your homework, isn't it? Sounds like.
Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
|
|
|
|
|
sampath-padamatinti wrote: Actually my requirement is "not use the strcat() function".
Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Are you new around here? It probably is one of these:
- I let others do my homework
- I am troll
- strcat() isn't safe enough; I prefer strcat_s()
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|