示例#1
0
/*
 * setEditText - set the specified edit window's text
 */
static void setEditText( HWND hwnd, char *tmp )
{
    int     len;

    if( tmp == NULL ) {
        return;
    }
    len = strlen( tmp );
    SetWindowText( hwnd, tmp );
    SendMessage( hwnd, EM_SETSEL, GET_EM_SETSEL_MPS( len, len ) );

} /* setEditText */
示例#2
0
Bool WInsertStringEntry( WStringEditInfo *einfo )
{
    HWND                lbox;
    Bool                ok;
    Bool                replace;
    WStringBlock        *block;
    uint_16             id;
    char                *text;
    char                *symbol;
    int                 pos;

    text = NULL;
    symbol = NULL;
    replace = FALSE;

    ok = (einfo != NULL && einfo->tbl != NULL && einfo->edit_dlg != NULL);

    if( ok ) {
        lbox = GetDlgItem ( einfo->edit_dlg, IDM_STREDLIST );
        ok = (lbox != NULL);
    }

    if( ok ) {
        ok = WGetEditWindowText( einfo->edit_dlg, &text );
    }

    if( ok ) {
        ok = WGetEditWindowID( einfo->edit_dlg, &symbol, &id,
                               einfo->info->symbol_table, einfo->combo_change );
    }

    if( ok ) {
        if( id == 0 ) {
            id = DEFAULT_STRING_ID;
        }
        block = WInsertStringData( einfo, id, text, symbol, &replace );
        ok = (block != NULL);
    }

    if( ok ) {
        pos = WFindStringPos( einfo->tbl, id );
        ok = (pos != -1);
    }

    if( ok ) {
        if( replace ) {
            SendMessage( lbox, LB_DELETESTRING, pos, 0 );
        }
        ok = WAddEditWinLBoxEntry( einfo, block, id, pos );
    }


    if( ok ) {
        WSetEditWindowID( einfo->edit_dlg, id, block->symbol[id & 0xf] );
        ok = (SendMessage( lbox, LB_SETCURSEL, pos, 0 ) != LB_ERR);
        if( ok ) {
            einfo->current_block = block;
            einfo->current_string = id;
            einfo->current_pos = pos;
#if 0
            einfo->current_block = NULL;
            einfo->current_string = 0;
            einfo->current_pos = -1;
            WHandleSelChange( einfo );
#endif
        }
    }

    if( ok ) {
        SetFocus( GetDlgItem( einfo->edit_dlg, IDM_STREDTEXT ) );
        SendDlgItemMessage( einfo->edit_dlg, IDM_STREDTEXT, EM_SETSEL,
                            GET_EM_SETSEL_MPS( 0, -1 ) );
    }

    if( symbol != NULL ) {
        WMemFree( symbol );
    }

    if( text != NULL ) {
        WMemFree( text );
    }

    return( ok );
}