示例#1
0
void WDoHandleSelChange( WAccelEditInfo *einfo, bool change, bool reset )
{
    HWND        lbox;
    box_pos     pos;
    WAccelEntry *entry;
    bool        mod;

    if( einfo == NULL ) {
        return;
    }

    lbox = GetDlgItem( einfo->edit_dlg, IDM_ACCEDLIST );
    if( lbox == (HWND)NULL ) {
        return;
    }

    pos = (box_pos)SendMessage( lbox, LB_GETCURSEL, 0, 0 );
    if( pos != LB_ERR ) {
        entry = (WAccelEntry *)SendMessage( lbox, LB_GETITEMDATA, pos, 0 );
    } else {
        entry = NULL;
    }

    if( einfo->current_entry != NULL && !reset ) {
        mod = WGetEditWindowKeyEntry( einfo, einfo->current_entry, TRUE );
        if( mod && einfo->current_pos != -1 ) {
            if( change || WQueryChangeEntry( einfo ) ) {
                WGetEditWindowKeyEntry( einfo, einfo->current_entry, FALSE );
                einfo->info->modified = true;
                SendMessage( lbox, LB_DELETESTRING, einfo->current_pos, 0 );
                WAddEditWinLBoxEntry( einfo, einfo->current_entry, einfo->current_pos );
            }
        }
    }

    if( entry != NULL ) {
        if( change ) {
            uint_16 id;
            if( entry->is32bit ) {
                id = entry->u.entry32.Id;
            } else {
                id = (uint_16)entry->u.entry.Id;
            }
            WSetEditWindowID( einfo->edit_dlg, entry->symbol, id );
        } else {
            WSetEditWindowKeyEntry( einfo, entry );
        }
    }

    einfo->current_entry = entry;
    einfo->current_pos = (pos == LB_ERR) ? -1 : pos;
    if ( pos != LB_ERR ) {
        SendMessage ( lbox, LB_SETCURSEL, pos, 0 );
    }
}
示例#2
0
void WDoHandleSelChange( WMenuEditInfo *einfo, Bool change, Bool reset )
{
    HWND        lbox;
    LRESULT     index;
    WMenuEntry  *entry;
    Bool        reinit;
    Bool        mod;

    if( einfo == NULL ) {
        return;
    }

    reinit = FALSE;

    lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
    if( lbox == (HWND)NULL ) {
        return;
    }

    index = SendMessage( lbox, LB_GETCURSEL, 0, 0 );
    if( index != LB_ERR ) {
        entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)index, 0 );
    } else {
        entry = NULL;
    }

    if( einfo->current_entry != NULL && !reset ) {
        mod = WGetEditWindowMenuEntry( einfo, einfo->current_entry, TRUE, NULL );
        if( mod && einfo->current_pos != -1 ) {
            if( change || WQueryChangeEntry( einfo ) ) {
                WGetEditWindowMenuEntry( einfo, einfo->current_entry, FALSE, &reinit );
                einfo->info->modified = TRUE;
                if( reinit ) {
                    WInitEditWindowListBox( einfo );
                } else {
                    SendMessage( lbox, LB_DELETESTRING, einfo->current_pos, 0 );
                    WAddEditWinLBoxEntry( lbox, einfo->current_entry, einfo->current_pos );
                    WModifyEntryInPreview( einfo, einfo->current_entry );
                }
            }
        }
    }

    WSetEditWindowControls( einfo, entry );
    if( entry != NULL ) {
        if( !change || reinit ) {
            WSetEditWindowMenuEntry( einfo, entry );
        } else {
            uint_16     id;
            Bool        pop_sep;
            MenuFlags   flags;
            if( entry->item->IsPopup ) {
                flags = entry->item->Item.Popup.ItemFlags;
            } else {
                flags = entry->item->Item.Normal.ItemFlags;
                id = entry->item->Item.Normal.ItemID;
            }
            pop_sep = (entry->item->IsPopup || (flags & MENU_SEPARATOR));
            WSetEditWindowID( einfo->edit_dlg, id, pop_sep, entry->symbol );
        }
    }

    einfo->current_entry = entry;
    einfo->current_pos = (index == LB_ERR ? -1 : index);
    if( index != LB_ERR ) {
        SendMessage( lbox, LB_SETCURSEL, (WPARAM)index, 0 );
    }
}