|
yes, it's the speed of your exe...
A compiler man make different optimizations of your code. It can make your program run faster, make a smaller executable, and other stuff.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I am trying to make a program that will stream MP3s over a TCP/IP LAN, what would be the best way to set something like this up.
Thanks
-Matt Newman
|
|
|
|
|
I am having a rather anoying problem with my CString's. Consider the following code:
CString strTest = _T("hello world");
ASSERT(strTest.Replace(_T("world"), _T("universe")) > 0)
ASSERT(strTest.Find(_T("world")) == -1)
Now, that the last ASSERT will always fail (indicating that "world" is present in the string). This can be verified by sticking an AfxMessageBox call in there too.
Why (or rather how) can this happen when the replace call always succeeds with one replacement.
Cheers,
James Millson
|
|
|
|
|
I think the culprit is your last ASSERT statement, CString's Find member returns -1, if the sub string was not found.
It should be:
ASSERT ( strTest.Find ( _T ( "world" ) ) != -1 )
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Nope, It should be just as James wrote it...
You want the ASSERT to PASS if "world" is NOT found.
In fact I compiled this snippet and both asserts
pass just fine on my system.
Steve T.
|
|
|
|
|
Your right Steve, I have no idea what it was that I thought he was asking... This kind of thing has been happening all day, I must be on crack or something
cheers,
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
That's what I thought . I can only get it to pass on my system if I do:
CString strTemp = _T("hello world");
CString strTest = new CString(strTemp).GetBuffer(0);
ASSERT(strTest.Replace(_T("world"), _T("universe")) > 0)
ASSERT(strTest.Find(_T("world")) == -1)
And I don't know if that's a very good way of doing it.
And the problem only occurs in the current usuage (i.e. it works elsewhere in the project). But i've stepped backwards and forwards for hours and nothing else looks wrong, and nothing is there to indicate it is.
How very odd
Cheers
James Millson
p.s. Oh, and yes, I made up the actual text in the example above, but other than that it is the same. In both cases the equivalent of "world" should not be present in the string.
|
|
|
|
|
I have one VB object and one VC object.
This VB object will create one ADO Connection object.
To share the same connection, it is need to pass the connection
from VB to VC object.
Is it possible?
If yes, how can it be done?
Thanks.
|
|
|
|
|
Does anybody here know what this can be translated to in the win32 api?
AfxGetThreadState()->m_lastSentMsg;
i know it has something to do with the message queue, but i want to know what its API equivelent is
|
|
|
|
|
I image you could just declare a global MSG variable, and each time your window procedure gets called, just store the messages information.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I use the getline function to retrieve lines from files. The problem is I have some files where lines are ended with a Carriage Return "\r" and some that are ended with a New Line "\n". How can I satisfy both without reading and checking every character?
|
|
|
|
|
Usually it's either \r\n or just \n.
What I do is totally strip any \r i come across and just
process the \n.
|
|
|
|
|
Is there a way to create a new Dao database using VC++? I know that this requires long answer, so if someone could provide a link to any help, it would be greatly apperciated.
Richard
|
|
|
|
|
yes, Using the CDaoDatabase::Create();
CDaoDatabase pdaodb;
pdaodb.Create("C:\\Mydb.mdb", dbLangGeneral, dbVersion30);
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Hi,
Would someone kindly help me out of this 6 hour long struggle.
I have an SDI app with a RichEditView. I don't need the RTF functionality, so I want to serialize text only. I've searched everywhere (even the MS Newsgroups) for a sample on how to serialize using streamin and streamout.
I understand that I have to set m_bRTF to false in order to save / load in text only, but for the life of me I can't find a sample that shows how.
An explanation or sample code would be great.
Thanks,
Frank
|
|
|
|
|
I'm not typing from much eperience here, but this is what a standard sample CMyAppWizCreatedRichEditDoc::Serialize does:
void CEditDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
}
else
{
}
CRichEditDoc::Serialize(ar);
}
CRichEditDoc::Serialize gets a pointer to the CRichEditView type object and calls serialize on that - and yes, if I don't set m_bRTF false some files fail to get read in.
If you are not using a CRichEditDoc, I would think you could fake it with a call to the view, but not sure what then happens to m_bRTF.
You can look in ...\MFC\SRC\VIEWRICH.CPP to see all the fun Stream stuff. The above code comes from the App Wizard if you select CRichEditView for your view class.
|
|
|
|
|
Thanks for the info Tim. My app is a basic appwizard generated sdi mfc app that uses RichEditDoc, and RichEditView. The serialize function in my app is exactly what you've listed in your example.
However, Where do I go from here? Ah the humanity! Where's the tylenol.
Frank
|
|
|
|
|
Hmm... I just use the Open... and Save stuff... however, I do notice that if I don't set the m_bRTF it will only show (the text of) files with the .txt extension...
Oh - and I think there's some tylenol in that white metal box with the red cross on it on top of the water cooler...
later...
CRichEditDoc::m_bRTF = FALSE;
CRichEditDoc::Serialize(ar);
|
|
|
|
|
Thanks again Tim.
I found some Excedrin...so now I'm on a major caffiene high! Woohoo!
Frank
|
|
|
|
|
GREETINGS
Could somebody help me with CheckListBox?
I can create it with .Create function, but it's useless. I need to attach it to ListBox control on the dialog.
Thank you!
LOVE & PEACE to everyone
|
|
|
|
|
Simply do what you usually would do to associate a litbox with a variable, and then substitute CListBox for CCheckListBox.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Thank you Ben .
I tried it, but there occures an error when i start the program...
Is there any way do do it with either SubclassDlgItem or something else?
Thank you very much!
LOVE & PEACE to everyone
LOVE & PEACE to everyone
|
|
|
|
|
Opps... forgor two important parts;
1) the listbox must be owner draw fixed.
2) the 'Has Strings' style must be enabled.
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
GREETINGS
Thank you Benner, it turned out that it is so easy! Thank you very much!
Good luck!
LOVE & PEACE to everyone
LOVE & PEACE to everyone
|
|
|
|
|
I had the following working OK up until I split the class up into two classes.
static const UINT SomeVariable = ::RegisterWindowMessage("SomeString");
ClassA::Method()
{
...
...
PostMessage(SomeVariable, 0, (LPARAM)pSomething);
...
}
BEGIN_MESSAGE_MAP(ClassA, CComboBox)
ON_REGISTERED_MESSAGE(SomeVariable, OnAddItem)
END_MESSAGE_MAP()
ClassA::OnAddItem(WPARAM, LPARAM)
{
...
...
}
I began to realize that I needed to split the class up, because I was starting to develop ClassB, ClassC, and etc.. and it was only the Member ::Method() that was going to be different. So I split up the class like this
static const UINT ClassA::RegisterWndMessage = ::RegisterWindowMessage("SomeString");
BEGIN_MESSAGE_MAP(ClassA, CComboBox)
ON_REGISTERED_MESSAGE(ClassA::RegisterWndMessage, OnAddItem)
END_MESSAGE_MAP()
ClassA::OnAddItem(WPARAM, LPARAM)
{
...
...
}
ClassB::Method()
{
...
...
PostMessage(ClassA::RegisterWndMessage, 0, (LPARAM)pSomething);
...
}
ClassC::Method()
{
...
...
PostMessage(ClassA::RegisterWndMessage, 0, (LPARAM)pSomething);
...
}
Only now each implementation must inherit from Class A. The member Method() is declared as NULL in class A, so that each inheritor must implement Method(). When I use the class now, each instance of Method() is executed, but the method ClassA::OnAddItem() is never executed. I've probably forgot to wire something about the message maps in order to get this to work, but I can't see it. Anybody got a suggestion. Thanks.
Chris
|
|
|
|