|
|
|
I Write a player to play *.wmv files using the Windows media player ActiveX Control .It use about 20MB Memory when playing a wmv File,But the Windows Media player provided by the system only use 8MB.I wonder how can I decrease the memory useage of my player,how can the Windows Media player provided by the system managed to do it ?
|
|
|
|
|
|
|
Hi
Could anyone please tell me how to hook a printer.
I want to collect all the data regarding the printer, pages printed, who printed it etc.
I believe, this is possible if we can hook the printer. Intercept any communication to the printer.
Thanks in advance
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Does anyone know how to declare an iterator to, say, a struct variable? Here's an eg of a struct I declared outside a function:
struct vStruct {
CString szString;
int nInt;
double dDouble;
} v;
Then, inside the function I have:
std::vector<vstruct> vStruct;
And the problem is when I do this:
std::vector<vstruct>::iterator iStruct;
Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
RalfPeter wrote:
And the problem is when I do this
What's the problem? What does the compiler say?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Well, I caught the problem. The data type and the name are the same. That's thouwing off the CP. Thx,
Ralf.
|
|
|
|
|
I think some of your < and > symbols have been stripped out by CP.
But what you need to do to declare the iterator is:
<br />
std::vector<vStruct>::iterator iStruct;<br />
Mike
|
|
|
|
|
Hi
I’m going to develop an application for university and I would really appreciate some advice. I’m creating a file managing system, like tar, that creates a ‘file’ which manages a collection of files. You can add files to the ‘file’, create directories (a directory would be a file with pointers to inodes), delete them, etc. It’s like creating a small file system. I have to develop it in Linux, in C++, it’ll be an Object Oriented Program. I was thinking of dividing the ‘file’ in three parts, the main or first section, the ‘inodes’ section and the files section. The inodes are small pieces of data that contains information of the files inside the ‘file’, its name, where it starts and the size in bytes among other things. I was thinking that all of them could have the same size, but that’s not good, as space will be wasted for file names. Then, for indexing the files inside the big ‘file’, I was thinking in giving them numbers, and searching sequentially, but I need something more efficient. I heard that the best solution to that are trees. Which is the easier solution to implement, one which is also fast? Any other ideas of how could I index files inside the big ‘files’? Any links or recommended books on the subject? I’m quite new in this area of programming and I didn’t find anything useful on the net.
Thank you very much for your time!
|
|
|
|
|
Hi all,
How can I get the information (Directories, Files, Drive used Memory Spaces and Unused Memory Spaces) from the other devices which is connected to the USB Ports(Thumb Drive, Flash Card) and even Harddisc, cddrive and Floppy Drive and so on.
Waiting for Result..........
Cheers
S.Darwin Paul Raj
DARWIN PAUL RAJ
|
|
|
|
|
Hello
I made a class for TCP-kommunicating using SOCKETS.
Only MFC, programmed with MS VS .NET C++
This class is to be used from 2 tolls, one client and one Server.
Everything works.
But when I build a tool containing Client and Server a very strange mistake happens.
The Server socket calls accept to wait for the client and stand still.
The client socket calls connect to get the Server and stand still.
Normally the Server goes on with the result of accept and then the client gies on with teh result fromn connect.
In ths speziel tool the server keeps on standing still and ist gets NO result of accept. But the Client gets immedialte the succes result.
But there is no server listeing to it.
Poor client. Nobody likes it.
It is exact the same procedure with all my three tools. And when I use the ClientServer tool with one of the other everything is ok.
Does anybody know how this can happen?
Im just very frustrated.
Thanks for any answer.
Gerhard from Germany
|
|
|
|
|
Hi Gerhard,
Have you looked at the MFC Sample CHATSRVR?
And the CSocket docs 8about MFC and sockets?
Do you start the server before the client?
The book UNIX network programming by Stevens
is a good book about sockets in general.
Regards,
Magnus
|
|
|
|
|
I am working on a project where I need to track information for each row in a listctrl.
I have create a class for the tracking.
Then when I load the listctrl I create a new class and store the pointer in the SetItemData of the row.
Example:
SetItemData( GetItemCount() - 1 , ( DWORD ) new CTrackingObject() );
This works great. The problem I have: "How do I delete the class when the ListCtrl is destroyed.
I have tried overloading the DeleteAllItems() but when I call the GetItemCount() method, I get an error.
Any ideas of how I can call the pointers from the listctrl and delete the classes?
|
|
|
|
|
Cedar Sith wrote:
SetItemData( GetItemCount() - 1 , ( DWORD ) new CTrackingObject() );
This is extremely unsafe code. The first parameter to SetItemData() should be the return value of InsertItem() .
Cedar Sith wrote:
Any ideas of how I can call the pointers from the listctrl and delete the classes?
Whenever the window that owns the list contol is being destroyed, that is the correct time to delete each data item in the control.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
DavidCrow wrote:
Whenever the window that owns the list contol is being destroyed, that is the correct time to delete each data item in the control.
I assume you mean in the destructor of the listctrl.
I have this code but I still get errors.
for ( int i = 0 ; i < GetItemCount(); i++ ) {
delete ( CShippingObject* ) GetItemData( i );
}
GetItemCount throws an error.
Any new suggestions?
P.s. I have changed my code to be
int nNewId = InsertItem( ...);
SetItemData( nNewId , ( DWORD ) new CTrackingObject() );
|
|
|
|
|
Cedar Sith wrote:
I assume you mean in the destructor of the listctrl.
No, I mean the owner of the list control. That's usually a dialog or a form view.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
DavidCrow wrote:
No, I mean the owner of the list control. That's usually a dialog or a form view.
I placed the following code in the form view destructor
for ( int i = 0 ; i < GetItemCount(); i++ ) {
delete ( CTrackingObject* ) GetItemData( i );
}
and received the same error.
It is almost as if once the parent window is closed the GetItemCount method no longer works.
Any new ideas? David, Thanks for the information so far.
|
|
|
|
|
Cedar Sith wrote:
placed the following code in the form view destructor
That won't work. You have to do it before the list view is destroyed.
Cedar Sith wrote:
It is almost as if once the parent window is closed the GetItemCount method no longer works.
Of course it doesn't. None of the methods will work; because the list view has already been destroyed. You'll have to put the code in OnDestroy() at the very latest, before you call the base class OnDestroy() handler.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
OnDestroy()
OnDestroy was the key. Thank you.
I was able to call my overloaded DeleteAllItems that deleted all of the pointers from an overloaded OnDestroy in my Overloades CmyListCtrl Class.
Here are my methods:
BOOL CmyListCtrl::DeleteAllItems( )
{
if ( m_lpszType == "ShippingQuotes" ) {
for ( int i = 0 ; i < GetItemCount(); i++ ) {
delete ( CShippingObject* ) GetItemData( i );
}
}
return CListCtrl::DeleteAllItems();
}
void CmyListCtrl::OnDestroy()
{
DeleteAllItems();
CListCtrl::OnDestroy();
}
Thank you for everyone that helped me out.
|
|
|
|
|
Cedar Sith wrote:
m_lpszType == "ShippingQuotes"
What type is m_lpszType ? LPCTSTR ? If so, this comparison almost definitely won't work. You can't compare two pointers as though they were strings. All it will check is that the pointers point to the same location. Even if they point to the same thing, if they are at different addresses, the comparison will be false. Use _tcscmp() instead.
Of course, if you're using CString this won't be a problem
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
m_lpszType == "ShippingQuotes"
m_lpszType is a CString. I use the overloaded CmyListCtrl in multiple places. Not every ListCtrl has pointers. So I use the type the differentiate the listctrls.
|
|
|
|
|
It seems that the MFC code for GetItemData and GetItemCount calls the following code:
ASSERT(::IsWindow(m_hWnd));
So if the window is being closed, mfc has already destroyed the m_hWnd pointer and mfc throws and error.
If anyone has an ideas on how to delete objects whose pointers have been placed in the itemdata field ... please let me know.
Thank you.
|
|
|
|
|
At the moment I'm trying to make an effort to use std::string and std::ifstream in my work, instead of using "stdio.h" . My main objective is to write elegant code -- performance is not an issue!
I need to read a lot of blocks (of various sizes) from file, and append them to various string buffers. The problem is that functions like ifstream::read are designed to read into char* style buffers, not string s; however there seems to be some kind of relationship between streambuf s and string s that I figured might make my life easier...?
using namespace std;
...
string mystring;
ifstream inputfile;
int length = 20; ...
char* buffer = new char [length];
inputfile.read (buffer, length);
mystring += buffer;
delete[] buffer;
char ch;
for (int i=0; i<length; i++)
{
inputfile >> ch;
mystring += ch;
}
I have the gut feeling that there must be a really elegant way to do this, using some combination of streambuf / ifstream::operator>> / ifstream::read etc. I figured the whole point of using std::string was that it can worry about the allocation side of things behind the scenes. However I'm finding the documentation a little cryptic and generalised.
Any ideas?
It's quite possible I just want the moon on a stick and I should go back to BASIC...
|
|
|
|