Thread: Problem with XP

  1. #16
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Now I feel dumb, re-read the code in the book and it had wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
    in it, I just skipped it when typing it in

  2. #17
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    It looks like this code is from chapter 3 of Charles Petzold's Programming Windows. You should note that you can copy the code from CD that comes with the book to your computer, so you needn't type it all in when you want to try out some examples. Also, note that there are several coding errors and typos in the book. Check the link in my signature below for a errata list.

  3. #18
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Good guess of where its from. Problem is that in my move I seem to have lost the CD.

  4. #19
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    because otherwise, the hCursor member would be set to any old garbage that was on the stack before wndclass.
    Don't know if that's the case. My first window didn't have a HCURSOR, but it wasn't just a "garbage" cursor in the strictest sense; if the cursor changed outside the window, the new cursor would be used inside the window. Maybe that's just Windows98, but I think leaving it blank just tells Windows not to bother changing the cursor when it goes on the window.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #20
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Probably, the value present in the memory location of hCursor is simply invalid, ie, it doesn't point to a cursor resource or similar. Windows would then load the default cursor. I suppose it could happen that hCursor gets a value that corresponds to a cursor resource, but that would be unlikely.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #21
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Originally posted by Hunter2
    Don't know if that's the case. My first window didn't have a HCURSOR, but it wasn't just a "garbage" cursor in the strictest sense; if the cursor changed outside the window, the new cursor would be used inside the window. Maybe that's just Windows98, but I think leaving it blank just tells Windows not to bother changing the cursor when it goes on the window.
    This result may be the case, but Tada was right when he said, "because otherwise, the hCursor member would be set to any old garbage that was on the stack before wndclass." The fact that hCursor contains garbage does not dictate what will happen to the cursor when you run the program - he was just saying it would contain garbage.

    It is likely that it contained 0. Especially if you are testing this in debug mode, since I believe all variables are initialized to 0 in debug mode (someone correct me if I am wrong). And from the MSDN page for WNDCLASS:

    hCursor
    Handle to the class cursor. This member must be a handle to a cursor resource. If this member is NULL, an application must explicitly set the cursor shape whenever the mouse moves into the application's window.

    I would assume if an application does NOT set the cursor, it remains the same.

  7. #22
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Right, and I always memset the WndClass struct, so it does contain zero or NULL, so since the application is supposed to be the one setting the cursor, Windows will set the cursor outside but won't bother changing it for you once it goes in. If hCursor were a "garbage" value, you would probably get Thantos's problem

    Basically, what I meant by "leaving it blank" was "don't change it after the struct has been zeromemoried". Sorry if I miscommunicated...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #23
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Originally posted by Hunter2
    Basically, what I meant by "leaving it blank" was "don't change it after the struct has been zeromemoried".
    Ok, I follow you now - just a misunderstanding. In the context of your reply to Tada's message, I assumed "leaving it blank" implied no initialization whatsoever, as Tada already explained about zeroing out all members of the struct in that very post you (partially) quoted.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with ezwin.h in XP
    By Good0m3n in forum C++ Programming
    Replies: 1
    Last Post: 05-26-2004, 01:03 PM
  2. Big Problem with XP (booting)
    By axon in forum Tech Board
    Replies: 11
    Last Post: 03-17-2004, 02:34 AM
  3. Stanby wake up problem [windows xp resnet]
    By Boomba in forum Tech Board
    Replies: 6
    Last Post: 01-06-2004, 08:51 PM
  4. XP Autoplay problem
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-09-2002, 08:59 AM