Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Build Application in VC++

Build Application in VC++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anassamar
    wrote on last edited by
    #1

    I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you

    thank you soso

    N C R H 4 Replies Last reply
    0
    • A anassamar

      I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you

      thank you soso

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      You might be using unicode build( which is default in vs2005 and later ). so should pass unicode string to MessageBox() function. To convert your string to unicode. use _T macro. MessageBox( _T("This is my first Visual C++ Application!"));

      nave [OpenedFileFinder] [My Blog]

      1 Reply Last reply
      0
      • A anassamar

        I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you

        thank you soso

        C Offline
        C Offline
        Chandrasekharan P
        wrote on last edited by
        #3

        Try using

        MessageBox(_T("This is my first Visual C++ Application!"));

        it should work

        A 1 Reply Last reply
        0
        • A anassamar

          I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you

          thank you soso

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          You are building for Unicode and therefore trying to pass an ANSI string to an API which expects an Unicode string. Include all your literal strings within the TEXT macro.

          anassamar wrote:

          MessageBox("This is my first Visual C++ Application!");

          MessageBox(_T("This is my first Visual C++ Application!")); The _T macro automatically emits an ANSI or an Unicode string (by prefixing nothing if building for MBCS or by prefixing L to the literal string if building for Unicode) These links may help you further to understand about string data types: The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^] The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^] This might help you with International programming and Unicode: International programming[^]

          It is a crappy thing, but it's life -^ Carlo Pallini

          1 Reply Last reply
          0
          • C Chandrasekharan P

            Try using

            MessageBox(_T("This is my first Visual C++ Application!"));

            it should work

            A Offline
            A Offline
            anassamar
            wrote on last edited by
            #5

            Ok, Thank you very much

            thank you soso

            1 Reply Last reply
            0
            • A anassamar

              I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you

              thank you soso

              H Offline
              H Offline
              hourui
              wrote on last edited by
              #6

              推荐网站www.codeproject.com 和 www.codeguru.com,在这里可以找到

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups