|
Hi,
I´m trying to make an application that uses a mySql database and a CTreeCtrl to display the element from the database. While I have managed to extract the information from the database using CDBVariant I have a problem while trying to insert the value into the tree.
From some reason the text that I´m extracting from the database is put in the CDBVariant.m_pstringA which is a pointer to a CStringA. The problem is that I can´t convert the CStringA variable into a LPCTSTR which is required by the CTreeCtrl::InsertItem(). Any ideas on how to do that?
Thanks.
<br />
CDBVariant varValue;<br />
short nFields = camere->GetODBCFieldCount();<br />
while(!camere->IsEOF())<br />
{<br />
for (short index = 1; index < nFields; index++)<br />
{<br />
camere->GetFieldValue(index,varValue);<br />
if (varValue.m_dwType == 10)<br />
{<br />
CStringA cam;<br />
cam.Append(varValue.m_pstringA->GetBuffer());<br />
}<br />
}<br />
camere->MoveNext();<br />
}<br />
|
|
|
|
|
call GetBuffer() on the CString
|
|
|
|
|
Josh Gray wrote: call GetBuffer() on the CString
There was no requirement to modify the CString internal buffer.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Unless you're doing a UNICODE build, you can do:
m_tree.InsertItem(*(varValue.m_pstringA),0, 0, hCamere, NULL);
since CString implements the (LPCTSTR) cast operator.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Also, try to avoid using CStringA or CStringW directly. Prefer to use CString instead: it is a macro that will convert to CStringW if unicode is defined or to CStringA otherwise.
If you have to work with CStringA or CStringW directly, then I think you have a design problem (mixing unicode and non-unicode in a wrong way).
|
|
|
|
|
I´ve already tried the GetBuffer() method but it didn´t work. Fortunatelly the solution of CPallini worked once I´ve changed the Character Set to "No Set".
Well, I was using CStringA only because it didn´t allowed me to put the value in a CString.
Thanks.
|
|
|
|
|
marius.ichim wrote: Well, I was using CStringA only because it didn´t allowed me to put the value in a CString
Then it's because you probably did something wrong with unicode settings. Maybe you should read this article.[^]
|
|
|
|
|
Hello All,
I have made a sdi application with a splitter control inside it. i have class derived from CFormView for right view. Now my problem is i have made a ui thread and i m sending a CString and a int message from that ui thread using SendMessage to my right view class. one time it works fine but when i regularly stop and start the thread it gives DEBUG ASSERTION FAILED ERROR in wincore.cpp and the position it shows is send message one.
Can anybody solve my problem please
thanks in advance
|
|
|
|
|
ASSERTION should give you idea, why app is failing.
neha.agarwal27 wrote: in wincore.cpp and the position it shows is send message
But what line in wincore.cpp ?
Prasad
MS MVP - VC++
|
|
|
|
|
line no 980
sometimes it also gives memory cannot be read error
|
|
|
|
|
Probably, you can show call stack , it is showing. Cannot guess without seeing some code.
Prasad
MS MVP - VC++
|
|
|
|
|
neha.agarwal27 wrote: line no 980
There's several versions of MFC in use. What's at that line in your MFC source?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Hi
In my programme Server was Lisening in port no "9090" and
client was connected to that by giving port no and IP-Address .
Now i want to know wheather Server can provide an Port no to client when they connect.
Because if same port no used by two client ,they cannot access(therfore server must assign a port no).
Give me a suggestion about this.
Regards
shakumar
shakumar
|
|
|
|
|
the port 9090 is the listening socket
when a connection is established a new socket is createdon the server side and the listening socket continues to listen. The server side port number used in the connection is assigned by the network stack
you can use the netstat command in windows to see which ports are being used
|
|
|
|
|
server will continue to listen on same port no.
When clients makes a connect server will accept the request and new socket will be created with diff id.
|
|
|
|
|
Thanks for Your Reply
shakumar
|
|
|
|
|
Are you actually running into a problem?
Or are you just wondering how it all works?
What's been said about server-ports is true. For example, a web server listens on port 80 and can accept multiple connection via that port. It does so by creating 1 listening socket on that port. When incoming connections are made, new sockets are created to handle each conversation/connection.
On the client side, you can run into problems if you assign a port there. Don't do it, always set your client-side port to 0.
If you were to attempt to test 2 clients fromt the same computer, you'd run into problems with conflicting ports. By using port 0
you're instructing your tcp stack to allocate an available client-side port -- avoiding any conflict.
It's not like you actually would care about this client-side port...
I don't know if this helps, but I thought I'd share...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
In VS install directory, there're some files(.cpp, .h) seems to be source code of MFC. So can I put them back into VC and compile them?
|
|
|
|
|
Yes but if you make any changes you will need to distribute your new DLL(s) along with your app
|
|
|
|
|
You can. But you really shouldn't do it unless you have a very good reason to do so. And I can't think of a good reason to.
If you want to change the behavior of some class, just subclass it and handle it in that good old C++ way...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Oh...I'd like to have a try. Just to know MFC libray better.
So are there any instructions about compiling MFC source code on the internet?
|
|
|
|
|
I'm not sure how building the library yourself will help you "know MFC libray better", but...
Take a look in the atl/mfc src directory.
For example, in VS 2005, there's a readme.txt that states:
Building ATL and MFC
To build either ATL or MFC open a command prompt and run vcvars32.bat from <path to vc8>\bin
Change directory to <path to vc8>\atlmfc\src
atlmfc.mak can be used to rebuild all ATL and MFC libraries and DLLs.
Following is the command line you can specify with NMAKE
nmake /f atlmfc.mak [ALL | ATL | MFC] [CLEAN= ] [LIBNAME= ] [PLATFORM= ]
Targets
ALL - builds both ATL and MFC. This is the default target. LIBNAME has to be
specified.
ATL - builds only ATL.
MFC - builds only MFC. LIBNAME has to be specified.
CLEAN=1 cleans the files generated by the specified targets
LIBNAME="name of the MFCdll being built" - specifying MFC80 builds the prebuilt DLLs
PLATFORM=[AMD64|IA64] if building for 64-bit on a 32-bit system
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Very long time ago, I just wondered why doesn't MFC add all Windows message handlers to CWnd and make them all virtual, so that derived classed don't need to add message handlers but only to override virtual functions.
MFC claims that it uses message maps rather than virtual functions just in order to tune the performance, now it's time to tell the real difference.
|
|
|
|
|
Cool. Let us know the results!
From Technical Note TN006:
"Microsoft Windows implements what are essentially virtual functions in window classes using its
messaging facility. Due to the large number of messages involved, providing a separate virtual
function for each Windows message results in a prohibitively large vtable.
Also, since the number of system-defined Windows messages changes over time, and since a specific
application may want to define some Windows messages of its own, the message-map mechanism
provides a level of indirection that prevents interface changes from breaking existing code."
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Hi All,
How Can we make a Modeless Dialog Box to Act as Modal Dialog Box??
Thanks
Today is a gift, that's why it is called the present.
|
|
|
|