Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • Leaders
Posted

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"

[sIGPIC]e[/sIGPIC]
Posted
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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...