Thread: Windows Programming

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    6

    Question Windows Programming

    I only have one error in my code and I dont know why it is wrong!
    (I have not run the code, but the part that is underlined in red sais:
    A value of type "long" cannot be used to initialize an entitity of type "HWND")
    All i am trying to do is create a window.

    Here is the part with the error. Its where I create a window.

    Code:
    HWND WINAPI CreateWindowEx(
            WS_EX_CLIENTEDGE,
            g_szClassName,
            "The title of my window",
            WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
            NULL, NULL, hInstance, NULL);
    
    
        if(hwnd == NULL)
        {
            MessageBox(NULL, "Window Creation Failed!", "Error!",
                MB_ICONEXCLAMATION | MB_OK);
            return 0;
        }
    
    
        ShowWindow(hwnd, nCmdShow);
        UpdateWindow(hwnd);
    How do I fix this?
    Last edited by Hazique35; 12-30-2012 at 08:48 AM.

  2. #2
    Registered User
    Join Date
    Dec 2012
    Posts
    6
    SORRY! I fixed the problem.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    The HWND WINAPI part is from the declaration of CreateWindowEx. Why did you put it in the call? It should be something like:
    Code:
    HWND hwnd = CreateWindowEx(...)
    For future reference, we have a forum specific to Windows programming. Use it. (I didn't move this thread because it's not really about Windows programming, and more about function usage.)
    Also, it would be helpful if you pointed out exactly which line is underlined.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Dec 2012
    Posts
    6
    Ya, I did that just before you posted.

    Anyway, sorry about posting here, I didnt see the other forum. Ill use it next time.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Is there a reason you are using the Win32 API instead of, say, Qt?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Differences between Windows XP and Windows Vista programming
    By nathan3011 in forum Windows Programming
    Replies: 3
    Last Post: 01-15-2009, 10:05 AM
  2. Windows 98/2000 programming in Windows XP
    By Bill83 in forum Windows Programming
    Replies: 3
    Last Post: 07-22-2005, 02:16 PM
  3. so THIS is how Windows programming in C++ goes
    By Brain Cell in forum Windows Programming
    Replies: 12
    Last Post: 06-28-2005, 12:21 PM
  4. Programming Windows API in C++
    By JoshR in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2005, 05:40 AM
  5. programming in Windows
    By Draco in forum C Programming
    Replies: 9
    Last Post: 07-15-2002, 10:48 PM