Jump to content
  • Advertisement
Sign in to follow this  
Lambi

WIN32 Crazy acting mouse pointer!

This topic is 4386 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm make a perfectly normal window, but my cursor act's weird. for example: wC.hCursor = LoadIcon(NULL, IDC_CROSS); make the cursor an exclamation mark (IDI_EXCLAMATION)... and wC.hCursor = LoadIcon(NULL, IDC_ARROW); make the cursor an application icon (IDI_APPLICATION)... here is the source:
//trim down the libraries
#define WIN32_LEAN_AND_MEAN
//the normal windows header
#include <windows.h>

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT paintStruct;
    HDC hDC;
    char string[] = "Hello, world!";

    switch(message)
    {
        case WM_CREATE:
            return 0;
            break;

        case WM_CLOSE:
            PostQuitMessage(0);
            return 0;
            break;

        case WM_PAINT:
            hDC = BeginPaint(hwnd, &paintStruct);
            SetTextColor(hDC, COLORREF(0x00FF0000));
            TextOut(hDC, 150, 150, string, sizeof(string)-1);
            EndPaint(hwnd, &paintStruct);
            return 0;
            break;

        default:
            break;
    }
    //pass all unhandled messages to Defwindowproc
    return (DefWindowProc(hwnd, message, wParam, lParam));
}

//main entry point of the program
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmdd)
{
    WNDCLASSEX wC;
    HWND hwnd;
    MSG msg;
    bool done;

    ///////////////////////////
    //defining my window class:
    wC.cbSize = sizeof(WNDCLASSEX);
    wC.style = CS_VREDRAW | CS_HREDRAW;
    wC.lpfnWndProc = (WNDPROC)WndProc;
    wC.cbClsExtra = 0;
    wC.cbWndExtra = 0;
    wC.hInstance = hInstance;
    wC.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wC.hCursor = LoadIcon(NULL, IDC_CROSS); //bug!!!
    wC.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wC.lpszMenuName = NULL;
    wC.lpszClassName = "MyClass";
    wC.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

    if(!RegisterClassEx(&wC)) return 0;
    //end windowclass
    ///////////////////////////
    //creating the window
    hwnd = CreateWindowEx(NULL,
                        "MyClass",
                        "First Windows app. v1.0",
                        WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU,
                        100, 100,
                        680, 480,
                        NULL,
                        NULL,
                        hInstance,
                        NULL);

    if(!hwnd) return 0;
    //end creating window
    ///////////////////////////
    //message loop
    done = false;
    while(!done)
    {
        PeekMessage(&msg, hwnd, NULL, NULL, PM_REMOVE);

        if(msg.message == WM_QUIT) done = true;
        else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return msg.wParam;
    //end message loop
    ///////////////////////////
    /*
    ShowWindow(hwnd, nCmdShow);
    UpdateWindow();
    */
    return 0;
}



[Edited by - Lambi on October 16, 2006 9:31:34 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Lambi
PS: How do I put my code in its own little window? :)

Use source instead of code: FAQ
EDIT: Also, might help if you describe the problem a little better. What do you mean by "acts weird"?

Share this post


Link to post
Share on other sites
As I said :P

Quote:

for example:
wC.hCursor = LoadIcon(NULL, IDC_CROSS);
make the cursor an exclamation mark (IDI_EXCLAMATION)...

and
wC.hCursor = LoadIcon(NULL, IDC_ARROW);
make the cursor an application icon (IDI_APPLICATION)...


when defining the windows class (wC in my case) and I set the hCursor equal to LoadIcon(NULL, IDC_ARROW) the mouse pointer look like the IDI_APPLICATION icon.

^_^

Share this post


Link to post
Share on other sites
Oops, I skimmed over that too quick I guess and thought CROSS and EXCLAMATION were the same somehow. Anyhow, I think it should be LoadCursor right (instead of LoadIcon)?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!