|
char s[2];
sprintf(s,"%c",nChar); // NOTE: %c NOT %d
Func(s);
OR
s[0] = (char)(unsigned char)nChar; // insurring proper conversion
s[1] = '\0';
Func(s)
Note: If you ever plan to allow code to work with Double Byte Characters or UNICODE, then neither of the above methods should be used (w/o modifying).
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Dear friends:
i have an audio file that use vivo's siren codec.
all of the data is pure audio data. but i don't know if i can add a wave header and then play it using Windows Media player.
can anyone help me?
if it can be played using Windows Media player, then can give me a sample wav file?
if it can't be played using Windows Media player, then how can i play this file?
|
|
|
|
|
Hi,
Data could be shared between processes through ways like file mapping, mailslot, pipe, DDE and so on. But if data contain pointers like the following structure, how can processes share this kind of data?
struct Pointers{<br />
FirstStruct* pFirstStruct;<br />
SecondStruct* pSecondStruct;<br />
}
Appreciating answers from anybody. Thanks.
|
|
|
|
|
What about using shared memory, through a memory-mapped file?
Fold With Us!
"For every complex problem there is an answer that is clear, simple, and wrong" - H.L. Mencken
|
|
|
|
|
One way this will work is to create a memory mapped file at the same virtual address in both processes. The pointers in your data structures must point to this 'shared' memory that is at exactly the same address.
One thing to keep in mind, virtual memory available in one process at a speciftic address might not necessarily be available in the second, like one has a DLL loaded there already or something.
I would strongly recommend against the use of the pointers like this.
You could change your data structure to store an index, and have an array of your FirstStruct and
SecondStruct in shared memory, then they would not have to be at same address.
struct DataIndexes{
DWORD dwFirstStructOffset;
DWORD dwSecondStructOffset;
}
array of FirstStruct in shared memory
array of SecondStruct in shared memory
These two don't need to be in same shared memory mapped file, either.
Then you do not have to worry if the data is shared at exactly the same virtual address.
If you know how many items you need ahead of time, the easiest way woudl be to just create array of
struct SharedData{
FirstStruct mFirst;
SecondStruct mSecond;
}
and make an array of them in the shared memory (via memory mapped file), which, again, would not have to be at same virtual address within each process.
|
|
|
|
|
Consider the following scenario
In a MDI application
A and B are two objects of Class V(CView) . There is one Document object D .
Consider data represented as T (say a buffer of 1024 bytes) . This data can be stored as a file (F) or in another device (R).
A is a graphical representation of F and B is a graphical representation of R .
F and R are managed by a Server (S)
In the app , D(the one and only one) talks to S .
I have some basic questions :
1) D , based on the API calls to S knows if the data it is receiving is meant for either A or B . Does D have knowledge of A and B . In other other words can he do
A->Populate() and B->Populate()
This would mean that the Doc class pushes data to its view . I wasnt too sure of this
2) If the above is not allowed , It meants that based on a call that D makes ( like UpdateAllViews)
A and B have to update their representation .
Consider that fact that my file has changed by 1 bit , do i have to reload/refresh the entire buffer ? If i want to avoid this I have to add a significant amount of information in D
I am not able to zero in on the right methodology . I hope some one can give me a direction
thanks
Engineering is the effort !
|
|
|
|
|
Generally, Doc/View is set up such that the document provides access to whatever data there is, and also sends notifications when that data changes. The views are responsible for deciding which data they'll display, how they'll display it, and how they respond to notifications. In your scenario, S should communicate to D the data change in such a way that D can update its buffer efficiently (potentially changing only those bytes that have actually changed, for instance), and then send a notification. The notification should reflect how the data has changed, such that the views can update themselves efficiently. Each view should then determine whether the change has any relevance to what it displays, and update appropriately.
Of course, these are guidelines - you can implement it in whatever way makes the most sense for your particular needs. There's no "one size fits all"...
You left me high and dry and changed me
You lied to me and now i’m angry...
|
|
|
|
|
Thank you for your reply .
|
|
|
|
|
Hi,
I am trying to return a string(char*) from a c++ dll and the string i return comes out blank. can anyone help me on this.
Vinayak D. Labade
|
|
|
|
|
where did you allocate your storage?
most people pass in the allocate storage with it size to the function they intended to call
char *pNew = new char[100];
memset(pNew, NULL, sizeof(pNew));
yourDLLFuncCall(pNew, sizeof(pNew));
delete [] pNew;
so that they could deallocate it once done at the caller itself. If you allocate storage in your DLL function and deallocate it in your main exe, there would be a tendency of getting a memory leak or crash when calling delete.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
On startup how do i resize the view to fit the size of the parent frame ?
|
|
|
|
|
I would try to maximise the Child Frame holding the view, like this for example (supposing you use MFC):
<code>
void CChildFrame::ActivateFrame(int nCmdShow)
{
nCmdShow = SW_MAXIMIZE;
CMDIChildWnd::ActivateFrame(nCmdShow);
}
HTH,
Fold With Us!
"For every complex problem there is an answer that is clear, simple, and wrong" - H.L. Mencken
|
|
|
|
|
Please be more precise and explain your problem clearly for better and beneficial replies.
Rahim Rattani
Software Engineer,
Matrix Systems (Pvt) Ltd.,
Karachi - Pakistan
|
|
|
|
|
Hello, I 'm writting an application with winsock and I want to resolve an ip address from a hostname. What I need is a function call to whom I 'll give for example "www.codeproject.com" and it will return to me its ip address. I know that there's such a function but I can't find it.
Thanks in advance,
Themis
|
|
|
|
|
There are a couple of nice examples here[^].
"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
|
|
|
|
|
Hello my best friends,
I'm a beginner to Visual C++ programming, so I have some "stupid" questions for you and I hope you guys to help me.
I'm working on my own very simple chatapplication, but I encounterd some problems. I've made a client and a server part, I've tested it out but I had the problem that I couldn't send a text string. My serverside establishes a connection with the clientside ( I know it because I put some control messages to be sure there is a connection).
But when I try to send a peace of text, it does nothing except that it shows the sending text on my display and the receiver part shows nothing on the display. I used the following code to send a string:
void CSimComDlg::OnSend()
{
m_Message.GetWindowText(strMESSAGE);
m_pArOut->WriteString(strMESSAGE);
m_pArOut->Flush();
m_MsgDsp.SetWindowText(_T(Name+":"+strMESSAGE+"\r\n"));
strMESSAGE.Empty();
}
And to read a received string:
void CSimComDlg::ReadReceive()
{
m_pArIn->ReadString(strMESSAGE);
m_MsgDsp.SetWindowText(_T("Chatter:"+strMESSAGE+"\r\n"));
strMESSAGE.Empty();
}
m_pArOut and m_pArIn are CArchive pointers (I use this in combination with CSocketFile to send data over internet).
Is there something wrong with these codes?
I've seen some other example codes on the internet, they include also the length of the message to send and they check also the buffer if there's more data coming in. But are they neccesary to put them in my code?
I hope you can help me boyzz
If my application works, I forget all my problems.
|
|
|
|
|
I am trying to capture events from a running instance of Microsoft Word. If I could do this using MFC libraries, this would be a walk in the park. However, I HAVE to do this using straight C++ without the help of MFC libraries what-so-ever.
I have done a lot of reading (especially on this site) on this topic and have tried to implement this event handling in a VC++ console application. I understand that you need to have event sinks to handle these events and that the COM object has to support the interface that the client application is exposing. The problem I have, is that in all the examples I have found on the web, the developers have created their own COM object and have a client that talks to that. What I haven't been able to find, is a straight forward example of how to make a connection to any of the Microsoft Office applications using the Adise method. Every time I try it, it fails.
Could anyone help me? I just need a basic explanation of how to set up this connection, or better yet, some very basic source on how to do this.
Any help would be massively appreciated!
|
|
|
|
|
I need to know if someone can tell me how i can make an struct array what uses an LPSTR or anything similar identifiyng method instead of the normal int method , i need it for a project in that i am.
Thank you for your help
Example:
MyArrayStruct("identifier").Anything=0xFF;
|
|
|
|
|
you need a map. try a CMap or a std::map
CMap< CString, LPCSTR, CPerson, CPerson& > myMap2;
CPerson person;
LPCSTR lpstrName = "Jones";
myMap2->SetAt( lpstrName, person );
or
typedef map< CString , CPerson> clrMap;
theMap clrMap;
...
clrMap::const_iterator it;
it = theMap.find(name);
if (it!=theMap.end())
{
return (*it).second;
}
Software | Cleek
|
|
|
|
|
Thank you Chris Losinger , I only make you one question, the first mode uses MFC if i`m not wrong, but the second don't uses it, right?
PD: I don't use that in my project, i need do it withuot the MFC classes, only with C++...
|
|
|
|
|
correct. if you don't use MFC, std::map will still work for you.
i would recommend std::map over CMap in any case.
-c
Software | Cleek
|
|
|
|
|
another question how i implement this function??
do you can explain me???
please...
Thank you
|
|
|
|
|
|
Pre-compiled a C library using msvc 6, blah.lib
In a new C++ project, include header and library location in Tools->Options->Directories, included header in the C++ file and include library in the Settings->Link tab
I get a linker error stating:
main.obj : error LNK2001: unresolved external symbol "int __cdecl hInitialise(int,struct HWND__ *,struct HDC__ *,unsigned int)" (?hInitialise@@YAHHPAUHWND__@@PAUHDC__@@I@Z)
I was not able to recompile the library into C++, cause of header problems....
|
|
|
|
|
This smells like a name mangling issue. Try to wrap the header file that contains your function declarations with
extern "C"
{
...
... all of your functions
...
} and then rebuild your library and then rebuild your app.
Chris Meech
I am Canadian. [heard in a local bar]
Gently arching his fishing rod back he moves the tip forward in a gentle arch releasing the line.... kersplunk [Doug Goulden]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|