📄 wm.c
字号:
0, DecodeGeneric },
{ "WM_PALETTEISCHANGING", WM_PALETTEISCHANGING, // 0x0310
0, DecodeGeneric },
{ "WM_PALETTECHANGED", WM_PALETTECHANGED, // 0x0311
0, DecodeGeneric },
{ "WM_HOTKEY", WM_HOTKEY, // 0x0312
MTF_TYPE_KEYBD, DecodeGeneric },
{ "WM_DDE_INITIATE", WM_DDE_INITIATE, // 0x03E0
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_TERMINATE", WM_DDE_TERMINATE, // 0x03E1
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_ADVISE", WM_DDE_ADVISE, // 0x03E2
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_UNADVISE", WM_DDE_UNADVISE, // 0x03E3
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_ACK", WM_DDE_ACK, // 0x03E4
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_DATA", WM_DDE_DATA, // 0x03E5
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_REQUEST", WM_DDE_REQUEST, // 0x03E6
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_POKE", WM_DDE_POKE, // 0x03E7
MTF_TYPE_DDE, DecodeGeneric },
{ "WM_DDE_EXECUTE", WM_DDE_EXECUTE, // 0x03E8
MTF_TYPE_DDE, DecodeGeneric }
};
INT gcMessages = sizeof(gaMsgs) / sizeof(MSGDESC);
//
// Arrays of integers large enough to hold the indexes of all
// the messages in the message table. This is used when
// selecting messages with the Messages dialog.
//
INT gaiSelected[sizeof(gaMsgs) / sizeof(MSGDESC)];
INT gaiSelected2[sizeof(gaMsgs) / sizeof(MSGDESC)];
MSGGROUP gaMsgGroup[] =
{
{ DID_MSGSDDE, MTF_TYPE_DDE, 0, 0 },
{ DID_MSGSCLIP, MTF_TYPE_CLIP, 0, 0 },
{ DID_MSGSMOUSE, MTF_TYPE_MOUSE, 0, 0 },
{ DID_MSGSNC, MTF_TYPE_NC, 0, 0 },
{ DID_MSGSKEYBD, MTF_TYPE_KEYBD, 0, 0 },
#ifdef FE_IME
{ DID_MSGSIME, MTF_TYPE_IME, 0, 0 },
#endif
{ DID_MSGSBM, MTF_TYPE_BM, 0, 0 },
{ DID_MSGSCB, MTF_TYPE_CB, 0, 0 },
{ DID_MSGSEM, MTF_TYPE_EM, 0, 0 },
{ DID_MSGSLB, MTF_TYPE_LB, 0, 0 },
{ DID_MSGSSTM, MTF_TYPE_STM, 0, 0 }
};
INT gcMsgGroups = sizeof(gaMsgGroup) / sizeof(MSGGROUP);
INT __cdecl MsgCmp(const void *p1, const void *p2);
PRIVATE VOID mprintf(LPSTR format, ...);
/*****************************************************************************\
* MsgCmp
*
* Callback function for qsort that sorts messages.
*
* Arguments:
* void *p1 - pointer to first item
* void *p2 - pointer to second item
*
* Returns:
* -1 if first input less than second input
* 1 if second input is less than first input
* 0 if inputs are equal
*
\*****************************************************************************/
INT __cdecl
MsgCmp(
const void *p1,
const void *p2
)
{
MSGDESC *pmd1 = (PMSGDESC)p1;
MSGDESC *pmd2 = (PMSGDESC)p2;
return pmd1->msg < pmd2->msg ? -1 : (pmd1->msg > pmd2->msg ? 1 : 0);
}
/*****************************************************************************\
* CalculatePrintfTabs
*
* Calculates the tabs needed for each field in the printf window. This
* is based on the largest string in the message table and the specified
* font.
*
* Arguments:
* HFONT hfont - Font to use in the calculations.
*
* Returns:
* VOID
\*****************************************************************************/
VOID
CalculatePrintfTabs(
HFONT hfont
)
{
MSGDESC *pmd;
HDC hdc;
INT dxMsg;
INT dxSpace;
INT dxHwnd;
INT tabs[3];
SIZE siz;
HFONT hfontOld;
INT i;
hdc = GetDC(NULL);
hfontOld = SelectObject(hdc, hfont);
dxMsg = 0;
for (pmd = gaMsgs, i = 0; i < gcMessages; pmd++, i++)
{
GetTextExtentPoint(hdc, pmd->pszMsg, lstrlen(pmd->pszMsg), &siz);
dxMsg = max(dxMsg, siz.cx);
}
//
// Calculate the widest possible hwnd value. It is assumed that the
// font will have the same width for all digits (or that '0' would
// be the widest).
//
GetTextExtentPoint(hdc, "00000000", 8, &siz);
dxHwnd = siz.cx;
GetTextExtentPoint(hdc, "AAAAAAAA", 8, &siz);
dxHwnd = max(dxHwnd, siz.cx);
GetTextExtentPoint(hdc, "BBBBBBBB", 8, &siz);
dxHwnd = max(dxHwnd, siz.cx);
GetTextExtentPoint(hdc, "CCCCCCCC", 8, &siz);
dxHwnd = max(dxHwnd, siz.cx);
GetTextExtentPoint(hdc, "DDDDDDDD", 8, &siz);
dxHwnd = max(dxHwnd, siz.cx);
GetTextExtentPoint(hdc, "EEEEEEEE", 8, &siz);
dxHwnd = max(dxHwnd, siz.cx);
GetTextExtentPoint(hdc, "FFFFFFFF", 8, &siz);
dxHwnd = max(dxHwnd, siz.cx);
GetTextExtentPoint(hdc, " ", 1, &siz);
dxSpace = siz.cx;
SelectObject(hdc, hfontOld);
ReleaseDC(NULL, hdc);
tabs[0] = dxHwnd + dxSpace;
tabs[1] = tabs[0] + dxMsg + dxSpace;
tabs[2] = tabs[1] + dxHwnd + dxSpace;
SetPrintfTabs(3, tabs);
}
/*****************************************************************************\
* PrintMsg
*
* Writes out a specified message.
*
* Arguments:
* LPMSG lpMsg - message to print out
*
* Returns:
* VOID
\*****************************************************************************/
VOID
PrintMsg(
LPMSG lpMsg
)
{
static MSGDESC md;
PMSGDESC pmd;
md.msg = lpMsg->message;
pmd = (PMSGDESC)bsearch(&md, gaMsgs, gcMessages, sizeof(MSGDESC), MsgCmp);
if (pmd)
{
if (pmd->Flags & MTF_SELECTED)
{
mprintf(szFormatName, lpMsg->hwnd, pmd->pszMsg, lpMsg->wParam,
lpMsg->lParam);
}
}
else
{
if (lpMsg->message >= WM_USER)
{
if (gfMsgsUser)
{
mprintf(szFormatUSER, lpMsg->hwnd, lpMsg->message - WM_USER,
lpMsg->wParam, lpMsg->lParam);
}
}
else
{
if (gfMsgsUnknown)
{
mprintf(szFormatUnknown, lpMsg->hwnd, lpMsg->message,
lpMsg->wParam, lpMsg->lParam);
}
}
}
}
/*****************************************************************************\
* mprintf
*
* Writes out a message to the specified device.
*
* Arguments:
* LPSTR format - Format string.
* ... - Optional arguments.
*
* Returns:
*
*
\*****************************************************************************/
PUBLIC INT FAR cdecl
ITvwprintf(
HWND hwnd,
LPSTR format,
va_list marker
)
{
LPSTR p;
TCHAR szBuffer[512];
for( p = format; *p != '\0'; p++ ) {
if (*p == '\r')
*p = ' ';
}
wvsprintf(szBuffer, format, marker );
return SendMessage( hwnd, WM_VWPRINTF, (WPARAM)szBuffer, (LPARAM)0 );
}
PRIVATE VOID
mprintf(
LPSTR format,
...
)
{
va_list marker;
CHAR szTemp[MAXSTRING];
INT iLen;
va_start(marker, format);
if (gfOutputWin)
{
ITvwprintf(ghwndPrintf, format, marker);
}
#if 0
if (gfOutputCom1)
{
iLen = wvsprintf(szTemp, format, marker);
M_lwrite(INT2HFILE(FH_COM1), szTemp, iLen);
}
#else //BUGBUG this doesn't work under NT. The com device needs to be explicitly opened.
if (gfOutputCom1 && gfhCom1 != INVALID_HANDLE_VALUE)
{
DWORD dwBytesWritten;
iLen = wvsprintf(szTemp, format, marker);
WriteFile(gfhCom1, szTemp, iLen, &dwBytesWritten, NULL);
WriteFile(gfhCom1, "\r\n", 2, &dwBytesWritten, NULL);
}
#endif // fix by Japanese team
if (gfOutputFile && gfhFile)
{
iLen = wvsprintf(szTemp, format, marker);
_lwrite(gfhFile, szTemp, iLen);
//BUGBUG _lclose(DUPHFILE(gfhFile)); /* flush the file buffer */
}
va_end(marker);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -