Sign in to follow this  

No cursor

This topic is 4841 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 have created a window:
    WNDCLASS wc;		
	DWORD flags;
	
	if (hPrevInstance == NULL)
	{
	    wc.style = CS_HREDRAW | CS_VREDRAW;
		wc.lpfnWndProc = WndProc;
		wc.cbClsExtra = 0;
		wc.cbWndExtra = sizeof(DWORD);
		wc.hInstance = hThisInstance;
		wc.hIcon = NULL;//LoadIcon(hThisInstance, MAKEINTRESOURCE(IDI_ICON1));
		wc.hCursor = LoadCursor(NULL, IDC_ARROW);
		wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
		wc.lpszMenuName = NULL;        
		wc.lpszClassName = "ENVIRO";
		if (!RegisterClass(&wc))
			return FALSE;  
	}
	flags = WS_POPUP | WS_VISIBLE | WS_EX_TOPMOST | WS_SYSMENU;
	flags = /*WS_POPUP | WS_MAXIMIZE |*/ WS_EX_TOPMOST | WS_VISIBLE;
/*    if (bResizingDisabled)
        flags =  WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
                 WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
    else
        flags = WS_OVERLAPPEDWINDOW;*/
    *lpHWnd =
        CreateWindow
        (   "ENVIRO",            // Class 
            "PompiPmopi(tm)", // Title bar 
			flags,
            CW_USEDEFAULT,              // Init. x pos 
            CW_USEDEFAULT,              // Init. y pos 
            400,                        // Init. x size 
            400,                        // Init. y size 
            NULL,                       // Parent window 
            NULL,                       // Menu handle 
            hThisInstance,                  // Program handle 
            NULL                        // Create parms 
        );
    if (!*lpHWnd)
        return FALSE;
	gHInstance = hThisInstance;
	gHWnd = *lpHWnd;
However, whenever I move the cursor on the window the cursor icon dissappears. Why is that? and how can I make the cursor visible in my window?

Share this post


Link to post
Share on other sites
I haven't tried myself, but I belive the line

wc.hCursor = LoadCursor(NULL, IDC_ARROW);

might be the problem. According to Microsoft:

HCURSOR LoadCursor(HINSTANCE hInstance,
LPCTSTR lpCursorName);

hInstance
[in] Handle to an instance of the module whose executable file contains the cursor to be loaded.

I personally don't think NULL is a valid choise, but the again I haven't tried it.

Johan

Share this post


Link to post
Share on other sites
I notice you break your own code in the second flags = line.


WNDCLASS wc;
DWORD flags;

if (hPrevInstance == NULL)
{
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(DWORD);
wc.hInstance = hThisInstance;
wc.hIcon = NULL;//LoadIcon(hThisInstance, MAKEINTRESOURCE(IDI_ICON1));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "ENVIRO";
if (!RegisterClass(&wc))
return FALSE;
}
flags = WS_POPUP | WS_VISIBLE | WS_EX_TOPMOST | WS_SYSMENU;
flags = /*WS_POPUP | WS_MAXIMIZE |*/ WS_EX_TOPMOST | WS_VISIBLE; //<--here. You define flags with WS_POPUP and WS_SYSMENU, but then kill that off with the second line. Why?

/* if (bResizingDisabled)
flags = WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
else
flags = WS_OVERLAPPEDWINDOW;*/

*lpHWnd =
CreateWindow
( "ENVIRO", // Class
"PompiPmopi(tm)", // Title bar
flags,
CW_USEDEFAULT, // Init. x pos
CW_USEDEFAULT, // Init. y pos
400, // Init. x size
400, // Init. y size
NULL, // Parent window
NULL, // Menu handle
hThisInstance, // Program handle
NULL // Create parms
);
if (!*lpHWnd)
return FALSE;
gHInstance = hThisInstance;
gHWnd = *lpHWnd;





And why are you using a HWND *? Just curious

Share this post


Link to post
Share on other sites
Quote:
Original post by The C modest god
I have found the problem.
I just did ShowCursor(FALSE) somewhere...


Amusing :D.

Atleast you'll remember NOT to do that again :).

Share this post


Link to post
Share on other sites

This topic is 4841 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this