2008-02-16 17:36:37 +01:00
|
|
|
/* -*- fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE" -*- */
|
|
|
|
/*
|
|
|
|
* Copyright 2008 by Eric House (xwords@eehouse.org). All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-12-06 16:59:30 +01:00
|
|
|
#include <stdio.h>
|
2008-02-16 17:36:37 +01:00
|
|
|
#include "cedebug.h"
|
|
|
|
|
2008-02-16 18:14:35 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
2008-02-16 17:36:37 +01:00
|
|
|
#define CASE_STR(c) case c: str = #c; break
|
|
|
|
|
|
|
|
const char*
|
|
|
|
messageToStr( UINT message )
|
|
|
|
{
|
|
|
|
const char* str;
|
|
|
|
switch( message ) {
|
|
|
|
CASE_STR( WM_NCACTIVATE );
|
|
|
|
CASE_STR( WM_QUERYNEWPALETTE );
|
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
CASE_STR( WM_IME_NOTIFY );
|
|
|
|
CASE_STR( WM_IME_SETCONTEXT );
|
|
|
|
#endif
|
|
|
|
CASE_STR( WM_WINDOWPOSCHANGED );
|
|
|
|
CASE_STR( WM_MOVE );
|
|
|
|
CASE_STR( WM_SIZE );
|
|
|
|
CASE_STR( WM_ACTIVATE );
|
|
|
|
CASE_STR( WM_SETTINGCHANGE );
|
|
|
|
CASE_STR( WM_VSCROLL );
|
|
|
|
CASE_STR( WM_COMMAND );
|
|
|
|
CASE_STR( WM_PAINT );
|
|
|
|
CASE_STR( WM_LBUTTONDOWN );
|
|
|
|
CASE_STR( WM_MOUSEMOVE );
|
|
|
|
CASE_STR( WM_LBUTTONUP );
|
|
|
|
CASE_STR( WM_KEYDOWN );
|
|
|
|
CASE_STR( WM_KEYUP );
|
|
|
|
CASE_STR( WM_CHAR );
|
|
|
|
CASE_STR( WM_TIMER );
|
|
|
|
CASE_STR( WM_DESTROY );
|
|
|
|
CASE_STR( XWWM_TIME_RQST );
|
2009-01-31 19:06:09 +01:00
|
|
|
CASE_STR( XWWM_HOSTNAME_ARRIVED );
|
|
|
|
CASE_STR( XWWM_SOCKET_EVT );
|
2008-02-23 23:02:10 +01:00
|
|
|
CASE_STR( WM_DRAWITEM );
|
|
|
|
CASE_STR( WM_NEXTDLGCTL );
|
|
|
|
CASE_STR( WM_CTLCOLORSTATIC );
|
|
|
|
CASE_STR( WM_CTLCOLORBTN );
|
|
|
|
CASE_STR( WM_SETFONT );
|
|
|
|
CASE_STR( WM_INITDIALOG );
|
|
|
|
CASE_STR( WM_SHOWWINDOW );
|
|
|
|
CASE_STR( WM_WINDOWPOSCHANGING );
|
|
|
|
CASE_STR( WM_SETFOCUS );
|
|
|
|
CASE_STR( WM_NCPAINT );
|
2008-05-25 17:08:03 +02:00
|
|
|
CASE_STR( WM_ERASEBKGND );
|
2008-03-15 15:14:39 +01:00
|
|
|
CASE_STR( WM_NCCALCSIZE );
|
|
|
|
CASE_STR( WM_SETTEXT );
|
|
|
|
CASE_STR( WM_CTLCOLORDLG );
|
|
|
|
CASE_STR( WM_MOUSEACTIVATE );
|
|
|
|
CASE_STR( WM_SETCURSOR );
|
|
|
|
CASE_STR( WM_CTLCOLORLISTBOX );
|
|
|
|
CASE_STR( WM_CTLCOLOREDIT );
|
|
|
|
CASE_STR( WM_NCDESTROY );
|
|
|
|
CASE_STR( WM_NOTIFY );
|
2008-06-07 16:42:20 +02:00
|
|
|
CASE_STR( WM_NCHITTEST );
|
2008-08-27 14:16:33 +02:00
|
|
|
CASE_STR( WM_HSCROLL );
|
|
|
|
CASE_STR( WM_STYLECHANGED );
|
|
|
|
CASE_STR( WM_NOTIFYFORMAT );
|
|
|
|
CASE_STR( WM_KILLFOCUS );
|
2008-09-27 17:15:14 +02:00
|
|
|
CASE_STR( WM_CTLCOLORSCROLLBAR );
|
|
|
|
CASE_STR( WM_NCMOUSEMOVE );
|
|
|
|
CASE_STR( SBM_SETSCROLLINFO );
|
2008-10-13 03:22:58 +02:00
|
|
|
CASE_STR( WM_HOTKEY );
|
|
|
|
CASE_STR( WM_CLOSE );
|
|
|
|
CASE_STR( WM_ACTIVATEAPP );
|
2008-10-31 05:31:46 +01:00
|
|
|
CASE_STR( WM_ENTERMENULOOP );
|
|
|
|
CASE_STR( WM_EXITMENULOOP );
|
|
|
|
CASE_STR( WM_INITMENUPOPUP );
|
|
|
|
CASE_STR( WM_CANCELMODE );
|
2009-02-21 18:03:30 +01:00
|
|
|
CASE_STR( WM_ENTERIDLE );
|
2009-08-29 15:37:37 +02:00
|
|
|
CASE_STR( WM_GETDLGCODE );
|
2008-02-16 17:36:37 +01:00
|
|
|
default:
|
|
|
|
str = "<unknown>";
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
} /* messageToStr */
|
|
|
|
|
2008-02-16 18:14:35 +01:00
|
|
|
void
|
|
|
|
XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg )
|
|
|
|
{
|
|
|
|
XP_UCHAR buf[512];
|
2009-11-15 16:46:57 +01:00
|
|
|
(void)WideCharToMultiByte( CP_UTF8, 0, arg, -1,
|
2008-02-16 18:14:35 +01:00
|
|
|
buf, sizeof(buf), NULL, NULL );
|
|
|
|
XP_LOGF( "%s: %s", prefix, buf );
|
|
|
|
}
|
|
|
|
|
2008-09-09 14:20:45 +02:00
|
|
|
void
|
|
|
|
logRect( const char* comment, const RECT* rect )
|
|
|
|
{
|
|
|
|
XP_LOGF( "%s: %s: left=%ld,top=%ld,right=%ld,bottom=%ld", __func__,
|
|
|
|
comment, rect->left, rect->top, rect->right, rect->bottom );
|
|
|
|
}
|
|
|
|
|
2008-02-16 17:36:37 +01:00
|
|
|
#undef CASE_STR
|
2008-02-16 18:14:35 +01:00
|
|
|
|
2008-09-14 18:01:28 +02:00
|
|
|
void
|
|
|
|
logLastError( const char* comment )
|
|
|
|
{
|
|
|
|
LPVOID lpMsgBuf;
|
|
|
|
DWORD lastErr = GetLastError();
|
|
|
|
XP_UCHAR msg[256];
|
|
|
|
XP_U16 len;
|
|
|
|
XP_U16 lenSoFar;
|
|
|
|
|
2008-12-06 16:59:30 +01:00
|
|
|
snprintf( msg, sizeof(msg), "%s (err: %ld): ", comment, lastErr );
|
2008-09-14 18:01:28 +02:00
|
|
|
lenSoFar = strlen( msg );
|
|
|
|
|
|
|
|
FormatMessage(
|
|
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL,
|
|
|
|
lastErr,
|
|
|
|
0, // Default language
|
|
|
|
(LPTSTR) &lpMsgBuf,
|
|
|
|
0,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
len = wcslen( lpMsgBuf );
|
|
|
|
if ( len >= sizeof(msg)-lenSoFar ) {
|
|
|
|
len = sizeof(msg) - lenSoFar - 1;
|
|
|
|
}
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, lpMsgBuf, len + 1,
|
|
|
|
msg + lenSoFar, len + 1, NULL, NULL );
|
|
|
|
LocalFree( lpMsgBuf );
|
|
|
|
|
|
|
|
XP_LOGF( "system error: %s", msg );
|
|
|
|
} /* logLastError */
|
|
|
|
|
2008-02-16 18:14:35 +01:00
|
|
|
#endif /* DEBUG */
|