Exemple #1
0
BOOL WdeFreeCustLib ( WdeCustLib *lib )
{
    if (lib != NULL) {
        if  ( lib->controls != NULL ) {
            WdeFreeCustLibControls ( &(lib->controls) );
        }
        if ( lib->file_name != NULL ) {
            WdeMemFree ( lib->file_name );
        }
        if ( lib->info_name && HIWORD((uint_32)lib->info_name) ) {
            WdeMemFree ( lib->info_name );
        }
        if ( lib->style_name && HIWORD((uint_32)lib->style_name) ) {
            WdeMemFree ( lib->style_name );
        }
        if ( lib->flags_name && HIWORD((uint_32)lib->flags_name) ) {
            WdeMemFree ( lib->flags_name );
        }
        if  ( lib->inst != NULL ) {
            FreeLibrary ( lib->inst );
        }
        if  ( !lib->ms_lib && (lib->class_list != NULL) ) {
            GlobalFree ( lib->class_list );
        }
        WdeMemFree ( lib );
    } else {
        WdeWriteTrail("WdeFreeCustLib: NULL lib!");
        return ( FALSE );
    }

    return ( TRUE );
}
Exemple #2
0
void WdeFiniHints( void )
{
    LIST             *plist;
    WdePopupListItem *p;

    for ( plist = WdePopupList; plist != NULL; plist = ListConsume ( plist ) ) {
        p = (WdePopupListItem *)ListElement( plist );
        WdeMemFree( p );
    }
}
Exemple #3
0
BOOL WdeFreeCustLib( WdeCustLib *lib )
{
    if( lib != NULL ) {
        if( lib->file_name != NULL ) {
            WdeMemFree( lib->file_name );
        }
        if( lib->inst != NULL ) {
            FreeLibrary( lib->inst );
        }
        if( lib->lpcci != NULL ) {
            WdeMemFree( lib->lpcci );
        }
        WdeMemFree( lib );
    } else {
        WdeWriteTrail( "WdeFreeCustLib: NULL lib!" );
        return( FALSE );
    }

    return( TRUE );
}
Exemple #4
0
Bool WdeSetEXFlagText( uint_32 flags, char **text )
{
    uint_32 mask;

    if( text == NULL ) {
        return( FALSE );
    }

    *text = NULL;
    mask = WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE;
    if( (flags & mask) == mask ) {
        WdeAddStyleString( text, "WS_EX_OVERLAPPEDWINDOW" );
    } else {
        if( flags & WS_EX_CLIENTEDGE ) {
            WdeAddStyleString( text, "WS_EX_CLIENTEDGE" );
        }
        // WINDOWEDGE will be caught below
    }

    mask = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
    if( (flags & mask) == mask ) {
        WdeAddStyleString( text, "WS_EX_PALETTEWINDOW" );
    } else {
        if( flags & WS_EX_WINDOWEDGE ) {
            WdeAddStyleString( text, "WS_EX_WINDOWEDGE" );
        }
        if( flags & WS_EX_TOOLWINDOW ) {
            WdeAddStyleString( text, "WS_EX_TOOLWINDOW" );
        }
        if( flags & WS_EX_TOPMOST ) {
            WdeAddStyleString( text, "WS_EX_TOPMOST" );
        }
    }

    if( flags & WS_EX_TRANSPARENT ) {
        WdeAddStyleString( text, "WS_EX_TRANSPARENT" );
    }

    if( WdeSetFlagText( WindowEXMap, WindowStyle, flags, text ) ) {
        return( TRUE );
    }

    if( *text != NULL ) {
        WdeMemFree( *text );
        *text = NULL;
    }

    return( FALSE );
}
Exemple #5
0
Bool WdeSetWindowFlagText( unsigned long flags, char **text )
{
    if( text == NULL ) {
        return( FALSE );
    }

    *text = NULL;
    if( WdeSetFlagText( WindowMap, WindowStyle, flags, text ) ) {
        return( TRUE );
    }

    if( *text != NULL ) {
        WdeMemFree( *text );
        *text = NULL;
    }

    return( FALSE );
}
Exemple #6
0
static Bool WdeSetDefaultTestControlEntries( HWND win )
{
    int         index;
    char        *text;
    char        *str;
    char        cname[20];
    int         len;
    uint_8      class;

    len = GetClassName( win, cname, 19 );
    if( len == 0 ) {
        return( TRUE );
    }

    class = WdeGetClassFromClassName( cname );

    if( class == CLASS_LISTBOX || class == CLASS_COMBOBOX ) {
        str = NULL;
        text = WdeAllocRCString( WDE_TESTITEM );
        if( text != NULL ) {
            str = (char *)WdeMemAlloc( strlen( text ) + 10 + 1 );
            if( str == NULL ) {
                WdeFreeRCString( text );
                return( TRUE );
            }
        } else {
            return( TRUE );
        }
        SendMessage( win, WM_SETREDRAW, FALSE, 0 );
        for( index = 1; index <= TEST_DEFAULT_ENTRIES; index++ ) {
            sprintf( str, text, index );
            if( class == CLASS_LISTBOX ) {
                SendMessage( win, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)str );
            } else {
                SendMessage( win, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)str );
            }
        }
        SendMessage( win, WM_SETREDRAW, TRUE, 0 );
        InvalidateRect( win, NULL, TRUE );
        WdeMemFree( str );
        WdeFreeRCString( text );
    }
Exemple #7
0
Bool WdeCreateWdePopupListItem( int num, HMENU menu, WdePopupHintItem *hint_items )
{
    WdePopupListItem *p;

    p = (WdePopupListItem *)WdeMemAlloc( sizeof( WdePopupListItem ) );

    if( p != NULL ) {
        p->num = num;
        p->menu = menu;
        p->hint_items = hint_items;
        if( WdeInitHintItems( num, menu, hint_items ) ) {
            ListAddElt( &WdePopupList, p );
        } else {
            WdeMemFree( p );
            return( FALSE );
        }
    } else {
        return( FALSE );
    }

    return( TRUE );
}
Exemple #8
0
Bool WdeSetDialogFlagText( unsigned long flags, char **text )
{
    if( text == NULL ) {
        return( FALSE );
    }

    *text = NULL;
    if( WdeSetFlagText( DialogMap, ControlStyle, flags, text ) ) {
        if( (flags & (WS_CHILD | WS_POPUP)) == 0 ) {
            WdeAddStyleString( text, "WS_OVERLAPPED" );
        }
        if( WdeSetFlagText( WindowMap, WindowStyle, flags, text ) ) {
            return( TRUE );
        }
    }

    if( *text != NULL ) {
        WdeMemFree( *text );
        *text = NULL;
    }

    return( FALSE );
}
Exemple #9
0
BOOL WdeFreeCustControl ( WdeCustControl *control )
{
    uint_16 type;
    uint_16 num_types;


    if ( control != NULL) {
        if ( !control->ms_lib ) {
            num_types = control->control_info.bor.wCtlTypes;
            for ( type = 0; type < num_types; type++ ) {
                if  (control->control_info.bor.Type[type].hToolBit) {
                    DeleteObject (
                        control->control_info.bor.Type[type].hToolBit );
                }
            }
        }
        WdeMemFree ( control );
    } else {
        WdeWriteTrail("WdeFreeCustControl: NULL control!");
        return ( FALSE );
    }

    return ( TRUE );
}
Exemple #10
0
void WdeDisplayHint( int id )
{
    char        *buf;
    char        *mditext;
    WdeHintItem *hint;

    if( id < WDE_MDI_FIRST ) {
        hint = WdeGetHintItem( id );
        if( hint != NULL ) {
            WdeSetStatusByID( -1, hint->hint );
        }
    } else {
        mditext = WdeAllocRCString( WDE_HINT_MDIMSG );
        if( mditext != NULL ) {
            buf = WdeMemAlloc( strlen( mditext ) + 20 + 1 );
            if( buf != NULL ) {
                sprintf( buf, mditext, WDE_MDI_FIRST + 1 - id );
                WdeSetStatusText( NULL, buf, TRUE );
                WdeMemFree( buf );
            }
            WdeFreeRCString( mditext );
        }
    }
}
Exemple #11
0
Bool WdeDBI2Mem( WdeDialogBoxInfo *info, uint_8 **mem, uint_32 *size )
{
    Bool                ok;
    uint_32             pos, memsize, sz, pad;
    LIST                *l;
    WdeDialogBoxControl *ci;
    Bool                is32bit;
    Bool                is32bitEx;

    is32bit = info->dialog_header->is32bit;
    is32bitEx = info->dialog_header->is32bitEx;

    ok = ( info && mem && size );

    if( ok ) {
        *mem = NULL;
        memsize = (int) WdeCalcSizeOfWdeDialogBoxInfo( info );
        ok = ( memsize != 0 );
    }

    if( ok ) {
        *mem = WdeMemAlloc( memsize );
        ok = ( *mem != NULL );
    }

    if( ok ) {
        if( is32bit && is32bitEx ) {
            pos = WdeDialogBoxExHeaderToMem( info->dialog_header, *mem );
        } else {
            pos = WdeDialogBoxHeaderToMem( info->dialog_header, *mem );
        }
        ok = ( pos != 0 );
    }

    if( ok ) {
        for ( l = info->control_list; l; l = ListNext(l) ) {
            ci = ListElement ( l );
            if( ci == NULL ) {
                ok = FALSE;
                break;
            }
            if( is32bit ) {
                pad = CALC_PAD( pos, sizeof(uint_32) );
                memset( (*mem)+pos, 0, pad );
                pos += pad;
            }
            sz = WdeDialogBoxControlToMem( ci, (*mem)+pos, is32bit, is32bitEx );
            if( sz == 0 ) {
                ok = FALSE;
                break;
            }
            pos += sz;
        }
    }

    if( is32bit ) {
        pad = CALC_PAD( pos, sizeof(uint_32) );
        memset( (*mem)+pos, 0, pad );
        pos += pad;
    }

    if ( ok ) {
        ok = ( pos == memsize );
        if ( ok ) {
            *size = memsize;
        }
    } else {
        if ( mem && *mem ) {
            WdeMemFree ( *mem );
            *mem = NULL;
        }
    }

    return ( ok );
}
Exemple #12
0
BOOL WdeLoadBorCustomControls ( WdeCustLib *lib )
{
    WdeListClassesProc   list_proc;
    HGLOBAL              list_global;
    uint_8              *list_locked;
    uint_16              num_classes;
    WdeBorlandClassList *class_list;
    uint_32              class_list_size;

    /* touch unused var to get rid of warning */
    _wde_touch( lib );

    list_proc = (WdeListClassesProc) GetProcAddress(lib->inst, "ListClasses");

    if ( list_proc == NULL ) {
        if ( WdeQueryAssumeMS () ) {
            lib->ms_lib = TRUE;
            return ( WdeLoadMSCustomControls ( lib ) );
        } else {
            WdeWriteTrail("WdeLoadBorCustomControls: User aborted load!");
            return ( FALSE );
        }
    }

    if ( WdeCustLOADRESInst == NULL ) {
        WdeCustLOADRESInst = MakeProcInstance ( (FARPROC) WdeCustLOADRES,
                                                WdeGetAppInstance() );
    }

    if ( WdeCustEDITRESInst == NULL ) {
        WdeCustEDITRESInst = MakeProcInstance ( (FARPROC) WdeCustEDITRES,
                                                WdeGetAppInstance() );
    }

#if 0
    list_global = (*list_proc) ( "WdeMainClass", WDE_VERSION,
                                 (LPFNLOADRES) WdeCustLOADRES,
                                 (LPFNEDITRES) WdeCustEDITRES );
#else
    list_global = (*list_proc) ( "WdeMainClass", WDE_VERSION,
                                 (LPFNLOADRES) WdeCustLOADRESInst,
                                 (LPFNEDITRES) WdeCustEDITRESInst );
#endif

    if ( list_global == NULL ) {
        WdeWriteTrail("WdeLoadBorCustomControls: ListClasses returned NULL!");
        return ( FALSE );
    }

    list_locked = (uint_8 *) GlobalLock ( list_global );
    if ( list_locked == NULL ) {
        WdeWriteTrail("WdeLoadBorCustomControls: Could lock global memory!");
        GlobalFree( list_global );
        return ( FALSE );
    }

    num_classes = *((uint_16 *) list_locked);

    class_list_size = sizeof(WdeBorlandClassList) +
                      (num_classes-1) * sizeof(WdeBorlandCtlClass);

    class_list = ( WdeBorlandClassList *) WdeMemAlloc ( class_list_size );
    if ( class_list == NULL ) {
        WdeWriteTrail("WdeLoadBorCustomControls: class list alloc failed!");
        GlobalUnlock ( list_global );
        GlobalFree( list_global );
        return ( FALSE );
    }

    memcpy ( class_list, list_locked, class_list_size );

    lib->class_list = list_global;

    if ( !WdeAddBorControlsToCustLib ( lib, class_list ) ) {
        WdeWriteTrail("WdeLoadBorCustomControls: Add to CustLib failed!");
        WdeMemFree    ( class_list );
        GlobalUnlock ( list_global );
        GlobalFree   ( list_global );
        return ( FALSE );
    }

    WdeMemFree    ( class_list );
    GlobalUnlock ( list_global );

    WdeMemValidate ( lib );

    return ( TRUE );
}
Exemple #13
0
WdeDialogBoxInfo *WdeLoadDialogFromRes( WdeResInfo *res_info,
                                        WResLangNode *lnode, Bool is32bit )
{
    DialogExHeader32        h32ex;
    DialogBoxHeader32       h32;
    DialogBoxHeader         h16;

    DialogBoxControl        c16;
    DialogBoxControl32      c32;
    DialogBoxExControl32    c32ex;

    WdeDialogBoxInfo        *dlg_info;
    WResFileID              file;
    WdeDialogBoxControl     *control;
    LIST                    *prev_control;
#if 0
    WdeDialogBoxControl     *nc;
    LIST                    *clist;
#endif
    int                     index;
    char                    *file_name;
    Bool                    ok;

    dlg_info = NULL;
    file = -1;

    ok = (res_info != NULL && lnode != NULL);

    if( ok ) {
        file_name = res_info->info->tmp_file;
        dlg_info = (WdeDialogBoxInfo *)WdeMemAlloc( sizeof( WdeDialogBoxInfo ) );
        ok = (dlg_info != NULL);
    }

    if( ok ) {
        dlg_info->dialog_header = WdeAllocDialogBoxHeader();
        ok = (dlg_info->dialog_header != NULL);
    }

    if( ok ) {
        dlg_info->dialog_header->is32bit = is32bit;
        dlg_info->control_list = NULL;
        dlg_info->MemoryFlags = 0;
        file = ResOpenFileRO( file_name );
        ok = (file != -1);
    }

    if( ok ) {
        dlg_info->MemoryFlags = lnode->Info.MemoryFlags;
        ok = (lseek( file, lnode->Info.Offset, SEEK_SET ) != -1);
    }

    if( ok ) {
        if( is32bit ) {
            /* JPK - check if its an extended dialog */
            dlg_info->dialog_header->is32bitEx = ResIsDialogEx( file );
            lseek( file, lnode->Info.Offset, SEEK_SET );

            if( dlg_info->dialog_header->is32bitEx ) {
                ok = !ResReadDialogExHeader32( &h32, &h32ex, file );
            } else {
                ok = !ResReadDialogBoxHeader32( &h32, file );
            }
        } else {
            ok = !ResReadDialogBoxHeader( &h16, file );
        }
    }

    if( ok ) {
        if( is32bit ) {
            if( dlg_info->dialog_header->is32bitEx ) {
                dlg_info->dialog_header->FontWeight = h32ex.FontWeight;
                dlg_info->dialog_header->FontItalic = h32ex.FontItalic;
                dlg_info->dialog_header->HelpId = h32ex.HelpId;
                dlg_info->dialog_header->FontWeightDefined = (h32ex.FontWeightDefined != 0);
                dlg_info->dialog_header->FontItalicDefined = (h32ex.FontItalicDefined != 0);
            }
            dlg_info->dialog_header->Style = h32.Style;
            dlg_info->dialog_header->ExtendedStyle = h32.ExtendedStyle;
            dlg_info->dialog_header->NumOfItems = h32.NumOfItems;
            dlg_info->dialog_header->Size = h32.Size;
            dlg_info->dialog_header->MenuName = h32.MenuName;
            dlg_info->dialog_header->ClassName = h32.ClassName;
            dlg_info->dialog_header->Caption = h32.Caption;
            dlg_info->dialog_header->PointSize = h32.PointSize;
            dlg_info->dialog_header->FontName = h32.FontName;
        } else {
            dlg_info->dialog_header->Style = h16.Style;
            dlg_info->dialog_header->NumOfItems = h16.NumOfItems;
            dlg_info->dialog_header->Size = h16.Size;
            dlg_info->dialog_header->MenuName = h16.MenuName;
            dlg_info->dialog_header->ClassName = h16.ClassName;
            dlg_info->dialog_header->Caption = h16.Caption;
            dlg_info->dialog_header->PointSize = h16.PointSize;
            dlg_info->dialog_header->FontName = h16.FontName;
        }

        prev_control = NULL;
        for( index = 0; index < GETHDR_NUMITEMS( dlg_info->dialog_header ); index++ ) {
            control = WdeAllocDialogBoxControl();
            if( control == NULL ) {
                ok = FALSE;
                break;
            }
            if( is32bit ) {
                /*
                 * JPK - check which control structure to expect based on
                 *       whether this an extended dialog or not
                */
                if( dlg_info->dialog_header->is32bitEx ) {
                    if( ResReadDialogExControl32( &c32ex, file ) ) {
                        ok = FALSE;
                        break;
                    }
                    control->HelpId = c32ex.HelpId;
                    control->ExtendedStyle = c32ex.ExtendedStyle;
                    control->Style = c32ex.Style;
                    control->Size = c32ex.Size;
                    control->ID = c32ex.ID;
                    control->ClassID = c32ex.ClassID;
                    control->Text = c32ex.Text;
                    control->ExtraBytes = c32ex.ExtraBytes;
                } else {
                    if( ResReadDialogBoxControl32( &c32, file ) ) {
                        ok = FALSE;
                        break;
                    }
                    control->Style = c32.Style;
                    control->ExtendedStyle = c32.ExtendedStyle;
                    control->Size = c32.Size;
                    control->ID = c32.ID;
                    control->ClassID = c32.ClassID;
                    control->Text = c32.Text;
                    control->ExtraBytes = c32.ExtraBytes;
                }
            } else {
                if( ResReadDialogBoxControl( &c16, file ) ) {
                    ok = FALSE;
                    break;
                }
                control->Size = c16.Size;
                control->ID = c16.ID;
                control->Style = c16.Style;
                control->ClassID = c16.ClassID;
                control->Text = c16.Text;
                control->ExtraBytes = c16.ExtraBytes;
            }
            if ( prev_control == NULL ) {
                ListAddElt( &dlg_info->control_list, (void *)control );
                prev_control = dlg_info->control_list;
            } else {
                ListInsertElt( prev_control, (void *)control );
                prev_control = ListNext( prev_control );
            }
        }
    }

#if 0
    /*
     * JPK - if the dialog is 32 bit but not EX, then convert the dialog
     *       header and the control list to EX; this will force all
     *       dialogs to EX, for now
    */
    if( is32bit && !dlg_info->dialog_header->is32bitEx ) {
        /* deal with the dialog header first */
        dlg_info->dialog_header->is32bitEx = TRUE;

        dlg_info->dialog_header->FontWeight = 0;
        dlg_info->dialog_header->FontItalic = 0;
        dlg_info->dialog_header->HelpId = 0;
        dlg_info->dialog_header->FontWeightDefined = FALSE;
        dlg_info->dialog_header->FontItalicDefined = FALSE;

        /* now deal with the list of controls */
        nc = (WdeDialogBoxControl *)WdeMemAlloc( sizeof( WdeDialogBoxControl ) );
        for( clist = dlg_info->control_list; clist != NULL; clist = ListNext( clist ) ) {
            control = (WdeDialogBoxControl *)ListElement( clist );
            memcpy( nc, control, sizeof( WdeDialogBoxControl ) );

            nc->HelpId = 0;
            nc->ExtendedStyle = control->ExtendedStyle;
            nc->Style = control->Style;
            memcpy( &nc->Size, &control->Size, sizeof( DialogSizeInfo ) );
            nc->ID = control->ID;
            nc->ClassID = control->ClassID;
            nc->Text = control->Text;
            nc->ExtraBytes = control->ExtraBytes;

            memcpy( control, nc, sizeof( WdeDialogBoxControl ) );
        }
        WdeMemFree( nc );
    }
#endif

    if( !ok ) {
        if( dlg_info != NULL ) {
            WdeFreeDialogBoxInfo( dlg_info );
            dlg_info = NULL;
        }
    }

    if( file != -1 ) {
        ResCloseFile( file );
    }

    return( dlg_info );
}
Exemple #14
0
Bool WdeLoadCustomLib ( Bool ms_lib, Bool load_only )
{
    char              *name;
    HINSTANCE          inst;
    WdeCustLib        *lib;
    BOOL               ret;
    WdeGetFileStruct   gf;

    gf.file_name = NULL;
    gf.title     = WdeCustOpenTitle;
    gf.filter    = WdeCustFilter;

    name = WdeGetOpenFileName ( &gf );

    if ( !name ) {
        return ( FALSE );
    }

    inst = LoadLibrary ( name );

    if ( inst <= HINSTANCE_ERROR ) {
        WdeWriteTrail("WdeLoadCustomLib: LoadLibrary call failed!");
        WdeMemFree ( name );
        return ( FALSE );
    }

    lib = WdeAllocCustLib ();
    if ( lib == NULL ) {
        WdeWriteTrail("WdeLoadCustomLib: WdeAllocCustLib failed!");
        WdeMemFree ( name );
        FreeLibrary ( inst );
        return ( FALSE );
    }

    lib->inst      = inst;
    lib->ms_lib    = ms_lib;
    lib->load_only = load_only;
    lib->file_name = name;

    if( load_only ) {
        WdeSetStatusByID( -1, WDE_LIBRARYLOADED );
        ret = TRUE;
    } else {
        if( ms_lib ) {
            ret = WdeLoadMSCustomControls( lib );
        } else {
            ret = WdeLoadBorCustomControls( lib );
        }
    }

    if ( !ret ) {
        WdeFreeCustLib ( lib );
        return ( FALSE );
    }

    if ( load_only ) {
        WdeInsertObject ( &WdeLibList, (void *) lib );
    } else {
        WdeInsertObject ( &WdeCustomLibList, (void *) lib );
    }

    return( TRUE );
}
Exemple #15
0
Bool WdeOpenResource( char *fn )
{
    char                *name;
    WdeResInfo          *res_info;
    WdeGetFileStruct    gf;
    Bool                ok, got_name;

    WdeSetWaitCursor( TRUE );

    res_info = NULL;
    name = NULL;
    got_name = FALSE;

    if( fn != NULL ) {
        if( WdeFileExists( fn ) ) {
            name = WdeStrDup( fn );
            gf.fn_offset = WRFindFnOffset( name );
        } else {
            return( FALSE );
        }
    } else {
        gf.file_name = NULL;
        gf.title = WdeResOpenTitle;
        gf.filter = WdeResOpenFilter;
        ok = ((name = WdeGetOpenFileName( &gf )) != NULL);
    }

    if( ok ) {
        got_name = TRUE;
        ok = ((res_info = WdeLoadResource( name )) != NULL);
    }

    if( ok ) {
        res_info->hash_table = WRInitHashTable();
        ok = (res_info->hash_table != NULL);
    }

    if( ok ) {
        if( res_info->info->internal_type != WR_DONT_KNOW ) {
            res_info->is32bit = WRIs32Bit( res_info->info->internal_type );
        } else {
            res_info->is32bit = WRIs32Bit( res_info->info->file_type );
        }
        ok = WdeAddDlgItems( res_info );
    }

    if( ok ) {
        WdeFindAndLoadSymbols( res_info );
        ok = WdeCreateResourceWindow( res_info, gf.fn_offset, NULL );
    }

    if( ok ) {
        if( WdeResInfoHasDialogs( res_info ) ) {
            WdeSelectDialog( res_info );
        } else {
            WdeDisplayErrorMsg( WDE_PRJHASNODIALOGS );
        }
        ListAddElt( &WdeResList, (void *)res_info );
        WdeSetResModified( res_info, FALSE );
        WdeCheckBaseScrollbars( FALSE );
    }

    if( !ok ) {
        if( res_info != NULL ) {
            WdeFreeResInfo( res_info );
            res_info = NULL;
        }
        if( got_name ) {
            WdeDisplayErrorMsg( WDE_RESOURCESNOTLOADED );
        }
    }

    if( name != NULL ) {
        WdeMemFree( name );
    }

    WdeSetWaitCursor( FALSE );

    return( ok );
}
Exemple #16
0
Bool WdeCreateResourceWindow( WdeResInfo *res_info, int fn_offset, char *title )
{
    MDICREATESTRUCT     mdics;
    LRESULT             ret;
    HWND                win;
    Bool                ok;
    Bool                old;
    DWORD               style;
    RECT                r;
    HMENU               sys_menu;
    char                *win_title;
    int                 win_title_len;

    _wde_touch( fn_offset );

    WdeIncNumRes();

    style = 0;

    if( WdeGetNumRes() == 1 ) {
        WdeSetAppMenuToRes( TRUE );
        old = WdeSetStickyMode( WdeOldStickyMode );
        style = WS_MAXIMIZE;
    } else {
        if( WdeIsCurrentMDIWindowZoomed() ) {
            style = WS_MAXIMIZE;
        }
    }

    mdics.szClass = "WdeResClass";

    win_title = NULL;
    if( title == NULL ) {
        if( res_info->info->file_name ) {
            // perhaps make this an option
            //title = &res_info->info->file_name[fn_offset];
            mdics.szTitle = res_info->info->file_name;
        } else {
            WdeResCounter++;
            win_title_len = strlen( WdeResUntitled ) + 7;
            win_title = (char *)WdeMemAlloc( win_title_len );
            sprintf( win_title, "%s.%d", WdeResUntitled, 0xffff & WdeResCounter );
            mdics.szTitle = win_title;
        }
    } else {
        mdics.szTitle = title;
    }

    win = WdeGetMDIWindowHandle();
    GetClientRect( win, &r );

    mdics.hOwner = WdeGetAppInstance();
    mdics.x = CW_USEDEFAULT;
    mdics.y = CW_USEDEFAULT;
    mdics.cx = CW_USEDEFAULT;
    mdics.cy = CW_USEDEFAULT;
    //mdics.cx = r.right - r.left;
    //mdics.cy = r.bottom - r.top;
    mdics.style = style;
    mdics.lParam = (LPARAM)res_info;

    ret = SendMessage( win, WM_MDICREATE, 0, (LPARAM)&mdics );

    if( win_title != NULL ) {
        WdeMemFree( win_title );
    }

#ifdef __NT__
    win = (HWND)ret;
#else
    win = (HWND)LOWORD( ret );
#endif

    ok = (res_info->res_win != NULL && res_info->res_win == win);
    if( !ok ) {
        WdeWriteTrail( "WdeCreateResourceWindow: Bad window handle!" );
    }

    if( WdeIsDDE() ) {
        sys_menu = GetSystemMenu( win, FALSE );
        if( sys_menu != (HMENU)NULL ) {
            EnableMenuItem( sys_menu, SC_CLOSE, MF_GRAYED );
        }
    }

    if( ok ) {
        ok = WdeCreateEditWindows( res_info );
        if( !ok ) {
            WdeWriteTrail( "WdeCreateResourceWindow: Could not create edit windows!" );
        }
    }

    if( ok ) {
        OpenFormEdit( res_info->forms_win, WdeGetCreateTable(), MENU_NONE, SCROLL_NONE );
        WdeSetEditMode( res_info, TRUE );
        SetHorizontalInc( 1 );
        SetVerticalInc( 1 );
        InitState( res_info->forms_win );
        SetMouseRtn( res_info->forms_win, WdeMouseRtn );
        //MakeObjectCurrent( GetMainObject() );
    } else {
        if( WdeGetNumRes() == 1 ) {
            WdeSetAppMenuToRes( FALSE );
            WdeSetStickyMode( old );
        }
        WdeDecNumRes();
    }

    return( ok );
}
Exemple #17
0
Bool WdeSaveResource( WdeResInfo *res_info, Bool get_name )
{
    WdeGetFileStruct    gf;
    char                *filter;
    char                *fn;
    int                 fn_offset;
    Bool                got_name;
    Bool                ok;
    OBJPTR              main_obj;

    fn_offset = 0;
    got_name = FALSE;

    ok = (res_info != NULL && res_info->info != NULL);

    if( ok ) {
        if( res_info->info->save_name != NULL ) {
            fn = res_info->info->save_name;
        } else {
            res_info->info->save_type = res_info->info->file_type;
            fn = WdeStrDup( res_info->info->file_name );
            got_name = TRUE;
        }

        if( get_name || fn == NULL || *fn == '\0' ) {
            filter = WdeSelectSaveFilter( res_info->info->file_type );
            gf.file_name = fn;
            gf.title = WdeResSaveTitle;
            gf.filter = filter;
            fn = WdeGetSaveFileName( &gf );
            got_name = TRUE;
            res_info->info->save_type = WR_DONT_KNOW;
        }

        ok = (fn != NULL && *fn != '\0');
    }

    if( ok ) {
        if( got_name && res_info->info->save_name != NULL ) {
            WdeMemFree( res_info->info->save_name );
        }
        res_info->info->save_name = fn;
        if( res_info->info->save_type == WR_DONT_KNOW ) {
            res_info->info->save_type = WdeSelectFileType( fn, res_info->is32bit );
        }
        ok = (res_info->info->save_type != WR_DONT_KNOW);
    }

    if( ok ) {
        if( WdeIsHashTableDirty( res_info->hash_table ) &&
            !WdeIsHashSaveRejectedSet( res_info->hash_table ) ) {
            if( res_info->sym_name == NULL ) {
                res_info->sym_name = WdeCreateSymName( fn );
            }
        }
    }

    if( ok ) {
        if( WdeIsHashTableDirty( res_info->hash_table ) ) {
            if( (main_obj = GetMainObject()) != NULL ) {
                Forward( main_obj, RESOLVE_HELPSYMBOL, &ok, NULL ); /* JPK */
                Forward( main_obj, RESOLVE_SYMBOL, &ok, NULL );
            }
        }
        WdeCreateDLGInclude( res_info, res_info->sym_name );
        ok = WdeSaveResourceToFile( res_info );
        if( !ok ) {
            WdeDisplayErrorMsg( WDE_SAVEFAILED );
        }
    }

    if( ok ) {
        if( WdeIsHashTableDirty( res_info->hash_table ) &&
            !WdeIsHashSaveRejectedSet( res_info->hash_table ) ) {
            WdeWriteSymbols( res_info->hash_table, &res_info->sym_name, get_name );
        }
    }

    if( ok ) {
        //fn_offset = WRFindFnOffset( fn );
        SendMessage( res_info->res_win, WM_SETTEXT, 0, (LPARAM)(LPVOID)&fn[fn_offset] );
    }

    return( ok );
}
Exemple #18
0
void MemFree ( void *ptr )
{
    WdeMemFree ( ptr );
}