Thread: bitmaps and mouse location

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    35

    bitmaps and mouse location

    I have a simple window that opens, stays open, and closes when you click the X... nothing more.

    How would I put a picture into it, and how would I get the location of the mouse pointer in it?

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    Ok, to put a picture in your backround you need to have a bitmap(obviously) and to load that from a file the code will look like:

    Code:
    HBITMAP backround;
    HBRUSH hBrush;
    background = (HBITMAP)LoadImage(hinstance,"background.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    hBrush = CreatePatternBrush(backround);
    DeleteObject(background);
    
    //then in your class def for hbrbackground
    
    wndclass.hbrbackground = hBrush;
    //this will load your bitmap to the background.
    Now for mouse position, you simply trap the WM_MOUSEMOVE or button messages and then:
    Code:
    case WM_MOUSEMOVE:
                mouse.x = LOWORD(lParam);
                mouse.y = HIWORD(lParam);
                //other stuff

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    35
    I was looking for something more similar to a picturebox in Visual basic.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    317
    hmmm........ C++ board??????? What language are you using for your windows Apps? MFC, WIN32 API, Visual Basic?

    By the way you'll get more input if you post in the Windows forum.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Magnifier window that follows mouse - how?
    By midix in forum Windows Programming
    Replies: 9
    Last Post: 10-05-2007, 07:43 AM
  2. Problem in mouse position
    By Arangol in forum Game Programming
    Replies: 6
    Last Post: 08-08-2006, 07:07 AM
  3. Scrolling bitmaps and some other things
    By Gerread in forum Windows Programming
    Replies: 1
    Last Post: 06-04-2006, 09:23 AM
  4. Loading bitmaps with createfile() +CreateDIBSection
    By Stevo in forum Windows Programming
    Replies: 7
    Last Post: 05-13-2004, 09:22 PM
  5. Mouse in 800x600 24Bit Mode?
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 11-11-2001, 01:38 AM