Results 1 to 9 of 9
  1. #1
    mookamoka3's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    110
    Reputation
    14
    Thanks
    13

    [Helpith]Trippy error

    Code:
    // nigga.cpp : Defines the entry point for the application.
    //
    
    #include "stdafx.h"
    #include <Windows.h>
    
    using namespace std;
    
    int WINAPI _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
    {
    	MessageBox(NULL, "Sup Niggas!", "Note", MB_OK);
    	return 0;
    }
    the error is for both of the strings in the MessageBox:

    argument of type "const char *" is incompatible with parameter of type "LPCWSTR" 11

    I don't see any parameters with that name... js .

  2. #2
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Change the character set to multi-byte.

    Project properties -> general -> character set.

    Or use a LPCWSTR instead of a const char..

  3. #3
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    MessageBox comes in two flavors.... MessageBoxA and MessageBoxW, the A stands for ASCII and the W stand for wide-char or Unicode. Hold your mouse over the MessageBox function and Intellisense should display MessageBoxW, this is because based on the settings of the compiler it uses MessageBoxW by default. I figured it would be better if you learn this now since almost all Windows API functions come in these two flavors, ASCII supporting the English typeset and Unicode supporting an international typeset including english characters. So either change your compiler settings or Use the MessageBoxA since it will support cstrings a.k.a. ASCII strings a.k.a. char*

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  4. #4
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by why06 View Post
    MessageBox comes in two flavors.... MessageBoxA and MessageBoxW, the A stands for ASCII and the W stand for wide-char or Unicode. Hold your mouse over the MessageBox function and Intellisense should display MessageBoxW, this is because based on the settings of the compiler it uses MessageBoxW by default. I figured it would be better if you learn this now since almost all Windows API functions come in these two flavors, ASCII supporting the English typeset and Unicode supporting an international typeset including english characters. So either change your compiler settings or Use the MessageBoxA since it will support cstrings a.k.a. ASCII strings a.k.a. char*
    Intellisense is broken 90% of the time. Stick with my fix. ;D

    Naw I kid, this works too, but I ALWAYS call MessageBoxA, so yeah. \:

  5. #5
    bkbatman's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    usa
    Posts
    29
    Reputation
    6
    Thanks
    0
    My Mood
    Relaxed
    Quote Originally Posted by mookamoka3 View Post
    Code:
    // nigga.cpp : Defines the entry point for the application.
    //
    
    #include "stdafx.h"
    #include <Windows.h>
    
    using namespace std;
    
    int WINAPI _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
    {
    	MessageBox(NULL, "Sup Niggas!", "Note", MB_OK);
    	return 0;
    }
    the error is for both of the strings in the MessageBox:

    argument of type "const char *" is incompatible with parameter of type "LPCWSTR" 11

    I don't see any parameters with that name... js .
    do this bro, and remember u using namespace std; with out the header file
    #include <iostream> dont forget when ever u using namespace std; alway put this in


    #include <iostream>
    #include <Windows.h>

    using namespace std;
    int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrvInstance,
    LPSTR IpCmdLine,
    int nShowCmd)
    {
    MessageBox(NULL, L"Sup Niggas!", L"Note", MB_OK);
    return 0;
    }

  6. #6
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by bkbatman View Post
    do this bro, and remember u using namespace std; with out the header file
    #include <iostream> dont forget when ever u using namespace std; alway put this in


    #include <iostream>
    #include <Windows.h>

    using namespace std;
    int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrvInstance,
    LPSTR IpCmdLine,
    int nShowCmd)
    {
    MessageBox(NULL, L"Sup Niggas!", L"Note", MB_OK);
    return 0;
    }
    The L macro works as well but I don't think you can use it with variables.

  7. #7
    bkbatman's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    usa
    Posts
    29
    Reputation
    6
    Thanks
    0
    My Mood
    Relaxed

    ss

    Quote Originally Posted by Void View Post
    The L macro works as well but I don't think you can use it with variables.
    ? just copy and paste it

    he is trying to create a simple messagebox right then my code should work

    well if u got something else in mind ,post it he will be thank full so let see what
    what u have in my.
    Last edited by bkbatman; 02-07-2011 at 12:15 AM.

  8. #8
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by bkbatman View Post
    ? just copy and paste it

    he is trying to create a simple messagebox right then my code should work

    well if u got something else in mind ,post it he will be thank full so let see what
    what u have in my.
    He does not want to copy-paste, he wants to learn.

  9. The Following User Says Thank You to freedompeace For This Useful Post:

    Hell_Demon (02-07-2011)

  10. #9
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by Void View Post
    The L macro works as well but I don't think you can use it with variables.
    There's other functions for that =p
    Ah we-a blaze the fyah, make it bun dem!