Excessive occurences of WM_DRAWCLIPBOARD messages


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Excessive occurences of WM_DRAWCLIPBOARD messages

  1. #1
    Valentin Guest

    Excessive occurences of WM_DRAWCLIPBOARD messages


    Hi, All!

    The problem: double occurences of WM_DRAWCLIPBOARD for the same Clipboard
    contents.

    To repicate this situation, download Karl Peterson's ClipView from http://www.mvps.org/vb/code/ClipView.zip
    . Load it in IDE and insert Debug.Print "WM_CHANGECBCHAIN" and Debug.Print
    "WM_DRAWCLIPBOARD" in Form subclassing. Start MS Photo Editor with some jpg-file.
    Start ClipView. I believe you'll get the following (the same I've got): (1)
    WM_DRAWCLIPBOARD message (No.0) on load - which is normal as ClipView gets
    in clipboard viewchain (2) click right button on picture in PhotoEd and choose
    Copy command - you'll get 1st (normal) WM_DRAWCLIPBOARD, just as Karl intended
    (3) close PhotoEd - you'll get 2nd WM_DRAWCLIPBOARD, excessive. Similar things
    occur while drag copy/move in MS Office (Outlook, Excel). BTW, no WM_CHANGECBCHAIN's,
    as PhotoEd is higher than ClipView in viewchain.

    One way to avoid second messages (my app stores Clipboard by WM_DRAWCLIPBOARD's)
    is to clear Clipboard - not so polite to the user; another one is to calculate
    CRC32 which means tangible delay while copying big pictures. Is there some
    decent method doing things?

    I'd appreciate copying replies (if any) to my e-mail address.

    Thanks in advance,
    Valentin

  2. #2
    Karl E. Peterson Guest

    Re: Excessive occurences of WM_DRAWCLIPBOARD messages

    Hi Valentin --

    I posted a response to this in the vb.api group this morning. Unfortunately, it can
    be best summed up with, "I dunno." One guess would be that these apps are doing
    something in the background as they shut down?

    Sorry... Karl
    --
    http://www.mvps.org/vb


    "Valentin" <valb@gin.ru> wrote in message news:3b0a0831$1@news.devx.com...
    >
    > Hi, All!
    >
    > The problem: double occurences of WM_DRAWCLIPBOARD for the same Clipboard
    > contents.
    >
    > To repicate this situation, download Karl Peterson's ClipView from

    http://www.mvps.org/vb/code/ClipView.zip
    > Load it in IDE and insert Debug.Print "WM_CHANGECBCHAIN" and Debug.Print
    > "WM_DRAWCLIPBOARD" in Form subclassing. Start MS Photo Editor with some jpg-file.
    > Start ClipView. I believe you'll get the following (the same I've got): (1)
    > WM_DRAWCLIPBOARD message (No.0) on load - which is normal as ClipView gets
    > in clipboard viewchain (2) click right button on picture in PhotoEd and choose
    > Copy command - you'll get 1st (normal) WM_DRAWCLIPBOARD, just as Karl intended
    > (3) close PhotoEd - you'll get 2nd WM_DRAWCLIPBOARD, excessive. Similar things
    > occur while drag copy/move in MS Office (Outlook, Excel). BTW, no

    WM_CHANGECBCHAIN's,
    > as PhotoEd is higher than ClipView in viewchain.
    >
    > One way to avoid second messages (my app stores Clipboard by WM_DRAWCLIPBOARD's)
    > is to clear Clipboard - not so polite to the user; another one is to calculate
    > CRC32 which means tangible delay while copying big pictures. Is there some
    > decent method doing things?
    >
    > I'd appreciate copying replies (if any) to my e-mail address.
    >
    > Thanks in advance,
    > Valentin



  3. #3
    Join Date
    Apr 2009
    Location
    Beijing
    Posts
    2

    Smile

    Quote Originally Posted by Valentin View Post
    Hi, All!

    The problem: double occurences of WM_DRAWCLIPBOARD for the same Clipboard
    contents.

    To repicate this situation, download Karl Peterson's ClipView from http://www.mvps.org/vb/code/ClipView.zip
    . Load it in IDE and insert Debug.Print "WM_CHANGECBCHAIN" and Debug.Print
    "WM_DRAWCLIPBOARD" in Form subclassing. Start MS Photo Editor with some jpg-file.
    Start ClipView. I believe you'll get the following (the same I've got): (1)
    WM_DRAWCLIPBOARD message (No.0) on load - which is normal as ClipView gets
    in clipboard viewchain (2) click right button on picture in PhotoEd and choose
    Copy command - you'll get 1st (normal) WM_DRAWCLIPBOARD, just as Karl intended
    (3) close PhotoEd - you'll get 2nd WM_DRAWCLIPBOARD, excessive. Similar things
    occur while drag copy/move in MS Office (Outlook, Excel). BTW, no WM_CHANGECBCHAIN's,
    as PhotoEd is higher than ClipView in viewchain.

    One way to avoid second messages (my app stores Clipboard by WM_DRAWCLIPBOARD's)
    is to clear Clipboard - not so polite to the user; another one is to calculate
    CRC32 which means tangible delay while copying big pictures. Is there some
    decent method doing things?

    I'd appreciate copying replies (if any) to my e-mail address.

    Thanks in advance,
    Valentin
    here is my solution:

    void CMyWnd::OnDrawClipboard()
    {
    CDialog::OnDrawClipboard();

    if(m_hNext)
    ::SendMessage(m_hNext, WM_DRAWCLIPBOARD,0,0);

    CWnd* pWnd = GetClipboardOwner();

    // if app close activate WM_DRAWCLIPBOARD, GetClipboardOwner will return NULL, so we ignore this msg
    if (pWnd == NULL)
    return;
    ...
    // get data from copyboard
    ...
    }

  4. #4
    Join Date
    Apr 2009
    Location
    Beijing
    Posts
    2

    Smile solution

    hint: GetClipboardOwner() will return NULL when app closed.

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    But, your solution is not in Visual Basic.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center