Thread: New to C++. 1 or 2 Q's

  1. #1
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22

    Smile New to C++. 1 or 2 Q's

    OK, Been programming in BASIC, VB, Clipper, Dbase, 6809E asembler, 8088 assembler since 79 and through the years tried to get going on C++. I always seem to get stuck getting a handle on what libraries I need to include to get even the most basic things going.

    Well, guess what.. I can draw stupid little circles and stuff, do drop down menus and dialog boxes, but do you think I can get a handle on the mouse so I can track it's position at any given moment? Noooo way.

    I've got my message handler all set up and ready for the WM_MOUSEMOVE message but havn't got the foggiest where to get the pointer location from.

    Once I get it, I'm just gonna spit it back out next to the mouse pointer for a simple excersize. My simple windows program only carries the window.h library.

    Not looking for masses of code here, just enough to get me over this hump.

    Thanks!
    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    x = LOWORD (lParam) ;
    y = HIWORD (lParam);

    P.S. Goto this site. It has a bunch of books in it. Under the C/C++ section, there is an older version of Programming Windows by Petzold. You will learn a great deal from reading that book.

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    When processing your WN_MOUSEMOVE message you need to check the LPARAM passed to your WndProc callback. The least significant 2 bytes specific the horizontal posistion and the most significant 2 bytes specifiy the vertical. You can use the pre-defined HIWORD and LOWORD macros to separate the co-ords if neccessary, or GET_X_LPARAM and GET_Y_LPARAM macros to be extra portable.

  4. #4
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22
    Well you both added great info that helped me past that hurtle. so I threw this together.

    Code:
    		x=LOWORD(lParam);
    		y=HIWORD(lParam);
    		itoa(x,convertedX,10);
    		itoa(y,convertedY,10);
    
    
    		TextOut(hdc,x+10,y,"Test",4);
    The TextOut line actually lives in my WM_PAINT message handler not in my WM_MOUSEMOVE. However, "Test" only seems to print in the upper left corner and then that's it.

    Now, the reason I'm not trying to print convertedX or convertedY was because I actually did try and it didn't work so I was doing the old "baby steps" thing.

    I tried reming out ValidateRect with no change in effect, so I'm stumped. There's only 200 pages left in my 980 page book and I've read EVERY page. I'd expect to be doing better then this..

    My only guess is that there is some kind of redraw not happening or being inhibited.
    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

  5. #5
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22

    Talking

    Hey golfinguy.. Thanks for the book recommendation and the site. I checked out the book you suggested and it looks like it's got a tone a fantastic info.

    Thanks!

    Guardian
    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    There's also windows programming forum at this site, might find more answers there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Several Q's
    By Elyubarov in forum Windows Programming
    Replies: 9
    Last Post: 12-26-2004, 10:36 PM
  2. Q's
    By pktcperlc++java in forum C++ Programming
    Replies: 15
    Last Post: 12-24-2004, 11:36 AM
  3. Qs about RAID0 & expandability
    By Markallen85 in forum Tech Board
    Replies: 2
    Last Post: 01-18-2004, 02:52 PM
  4. 2 q's: SPI_SETFLATMENU & platform SDK
    By Mithoric in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2003, 10:44 AM
  5. I have 2 Q's for you all
    By robid1 in forum C Programming
    Replies: 5
    Last Post: 06-24-2003, 05:52 AM