ADARSH Try int x = Convert::ToInt32(str); or int x = Convert::ToInt16(str); Convert has several conversions available. Cheers John
bollwerj
Posts
-
conversion form String type to int type -
STRING* to LPTSTRNik Thanks for the tip Actually, the only method that worked for me was method 2. Method 3 would not compile. The include altstr.h produced IServiceProvider error. Method 1 compiled OK, but I had to use a LPSTR cast to get it to compile. However, it produced a number (34") regardless of the value of the String* that I fed it. Perhaps there are ways to get methods 1 & 3 to work, but I don't know enough about .Net to figure out how. Cheers and best wishes in your PhD effort. John
-
STRING* to LPTSTRDirk, Thanks for the response. I seem to be a bit thick headed, I don't understand what you are suggesting. What data type is pStr? The compiler does not recognize GetBuffer as a member of LPTSTR or of .Net String class. It is a member of .Net MemoryStream class. How do you propose that I do this? What I am doing now to convert a String* variable named line to a LPTSTR (char*) is: char* chars = new char[line->length+1]; for (register i = 0; i < line->length; i++) { chars[i] = (char)line->Chars[i]; } //Add the NULL at the end chars[line->length] = '\0'; The above seems to work but it just seems like a lot of processing to just convert from one data type to another. I'm thinking that there must be a more straightforward way. Thanks John B
-
STRING* to LPTSTRAnyone know a simple way to convert a String* variable to a LPTSTR variable?
-
ListView Item Selection ProblemHere is what seems to be happening: The first time an item is selected, the SelectedIndexChanged event is called and a SelectedListViewItemCollection is returned containing the selected item. Subsequent item selections seem to cause the SelectedIndexChanged event to be fired TWICE, the first time returning an empty collection but the second time returning selected items. Is this the way it is supposed to work??????? John B:confused:
-
ListView Item Selection ProblemProblem is in getting the selected item in a ListView. The view property is Details and MultiSelect is set to false. listView Here is the code I use: Void Form1::lvMain_SelectedIndexChanged(System::Object * sender, System::EventArgs * e) { ListView::SelectedListViewItemCollection* lvc = lvMain->get_SelectedItems(); IEnumerator* ie = lvc->GetEnumerator(); ie->MoveNext(); ListViewItem* lvi = __try_cast(ie->Current); . . . } The first time a selection is made in the listbox by clicking on an item, the selected item is returned in the SelectedListViewItemCollection which has a count of 1. without a problem. HOWEVER, the next time an item is clicked, the SelectedListViewItemCollection that is returned has a count of 0. Naturally, attempting to move the iterator causes an exception to be thrown. Does anyone know why nothing is returned in the SelectedListViewItemCollection when the selection is changed the second time??? Also, what is the solution??? Appreciate any help. John B
-
Messageboxes in managed C++Had the same problem and found the solution in one of Microsoft's articles. At the beginning of the.cpp file, after the includes, I put the following: #ifdef MessageBox #undef MessageBox #endif The problem seems to be caused by a confliction in MessageBox declarations between the .Net declaration and the one in the windows.h file. Cheers