Пример #1
0
void
mswin_display_text_window(HWND hWnd)
{
    PNHTextWindow data;

    data = (PNHTextWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
    if (data && data->window_text) {
        HWND control;
        control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
        SendMessage(control, EM_FMTLINES, 1, 0);
        SetWindowText(control, data->window_text);
    }

    mswin_popup_display(hWnd, NULL);
    mswin_popup_destroy(hWnd);
}
Пример #2
0
void mswin_display_text_window (HWND hWnd)
{
    PNHTextWindow data;

    data = (PNHTextWindow)GetWindowLong(hWnd, GWL_USERDATA);
    if( data ) {
        HWND control;
        control = GetDlgItem(hWnd, IDC_TEXT_CONTROL);
        SendMessage(control, EM_FMTLINES, 1, 0 );
        mswin_render_text(data->window_text, GetDlgItem(hWnd, IDC_TEXT_CONTROL));

        data->done = 0;
        mswin_popup_display(hWnd, &data->done);
        mswin_popup_destroy(hWnd);
    }
}
Пример #3
0
int mswin_menu_window_select_menu (HWND hWnd, int how, MENU_ITEM_P ** _selected)
{
	PNHMenuWindow data;
	int ret_val;
    MENU_ITEM_P *selected = NULL;
	int i;
	char* ap;
	char accell_str[256];

	assert( _selected!=NULL );
	*_selected = NULL;
	ret_val = -1;

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

	/* set menu type */
	SetMenuListType(hWnd, how);

	/* Ok, now give items a unique accelerators */
	ZeroMemory(accell_str, sizeof(accell_str));
	ap = accell_str;

#if defined(WIN_CE_SMARTPHONE)
	if( data->menu.size>10 ) {
		*ap++ = MENU_FIRST_PAGE;
		*ap++ = MENU_LAST_PAGE;
		*ap++ = MENU_NEXT_PAGE;
		*ap++ = MENU_PREVIOUS_PAGE;
		if( data->how == PICK_ANY ) {
			*ap++ = MENU_SELECT_ALL;
			*ap++ = MENU_UNSELECT_ALL;
			*ap++ = MENU_INVERT_ALL;
			*ap++ = MENU_SELECT_PAGE;
			*ap++ = MENU_UNSELECT_PAGE;
			*ap++ = MENU_INVERT_PAGE;
		}
		*ap++ = MENU_SEARCH;
	}
#endif

	if( data->type == MENU_TYPE_MENU ) {
		char next_char = 'a';

		for( i=0; i<data->menu.size;  i++) {
			if( data->menu.items[i].accelerator!=0 ) {
				*ap++ = data->menu.items[i].accelerator;
				next_char = (char)(data->menu.items[i].accelerator+1);
			} else if( NHMENU_IS_SELECTABLE(data->menu.items[i]) ) {
				if ( (next_char>='a' && next_char<='z') ||
					 (next_char>='A' && next_char<='Z') )  {
					 data->menu.items[i].accelerator = next_char;
					 *ap++ = data->menu.items[i].accelerator;
				} else {
					if( next_char > 'z' ) next_char = 'A';
					else if ( next_char > 'Z' ) break;

					data->menu.items[i].accelerator = next_char;
					*ap++ = data->menu.items[i].accelerator;
				}

				next_char ++;
			}
		}

		/* collect group accelerators */
		data->menu.gacc[0] = '\0';
		ap = data->menu.gacc;
		if( data->how != PICK_NONE ) {
			for( i=0; i<data->menu.size;  i++) {
				if( data->menu.items[i].group_accel && 
					!strchr(data->menu.gacc, data->menu.items[i].group_accel) ) {
					*ap++ = data->menu.items[i].group_accel;
					*ap = '\x0';
				}
			}
		}

		reset_menu_count(NULL, data);
	}

#if defined(WIN_CE_SMARTPHONE)
	if( data->type==MENU_TYPE_MENU ) NHSPhoneSetKeypadFromString( accell_str );
#endif

	mswin_popup_display(hWnd, &data->done);

	/* get the result */
	if( data->result != -1 ) {
		if(how==PICK_NONE) {
			if(data->result>=0) ret_val=0;
			else				ret_val=-1;
		} else if(how==PICK_ONE || how==PICK_ANY) {
			/* count selected items */
			ret_val = 0;
			for(i=0; i<data->menu.size; i++ ) {
				if( NHMENU_IS_SELECTABLE(data->menu.items[i]) &&
					NHMENU_IS_SELECTED(data->menu.items[i]) ) {
					ret_val++;
				}
			}
			if( ret_val > 0 ) {
				int sel_ind;

				selected = (MENU_ITEM_P*)malloc(ret_val*sizeof(MENU_ITEM_P));
				if( !selected ) panic("out of memory");

				sel_ind = 0;
				for(i=0; i<data->menu.size; i++ ) {
					if( NHMENU_IS_SELECTABLE(data->menu.items[i]) &&
						NHMENU_IS_SELECTED(data->menu.items[i]) ) {
						selected[sel_ind].item = data->menu.items[i].identifier;
						selected[sel_ind].count = data->menu.items[i].count;
						sel_ind++;
					}
				}
				ret_val = sel_ind;
				*_selected = selected;
			}
		}
	}

	mswin_popup_destroy(hWnd);

#if defined(WIN_CE_SMARTPHONE)
	if( data->type==MENU_TYPE_MENU ) NHSPhoneSetKeypadDefault();
#endif

	return ret_val;
}