Ejemplo n.º 1
0
void
mswin_status_window_size(HWND hWnd, LPSIZE sz)
{
    TEXTMETRIC tm;
    HGDIOBJ saveFont;
    HDC hdc;
    PNHStatusWindow data;
    RECT rt;
    GetWindowRect(hWnd, &rt);
    sz->cx = rt.right - rt.left;
    sz->cy = rt.bottom - rt.top;

    data = (PNHStatusWindow) GetWindowLong(hWnd, GWL_USERDATA);
    if (data) {
        hdc = GetDC(hWnd);
        saveFont = SelectObject(
            hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
        GetTextMetrics(hdc, &tm);

        /* see if the status window can fit 80 characters per line */
        if ((80 * tm.tmMaxCharWidth) >= sz->cx)
            data->nhstat_format = NHSTAT_LINES_4;
        else
            data->nhstat_format = NHSTAT_LINES_2;

        /* set height of the status box */
        sz->cy = tm.tmHeight * data->nhstat_format;

        SelectObject(hdc, saveFont);
        ReleaseDC(hWnd, hdc);
    }
}
Ejemplo n.º 2
0
Archivo: mhmenu.c Proyecto: yzh/yzhack
LRESULT onMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
    LPMEASUREITEMSTRUCT lpmis; 
    TEXTMETRIC tm;
	HGDIOBJ saveFont;
	HDC hdc;
	PNHMenuWindow data;
	RECT list_rect;

    lpmis = (LPMEASUREITEMSTRUCT) lParam; 
	data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
	GetClientRect(GetMenuControl(hWnd), &list_rect);

	hdc = GetDC(GetMenuControl(hWnd));
	saveFont = SelectObject(hdc, mswin_get_font(NHW_MENU, ATR_INVERSE, hdc, FALSE));
	GetTextMetrics(hdc, &tm);

    /* Set the height of the list box items. */
    lpmis->itemHeight = max(tm.tmHeight, TILE_Y)+2;
	lpmis->itemWidth = list_rect.right - list_rect.left;

	SelectObject(hdc, saveFont);
	ReleaseDC(GetMenuControl(hWnd), hdc);
	return TRUE;
}
Ejemplo n.º 3
0
void mswin_status_window_size (HWND hWnd, LPSIZE sz)
{
    TEXTMETRIC tm;
    HGDIOBJ saveFont;
    HDC hdc;
    PNHStatusWindow data;
    RECT rt;
    GetWindowRect(hWnd, &rt);
    sz->cx = rt.right - rt.left;
    sz->cy = rt.bottom - rt.top;

    data = (PNHStatusWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA);
    if(data) {
        hdc = GetDC(hWnd);
        saveFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
        GetTextMetrics(hdc, &tm);

        sz->cy = tm.tmHeight * NHSW_LINES;

        SelectObject(hdc, saveFont);
        ReleaseDC(hWnd, hdc);
    }
}
Ejemplo n.º 4
0
INT_PTR CALLBACK
NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;

    UNREFERENCED_PARAMETER(lParam);

    switch (message) {
    case WM_INITDIALOG:
        /* set text control font */
        hdc = GetDC(hWnd);
        SendMessage(hWnd, WM_SETFONT,
                    (WPARAM) mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE),
                    0);
        ReleaseDC(hWnd, hdc);

        SetFocus(GetDlgItem(hWnd, IDOK));
        return FALSE;

    case WM_PAINT: {
        char VersionString[BUFSZ];
        RECT rt;
        HDC hdcBitmap;
        HANDLE OldBitmap;
        HANDLE OldFont;
        PAINTSTRUCT ps;

        hdc = BeginPaint(hWnd, &ps);
        /* Show splash graphic */

        hdcBitmap = CreateCompatibleDC(hdc);
        SetBkMode(hdc, OPAQUE);
        OldBitmap = SelectObject(hdcBitmap, GetNHApp()->bmpSplash);
        (*GetNHApp()->lpfnTransparentBlt)(hdc, SPLASH_OFFSET_X, SPLASH_OFFSET_Y,
                                  SPLASH_WIDTH, SPLASH_HEIGHT, hdcBitmap, 0,
                                  0, SPLASH_WIDTH, SPLASH_HEIGHT,
                                  TILE_BK_COLOR);

        SelectObject(hdcBitmap, OldBitmap);
        DeleteDC(hdcBitmap);

        SetBkMode(hdc, TRANSPARENT);
        /* Print version number */

        SetTextColor(hdc, RGB(0, 0, 0));
        rt.right = rt.left = SPLASH_VERSION_X;
        rt.bottom = rt.top = SPLASH_VERSION_Y;
        Sprintf(VersionString, "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR,
                PATCHLEVEL);
        OldFont = SelectObject(hdc, version_splash_font);
        DrawText(hdc, VersionString, strlen(VersionString), &rt,
                 DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
        DrawText(hdc, VersionString, strlen(VersionString), &rt,
                 DT_LEFT | DT_NOPREFIX);
        EndPaint(hWnd, &ps);
    } break;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDOK:
            mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
            if (GetNHApp()->hMainWnd == hWnd)
                GetNHApp()->hMainWnd = NULL;
            DestroyWindow(hWnd);
            SetFocus(GetNHApp()->hMainWnd);
            return TRUE;
        }
        break;
    }
    return FALSE;
}
Ejemplo n.º 5
0
void mswin_display_RIP_window (HWND hWnd)
{
	MSG msg;
	RECT rt;
	PNHRIPWindow data;
	HWND mapWnd;
	RECT riprt;
	RECT clientrect;
	RECT textrect;
	HDC hdc;
	HFONT OldFont;

	data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA);

	GetNHApp()->hPopupWnd = hWnd;
	mapWnd = mswin_hwnd_from_winid(WIN_MAP);
	if( !IsWindow(mapWnd) ) mapWnd = GetNHApp()->hMainWnd;
	GetWindowRect(mapWnd, &rt);
	GetWindowRect(hWnd, &riprt);
	GetClientRect (hWnd, &clientrect);
	textrect = clientrect;
	textrect.top += RIP_OFFSET_Y;
	textrect.left += RIP_OFFSET_X;
	textrect.right -= RIP_OFFSET_X;
	if (data->window_text)
	{
	    hdc = GetDC (hWnd);
	    OldFont = SelectObject (hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
	    DrawText (hdc, data->window_text, strlen(data->window_text), &textrect,
		DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
	    SelectObject (hdc, OldFont);
	    ReleaseDC(hWnd, hdc);
	}
	if (textrect.right - textrect.left > RIP_WIDTH)
	    clientrect.right = textrect.right + RIP_OFFSET_X - clientrect.right;
	else
	    clientrect.right = textrect.left + 2 * RIP_OFFSET_X + RIP_WIDTH - clientrect.right;
	clientrect.bottom = textrect.bottom + RIP_HEIGHT + RIP_OFFSET_Y - clientrect.bottom;
	GetWindowRect (GetDlgItem(hWnd, IDOK), &textrect);
	textrect.right -= textrect.left;
	textrect.bottom -= textrect.top;
	clientrect.bottom += textrect.bottom + RIP_OFFSET_Y;
	riprt.right -= riprt.left;
	riprt.bottom -= riprt.top;
	riprt.right += clientrect.right;
	riprt.bottom += clientrect.bottom;
	rt.left += (rt.right - rt.left - riprt.right) / 2;
	rt.top += (rt.bottom - rt.top - riprt.bottom) / 2;

	MoveWindow(hWnd, rt.left, rt.top, riprt.right, riprt.bottom, TRUE);
	GetClientRect (hWnd, &clientrect);
	MoveWindow (GetDlgItem(hWnd, IDOK),
	    (clientrect.right - clientrect.left - textrect.right) / 2,
	    clientrect.bottom - textrect.bottom - RIP_OFFSET_Y, textrect.right, textrect.bottom, TRUE);
	ShowWindow(hWnd, SW_SHOW);

	while( IsWindow(hWnd) &&
		   GetMessage(&msg, NULL, 0, 0)!=0 ) {
		if( !IsDialogMessage(hWnd, &msg) ) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	GetNHApp()->hPopupWnd = NULL;
}
Ejemplo n.º 6
0
BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	PNHRIPWindow data;

	data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA);
	switch (message)
	{
	case WM_INITDIALOG:
	    /* set text control font */
		hdc = GetDC(hWnd);
		SendMessage(hWnd, WM_SETFONT,
			(WPARAM)mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE), 0);
		ReleaseDC(hWnd, hdc);

		SetFocus(GetDlgItem(hWnd, IDOK));
	return FALSE;

	case WM_MSNH_COMMAND:
		onMSNHCommand(hWnd, wParam, lParam);
	break;

	case WM_PAINT:
	{
		int bitmap_offset;
		RECT clientrect;
		RECT textrect;
		HDC hdcBitmap;
		HANDLE OldBitmap;
		PAINTSTRUCT ps;
		HFONT OldFont;

		hdc = BeginPaint (hWnd, &ps);
		OldFont = SelectObject (hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
		hdcBitmap = CreateCompatibleDC(hdc);
		SetBkMode (hdc, TRANSPARENT);
		GetClientRect (hWnd, &clientrect);
		textrect = clientrect;
		textrect.top += RIP_OFFSET_Y;
		textrect.left += RIP_OFFSET_X;
		textrect.right -= RIP_OFFSET_X;
		if (data->window_text)
		{
			DrawText (hdc, data->window_text, strlen(data->window_text), &textrect,
				DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
			DrawText (hdc, data->window_text, strlen(data->window_text), &textrect,
				DT_LEFT | DT_NOPREFIX);
		}
		OldBitmap = SelectObject(hdcBitmap, GetNHApp()->bmpRip);
		SetBkMode (hdc, OPAQUE);
		bitmap_offset = (textrect.right - textrect.left - RIP_WIDTH) / 2;
		BitBlt (hdc, textrect.left + bitmap_offset, textrect.bottom, RIP_WIDTH,
			RIP_HEIGHT, hdcBitmap, 0, 0, SRCCOPY);
		SetBkMode (hdc, TRANSPARENT);
		if (data->rip_text)
		{
			textrect.left += RIP_GRAVE_X + bitmap_offset;
			textrect.top = textrect.bottom + RIP_GRAVE_Y;
			textrect.right = textrect.left + RIP_GRAVE_WIDTH;
			textrect.bottom = textrect.top + RIP_GRAVE_HEIGHT;
			DrawText (hdc, data->rip_text, strlen(data->rip_text), &textrect,
				DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK);
		}
		SelectObject (hdcBitmap, OldBitmap);
		SelectObject (hdc, OldFont);
		DeleteDC (hdcBitmap);
		EndPaint (hWnd, &ps);
	}
	break;

	case WM_COMMAND:
		switch (LOWORD(wParam))
        {
          case IDOK:
			mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
			if( GetNHApp()->hMainWnd==hWnd )
				GetNHApp()->hMainWnd=NULL;
			DestroyWindow(hWnd);
			SetFocus(GetNHApp()->hMainWnd);
			return TRUE;
		}
	break;

	case WM_CLOSE:
	    /* if we get this here, we saved the bones so we can just force a quit */

	    mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
	    if( GetNHApp()->hMainWnd==hWnd )
		GetNHApp()->hMainWnd=NULL;
	    DestroyWindow(hWnd);
	    SetFocus(GetNHApp()->hMainWnd);
	    program_state.stopprint++;
	    return TRUE;

	case WM_DESTROY:
		if( data ) {
			if( data->window_text ) free(data->window_text);
			if( data->rip_text ) free(data->rip_text);
			if (data->rip_bmp != NULL) DeleteObject(data->rip_bmp);
			free(data);
			SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
		}
	break;

	}
	return FALSE;
}
Ejemplo n.º 7
0
LRESULT CALLBACK TextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HWND control;
    HDC hdc;
    PNHTextWindow data;

    data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA);
    switch (message) {
    case WM_INITDIALOG:
        /* set text control font */
        control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
        if( !control ) {
            panic("cannot get text view window");
        }

        hdc = GetDC(control);
        SendMessage(control, WM_SETFONT, (WPARAM)mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE), 0);
        ReleaseDC(control, hdc);

#if defined(WIN_CE_SMARTPHONE)
        /* special initialization for SmartPhone dialogs */
        NHSPhoneDialogSetup(hWnd, FALSE, GetNHApp()->bFullScreen);
#endif
        /* subclass edit control */
        editControlWndProc = (WNDPROC)GetWindowLong(control, GWL_WNDPROC);
        SetWindowLong(control, GWL_WNDPROC, (LONG)NHTextControlWndProc);

        if( !program_state.gameover && GetNHApp()->bWrapText ) {
            DWORD styles;
            styles = GetWindowLong(control, GWL_STYLE);
            if( styles ) {
                SetWindowLong(control, GWL_STYLE, styles & (~WS_HSCROLL));
                SetWindowPos(control, NULL, 0, 0, 0, 0,
                             SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE );
            }
        }

        SetFocus(control);
        return FALSE;

    case WM_MSNH_COMMAND:
        onMSNHCommand(hWnd, wParam, lParam);
        break;

    case WM_SIZE:
        LayoutText(hWnd);
        return FALSE;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDOK:
        case IDCANCEL:
            data->done = 1;
            return TRUE;
        }
        break;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORSTATIC: { /* sent by edit control before it is drawn */
        HDC hdcEdit = (HDC) wParam;
        HWND hwndEdit = (HWND) lParam;
        if( hwndEdit == GetDlgItem(hWnd, IDC_TEXT_CONTROL) ) {
            SetBkColor(hdcEdit, mswin_get_color(NHW_TEXT, MSWIN_COLOR_BG));
            SetTextColor(hdcEdit, mswin_get_color(NHW_TEXT, MSWIN_COLOR_FG));
            return (BOOL)mswin_get_brush(NHW_TEXT, MSWIN_COLOR_BG);
        }
    }
    return FALSE;

    case WM_DESTROY:
        if( data ) {
            mswin_free_text_buffer(data->window_text);
            free(data);
            SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
        }
        break;

    }
    return FALSE;
}
Ejemplo n.º 8
0
LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    RECT rt;
    PAINTSTRUCT ps;
    HDC hdc;
    PNHStatusWindow data;

    data = (PNHStatusWindow)GetWindowLongPtr(hWnd, GWLP_USERDATA);
    switch (message) {
    case WM_MSNH_COMMAND: {
        switch( wParam ) {
        case MSNH_MSG_PUTSTR: {
            PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam;
            strncpy(data->window_text[data->index], msg_data->text,
                    MAXWINDOWTEXT);
            strncat(data->window_text[data->index], "\n",
                    MAXWINDOWTEXT-strlen(data->window_text[data->index]));
            data->index = (data->index+1) % NHSW_LINES;
            InvalidateRect(hWnd, NULL, TRUE);
            break;
        }
        case MSNH_MSG_CLEAR_WINDOW:
            data->index = 0;
            ZeroMemory(data->window_text, sizeof(data->window_text));
            InvalidateRect(hWnd, NULL, TRUE);
            break;
        }
    }
    break;

    case WM_PAINT: {
        int i;
        SIZE sz;
        HGDIOBJ oldFont;
        TCHAR wbuf[BUFSZ];
        COLORREF OldBg, OldFg;

        hdc = BeginPaint(hWnd, &ps);
        GetClientRect(hWnd, &rt);

        oldFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));

        OldBg = SetBkColor(hdc, status_bg_brush
                           ? status_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_STATUS));
        OldFg = SetTextColor(hdc, status_fg_brush
                             ? status_fg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_FG_STATUS));

        for(i=0; i<NHSW_LINES; i++ ) {
            GetTextExtentPoint32(hdc, NH_A2W(data->window_text[i], wbuf, sizeof(wbuf)), strlen(data->window_text[i]), &sz);
            NH_A2W(data->window_text[i], wbuf, BUFSZ);
            DrawText(hdc, wbuf, strlen(data->window_text[i]), &rt, DT_LEFT | DT_END_ELLIPSIS);
            rt.top += sz.cy;
        }

        SelectObject(hdc, oldFont);
        SetTextColor (hdc, OldFg);
        SetBkColor (hdc, OldBg);
        EndPaint(hWnd, &ps);
    }
    break;

    case WM_DESTROY:
        free(data);
        SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)0);
        break;

    case WM_SETFOCUS:
        SetFocus(GetNHApp()->hMainWnd);
        break;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Ejemplo n.º 9
0
LRESULT CALLBACK
StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    RECT rt;
    PAINTSTRUCT ps;
    HDC hdc;
    PNHStatusWindow data;

    data = (PNHStatusWindow) GetWindowLong(hWnd, GWL_USERDATA);
    switch (message) {
    case WM_MSNH_COMMAND: {
        switch (wParam) {
        case MSNH_MSG_PUTSTR:
        case MSNH_MSG_CLEAR_WINDOW:
            ZeroMemory(data->window_text, sizeof(data->window_text));
            FormatStatusString(data->window_text, data->nhstat_format);
            break;

        case MSNH_MSG_CURSOR: {
            PMSNHMsgCursor msg_data = (PMSNHMsgCursor) lParam;
            if (msg_data->y == 0) {
                InvalidateRect(hWnd, NULL, TRUE);
            }
        } break;
        }
    } break;

    case WM_PAINT: {
        HGDIOBJ oldFont;
        TCHAR wbuf[MAXWINDOWTEXT];
        COLORREF OldBg, OldFg;

        hdc = BeginPaint(hWnd, &ps);
        GetClientRect(hWnd, &rt);

        oldFont = SelectObject(
            hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
        OldBg = SetBkColor(hdc, mswin_get_color(NHW_STATUS, MSWIN_COLOR_BG));
        OldFg =
            SetTextColor(hdc, mswin_get_color(NHW_STATUS, MSWIN_COLOR_FG));

        DrawText(hdc, NH_A2W(data->window_text, wbuf, MAXWINDOWTEXT),
                 strlen(data->window_text), &rt, DT_LEFT | DT_NOPREFIX);

        SetTextColor(hdc, OldFg);
        SetBkColor(hdc, OldBg);
        SelectObject(hdc, oldFont);
        EndPaint(hWnd, &ps);
    } break;

    case WM_DESTROY:
        free(data);
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) 0);
        break;

    case WM_SETFOCUS:
        SetFocus(GetNHApp()->hMainWnd);
        break;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Ejemplo n.º 10
0
INT_PTR CALLBACK
NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HWND control;
    HDC hdc;
    PNHTextWindow data;
    TCHAR title[MAX_LOADSTRING];

    data = (PNHTextWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
    switch (message) {
    case WM_INITDIALOG:
        /* set text control font */
        control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
        if (!control) {
            panic("cannot get text view window");
        }

        hdc = GetDC(control);
        SendMessage(control, WM_SETFONT,
                    (WPARAM) mswin_get_font(NHW_TEXT, ATR_NONE, hdc, FALSE),
                    0);
        ReleaseDC(control, hdc);

        /* subclass edit control */
        editControlWndProc =
            (WNDPROC) GetWindowLongPtr(control, GWLP_WNDPROC);
        SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR) NHEditHookWndProc);

        SetFocus(control);

        /* Even though the dialog has no caption, you can still set the title
           which shows on Alt-Tab */
        LoadString(GetNHApp()->hApp, IDS_APP_TITLE, title, MAX_LOADSTRING);
        SetWindowText(hWnd, title);
        return FALSE;

    case WM_MSNH_COMMAND:
        onMSNHCommand(hWnd, wParam, lParam);
        break;

    case WM_SIZE: {
        RECT rt;

        GetWindowRect(hWnd, &rt);
        ScreenToClient(GetNHApp()->hMainWnd, (LPPOINT) &rt);
        ScreenToClient(GetNHApp()->hMainWnd, ((LPPOINT) &rt) + 1);
        mswin_update_window_placement(NHW_TEXT, &rt);

        LayoutText(hWnd);
    }
    return FALSE;

    case WM_MOVE: {
        RECT rt;
        GetWindowRect(hWnd, &rt);
        ScreenToClient(GetNHApp()->hMainWnd, (LPPOINT) &rt);
        ScreenToClient(GetNHApp()->hMainWnd, ((LPPOINT) &rt) + 1);
        mswin_update_window_placement(NHW_TEXT, &rt);
    }
    return FALSE;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDOK:
        case IDCANCEL:
            mswin_window_mark_dead(mswin_winid_from_handle(hWnd));
            if (GetNHApp()->hMainWnd == hWnd)
                GetNHApp()->hMainWnd = NULL;
            DestroyWindow(hWnd);
            SetFocus(GetNHApp()->hMainWnd);
            return TRUE;
        }
        break;

    case WM_CTLCOLORSTATIC: { /* sent by edit control before it is drawn */
        HDC hdcEdit = (HDC) wParam;
        HWND hwndEdit = (HWND) lParam;
        if (hwndEdit == GetDlgItem(hWnd, IDC_TEXT_CONTROL)) {
            SetBkColor(hdcEdit, text_bg_brush ? text_bg_color
                       : (COLORREF) GetSysColor(
                           DEFAULT_COLOR_BG_TEXT));
            SetTextColor(hdcEdit, text_fg_brush ? text_fg_color
                         : (COLORREF) GetSysColor(
                             DEFAULT_COLOR_FG_TEXT));
            return (INT_PTR)(text_bg_brush
                             ? text_bg_brush
                             : SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
        }
    }
    return FALSE;

    case WM_DESTROY:
        if (data) {
            if (data->window_text)
                free(data->window_text);
            free(data);
            SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) 0);
        }
        break;
    }
    return FALSE;
}
Ejemplo n.º 11
0
Archivo: mhmenu.c Proyecto: yzh/yzhack
void onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	PNHMenuWindow data;

	data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
	switch( wParam ) {
	case MSNH_MSG_PUTSTR: 
	{
		PMSNHMsgPutstr msg_data = (PMSNHMsgPutstr)lParam;
		HWND   text_view;

		if( data->type!=MENU_TYPE_TEXT )
			SetMenuType(hWnd, MENU_TYPE_TEXT);

		if( !data->text.text ) {
			data->text.text = mswin_init_text_buffer(
						program_state.gameover? FALSE : GetNHApp()->bWrapText
					);
			if( !data->text.text ) break;
		}
		
		mswin_add_text(data->text.text, msg_data->attr, msg_data->text); 
		
		text_view = GetDlgItem(hWnd, IDC_MENU_TEXT);
		if( !text_view ) panic("cannot get text view window");
		mswin_render_text(data->text.text, text_view);
	} break;

	case MSNH_MSG_STARTMENU:
	{
		int i;

		if( data->type!=MENU_TYPE_MENU )
			SetMenuType(hWnd, MENU_TYPE_MENU);

		if( data->menu.items ) free(data->menu.items);
		data->how = PICK_NONE;
		data->menu.items = NULL;
		data->menu.size = 0;
		data->menu.allocated = 0;
		data->done = 0;
		data->result = 0;
		for (i = 0; i < NUMTABS; ++i)
			data->menu.tab_stop_size[i] = MIN_TABSTOP_SIZE;
	} break;

	case MSNH_MSG_ADDMENU:
	{
		PMSNHMsgAddMenu msg_data = (PMSNHMsgAddMenu)lParam;
		char *p, *p1;
		int new_item;
		HDC hDC;
		int column;
		HFONT saveFont;
		
		if( data->type!=MENU_TYPE_MENU ) break;
		if( strlen(msg_data->str)==0 ) break;

		if( data->menu.size==data->menu.allocated ) {
			data->menu.allocated += 10;
			data->menu.items = (PNHMenuItem)realloc(data->menu.items, data->menu.allocated*sizeof(NHMenuItem));
		}

		new_item = data->menu.size;
		ZeroMemory( &data->menu.items[new_item], sizeof(data->menu.items[new_item]));
		data->menu.items[new_item].glyph = msg_data->glyph;
		data->menu.items[new_item].identifier = *msg_data->identifier;
		data->menu.items[new_item].accelerator = msg_data->accelerator;
		data->menu.items[new_item].group_accel = msg_data->group_accel;
		data->menu.items[new_item].attr = msg_data->attr;
		parse_menu_str(data->menu.items[new_item].str, msg_data->str, NHMENU_STR_SIZE);
		data->menu.items[new_item].presel = msg_data->presel;

		/* calculate tabstop size */
		p = strchr(data->menu.items[new_item].str, '\t');
		if( p ) {
			data->menu.items[new_item].has_tab = TRUE;
			hDC = GetDC(hWnd);
			saveFont = SelectObject(hDC, mswin_get_font(NHW_MENU, msg_data->attr, hDC, FALSE));
			p1 = data->menu.items[new_item].str;
			column = 0;
			for (;;) {
				TCHAR wbuf[BUFSZ];
				RECT drawRect;
				SetRect ( &drawRect, 0, 0, 1, 1 );
				if (p != NULL) *p = '\0'; /* for time being, view tab field as zstring */
				DrawText(hDC,
					NH_A2W(p1, wbuf, BUFSZ),
/*JP
					strlen(p1),
*/
					-1,
					&drawRect,
					DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_EXPANDTABS | DT_SINGLELINE
				);
				data->menu.tab_stop_size[column] =
					max( data->menu.tab_stop_size[column], drawRect.right - drawRect.left );
				if (p != NULL) *p = '\t';
				else /* last string so, */ break;

				++column;
				p1 = p + 1;
				p = strchr(p1, '\t');
			}
			SelectObject(hDC, saveFont);
			ReleaseDC(hWnd, hDC);
		} else {
			data->menu.items[new_item].has_tab = FALSE;
		}

		/* increment size */
		data->menu.size++;
	} break;

	case MSNH_MSG_ENDMENU:
	{
		PMSNHMsgEndMenu msg_data = (PMSNHMsgEndMenu)lParam;
		if( msg_data->text ) {
			strncpy( data->menu.prompt, msg_data->text, sizeof(data->menu.prompt)-1 );
		} else {
			ZeroMemory(data->menu.prompt, sizeof(data->menu.prompt));
		}
	} break;

	} /* end switch */
}
Ejemplo n.º 12
0
Archivo: mhmenu.c Proyecto: yzh/yzhack
LRESULT CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PNHMenuWindow data;
	
	CheckInputDialog(hWnd, message, wParam, lParam);	

	data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
	switch (message) 
	{
	case WM_INITDIALOG: {
		HWND text_control;
		HDC hDC;

		text_control = GetDlgItem(hWnd, IDC_MENU_TEXT);

		data = (PNHMenuWindow)malloc(sizeof(NHMenuWindow));
		ZeroMemory(data, sizeof(NHMenuWindow));
		data->type = MENU_TYPE_TEXT;
		data->how = PICK_NONE;
		data->result = 0;
		data->done = 0;
		data->bmpChecked = LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_MENU_SEL));
		data->bmpCheckedCount = LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_MENU_SEL_COUNT));
		data->bmpNotChecked = LoadBitmap(GetNHApp()->hApp, MAKEINTRESOURCE(IDB_MENU_UNSEL));
		SetWindowLong(hWnd, GWL_USERDATA, (LONG)data);

		/* subclass edit control */
		editControlWndProc = (WNDPROC)GetWindowLong(text_control, GWL_WNDPROC);
		SetWindowLong(text_control, GWL_WNDPROC, (LONG)NHMenuTextWndProc);

		/* set text window font */
		hDC = GetDC(text_control);
		SendMessage(
			text_control, 
			WM_SETFONT, 
			(WPARAM)mswin_get_font(NHW_TEXT, ATR_NONE, hDC, FALSE),
			(LPARAM)0
		);
		ReleaseDC(text_control, hDC);

#if defined(WIN_CE_SMARTPHONE)
		/* special initialization for SmartPhone dialogs */ 
		NHSPhoneDialogSetup(hWnd, FALSE, GetNHApp()->bFullScreen);
#endif
	} break;

	case WM_MSNH_COMMAND:
		onMSNHCommand(hWnd, wParam, lParam);
	break;

	case WM_SIZE:
		LayoutMenu(hWnd);
	return FALSE;

	case WM_COMMAND: 
	{
		switch (LOWORD(wParam)) 
        { 
		case IDCANCEL:
			if( data->type == MENU_TYPE_MENU && 
			    (data->how==PICK_ONE || data->how==PICK_ANY) &&
			    data->menu.counting) {
				HWND list;
				int i;

				/* reset counter if counting is in progress */
				list = GetMenuControl(hWnd);
				i = ListView_GetNextItem(list, -1,	LVNI_FOCUSED);
				if( i>=0 ) {
					SelectMenuItem(list, data, i,  0);
				}
				return FALSE;
			} else {
				data->result = -1;
				data->done = 1;
			}
		return FALSE;

		case IDOK:
			data->done = 1;
			data->result = 0;
		return FALSE;
		}
	} break;

	case WM_NOTIFY:
	{
		LPNMHDR	lpnmhdr = (LPNMHDR)lParam;
		switch (LOWORD(wParam)) {
		case IDC_MENU_LIST:
		{
			if( !data || data->type!=MENU_TYPE_MENU ) break;

			switch(lpnmhdr->code) {
			case LVN_ITEMACTIVATE: 
			{
				LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lParam;
				if(data->how==PICK_ONE) {
					if( lpnmlv->iItem>=0 &&
						lpnmlv->iItem<data->menu.size &&
						NHMENU_IS_SELECTABLE(data->menu.items[lpnmlv->iItem]) ) {
						SelectMenuItem(
							lpnmlv->hdr.hwndFrom, 
							data, 
							lpnmlv->iItem, 
							-1
						);
						data->done = 1;
						data->result = 0;
						return TRUE;
					}
				} else if( data->how==PICK_ANY ) {
					if( lpnmlv->iItem>=0 &&
						lpnmlv->iItem<data->menu.size &&
						NHMENU_IS_SELECTABLE(data->menu.items[lpnmlv->iItem]) ) {
						SelectMenuItem(
							lpnmlv->hdr.hwndFrom, 
							data, 
							lpnmlv->iItem, 
							NHMENU_IS_SELECTED(data->menu.items[lpnmlv->iItem])? 0 : -1
						);
					}
				}
			} break;

			case NM_CLICK: {
				LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW) lParam;
				if( lpnmlv->iItem==-1 ) return 0;
				if( data->how==PICK_ANY ) {
					SelectMenuItem(
						lpnmlv->hdr.hwndFrom, 
						data, 
						lpnmlv->iItem, 
						NHMENU_IS_SELECTED(data->menu.items[lpnmlv->iItem])? 0 : -1
					);
				}
			} break;

			case LVN_ITEMCHANGED: 
			{
				LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)lParam;
				if( lpnmlv->iItem==-1 ) return 0;
				if( !(lpnmlv->uChanged & LVIF_STATE) ) return 0;

				/* update item that has the focus */
				data->menu.items[lpnmlv->iItem].has_focus = !!(lpnmlv->uNewState & LVIS_FOCUSED);
				ListView_RedrawItems(lpnmlv->hdr.hwndFrom, lpnmlv->iItem, lpnmlv->iItem);

				/* update count for single-selection menu (follow the listview selection) */
				if( data->how==PICK_ONE ) {
					if( lpnmlv->uNewState & LVIS_SELECTED ) {
						SelectMenuItem(
							lpnmlv->hdr.hwndFrom, 
							data, 
							lpnmlv->iItem, 
							-1
						);
					}
				}

				/* check item focus */
				data->menu.items[lpnmlv->iItem].has_focus = !!(lpnmlv->uNewState & LVIS_FOCUSED);
				ListView_RedrawItems(lpnmlv->hdr.hwndFrom, lpnmlv->iItem, lpnmlv->iItem);
			} break;

			case NM_KILLFOCUS:
				reset_menu_count(lpnmhdr->hwndFrom, data);
			break;

			}
		} break;
		}
	} break;

	case WM_SETFOCUS:
		if( hWnd!=GetNHApp()->hPopupWnd ) {
			SetFocus(GetNHApp()->hPopupWnd );
			return 0;
		}
	break;
	
    case WM_MEASUREITEM: 
		if( wParam==IDC_MENU_LIST )
			return onMeasureItem(hWnd, wParam, lParam);
		else
			return FALSE;

    case WM_DRAWITEM:
		if( wParam==IDC_MENU_LIST )
			return onDrawItem(hWnd, wParam, lParam);
		else
			return FALSE;

	case WM_CTLCOLORBTN:
	case WM_CTLCOLOREDIT:
	case WM_CTLCOLORSTATIC: { /* sent by edit control before it is drawn */
		HDC hdcEdit = (HDC) wParam; 
		HWND hwndEdit = (HWND) lParam;
		if( hwndEdit == GetDlgItem(hWnd, IDC_MENU_TEXT) ) {
			SetBkColor(hdcEdit, mswin_get_color(NHW_TEXT, MSWIN_COLOR_BG));
			SetTextColor(hdcEdit, mswin_get_color(NHW_TEXT, MSWIN_COLOR_FG)); 
			return (BOOL)mswin_get_brush(NHW_TEXT, MSWIN_COLOR_BG);
		}
	} return FALSE;

	case WM_DESTROY:
		if( data ) {
			DeleteObject(data->bmpChecked);
			DeleteObject(data->bmpCheckedCount);
			DeleteObject(data->bmpNotChecked);
			if( data->type == MENU_TYPE_TEXT ) {
				if( data->text.text ) {
					mswin_free_text_buffer(data->text.text);
					data->text.text = NULL;
				}
			}
			free(data);
			SetWindowLong(hWnd, GWL_USERDATA, (LONG)0);
		}
		return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 13
0
Archivo: mhmenu.c Proyecto: yzh/yzhack
void mswin_menu_window_size (HWND hWnd, LPSIZE sz)
{
    TEXTMETRIC tm;
	HWND control;
	HGDIOBJ saveFont;
	HDC hdc;
	PNHMenuWindow data;
	int i;
	RECT rt, wrt;
	int extra_cx;

	GetClientRect(hWnd, &rt);
	sz->cx = rt.right - rt.left;
	sz->cy = rt.bottom - rt.top;

	GetWindowRect(hWnd, &wrt);
	extra_cx = (wrt.right-wrt.left) - sz->cx;

	data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);
	if(data) {
		control = GetMenuControl(hWnd);
		hdc = GetDC(control);

		if( data->type==MENU_TYPE_MENU ) {
			/* Calculate the width of the list box. */
			saveFont = SelectObject(hdc, mswin_get_font(NHW_MENU, ATR_NONE, hdc, FALSE));
			GetTextMetrics(hdc, &tm);
			for(i=0; i<data->menu.size; i++ ) {
				LONG menuitemwidth = 0;
				int column;
				char *p, *p1;

				p1 = data->menu.items[i].str;
				p = strchr(data->menu.items[i].str, '\t');
				column = 0;
				for (;;) {
					TCHAR wbuf[BUFSZ];
					RECT tabRect;
					SetRect ( &tabRect, 0, 0, 1, 1 );
					if (p != NULL) *p = '\0'; /* for time being, view tab field as zstring */
					DrawText(hdc,
						NH_A2W(p1, wbuf, BUFSZ),
/*JP
						strlen(p1),
*/
						-1,
						&tabRect,
						DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE
					);
					/* it probably isn't necessary to recompute the tab width now, but do so
					 * just in case, honoring the previously computed value
					 */
					menuitemwidth += max(data->menu.tab_stop_size[column],
					    tabRect.right - tabRect.left);
					if (p != NULL) *p = '\t';
					else /* last string so, */ break;
					/* add the separation only when not the last item */
					/* in the last item, we break out of the loop, in the statement just above */
					menuitemwidth += TAB_SEPARATION;
					++column;
					p1 = p + 1;
					p = strchr(p1, '\t');
				}

				sz->cx = max(sz->cx, 
					(LONG)(2*TILE_X + menuitemwidth + tm.tmAveCharWidth*12 + tm.tmOverhang));
			}
			SelectObject(hdc, saveFont);
		} else {
			/* do not change size for text output - the text will be formatted to
			   fit any window */
		}
		sz->cx += extra_cx;

		ReleaseDC(control, hdc);
	}
}
Ejemplo n.º 14
0
void
mswin_display_RIP_window(HWND hWnd)
{
    MSG msg;
    RECT rt;
    PNHRIPWindow data;
    HWND mapWnd;
    RECT riprt;
    RECT clientrect;
    RECT textrect;
    HFONT OldFont;
    MonitorInfo monitorInfo;

    win10_monitor_info(hWnd, &monitorInfo);

    data = (PNHRIPWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);

    data->x = (int)(RIP_OFFSET_X * monitorInfo.scale);
    data->y = (int)(RIP_OFFSET_Y * monitorInfo.scale);
    data->width = (int)(RIP_WIDTH * monitorInfo.scale);
    data->height = (int)(RIP_HEIGHT * monitorInfo.scale);
    data->graveX = (int)(RIP_GRAVE_X * monitorInfo.scale);
    data->graveY = (int)(RIP_GRAVE_Y * monitorInfo.scale);
    data->graveWidth = (int)(RIP_GRAVE_WIDTH * monitorInfo.scale);
    data->graveHeight = (int)(RIP_GRAVE_HEIGHT * monitorInfo.scale);

    GetNHApp()->hPopupWnd = hWnd;
    mapWnd = mswin_hwnd_from_winid(WIN_MAP);
    if (!IsWindow(mapWnd))
        mapWnd = GetNHApp()->hMainWnd;
    GetWindowRect(mapWnd, &rt);
    GetWindowRect(hWnd, &riprt);
    GetClientRect(hWnd, &clientrect);
    textrect = clientrect;
    textrect.top += data->y;
    textrect.left += data->x;
    textrect.right -= data->x;
    if (data->window_text) {
        HDC hdc = GetDC(hWnd);
        OldFont = SelectObject(hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE)->hFont);
        DrawText(hdc, data->window_text, strlen(data->window_text), &textrect,
                 DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
        SelectObject(hdc, OldFont);
        ReleaseDC(hWnd, hdc);
    }
    if (textrect.right - textrect.left > data->width)
        clientrect.right = textrect.right + data->y - clientrect.right;
    else
        clientrect.right =
            textrect.left + 2 * data->x + data->width - clientrect.right;
    clientrect.bottom =
        textrect.bottom + data->height + data->y - clientrect.bottom;
    GetWindowRect(GetDlgItem(hWnd, IDOK), &textrect);
    textrect.right -= textrect.left;
    textrect.bottom -= textrect.top;
    clientrect.bottom += textrect.bottom + data->y;
    riprt.right -= riprt.left;
    riprt.bottom -= riprt.top;
    riprt.right += clientrect.right;
    riprt.bottom += clientrect.bottom;
    rt.left += (rt.right - rt.left - riprt.right) / 2;
    rt.top += (rt.bottom - rt.top - riprt.bottom) / 2;

    MoveWindow(hWnd, rt.left, rt.top, riprt.right, riprt.bottom, TRUE);
    GetClientRect(hWnd, &clientrect);
    MoveWindow(GetDlgItem(hWnd, IDOK),
               (clientrect.right - clientrect.left - textrect.right) / 2,
               clientrect.bottom - textrect.bottom - data->y,
               textrect.right, textrect.bottom, TRUE);
    ShowWindow(hWnd, SW_SHOW);

    while (IsWindow(hWnd) && GetMessage(&msg, NULL, 0, 0) != 0) {
        if (!IsDialogMessage(hWnd, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    GetNHApp()->hPopupWnd = NULL;
}
Ejemplo n.º 15
-1
Archivo: mhmenu.c Proyecto: yzh/yzhack
LRESULT onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
    LPDRAWITEMSTRUCT lpdis; 
	PNHMenuItem item;
	PNHMenuWindow data;
    TEXTMETRIC tm;
	HGDIOBJ saveFont;
	HDC tileDC;
	short ntile;
	int t_x, t_y;
	int x, y;
	TCHAR wbuf[BUFSZ];
	RECT drawRect;
	COLORREF OldBg, OldFg, NewBg;
	char *p, *p1;
	int column;

	lpdis = (LPDRAWITEMSTRUCT) lParam; 

    /* If there are no list box items, skip this message. */
    if (lpdis->itemID == -1) return FALSE;

	data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);

    item = &data->menu.items[lpdis->itemID];

	tileDC = CreateCompatibleDC(lpdis->hDC);
	saveFont = SelectObject(lpdis->hDC, mswin_get_font(NHW_MENU, item->attr, lpdis->hDC, FALSE));
	NewBg = mswin_get_color(NHW_MENU, MSWIN_COLOR_BG);
	OldBg = SetBkColor(lpdis->hDC, NewBg);
	OldFg = SetTextColor(lpdis->hDC, mswin_get_color(NHW_MENU, MSWIN_COLOR_FG)); 

    GetTextMetrics(lpdis->hDC, &tm);

	x = lpdis->rcItem.left + 1;

	/* print check mark if it is a "selectable" menu */
	if( data->how!=PICK_NONE ) {
		if( NHMENU_IS_SELECTABLE(*item) ) {
			HGDIOBJ saveBrush;
			HBRUSH	hbrCheckMark;
			char buf[2];

			switch(item->count) {
			case -1: hbrCheckMark = CreatePatternBrush(data->bmpChecked); break;
			case 0: hbrCheckMark = CreatePatternBrush(data->bmpNotChecked); break;
			default: hbrCheckMark = CreatePatternBrush(data->bmpCheckedCount); break;
			}

			y = (lpdis->rcItem.bottom + lpdis->rcItem.top - TILE_Y) / 2; 
			SetBrushOrgEx(lpdis->hDC, x, y, NULL);
			saveBrush = SelectObject(lpdis->hDC, hbrCheckMark);
			PatBlt(lpdis->hDC, x, y, TILE_X, TILE_Y, PATCOPY);
			SelectObject(lpdis->hDC, saveBrush);
			DeleteObject(hbrCheckMark);

			x += TILE_X + 5;

			if(item->accelerator!=0) {
				buf[0] = item->accelerator;
				buf[1] = '\x0';

				SetRect( &drawRect, x, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom );
/*JP
				DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
*/
				DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), -1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
			}
			x += tm.tmAveCharWidth + tm.tmOverhang + 5;
		} else {
			x += TILE_X + tm.tmAveCharWidth + tm.tmOverhang + 10;
		}
	}

	/* print glyph if present */
	if( item->glyph != NO_GLYPH ) {
		HGDIOBJ saveBmp;

		saveBmp = SelectObject(tileDC, GetNHApp()->bmpTiles);				
		ntile = glyph2tile[ item->glyph ];
		t_x = (ntile % TILES_PER_LINE)*TILE_X;
		t_y = (ntile / TILES_PER_LINE)*TILE_Y;

		y = (lpdis->rcItem.bottom + lpdis->rcItem.top - TILE_Y) / 2; 

		nhapply_image_transparent(
			lpdis->hDC, x, y, TILE_X, TILE_Y, 
			tileDC, t_x, t_y, TILE_X, TILE_Y, TILE_BK_COLOR );
		SelectObject(tileDC, saveBmp);
	}

	x += TILE_X + 5;

	/* draw item text */
	if( item->has_tab ) {
		p1 = item->str;
		p = strchr(item->str, '\t');
		column = 0;
		SetRect( &drawRect, x, lpdis->rcItem.top, min(x + data->menu.tab_stop_size[0], lpdis->rcItem.right),
			lpdis->rcItem.bottom );
		for (;;) {
			TCHAR wbuf[BUFSZ];
			if (p != NULL) *p = '\0'; /* for time being, view tab field as zstring */
			DrawText(lpdis->hDC,
				NH_A2W(p1, wbuf, BUFSZ),
/*JP
				strlen(p1),
*/
				-1,
				&drawRect,
				DT_LEFT | DT_VCENTER | DT_SINGLELINE
			);
			if (p != NULL) *p = '\t';
			else /* last string so, */ break;

			p1 = p + 1;
			p = strchr(p1, '\t');
			drawRect.left = drawRect.right + TAB_SEPARATION;
			++column;
			drawRect.right = min (drawRect.left + data->menu.tab_stop_size[column], lpdis->rcItem.right);
		}
	} else {
		TCHAR wbuf[BUFSZ];
		SetRect( &drawRect, x, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom);
		DrawText(lpdis->hDC,
			NH_A2W(item->str, wbuf, BUFSZ),
/*JP
			strlen(item->str),
*/
			-1,
			&drawRect,
			DT_LEFT | DT_VCENTER | DT_SINGLELINE
		);
	}

	/* draw focused item */
	if( item->has_focus ) {
		RECT client_rt;
		HBRUSH bkBrush;

		GetClientRect(lpdis->hwndItem, &client_rt);
		if( NHMENU_IS_SELECTABLE(*item) && 
			data->menu.items[lpdis->itemID].count>0 &&
			item->glyph != NO_GLYPH ) {
			if( data->menu.items[lpdis->itemID].count==-1 ) {
				_stprintf(wbuf, TEXT("Count: All") );
			} else {
				_stprintf(wbuf, TEXT("Count: %d"), data->menu.items[lpdis->itemID].count );
			}

			SelectObject(lpdis->hDC, mswin_get_font(NHW_MENU, ATR_BLINK, lpdis->hDC, FALSE));

			/* calculate text rectangle */
			SetRect( &drawRect, client_rt.left, lpdis->rcItem.top, client_rt.right, lpdis->rcItem.bottom );
/*JP
			DrawText(lpdis->hDC, wbuf, _tcslen(wbuf), &drawRect, 
*/
			DrawText(lpdis->hDC, wbuf, -1, &drawRect, 
					 DT_CALCRECT | DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX );
			
			/* erase text rectangle */
			drawRect.left = max(client_rt.left+1, client_rt.right - (drawRect.right - drawRect.left) - 10);
			drawRect.right = client_rt.right-1;
			drawRect.top = lpdis->rcItem.top;
			drawRect.bottom = lpdis->rcItem.bottom;
			bkBrush = CreateSolidBrush( GetBkColor(lpdis->hDC) );
			FillRect(lpdis->hDC, &drawRect, bkBrush );
			DeleteObject( bkBrush );

			/* draw text */
/*JP
			DrawText(lpdis->hDC, wbuf, _tcslen(wbuf), &drawRect, 
*/
			DrawText(lpdis->hDC, wbuf, -1, &drawRect, 
					 DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX );
		}

		/* draw focus rect */
		SetRect( &drawRect, client_rt.left, lpdis->rcItem.top, client_rt.right, lpdis->rcItem.bottom );
		DrawFocusRect(lpdis->hDC, &drawRect);
	}

	SetTextColor (lpdis->hDC, OldFg);
	SetBkColor (lpdis->hDC, OldBg);
	SelectObject(lpdis->hDC, saveFont);
	DeleteDC(tileDC);
	return TRUE;
}