visual studio 2008 win32 api tutorial HELP

This is a discussion on visual studio 2008 win32 api tutorial HELP within the C++ Programming forums, part of the General Programming Boards category; Hi there, I want to learn how to create win32 api programs. Does anyone know of any tutorials that i ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    17

    visual studio 2008 win32 api tutorial HELP

    Hi there,

    I want to learn how to create win32 api programs.
    Does anyone know of any tutorials that i can learn off?

    I found a website but it only works with DEV C ++

    This is the Code:

    Code:
    #include <windows.h>
    
    int WinMain(HINSTANCE hInstance, HINSTANCE pInstance,
    			LPSTR lpCmdLine, int nShowCmd)
    {
    
    	
    
    		MessageBox(NULL, "Hello World", 
    		"Title", MB_OK | MB_ICONINFORMATION);
    		
    		if (MessageBox(NULL, "Do you?", "Do You?",
    		MB_YESNO | MB_ICONQUESTION) == IDYES)
    		MessageBox(NULL, "Yes", "Yes", MB_OK);
    
    
    
    
    	return 0;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    And why do you think that only works with Dev-C++?

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    17
    Quote Originally Posted by tabstop View Post
    And why do you think that only works with Dev-C++?
    I have know idea but feel that you will tell me.

    Is it something to with that it doesn't have;

    void main()

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    The absence of void main() is an extremely good thing.

    No, the point is: that program works just fine in Visual Studio.

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    17
    When i debug it i get these errors:

    Error 2 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [12]' to 'LPCWSTR' c:\users\tecmeister\desktop\c++\win32 api\projects\messagebox\messagebox\main.cpp 10 messageBox

    Error 4 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [4]' to 'LPCWSTR' c:\users\tecmeister\desktop\c++\win32 api\projects\messagebox\messagebox\main.cpp 14 messageBox

    Error 3 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR' c:\users\tecmeister\desktop\c++\win32 api\projects\messagebox\messagebox\main.cpp 13 messageBox

    Warning 1 warning C4007: 'WinMain' : must be '__stdcall' c:\users\tecmeister\desktop\c++\win32 api\projects\messagebox\messagebox\main.cpp 5 messageBox

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Somehow you've got things set up so that it expects wide-character strings (and obviously I don't). Since I don't know where you set that up, I can't tell you how to fix it -- BUT you should be able to turn all your "string literals" into L"long string literals" by prefixing the quotes with an L. That should work.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    17
    Im sorry i dont really understand you properly would you be able to correct it for me so i can see.

    Thanks for your help much appreciated.

    This is the website that i have got the info off:
    http://www.zeuscmd.com/tutorials/win...inFunction.php
    Last edited by Swink; 07-25-2008 at 04:13 PM.

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by Swink View Post
    Im sorry i dont really understand you properly would you be able to correct it for me so i can see.

    Thanks for your help much appreciated.
    Well, that's the thing; I did, already. Did you read my post? Did you notice how "things in quotes" became L"things in quotes"? Everything that is "in quotes" needs to have an L in front of it.

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    17
    Ok now i understand

    But that didnt work

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Wait -- you're using Visual Studio? Why didn't you click on the Visual Studio download of sample files, instead of the Dev-C++ download of sample files?

  11. #11
    Registered User
    Join Date
    Jul 2008
    Posts
    17
    I have found out what the problem was it was because i had to change the settings:

    Here it is for anyone else who has the same problem:

    Change your project configuration to use multibyte strings. Press ALT+F7 to open the properties, and navigate to Configuration Properties > General. Switch Character Set to "Use Multi-Byte Character Set".

    Much appropriated tho tabstop

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to Visual Studio 2008
    By bargomer in forum C++ Programming
    Replies: 5
    Last Post: 09-19-2008, 02:16 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21