|
|
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I am trying to use MessageBox in .NET but I keep getting an error.
Code I am using:
MessageBox( NULL, "This is the text", "MessageBox", MB_OK );
Error I am recieving:
error C2065: 'MB_OK' : undeclared identifier
I get this error, however, when I mouse over MB_OK it gives me a tooltip saying "#define MB_OK 0x00000000L". Anyone know what I can use in it's place or how to fix this?
Thanks,
Tom Sapp
http://www.sappsworld.com
|
|
|
|
|
I just use 0.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well, that resolved that issue. Now I have this issue:
error C2514: 'System::Windows::Forms::MessageBox' : class has no constructors
Guess I am not doing something right!
Thanks,
Tom Sapp
http://www.sappsworld.com
|
|
|
|
|
Oh, this is a managed C++ message box. In that case - MessageBox has no constructors. Instead, it has a static method called Show. In that case, you need to pass in the managed enum, you can't pass in a MB value or a number.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I create a big file, using the SetEndofFile, then i Seek the filepointer and write some data in it, but i found the func WriteFile take a long time, Why?
HANDLE hFile = CreateFile(_T("D:\\writetest.dat"),
GENERIC_WRITE,
FILE_SHARE_WRITE|FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_RANDOM_ACCESS,
NULL);
LARGE_INTEGER llPos, llNew;
llPos.QuadPart = 2000*1024;
llPos.QuadPart *= 1024;
SetFilePointerEx(hFile, llPos, &llNew, FILE_BEGIN);
SetEndOfFile(hFile);
llPos.QuadPart = 1800*1024;
llPos.QuadPart *= 1024;
SetFilePointerEx(hFile, llPos, &llNew, FILE_BEGIN);
DWORD dwBytes = 256 * 1024;
BYTE * pBuffer = new BYTE[dwBytes];
DWORD dwBytesWritten;
DWORD dwBegin = GetTickCount();
WriteFile(hFile, pBuffer, dwBytes, &dwBytesWritten, NULL);
DWORD dwTime = GetTickCount() - dwBegin;
CString strTime;
strTime.Format(_T("Time: %d"), dwTime);
AfxMessageBox(strTime);
delete []pBuffer;
CloseHandle(hFile);
-- ed. Sent to the C++ forum at 10:08 Friday 4th November, 2005
-- modified at 10:09 Friday 4th November, 2005
|
|
|
|
|
You need to structure your code like this. Now you'll need to derive the correct values for the constants. I think you can manage that though.
for(int i = 0; i < NO_PROGRAMMING_QUESTIONS_IN_LOUNGE; i++)
cout << POST_UNDER_CORRECT_PROGRAMMING_FORUM << endl;
Some assembly required.
Code-frog System Architects, Inc.
|
|
|
|
|
you forget he is writing to a file.... In context it should be this:
<br />
html_open("message in Visual C++ Forum");<br />
html_write("question");<br />
while (!answerfound)<br />
{<br />
Sleep(1);<br />
}<br />
if (tryPostingInLounge) throw(MassiveSarcasticResponse);<br />
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
So I really come across as MassivelySarcastic eh? Tsk*, Tsk*... I need to tone down I suppose. How though... Guess I need to quit working out and feeling so healthy. Maybe more 125 hour work weeks would tone me down...
Some assembly required.
Code-frog System Architects, Inc.
|
|
|
|
|
code-frog wrote: Maybe more 125 hour work weeks would tone me down.
Possibly tone you down to 6 feet under.... please don't try it....
I admit to a level of sarcasm too. we're even.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
FWIW, I think that MassivelySarcastic was a perfectly acceptable tone.
Why would you want to change it?
Two quotes come to mind:
"Gentle persuasion is fine, but nastiness gets better results."
"I'm not paid to make friends. If I made friends, I wouldn't be doing my job."
You keep right ahead with the MassivelySarcastic approach.
|
|
|
|
|
code-frog wrote: I need to tone down I suppose
Not at all. Squash them early, if miscreants persist in ignoring the rules of our society. The "No Programming Questions In The Lounge" statement is rather clear, and should be enforced. Good job, though it really shouldn't be necessary... Carry on - I'm off.
"...a photo album is like Life, but flat and stuck to pages." - Shog9
|
|
|
|
|
To be fair to him, I don't think we have a forum dedicated to C.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Well, I couldn't resist. Do we bust out a solution right here man? Should we? Do we cross that line and make ourselves rebels? I love a little rebellious nature now and then.
Some assembly required.
Code-frog System Architects, Inc.
|
|
|
|
|
code-frog wrote: Well, I couldn't resist
I'm kind of being sarcastic as well. I couldn't resist saying *something* when someone is probably using C style file handling in a C++ program, in the year 2005.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How about trying to use C99 (ISO/IEC 9899:1999) in a C++ program?!
Maxwell Chen
|
|
|
|
|
Whats wrong with the 'C' FILE aproch even in a C++ program. I did it once when i needed to write u pure ANSCI c++ program ???
codito ergo sum
|
|
|
|
|
BadKarma wrote: Whats wrong with the 'C' FILE aproch even in a C++ program.
Everything. It's very ugly.
BadKarma wrote: I did it once when i needed to write u pure ANSCI c++ program ???
I don't see the correlation. A pure ANSI C++ program would use C++ file handing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: I don't see the correlation. A pure ANSI C++ program would use C++ file handing.
Which classes should i us;)e then?;)
codito ergo sum
|
|
|
|
|
ifstream/ofstream - iostreams are the c++ file handling class library.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am continually surprised by people who think they are C++ programmers because they write thier C code in files that end with .cpp or .cxx. They think a constant is made with #define, they've never even heard of Scott Meyers, etc., etc.
Matt Gerrans
|
|
|
|
|
Yep, the world is full of people who use C++, but have no idea of half the stuff it offers them.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|