Thread: a little confused

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    186

    a little confused

    I'm reading a tutorial on Win32 app programming and its done in C which I don't know (I don't really know any C++) but I figured I'd give it a shot (I do know some java). I'm using Visual C++ in visual studio so I made an empty project file and put in this code:
    Code:
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
        LPSTR lpCmdLine, int nCmdShow)
    {
        MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
        return 0;
    }
    I compiled it and got errors but then I realized that it was a .cpp file and just renamed it to a .c file. It then compiled and ran but the message that popped up was in like japanese or something. It was characters.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Use the TEXT() around any text - this means that your code will work both when it's unicode and when it's not. e.g.
    Code:
    MessageBox(NULL, TEXT("Goodbye, cruel world!"), TEXT("Note"), MB_OK);
    --
    Mats

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    186
    Hey thanks that worked

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    186
    I have a question about icons, in my test.c file I have these lines:
    Code:
    wc.hIcon  = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
        wc.hIconSm  = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0);
    And in my testr.rc file I have:
    Code:
    IDI_MYICON ICON "menu_one.ico"
    And finally in my resource.h file I have:
    Code:
    #define IDI_MYICON 201
    I put the icon "menu_one.ico" in the same folder as all three of those files.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And the question is?

    --
    Mats

  6. #6
    Registered User
    Join Date
    Jul 2007
    Posts
    186
    o haha sry, why doesn't it work?

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Describe what doesn't work, please!

    Are you checking the return values from LoadIcon and LoadImage? Are they valid, if not, what is the error code?

    --
    Mats

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confused about Memory
    By gL_nEwB in forum C++ Programming
    Replies: 22
    Last Post: 06-20-2006, 07:32 PM
  2. why wont this compile?!? :confused:
    By jdude in forum C++ Programming
    Replies: 5
    Last Post: 11-25-2004, 01:13 AM
  3. So Now Im getting confused?!?!?
    By zergdeath1 in forum C++ Programming
    Replies: 11
    Last Post: 03-06-2004, 05:41 PM
  4. confused.. in selecting my line of deapth
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-04-2003, 01:21 PM
  5. Extern Question, really confused
    By SourceCode in forum C Programming
    Replies: 10
    Last Post: 03-26-2003, 11:11 PM