joe_pool_is Posted June 28, 2006 Posted June 28, 2006 Looking at the VS 2005 Express example for C++ "How to Modify the Size of Placement of a Picture at Run Time": private: void StretchPic() { // Stretch the picture to fit the control. pictureBox1->SizeMode = PictureBoxSizeMode::StretchImage; // Load the picture into the control. // You should replace the bold image // in the sample below with an icon of your own choosing. pictureBox1->Image = Image::FromFile(String::Concat( System::Environment::GetFolderPath( System::Environment::SpecialFolder::Personal), "\\Image.gif")); } Does not work. I can find the image ok, but the filename starts with "C:\Documents and ..." but the compiler breaks at the "C" (first letter). Any idea why this example doesn't work? Quote Avoid Sears Home Improvement
Leaders snarfblam Posted June 28, 2006 Leaders Posted June 28, 2006 Escape sequences? The backslach begins an escape sequence. \r is carrige return. \n is newline. For each backslash you want to place in a string, type in two: \\. System::String path = "C:\\Documents and settings\\things and stuff\\file.exension" Quote [sIGPIC]e[/sIGPIC]
joe_pool_is Posted June 29, 2006 Author Posted June 29, 2006 Escape sequences? The backslach begins an escape sequence. \r is carrige return. \n is newline. For each backslash you want to place in a string, type in two: \\. System::String path = "C:\\Documents and settings\\things and stuff\\file.exension" Yes! I spent some time on this last night, and also came to this conclusion. Why would Microsoft's example spit out strings that C++ can not use, namely GetFolderPath()? Do they typically show example code that has not been tested? I don't suppose C++ has some built in function (that is compatible with MFC, STL, CLR, WIN32, etc.) for taking a string and doubling every "\" that it comes across, does it? Quote Avoid Sears Home Improvement
Administrators PlausiblyDamp Posted June 29, 2006 Administrators Posted June 29, 2006 Not sure if it works in C++ (don't have it installed on the PC to test either) but in C# if you prefix the string with an @ symbol then it doesn't escape anything. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
joe_pool_is Posted June 29, 2006 Author Posted June 29, 2006 FWIW: The @ symbol didn't work. Quote Avoid Sears Home Improvement
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.