CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2005
    Posts
    6

    Repaint of region within C++ application

    Hi all,
    As someone with limited knowledge of C++ I'm trying to figure out how to repaint a part of my application.
    I right click on an icon and select 'Mark' which basically adds a 'Checkmark' bmp to the icon I'm right clicking on. The problem is that the 'Checkmark' doesn't appear unless I move the app. or drag another window over the app. containg the icon, which of course fires a repaint of my app. How can I add it so that upon right clicking on the icon it repaints the screen ther and then. I've heard that 'invalidaterect' and 'updatewindow' may work but not sure how to implement.

    Thanks in advance.

    Neil

    Below is the code that needs to call the repaint.

    LRESULT OnGfxMarkitem(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    {
    if (iHitInternal1 == htItem)
    {
    if ( GetItemImage(iHitInternal2) != COMPARE_TOOL_IMAGE_INDX)
    {
    CWindow wnd(m_hOwnerWindow);
    SetItemImage(iHitInternal2,COMPARE_TOOL_IMAGE_INDX);
    wnd.SendMessage(WM_OUTBAR_NOTIFY, NM_OB_ITEMCLICK_COMPARE, iHitInternal2);
    }
    else
    {
    SetItemImage(iHitInternal2,DEFAULT_IMAGE_INDX);
    }
    }
    return 0;
    }

  2. #2
    Join Date
    Oct 2004
    Location
    Romania/Cluj-Napoca(Kolozsvár)
    Posts
    214

    Re: Repaint of region within C++ application

    You just call UpdateWindow for the window that contains your icon(s) right after you have finished with adding the 'Checkmark'.
    //Exceptions exist!

  3. #3
    Join Date
    Jun 2005
    Posts
    6

    Re: Repaint of region within C++ application

    How do I call UpdateWindow for the window that contains the icons in the code I posted?
    Thanks

  4. #4
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Repaint of region within C++ application

    Quote Originally Posted by neilharvey
    How do I call UpdateWindow for the window that contains the icons in the code I posted?
    Sorry, but I don't understand the code you posted. What is CWindow wnd supposed to do there? Looks like you're mixing MFC with ATL?

  5. #5
    Join Date
    Jun 2005
    Posts
    6

    Re: Repaint of region within C++ application

    Like I said it's new to me and I'm trying to get some hints as to how to solve my problem. gstercken, perhaps you can explain MFC and ATL?
    Anyone else know how I can call UpdateWindow in the code I first posted?
    Tahnks

  6. #6
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Repaint of region within C++ application

    Quote Originally Posted by neilharvey
    gstercken, perhaps you can explain MFC and ATL?
    See MSDN for details - it's all there.
    The question is: How did you create your application in the first place? And where and how did you add the code you posted?

  7. #7
    Join Date
    Jun 2005
    Posts
    6

    Re: Repaint of region within C++ application

    The application was written by someone no longer with the firm. I am desperately trying to add the functionality described in the first post and although I know what I'm trying to achieve I am having difficulty implementing it. Like I said, I think I need to use UpdateWindow but how do I specify what area to update and the exact syntax. The code I posted comes from one of the header files being used by the app. Thanks

  8. #8
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Repaint of region within C++ application

    Quote Originally Posted by neilharvey
    Like I said, I think I need to use UpdateWindow but how do I specify what area to update and the exact syntax.
    No, I don't think so. UpdateWindow is only required if for some reason you need to redraw a window immediately (before returning control to the system and processing WM_PAINT messages). That's not the case in your situation.

  9. #9
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Repaint of region within C++ application

    Quote Originally Posted by gstercken
    No, I don't think so. UpdateWindow is only required if for some reason you need to redraw a window immediately (before returning control to the system and processing WM_PAINT messages). That's not the case in your situation.
    Well, it sounds like the OP infact needs an immediate redraw here, g !! See below>>>

    How can I add it so that upon right clicking on the icon it repaints the screen ther and then

  10. #10
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Repaint of region within C++ application

    Quote Originally Posted by kirants
    Well, it sounds like the OP infact needs an immediate redraw here, g !! See below>>>
    I still don't think so. In the WM_RBUTTONDOWN handler, the new icon is set. After that, the handler returns, WM_PAINT messages will be processed, and the window is redrawn immediately with the new icon. What I find rather strange in the OP's code is that CWindow instance created locally on the stack...

  11. #11
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Repaint of region within C++ application

    Yep. I don't understand the code though.. OP, please explain what the code is ? Is it the WndProc handler for that window or is it handler in the parent window.. Please elaborate !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured