示例#1
0
static LRESULT onSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	HMENU	hMenu;

	hMenu = GetSystemMenu(hWnd, FALSE);
	switch(wParam)
	{
		case IDM_TRACE_TRACE:
			tracewin.en ^= 1;
			CheckMenuItem(hMenu, IDM_TRACE_TRACE,
								(tracewin.en & 1)?MF_CHECKED:MF_UNCHECKED);
			break;

		case IDM_TRACE_VERBOSE:
			tracewin.en ^= 2;
			CheckMenuItem(hMenu, IDM_TRACE_VERBOSE,
								(tracewin.en & 2)?MF_CHECKED:MF_UNCHECKED);
			break;

		case IDM_TRACE_ENABLE:
			tracewin.en ^= 4;
			CheckMenuItem(hMenu, IDM_TRACE_ENABLE,
								(tracewin.en & 4)?MF_CHECKED:MF_UNCHECKED);
			break;

		case IDM_TRACE_FILEOUT:
			if (tracewin.tf != NULL)
			{
				textfile_close(tracewin.tf);
				tracewin.tf = NULL;
			}
			else
			{
				tracewin.tf = textfile_create(OEMTEXT("traceout.txt"),
																0x800);
			}
			CheckMenuItem(hMenu, IDM_TRACE_FILEOUT,
									(tracewin.tf)?MF_CHECKED:MF_UNCHECKED);
			break;

		case IDM_TRACE_CLEAR:
			View_ClrString();
			break;

		default:
			return DefWindowProc(hWnd, WM_SYSCOMMAND, wParam, lParam);
	}
	return FALSE;
}
示例#2
0
static LRESULT CALLBACK traceproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {

    RECT	rc;
    HMENU	hmenu;

    switch (msg) {
    case WM_CREATE:
        hmenu = GetSystemMenu(hWnd, FALSE);
        InsertMenu(hmenu, 0, MF_BYPOSITION | MF_STRING,
                   IDM_TRACE1, trace1);
        InsertMenu(hmenu, 1, MF_BYPOSITION | MF_STRING,
                   IDM_TRACE2, trace2);
        InsertMenu(hmenu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
        InsertMenu(hmenu, 3, MF_BYPOSITION | MF_STRING,
                   IDM_TRACEEN, traceen);
        InsertMenu(hmenu, 4, MF_BYPOSITION | MF_STRING,
                   IDM_TRACEFH, tracefh);
        InsertMenu(hmenu, 5, MF_BYPOSITION | MF_STRING,
                   IDM_TRACECL, tracecl);
        InsertMenu(hmenu, 6, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);

        CheckMenuItem(hmenu, IDM_TRACE1,
                      (tracewin.en & 1)?MF_CHECKED:MF_UNCHECKED);
        CheckMenuItem(hmenu, IDM_TRACE2,
                      (tracewin.en & 2)?MF_CHECKED:MF_UNCHECKED);
        CheckMenuItem(hmenu, IDM_TRACEEN,
                      (tracewin.en & 4)?MF_CHECKED:MF_UNCHECKED);

        GetClientRect(hWnd, &rc);
        hView = CreateWindowEx(WS_EX_CLIENTEDGE,
                               ClassEdit, NULL,
                               WS_CHILD | WS_VISIBLE | ES_READONLY | ES_LEFT |
                               ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL,
                               0, 0, rc.right, rc.bottom,
                               hWnd, (HMENU)IDC_VIEW, g_hInstance, NULL);
        if (!hView) {
            break;
        }
        SendMessage(hView, EM_SETLIMITTEXT, (WPARAM)VIEW_BUFFERSIZE, 0);

        hfView = CreateFont(VIEW_SIZE, 0, 0, 0, 0, 0, 0, 0,
                            SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                            DEFAULT_QUALITY, FIXED_PITCH, viewfont);
        if (!hfView) {
            break;
        }
        SendMessage(hView, WM_SETFONT, (WPARAM)hfView,
                    MAKELPARAM(TRUE, 0));
        hBrush = CreateSolidBrush(VIEW_BGCOLOR);
        SetFocus(hView);
        return(TRUE);

    case WM_SYSCOMMAND:
        switch(wp) {
        case IDM_TRACE1:
            tracewin.en ^= 1;
            hmenu = GetSystemMenu(hWnd, FALSE);
            CheckMenuItem(hmenu, IDM_TRACE1,
                          (tracewin.en & 1)?MF_CHECKED:MF_UNCHECKED);
            break;

        case IDM_TRACE2:
            tracewin.en ^= 2;
            hmenu = GetSystemMenu(hWnd, FALSE);
            CheckMenuItem(hmenu, IDM_TRACE2,
                          (tracewin.en & 2)?MF_CHECKED:MF_UNCHECKED);
            break;

        case IDM_TRACEEN:
            tracewin.en ^= 4;
            hmenu = GetSystemMenu(hWnd, FALSE);
            CheckMenuItem(hmenu, IDM_TRACEEN,
                          (tracewin.en & 4)?MF_CHECKED:MF_UNCHECKED);
            break;

        case IDM_TRACEFH:
            if (tracewin.tf != NULL) {
                textfile_close(tracewin.tf);
                tracewin.tf = NULL;
            }
            else {
                tracewin.tf = textfile_create(OEMTEXT("traceout.txt"),
                                              0x800);
            }
            hmenu = GetSystemMenu(hWnd, FALSE);
            CheckMenuItem(hmenu, IDM_TRACEFH,
                          (tracewin.tf)?MF_CHECKED:MF_UNCHECKED);
            break;

        case IDM_TRACECL:
            View_ClrString();
            break;

        default:
            return(DefWindowProc(hWnd, msg, wp, lp));
        }
        break;

    case WM_MOVE:
        if (!(GetWindowLong(hWnd, GWL_STYLE) &
                (WS_MAXIMIZE | WS_MINIMIZE))) {
            GetWindowRect(hWnd, &rc);
            tracecfg.posx = rc.left;
            tracecfg.posy = rc.top;
        }
        break;

    case WM_SIZE:							// window resize
        if (!(GetWindowLong(hWnd, GWL_STYLE) &
                (WS_MAXIMIZE | WS_MINIMIZE))) {
            GetWindowRect(hWnd, &rc);
            tracecfg.width = rc.right - rc.left;
            tracecfg.height = rc.bottom - rc.top;
        }
        MoveWindow(hView, 0, 0, LOWORD(lp), HIWORD(lp), TRUE);
        View_ScrollToBottom(hView);
        break;

    case WM_SETFOCUS:
        SetFocus(hView);
        return(0L);

    case WM_CTLCOLORSTATIC:
    case WM_CTLCOLOREDIT:
        SetTextColor((HDC)wp, VIEW_FGCOLOR);
        SetBkColor((HDC)wp, VIEW_BGCOLOR);
        return((LRESULT)hBrush);

    case WM_CLOSE:
        break;

    case WM_DESTROY:
        if (hBrush) {
            DeleteObject(hBrush);
        }
        if (hfView) {
            DeleteObject(hfView);
        }
        break;
#if 0
    case WM_ENTERSIZEMOVE:
        winloc_movingstart();
        break;

    case WM_MOVING:
        winloc_movingproc((RECT *)lp);
        break;

    case WM_ERASEBKGND:
        return(FALSE);
#endif
    default:
        return(DefWindowProc(hWnd, msg, wp, lp));
    }
    return(0L);
}