|
One solution is an edit control.
Kuphryn
|
|
|
|
|
im looking for more like the text button on paint...ie the user clicks on the button, then clicks on a place on the drawing area and is able to write text there...then should beable to drag and drop the text if neccesary
smile...its your destiny
|
|
|
|
|
i encouter the following problems:
1) when i declare an int for textfile and wan to assign it to dialog int member variable, the value output is not the same as in the textfile and also has this warning that my member variable eg, int m_temp is nt referenceed.
2)how to output more than 2 words per line from a textfile coz it always output only the 1st word.
thanx!
|
|
|
|
|
coda_x wrote:
1) when i declare an int for textfile and wan to assign it to dialog int member variable, the value output is not the same as in the textfile and also has this warning that my member variable eg, int m_temp is nt referenceed.
I don't quite understand what you're after here. How about a code snippet?
coda_x wrote:
2)how to output more than 2 words per line from a textfile coz it always output only the 1st word.
You didn't mention what type of file object you had so I'm going to show you an example using a CStdioFile object.
CStdioFile file("somefile.txt", CFile::modeCreate | CFile::modeWrite);<br />
file.WriteString("word1 word2 word3 word4\n");
or
file.WriteString("word1 ");<br />
file.WriteString("word2 ");<br />
file.WriteString("word3 ");<br />
file.WriteString("word4\n");
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
Is it possible to get the command line of a process thanks to its id or handle ?
Thank in advance.
Robin.
|
|
|
|
|
Here is one solution from MSDN.
http://support.microsoft.com/defaul...&NoWebContent=1
Kuphryn
|
|
|
|
|
Whenever I'm opening a CFileDialog, like:
CString filepath;
CFileDialog file(FALSE);
if(file.DoModal()==IDOK){
filepath = file.GetPathName();
}
else{
AfxMessageBox("File Save cancelled");
return;
}
The OS is loading quite a lot of memory all at once. Even if I press the CANCEL button and close the dialog box, the memory usage doesn't decrease.
Any suggestion how to kill it.
|
|
|
|
|
Make sure you're measuring the right thing.
If you're looking in Task Manager, the 'Mem Usage' column is in fact the working set size. The 'working set' is the amount of physical memory currently assigned to your program, and includes any code or data shared with other processes.
When you create a common dialog, Windows has to swap in the code from the common dialogs DLL, comdlg32.dll . Thus your working set increases.
However, Windows will only trim your working set (swap out physical pages) when the working set exceeds a particular size, or when memory demand is high. You might not see the working set decrease again in the lifetime of your process.
If you suspect a leak, monitor the 'VM Size' column in Task Manager. This shows the actual amount of virtual memory which is committed by your process (again including code size, which might be shared). You might still see an increase if the common dialogs DLL - or MFC - perform any one-time allocations for the process - some DLLs do so.
Changes in this column will only catch memory allocated with VirtualAlloc or a growing heap; it won't catch small leaks in your heap (since the VM size of the heap will only change if the heap needs more memory to manage). For that, see the crtdbg.h header file.
|
|
|
|
|
Read this article and then decide if you still want to pursue this:
http://www.flounder.com/howbig.htm
Yes, there are ways of making your EXE/DLL smaller, or even use a tad less memory, but you have to weigh the investment with the return on that investment. See here:
http://msdn.microsoft.com/msdnmag/issues/01/01/hood/default.aspx
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I'd like to run the function defined as 'void CEnumProcessTestDlg::Run();'
for every 100 milliseconds. I try to use timeSetEvent,setTimer but I couldn't manageto run these functions. I know that I must use these functions, but I couldn't.I think My declerations are wrongly. How can I run my function for every 100 ms.?
|
|
|
|
|
Use a CALLBACK function. When you set up a CALLBACK function, you are setting up an Event function which gets called whenever the specified event happens, in your case 100ms has passed.
<br />
void SetTestTimer() { _TimerID = timeSetEvent(_TimerRate, 0, &Run, (DWORD)this, TIME_PERIODIC); };<br />
then define your Callback in the header (and as appropriate in the .cpp) as :
<br />
static void CALLBACK Run(UINT wTimerID, UINT msg, UINT dwUser, DWORD dw1, DWORD dw2);<br />
The CALLBACK must be static and have those parameters to run from SetTimer because they act as a function signature, otherwise the function will never get called . Have a nice day.
Alan.
"Once I was but the Learner, now I am the Master" [Darth Vader]
|
|
|
|
|
Hi all, I'm almost there with my array template class, I just have one horrid problem before success . OK, I'm reserving a raw memory chunk using malloc/realloc. If T is an object I am then using the placement new operator (default) to construct the objects inside this reserved block, otherwise I am doing a block initialise on the data. Here's the problem, when I have an array of chars, everything is fine (the placement new path is not necessary), however if I have an array of
<br />
class MyClass<br />
{<br />
public:<br />
MyClass(void);<br />
~MyClass(void);<br />
<br />
array<char> string1;<br />
array<char> string2;<br />
};<br />
<br />
HRESULT Allocate(unsigned int alloc)<br />
{<br />
unsigned int size = sizeof(T);<br />
if(size > 4)<br />
{<br />
m_pItem = malloc(alloc*size);<br />
<br />
new(m_pItem) T[alloc];<br />
}else...<br />
}<br />
Malloc reserves enough space for say 10 of these objects and returns a pointer to the data which is stored. The placement new operator then gets passed this pointer, but fatally constructs the object 4 bits on from m_pItem. Its strange because my debug window says new[] returned 0x00322c50 yet if I use T* p = new(m_pItem) T[alloc]; instead, p = 0x00322c54 but the debug window still claims 0x00322c50 was returned??? Also m_pItem shows complete garbage in the debug window (so it ain't there), but looking at the mem address 0x00322c54, I can see the object has been nicely constructed there. What the hell is going on?
|
|
|
|
|
OK, just managed to find out that when you use new(m_pItem) T[alloc] - the array form of placement new, it may, depending on the object, add some extra overhead to the allocation. Urrrggghhh. Apparently its safer to just loop through the number of objects and use the non-array placement of new - new(m_pItem) T;, which doesn't add any overhead, and everything is hunky dory. What a crock of sh*t. Now all I need to do is figure out how to destroy objects without making a fuss or memory leak .
Alan.
|
|
|
|
|
Hi !
I'm developping using the Visual C++ environnement, but I'm not using the MFC nor the Win32 API directly. Thus, I'm thinking about using another editor for my C++ sources.
Any suggestions, or is the Microsoft's editor the best ?
Thanks !
Jerome
|
|
|
|
|
I couldn't live without CodeWright.
Bernd
|
|
|
|
|
I couldn't live without ED.;) See sig.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
If the default editor does not work for you, can can change it by right clicking on any file icon in the Solution explorer (View->Solution Explorer) and then choose 'Open With....' to enter the location of your favourite editor.
Hope this helps
|
|
|
|
|
I love the original VS editor, its neat, tidy, clear, concise and has all the tools you need for debugging, what more could you possibly want?
|
|
|
|
|
Hi,
I am using CFormView and there is a situation where 2 ActiveX controls overlap
one on the other.
My problem is the first ActiveX control which is below the other is refreshed
every 1 second, due to this the second control which is on top gets hidden.
As I have used CRectTracker on the second control, the tracker gets erased.
What do I need to do so that the first control which is below the second control, gets clipped by the second control.
Thanks,
Sansky
John 3:16
For God so loved the world,
that he gave his only begotten Son ( Jesus Christ ) ,
that whosoever believeth in him should not perish, but have everlasting life.
|
|
|
|
|
Hi,
I have to read from very large files (> GBytes) and parse it (MPEG data, trick modes: FFW/FRw)in "real time" (about 10 MByte/S) on Windows XP system. In some cases I have to read and parse it forwards and in other cases i have to read it starting at the enf of the file and parse it backwarts. I did it in C++ and MFC. I have used the CFile class. In both cases I read small portions (about 64k) from the file, move it into a ringbuffer for later parsing.In the case of forward this works fine.
Backwards I jump back a specific length and read/move that portion of data into the ringbuffer. Repeating this steps i walk backwarts the file in 64k steps.
In the case of small files or for some seconds (dependante on system memory) this works also fine.
But in opposite to forward the system cache seems to increase dramaticaly. At a certain time the sytem starts pageing all other applications in the memory, what causes the system reaction time to become very slow and the reading stream from the file is interrupted.
It seems to me that the cache manager is not optimized to read from a file in backward direction.
Are there any ideas or experiences out there how i can handle reading backwards in a file in "real time" ??
Is there anything i can do, that the cache manager understands that i am walking backwarts ..
Thanks a lot for your help.
Eddie
|
|
|
|
|
I'd try doing this using a Memory Mapped File, which theoretically should give much better results, and far simpiler code.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Memory Mapped File, definitely the way to go, its just like a portion of memory then, you can read forward, back even jump through hoops and its still fast .
Alan.
|
|
|
|
|
There are two basic 'hints' you can specify to CreateFile to tell Windows how you intend to manipulate the file.
Specifying no hint indicates to Windows that you mostly intend to read the file forwards. This is what you have at the moment. It will perform some asynchronous read-ahead from the file, and drop the cache mappings fairly quickly after each read. When it does drop them, it adds the physical memory pages to the tail of the list of free pages, so if it needs to reload them again, it doesn't need to reload from disk unless the pages have actually been reused.
Windows actually tries to interpret your read pattern and guess where the next read might occur.
If you use the FILE_FLAG_RANDOM_ACCESS flag, read-ahead is inhibited, and the cache manager is less aggressive about unmapping recently used sections.
Finally, I'll quickly mention FILE_FLAG_SEQUENTIAL_SCAN where the cache manager assumes that you're reading the file from end to end, never going back, and so adds unmapped cache data to the head, not the tail, of the free list so it gets reused quickly.
In order to be able to pass the FILE_FLAG_RANDOM_ACCESS flag, you'll need to subclass CFile .
More complete information in Inside Windows 2000 from MS Press (Solomon & Russinovich).
|
|
|
|
|
Thanks for your hints,
I tried FILE_FLAG_RANDOM_ACCESS from CFile. There was the possibility to use that flag at the CFile constructor.
(CFile::osRandomAccess See FILE_FLAG_RANDOM_ACCESS in CreateFile in the Platform SDK)
But this was not enougth, the memory consumtion still increase.
So I use the FILE_FLAG_NO_BUFFERING flag to bypass the Cache Manager at all.
(CFile::osNoBuffer See FILE_FLAG_NO_BUFFERING in CreateFile in the Platform SDK). After I did some additional tuning on my rinbuffers this seems to be the solution. Memory usage keeps nearly constant and the transfe-rate is enough to do real time parsing on the mpeg stream.
Thanks for all your comments,
Eddie
|
|
|
|
|
I kept a CListCtrl in my application and inserting columns by picking up column captions
by parsing from a flat file . The problem is InsertColumn method is inserting a cloumn but not displaying column caption ?? Rest of the columns are fine and no pronlem with Inserting items.
How to get the first coulmn name displayed??
thanks in advance
Warm Regards,
KKRam
|
|
|
|