Никогда не слышал о такой возможности, не предполагал о её существовании, но, ковыряясь в кишках винды, нашёл интересную функцию:
- Код: Выделить всё
/***************************************************************************\
* MB_CopyToClipboard
*
* Called in response to WM_COPY, it will save the title, message and button's
* texts to the clipboard in CF_UNICODETEXT format.
*
* ---------------------------
* Caption
* ---------------------------
* Text
* ---------------------------
* Button1 ... ButtonN
* ---------------------------
*
*
* History:
* 08-03-97 MCostea Created
\***************************************************************************/
void MB_CopyToClipboard(
HWND hwndDlg)
{
LPCWSTR lpszRead;
LPWSTR lpszAll, lpszWrite;
HANDLE hData;
static WCHAR szLine[] = L"---------------------------\r\n";
UINT cBufSize, i, cWrote;
LPMSGBOXDATA lpmb;
if (!(lpmb = (LPMSGBOXDATA)GetWindowLongPtr(hwndDlg, GWLP_USERDATA)))
return;
if (!OpenClipboard(hwndDlg))
return;
/*
* Calculate the buffer size:
* - the message text can be all \n, that will become \r\n
* - there are a few extra \r\n (that's why 8)
*/
cBufSize = (lpmb->lpszCaption ? wcslen(lpmb->lpszCaption) : 0) +
(lpmb->lpszText ? 2*wcslen(lpmb->lpszText) : 0) +
4*sizeof(szLine) +
lpmb->cButtons * gpsi->wMaxBtnSize +
8;
cBufSize *= sizeof(WCHAR);
if (!(hData = UserGlobalAlloc(LHND, (LONG)(cBufSize))) ) {
goto CloseClip;
}
USERGLOBALLOCK(hData, lpszAll);
UserAssert(lpszAll);
cWrote = wsprintf(lpszAll, L"%s%s\r\n%s",
szLine,
lpmb->lpszCaption ? lpmb->lpszCaption : L"",
szLine);
lpszWrite = lpszAll + cWrote;
lpszRead = lpmb->lpszText;
/*
* Change \n to \r\n in the text
*/
for (i = 0; *lpszRead; i++) {
if (*lpszRead == L'\n')
*lpszWrite++ = L'\r';
*lpszWrite++ = *lpszRead++;
}
cWrote = wsprintf(lpszWrite, L"\r\n%s", szLine);
lpszWrite += cWrote;
/*
* Remove & from the button texts
*/
for (i = 0; i<lpmb->cButtons; i++) {
lpszRead = lpmb->ppszButtonText[i];
while (*lpszRead) {
if (*lpszRead != L'&') {
*lpszWrite++ = *lpszRead;
}
lpszRead++;
}
*lpszWrite++ = L' ';
*lpszWrite++ = L' ';
*lpszWrite++ = L' ';
}
wsprintf(lpszWrite, L"\r\n%s\0", szLine);
USERGLOBALUNLOCK(hData);
NtUserEmptyClipboard();
/*
* If we just called EmptyClipboard in the context of a 16 bit
* app then we also have to tell WOW to nix its 16 handle copy of
* clipboard data. WOW does its own clipboard caching because
* some 16 bit apps use clipboard data even after the clipboard
* has been emptied. See the note in the server code.
*
* Note: this is another place (besides client\editec.c) where
* EmptyClipboard is called* for a 16 bit app not going through WOW.
* If we added others we might want to move this into EmptyClipboard
* and have two versions.
*/
if (GetClientInfo()->CI_flags & CI_16BIT) {
pfnWowEmptyClipBoard();
}
SetClipboardData(CF_UNICODETEXT, hData);
CloseClip:
NtUserCloseClipboard();
}