|
Khan,
could you please ellaborate your point. I am not able to get it.
My ActiveX control contains other controls along with the Edit control.
AZam
|
|
|
|
|
I meant that you could subclass it. Which basically means implementing the WndProc for the control.
The actual code would depend on whether you are using MFC or not. In MFC, it is really easy, as you could just derive a class from CEdit. Then in that class, you can control everything the edit control does, like, handling backspace, Esc etc. In WTL, it is just a little different.
Search this site for the many edit controls:
http://www.codeproject.com/editctrl/[^]
Here, you will find many implementations. Choose the best one for your purpose.
this is this.
|
|
|
|
|
hi,
I need to open an text file to save the output data from the machine, i could open the text file and could write the output data to the text file, but the problem is how could i save the previous test data output if i again run the program?
file = fopen("output.txt", "w+");
...
fputs(txt, file);
fputs("\n", file);
If i run the program, i could write the data of the present running data output, i need to save the old output data for the checking the drift?
Can i use rewind????
Thnaks in advance
|
|
|
|
|
use file = fopen("output.txt", "a+"); to append, see function description in MSDN.
Regards
Ray
"Je Suis Mort De Rire"
Blogging @ Keratoconus Watch
|
|
|
|
|
Open the file for append, "a(+)" instead of "w+".
"w+" always creates the file.
"a" creates the file if it doesn't exist. Else, it adds to at the (previous) end of the file.
|
|
|
|
|
ya thankyou, it is working!!
Its appending from the end of the previous data file, like
1 // 1 2 3 4 .......one data output
2
3
4
5 //5 6 7 8.....another data output
6
7
8
if i would like to have as,
1
2
3
4 //as first data output
nad the next file output should begin in new line as
1 5
2 6
3 7
4 8..
hwo could i proceed??i would like tos tart in new line again
|
|
|
|
|
You mean a new column.
Well, that's not easy to do. Considder the data in the file (from the first run).
It's something like this:
1<new line="">
2<new line="">
3<new line="">
4<new line="">
Now you want to insert characters (" 5") in the first line, after "1" and before the <newline> character.
To be able to do that (in the simplest way), you will have to create a new file.
Then read from the old file, one line at the time, modify that line and then write the modified line to the new file.
When the new file is done, delete the old file and rename the new file to the old files name.
Not very easy for a beginner. Can you considder another principle?
|
|
|
|
|
Helo Mr. Kakan,
Is it possible to do so
1 2 3 4
5 6 7 8
writing the new data in another next line???
|
|
|
|
|
Hello chaitanya.
That's much easier. That way, you just append to the file.
Just make sure you put a '\n' character ONLY at the end of line.
Today, you write a '\n' for each value, which gives a newline after each value. That's the reason why you get each value on a separate text line in the file.
I don't know what function you are using for writing to the file today, but i suspect you are using fputc() or fputs(), right?
There are numerous ways to write to a file, this is just one way.
You can to this, using fputc. (I assume FILE * file):
int number = '1';
fputc(number, file);
fputc((int) ' ', file);
number = '2';
fputc(number, file);
fputc((int) ' ', file);
number = '3';
fputc(number, file);
fputc((int) ' ', file);
And the last number:
fputc(number, file);
fputc((int) '\n', file);
Or, if you got all numbers at the same time, you can do this:
fprintf(file, "%d %d %d %d\n", 1,2,3,4);
fprintf(file, "%d %d %d %d\n", 5,6,7,8);
This is very basic knowledge, I think you should read a good beginners book about C and then go on with a book about C++.
Good luck
Kakan
|
|
|
|
|
I have written an MFC application which uses CRecordset to communicate with MS Access database through ODBC. The problem is with moderate use, the program will appear to pause or hang.. then all database operations will become extremely slow. It is so slow that it is unusable! Is there any reason for this? all help will be appreciated. btw.. my program uses quite a number of recordsets.. e.g to fill comboboxes, update Clistctrls...
|
|
|
|
|
Have a look at its memory usage - Is it increasing and increasing to unreasonable levels? If not RAM is its CPU usage blowing up out of control? If you can give more details such as answers to the above questions you'll get a lot more suggestions.
Steve
|
|
|
|
|
the database operations in the program seem to be allocating awful amounts of memory, in the range of 500 kb for each operation. Is this a sign of a memory leak? also when the program comes to the stage where it is unuseable, the CPU usage doesn't read high. however, the memory usage seems to be quite high (in the range of 30,000 kb).. the program usually uses 14 to 20 mb of memory.
|
|
|
|
|
I don't think that's particularly excessive. If you leave it for an hour and come back how much memory is being used?
Steve
|
|
|
|
|
this problem seems to surface during closing/opening a modeless dialog box repeatedly. The dialog box contains two CListctrls. The problem may lie with the modeless dialog box? Interestingly, other operations not involving creation/destruction of a child window do not cause any problems.
I create the modeless dialog like this:
CQuoteMan* QuoteMan = new CQuoteMan(this);
QuoteMan->Create(IDD_QUOTEMAN,this);
QuoteMan->SetWindowPos( &wndTopMost,100,100, 0, 0, SWP_NOZORDER | SWP_NOSIZE | WS_EX_CONTROLPARENT);
QuoteMan->ShowWindow(SW_SHOW);
and put "delete this" in the destructor of the modeless dialog class.
Also.. this modeless dialog uses 4 separate recordsets. Is there any danger in this?
|
|
|
|
|
You may already be doing this, but how are you closing the child dialogs?
You could try this:
OnClose()
{<br />
DestroyWindow();<br />
delete this;<br />
}
this is this.
|
|
|
|
|
chev_ls1 wrote: Also.. this modeless dialog uses 4 separate recordsets. Is there any danger in this?
Not unless each one is using it's own connection to the datasource. That's one open/close operation times four.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Sounds like you eaither A. have a memory leak you could drive a bus through or B. aren't committing database updates.
As a course of action I would have a look at my programs private bytes in performance manager, see if it going up over time. See MSDN "Debugging Techniques" section "Detecting Memory Leaks in MFC" for more information in tracking down your leak.
Otherwise you aren't committing your database changes, are you using transactions ?
Regards
Ray
"Je Suis Mort De Rire"
Blogging @ Keratoconus Watch
|
|
|
|
|
the database operations in the program seem to be allocating awful amounts of memory, in the range of 500 kb for each operation. Is this a sign of a memory leak? also when the program comes to the stage where it is unuseable, the CPU usage doesn't read high. however, the memory usage seems to be quite high (in the range of 30,000 kb).. the program usually uses 14 to 20 mb of memory.
|
|
|
|
|
Hi,
Have you enabled ODBC tracing. It also makes the operations slower.
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
what is the diff b/w heapalloc and new .
Pls help me.
never say die
|
|
|
|
|
new uses HeapAlloc internally. But it also adds caching and small block heaps and the like on top of it. new is a C++ keyword where as HeapAlloc is a Win32 API function.
Steve
|
|
|
|
|
Thanks for the answer.
But i want to know is there any thing like private heap and Global heap?
Pls help me
never say die
|
|
|
|
|
No. Win32 supports multiple heaps, you can create your own by calling HeapCreate and keep it to yourself - I guess in that case you could consider it private. Can you explain what you’re trying to do specifically? Maybe then I can be of more help.
Steve
|
|
|
|
|
Actually a project has been given to me which connects the client to IIS Server via soap.I have been assigned to devlope further.So any memory allocation done on Server Side using Heapalloc. When I asked the reason ,i was told that memory is bound(within) to the process so it has been done using HeapAlloc.
If u can help me further,I would be thankful to u
never say die
|
|
|
|
|
Calling new in C++ gets its memory from HeapAlloc underneath the hood. But it integrates with the language by:
- Knowing the size of the object it’s allocating (so you don't have to supply it).
- Calls constructors (and delete calls destructors).
- Avoids casts.
In short I'd just use new and delete . But beware:
If you allocate with new you must free with delete and if you allocate with HeapAlloc you must free it with HeapFree - You can't allocate some memory with new and free the same memory with HeapFree for example.
Steve
|
|
|
|