|
First, it will probably work better if you use "\r\n" instead of "\n\r". I had trouble remembering which one to use until I realized that "\r\n" is like "RN" as in "Registered Nurse".
People have asked about the maximum possible size of CString items and I have seen no answer to this question except 2,147,483,647 (2GB; INT_MAX). Since the return value of CString::GetLength is an int, it makes sense that a CString cannot be any larger than the value of an int. So in reality, a CString size is probably limited only to available memory.
|
|
|
|
|
Hi,
a Suggestion for this behavior.
The debugger will show you only 255 (or 256?) characters,
even when CString contains more than this amount.
HTH
Holger Persch
|
|
|
|
|
Why dont you use CStringList class which is a builtin linklist of CString. You can use it for storing each line in a sepetate element of the CStringlist object. You only have to call object.AddTail(data string) for each element.
For more information you can see the detail in the MSDN help.
|
|
|
|
|
Anyone have any usefull tips on how I can go about adding a menu
option in Internet Explorer's Right Click menu for a link. I am
developing downloading software in C++ and want IE to send links
to my program.
|
|
|
|
|
Hi,
Set a registry key entry at
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&MYMenuItemText
Now Make the Default Value what you wish the MyMenuItemText do,
Also you can add a Binary Value to a data item "Contexts"
0x20 Allows only Anchors to display the Context-Menu-Item
and the Data Item Flags can have a DWORD value of 0x01 that can run the Default Value;
"Best bet have a look how other programs alter the \MenuExt\
key.
Regardz
Colin Davies
|
|
|
|
|
Hello everybody!
I hope that someone can help me with the strange problem that I have.
I am printing the text on the page using DrawText function. The text is big enough so it may go across several pages. And the strange thing is that when I do Zoom in the Print Preview, size of the font changes so the boundary box of the resulting text is different for different zooms! And on the page itself it looks like different portion of the text is displayed per page for every zoom coefficient.
I wonder if someone knows what is the catch here?
Thanks in advance.
|
|
|
|
|
Hi,
try using CFont::CreatePointFont(...) for initalising the font.
HTH
Holger Persch
|
|
|
|
|
Hello!
Thanks for your suggestion.
Unfortunately it will not work, because this behavior (as I found out later) is caused by bug (feature?!) in CPreviewDC implementation of the DrawText routine that I am using to output text. It does not take into account m_hAttribDC and uses only m_hDC for drawing - as a result for different zoom levels there are fonts of different height, selected into m_hDC -> size of the bounding box for DrawText veries. I do not know yet how to overcome this bug, but for sure this is not that easy...
|
|
|
|
|
I'm trying to do the following ... pass some data from a VB client to a VC++ server via
COM. I realize that I have to use automation-compatible data types such as VARIANTs
and SAFEARRAYs. However, I'm having difficulty figuring-out exactly how to define the
method in IDL and interpret the data on the server side.
The data is a set of 29 variables, most of which are integers. Some are floats, with one
string and couple of arrays thrown in for good measure. Obviously it would be tedious
to set-up and use a method with 29 parameters. So, I'd like to pass all of the data in
one chunk if I can. Additionally, there will be 2 other chunks of data returned to the
client in the same method ... but that's a different question. The only thing I'm
trying to do now is get the chunk of data to the server.
In all that I've read, it seems that the best way to pass the chunks of data is using
arrays of VARIANTs. Is that true ? If so, how do I define the method interface in
IDL and how do I unpack the data on the server ?
Any guidance would be helpful.
Thank you,
Keith Gemeinhart
|
|
|
|
|
Thanks to all who replied. I have solved the problem ... and
in the near future, I will post a short description of how I
did it.
-Keith
|
|
|
|
|
I have a code that compiled fine with another compiler but with VC++ 6.0 I get some errors.
I'm form sweden and dont understand this one:
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
|
|
|
|
|
I mean whats an explicit cast?
|
|
|
|
|
Lets say you have a function that takes a void* as input.
void CMyDlg::MyFunc(void *pointer)
{
...
and inside the function, you want to tell the compiler that the pointer is to a char ...
This is the C++ way:
MessageBox( static_cast<char*>( pointer));
This is the C way
MessageBox((char*)pointer);
Both are explicit casts. An implicit cast occurs when the compiler can find an operator it can substitute to do the conversion. CString has one of these - operator LPCTSTR, but it only works for const char*.
HTH - you probably know these in another terminology.
|
|
|
|
|
Hi everyone,
PLEASE HELP ME OUT!!
I want to do the following SQL statement with ADO.
"CREATE TABLE Customer (Customer id INTEGER, Price INTEGER,ETC..)";
But how do i specify the name of the table (ie "Customer") which i want to create as a variable?? so i can have an edit box and have the user type in what they want as the table's name?? same thing for the fields. i don't want name and fields of the table to be predefined but allow the user to decide what to put in as the table name and fields. But with SQL statement, i can't put in variables inside the " CREATE TABLE..." quote right?
i also tried to define the SQL statement as a string first, then add variables inside the string and combining the strings. then have the SQL query the string. but i'm having trouble with that.
if you know a way to do solve this please let me know and i really appreciate it. Thanks
steve
|
|
|
|
|
Steve,
For your variables, iterate through the list and build up a string.
// replace following 2 code lines with code to pull values out of the UI you have built up.
char* pszVariables[] = {"Customer_Id", "Price", ...};
char* pszVariableTypes[] = {"INTEGER", "INTEGER", ...};
char** pszCurrentVar = pszVariables;
char** pszCurrentVarType = pszVariablesTypes;
_bstr_t bsVariables = ""; // you can use CString or something else if you want here.
while (pszCurrentVar && pszCurrentVarType && *pszCurrentVar && *pszCurrentVarType)
{
if (bsVariables.length())
{
bsVariables += " , ";
}
bsVariables += *pszCurrentVar;
bsVariables += " ";
bsVariables += *pszCurrentVarType;
pszCurrentVarType++;
pszCurrentVar++;
}
_bstr_t bsQuery;
bsQuery = "CREATE TABLE ";
bsQuery += pszTableName;
bsQuery += " (";
bsQuery += bsVariables;
bsQuery += ")";
// bsQuery now contains CREATE TABLE SQL statement.
// execute CREATE TABLE statement
MyConn.Execute(bsQuery);
Hope this helps,
-Erik
|
|
|
|
|
in an MFC dialog i have a Edit control. When you press enter it quits. How do i override this???
|
|
|
|
|
Override the OkOK method.
|
|
|
|
|
As Tim said, override OnOk, but if you leave in the call to CDialog::OnOk the dialog will still end.
|
|
|
|
|
Problem:
Main app using 3rd party libraries as base for most
classes. These 3rd party libs include windows.h.
Have DLL with descendant of CDialog in it. I'm told (MSDN) you can use a statically or dynamically linked Win32 DLL using MFC within a non-MFC program (the main program doesn't see the MFC).
How?
When I include the header for a class in my DLL (which at the moment contains nothing, was planned to contain my CDIalog), the main project won't build because it complains about including stdafx.h (I have afxwin.h included therein). If I try to leave out stdafx.h, of course the DLL itself won't build.
So what do I need to do to create a header that can be included in my main project, has the exports that won't drag MFC into the main App, and so that the DLL will still build?
Any help appreciated.
|
|
|
|
|
You can't export an MFC class from a DLL to a non-MFC application. There are many reasons for this, but suffice it to say that it can't be done.
What the MSDN means when it says you can use MFC in a DLL and call it from a non-MFC app, was that you can have a DLL that exports various functions, which can in and of themselves call MFC. You cannot call MFC derived classes directly from your app.
So, what you would do is create an export called "ShowMyDlg()" which will create the CDialog, and another function called "GetDataFromMyDialog()" to retive the data from it.
|
|
|
|
|
Howdy!
I assigned the OFN_ALLOWMULTISELECT flag when I created my Open file dialog, but I don't know how to get the selected filenames.
Oh btw, I'm not using MFC.
Anyway, if you can help me, please post a reply.
Thanks!!
|
|
|
|
|
The lpstrFile member of your OPENFILENAME struct points to a double-null-terminated list of the files. For example:
c:\foo\bar.exe\0c:\foo\bleat.exe\0\0
|
|
|
|
|
Hello,
I have a function that returns several strings. This function is run over and over again many times. I would like to store all the returned strings in an array. I'm assuming that I have to use a struct. But, how do I get the values inside by index after its created. In VB (yea, i know.) It would be something like this:
Private Type StrData
String1 as string
String2 as String
End Type
Then to access the array it would be something like this:
rtn = StrData.String1(0)
So, how do I convert this to C++ and MFC?
Thanks!
Frank
|
|
|
|
|
I don't understand what rtn = StrData.String1(0) means exactly. What is the (0) there for? "String1" isn't an array.
Anyway, to make a typedef'd struct:
typedef struct
{
CString String1, String2;
} StrData;
To make an array of those, you can use a linked list (since it sounds like you don't know exactly how many structs you'll have). Use std::list<StrData> in STL, or CList<StrData, StrData&> in MFC.
|
|
|
|
|
Thanks Mike. In VB, rtn = StrData.String1(0) the (0) is the index of the n'th (where n is just a number) String1 object contained in the data type StrData. (I think)
I'm afraid I'm new to using "Linked Lists". Could you expand a bit on the usage in MFC? What do I do with the code CList<strdata, strdata&="">.
Thanks again,
Frank
|
|
|
|