News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Richedit and clipboard

Started by ToutEnMasm, October 05, 2011, 05:48:19 AM

Previous topic - Next topic

ToutEnMasm


I try (without success) to copy paste (in text format) the code of this page in a richedit:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms649016(v=vs.85).aspx#_win32_Using_the_Owner_Display_Clipboard_Format
Results are various and not verry good:
Sometimes i got the last copy of text and the passed text isn't the same in  the edit than in the richedit.
I have made an executable to test this.
The goal is to have the same write in the edit and in the richedit.

hutch--

Yves,

I am getting identical content with your test piece, what differences are you getting ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm


I got a single line in the richedit and when i use the copy in text format in the richedit ,the text doesn't appear or is truncated.

jj2007

Multiple lines in the RichEdit here but clearly the text is truncated.
It works fine with RichMasm, I get
Sign in
Windows Dev Center - Desktop
....
Terms of use | Trademarks | Privacy Statement | Site Feedback | United States (English)
© 2011 Microsoft. All rights reserved.


You will get better results with this modification in line 200:
Quotemov Hredit,eax   
   invoke SendMessage, eax, EM_EXLIMITTEXT, 0, -1

ToutEnMasm


You must got:
Quote
LRESULT CALLBACK MainWindowProc(hwnd, msg, wParam, lParam)
HWND hwnd;
UINT msg;
WPARAM wParam;
LPARAM lParam;
{
    static RECT rcViewer;

    RECT rc;
    LPRECT lprc;
    LPPAINTSTRUCT lpps;

    switch (msg)
    {
        //
        // Handle other messages.
        //
        case WM_PAINTCLIPBOARD:
            // Determine the dimensions of the label.

            SetRect(&rc, 0, 0,
                pboxLocalClip->rcText.right + CX_MARGIN,
                pboxLocalClip->rcText.top * 2 + cyText
            );

            // Center the image in the clipboard viewer window.

            if (rc.right < rcViewer.right)
            {
                rc.left = (rcViewer.right - rc.right) / 2;
                rc.right += rc.left;
            }
            if (rc.bottom < rcViewer.bottom)
            {
                rc.top = (rcViewer.bottom - rc.bottom) / 2;
                rc.bottom += rc.top;
            }

            // Paint the image, using the specified PAINTSTRUCT
            // structure, by calling the application-defined
            // PaintLabel function.

            lpps = (LPPAINTSTRUCT) GlobalLock((HGLOBAL) lParam);
            PaintLabel(lpps, pboxLocalClip, &rc);
            GlobalUnlock((HGLOBAL) lParam);
            break;

        case WM_SIZECLIPBOARD:
            // Save the dimensions of the window in a static
            // RECT structure.

            lprc = (LPRECT) GlobalLock((HGLOBAL) lParam);
            memcpy(&rcViewer, lprc, sizeof(RECT));
            GlobalUnlock((HGLOBAL) lParam);

            // Set the scroll ranges to zero (thus eliminating
            // the need to process the WM_HSCROLLCLIPBOARD and
            // WM_VSCROLLCLIPBOARD messages).

            SetScrollRange((HWND) wParam, SB_HORZ, 0, 0, TRUE);
            SetScrollRange((HWND) wParam, SB_VERT, 0, 0, TRUE);

            break;

        case WM_ASKCBFORMATNAME:
            LoadString(hinst, IDS_OWNERDISPLAY,
                (LPSTR) lParam, wParam);
            break;

        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}

It is only copiing pieces of codes that i have a probem


jj2007

Quote from: ToutEnMasm on October 05, 2011, 07:55:40 AM

You must got:
Quote
LRESULT CALLBACK MainWindowProc(hwnd, msg, wParam, lParam)
...  return 0;
}

It is only copiing pieces of codes that i have a probem

For that short piece of code, both controls show the same result. You will get trouble if you paste code that is longer than the edit control's limits, therefore in RichEdit you got the EM_EXLIMITTEXT message. I am sure you just forgot it, no problem.

By the way, the URL you posted is cute - I learnt a new function:

MsgBox 0, str$(rv(GetClipboardSequenceNumber)), "Hi", MB_OK

Extremely useful to check if the clipboard has changed :bg

ToutEnMasm

Quote
For that short piece of code, both controls show the same result.
Bad chance ,I write code who don't work only for me.Perhaps XP SP3 ?
:'(