MessageBox in visual c++

howe to make a MessageBox

Page 1 of 1

8 Replies - 14478 Views - Last Post: 06 August 2009 - 01:46 AM Rate Topic: -----

#1 warework  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 08-July 09

MessageBox in visual c++

Posted 05 August 2009 - 03:00 AM

im try to make a MessageBox im try with this code
#include <windows.h>
int WINAPI WinMain (HINSTANCE) hInstance, HINCSTANCE hPREIVInstance, PSTR szcmdline, int iCmdshow )
{
	massagebox (NULL, TEXT ("massagebox"), TEXT ("C++ COMPILER"), 0);
	return 0;
 }


but only get error

This post has been edited by warework: 06 August 2009 - 01:40 AM

Is This A Good Question/Topic? 0
  • +

Replies To: MessageBox in visual c++

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6112
  • View blog
  • Posts: 23,672
  • Joined: 23-August 08

Re: MessageBox in visual c++

Posted 05 August 2009 - 05:22 AM

It's MessageBox not massagebox

Attention to detail is very important in programming.
Was This Post Helpful? 0
  • +
  • -

#3 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1112
  • View blog
  • Posts: 4,619
  • Joined: 09-June 09

Re: MessageBox in visual c++

Posted 05 August 2009 - 09:43 AM

lol
Was This Post Helpful? 0
  • +
  • -

#4 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 77
  • View blog
  • Posts: 985
  • Joined: 09-May 09

Re: MessageBox in visual c++

Posted 05 August 2009 - 10:03 AM

MessageBox(" THIS IS A MESSAGE ");
Was This Post Helpful? 0
  • +
  • -

#5 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: MessageBox in visual c++

Posted 05 August 2009 - 01:13 PM

View Postdeery5000, on 5 Aug, 2009 - 09:03 AM, said:

MessageBox(" THIS IS A MESSAGE ");


Nice try, but wrong. MessageBox() has several more parameters. The code in the original post was correct except for the spelling of MessageBox.
Was This Post Helpful? 0
  • +
  • -

#6 wildgoose  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 67
  • View blog
  • Posts: 468
  • Joined: 29-June 09

Re: MessageBox in visual c++

Posted 05 August 2009 - 01:31 PM

You aren't specifying a parent application by passing NULL for the window, and I always...

    | MB_TOPMOST...

...on the fourth parameter or the Message Box can be easily hidden behind under applications!

You're using a zero for type? What is that? You should have some box type such as MB_ICONWARNING or MB_ICON_YESNO, etc.
Was This Post Helpful? 0
  • +
  • -

#7 YamNad  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 120
  • Joined: 11-July 09

Re: MessageBox in visual c++

Posted 05 August 2009 - 02:27 PM

#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, L"Message Box", L"Message", MB_OK);
return 0;
}

Was This Post Helpful? 1
  • +
  • -

#8 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 77
  • View blog
  • Posts: 985
  • Joined: 09-May 09

Re: MessageBox in visual c++

Posted 05 August 2009 - 03:11 PM

View PostAncient Dragon, on 5 Aug, 2009 - 12:13 PM, said:

View Postdeery5000, on 5 Aug, 2009 - 09:03 AM, said:

MessageBox(" THIS IS A MESSAGE ");


Nice try, but wrong. MessageBox() has several more parameters. The code in the original post was correct except for the spelling of MessageBox.


Does this work, does it , does it . . . . LOL

This post has been edited by deery5000: 05 August 2009 - 03:17 PM

Was This Post Helpful? 0
  • +
  • -

#9 warework  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 08-July 09

Re: MessageBox in visual c++

Posted 06 August 2009 - 01:46 AM

------ Build started: Project: empenrt, Configuration: Debug Win32 ------
Compiling...
form.cpp
.\form.cpp(4) : error C2664: 'MessageBox' : cannot convert parameter 2 from 'const wchar_t [12]' to 'LPCTSTR'
		Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Build log was saved at "file://d:\Documents and Settings\Ägaren\Mina dokument\Visual Studio 2008\Projects\empenrt\empenrt\Debug\BuildLog.htm"
empenrt - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

now im get this fail when try to start this
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MessageBox(NULL, L"Message Box", L"Message", MB_OK);
return 0;
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1