Getting error while trying to create a class for pushbutton with CreateWindowEx in Dev C++

Help
bhavk
2012-12-09
2012-12-09
  • bhavk
    bhavk
    2012-12-09

    Hi,

    I am trying to create a class for a pushbutton in dev c++ but am getting error "crosses initialization of `WinPushButton button3'". Can somebody tell me why is this occuring and solution for this.
    Following is the code:

    controls.h:
    class WinPushButton
    {
    private:
    HWND hButton;
    public:
    WinPushButton(LPCTSTR CaptionStr, int x, int y, int nWidth, int nHeight, HWND hWndParent);

    };
    WinPushButton::WinPushButton(LPCTSTR CaptionStr, int x, int y, int nWidth, int nHeight, HWND hWndParent)
    {
    hButton=CreateWindowEx(WS_EX_LEFT, "BUTTON", CaptionStr,
    BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,
    x, y, nWidth, nHeight,
    hWndParent, NULL, NULL, NULL);
    }

    main.cpp:

    include <windows.h>

    include "controls.h"

    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    switch(msg)
    {
    case WM_CREATE:
    WinPushButton button3("Button3",10,10,10,10,hwnd);
    break;
    case WM_CLOSE:
    DestroyWindow(hwnd);
    break;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
    }