windows programing setting up window

i have these tow errors and can't fix them what ever i try. i am running windows 8.1

Error 1 error C3861: 'InitMainWindow': identifier not found

Error 2 error C2440: '=' : cannot convert from 'LRESULT (__stdcall *)(HWND,WPARAM,LPARAM)' to 'WNDPROC'

code:

#include <windows.h>    // include the basic windows header file

bool InitMainWindow(HINSTANCE, int);

LRESULT CALLBACK MsgProc(HWND UINT, WPARAM, LPARAM);

const int width = 800;
const int height = 600;

HWND hwnd = NULL;

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int     nCmdShow)
{
    if (!InitMainWindow(hInstance, nCmdShow))
        return 1;

     MSG msg = { 0 };
     while (WM_QUIT != msg.message)
     {
         if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
         {
             TranslateMessage(&msg);
             DispatchMessage(&msg);
         }
         return static_cast<int>(msg.wParam);
     }
}

bool InitMainWindow(HINSTANCE hInstance, int nCmdShow)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(wcex);
    wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.lpfnWndProc = MsgProc;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
    wcex.lpszClassName = NULL;
    wcex.lpszMenuName = NULL;
    wcex.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

    if (!RegisterClassEx(&wcex))
        return false;

    hwnd = CreateWindow (
        NULL,
        NULL,
        WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION,
        GetSystemMetrics(SM_CXSCREEN) / 2 - width / 2,
        GetSystemMetrics(SM_CYSCREEN) / 2 - height / 2,
        width,
        height,
        (HWND)NULL,
        (HMENU)NULL,
        hInstance,
        (LPVOID*)NULL);

    if (!hwnd)
        return false;
    ShowWindow(hwnd, nCmdShow);
    return true;

}

LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    case WM_CHAR:
        switch (wParam)
        {

         case VK_ESCAPE:
             PostQuitMessage(0);
             return 0;
        }
        return 0;
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}

Answers


You're missing a comma in your declaration of MsgProc.

You have

LRESULT CALLBACK MsgProc(HWND UINT, WPARAM, LPARAM);

which declares a function that takes an HWND named UINT.

You need

LRESULT CALLBACK MsgProc(HWND, UINT, WPARAM, LPARAM);

After this, it compiles fine.


Need Your Help

how can i call method from another class in iPhone Xcode

iphone objective-c xcode4.2

i have trouble with calling method from another class this is my code

informix query to look for where is null when no record is found

sql performance null informix

I want to write a query to return a result set based on a parameter I pass in,but if there are no matching records I want to return the result set where that parameter is null (the column I use in ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.