Thread: Drawing, rubber banding in a dialog (MFC)?

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    34

    Drawing, rubber banding in a dialog (MFC)?

    I'm having a hard time figuring out how to rubber band a rectangle in a dialog. I've done this in a view by following some simple directions, and that took all of probably 3 minutes. The dialog seems to be entirely different as I no longer have OnDraw or the document/view architecture. The program is basically one large dialog with a 2D image rendered in the top right corner and the other buttons are for interacting with this image. What I want to do is rubber band a rectangle in this 2D image area on top of the image after it is rendered so that you may select and area in the 2D image. It sort of works, but it seems to kind of draw behind the 2D rendered image. When you try to select the area, you don't see anything during Lmousebuttondown and mousemove events until the lmousebuttonup event in which you see a white rectangle flash for a second and that's it. The selection itself works, you just cannot see what you are selecting, except in the separate and optional 3D view. I did not write this software to begin with, I just work on it part time (i'm a student). Thank you for any help you may be able to give.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Post some code...

    'Rubber banding', what do you mean?

    I draw a rectangle for selecting an area in an image. I have a 'frame' DC (just the image, a rectangle DC (transparent with rectangle drawn on it) and the screen DC.

    something like.....

    OnMouseMove
    clear rectangle DC
    draw new rectangle (watch conversion between screen coords and window coords)
    call a paint

    OnPaint
    if update rect includes image area
    draw image to screen DC
    if rectangle DC is not null
    draw rectangel to screen DC
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    If you are using MFC, there is a CRectTracker class for this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 04-27-2004, 08:02 PM
  2. Drawing in a dialog box with MFC
    By Gravedigga in forum Windows Programming
    Replies: 3
    Last Post: 01-03-2004, 11:01 PM
  3. Dialog Box & Property Sheet :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2002, 01:33 PM
  4. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM