MessageBox

Can I use format in MessagBox::Show?

I want to use like below.

char *filename;
filename = "test.txt";
....
....
MessageBox::Show ("Failed to open file %s", filename);

Is there any way to use like this, "Failed to open file %s", filename, in MessageBox?
Is this C++?
Yes, it is Visual C++.
Then I've not heard of MessageBox::Show before,but just MessageBox() function--WinAPI.


But I know of a trick of combining the windows version of sprintf which is wsprintf,with MessageBox() function, and it works exactly as printf(in C).

eg:

1
2
3
4
5
6
TCHAR test[100];  //*an array of wchar_t/char of 100 elements functioning as the buffer
wsprintf(test,
      TEXT("This is a test code: %i meaning Aceix.\n1 for A\n3 for c\n5 for e\n9 for i\n24 for x\n\nThanks for understanding my CODE!"),
      135924);   //This stores the string into the buffer works somehow like printf

MessageBox(NULL,test,TEXT("Info..."),NULL);  //This is to display the buffer in a message box. 


--------------------------------References--------------------------------------
* will be wchar_t if UNICODE is defined, otherwise, char


HTH(Hope This Helps),
Aceix.
Last edited on
Topic archived. No new replies allowed.