Ejemplo n.º 1
0
bool WdeDisplayOptions( void )
{
    HWND      dialog_owner;
    DLGPROC   dlgproc;
    HINSTANCE app_inst;
    INT_PTR   modified;

    WdeSetStatusText( NULL, " ", false );
    WdeSetStatusByID( WDE_DISPLAYOPTIONS, 0 );

    dialog_owner = WdeGetMainWindowHandle();
    app_inst = WdeGetAppInstance();
    dlgproc = MakeProcInstance_DLG( WdeOptionsDlgProc, app_inst );
    modified = JDialogBoxParam( app_inst, "WdeOptions", dialog_owner, dlgproc, (LPARAM)NULL );
    FreeProcInstance_DLG( dlgproc );

    if( modified == -1 ) {
        WdeWriteTrail( "WdeDisplayOptions: Dialog not created!" );
        return( FALSE );
    }

    WdeSetStatusReadyText();

    return( TRUE );
}
Ejemplo n.º 2
0
Bool WdeSetCurrentCustControl( int which )
{
    int       ret;
    HINSTANCE inst;
    FARPROC   proc;

    if( WdeCustomLibList == NULL ) {
        WdeSetStatusByID( -1, WDE_NOCUSTLOADED );
        return( TRUE );
    }

    if( !WDE_CHECK_WHICH( which ) ) {
        WdeWriteTrail( "WdeSetCurrentCustControl: bad which!" );
        return( FALSE );
    }

    inst = WdeGetAppInstance();
    proc = MakeProcInstance( (FARPROC)WdeSelectCustProc, inst );
    if( proc == NULL ) {
        WdeWriteTrail( "WdeSetCurrentCustomControl: MakeProcInstance failed!" );
        return( FALSE );
    }
    ret = JDialogBoxParam( inst, "WdeSelectCustom", WdeGetMainWindowHandle(),
                           (DLGPROC)proc, (LPARAM)(LPVOID)&which );
    FreeProcInstance( proc );

    /* if the window could not be created return FALSE */
    if( ret == -1 ) {
        WdeWriteTrail( "WdeSetCurrentCustomControl: Could not create selection window!" );
        return( FALSE );
    }

    return( TRUE );
}
Ejemplo n.º 3
0
BOOL WdeLoadMSCustomControls( WdeCustLib *lib )
{
    WdeCustInfoProc  info_proc;
    WdeCustStyleProc style_proc;
    WdeCustFlagsProc flags_proc;
    HWND             dialog_owner;
    FARPROC          proc_inst;
    HINSTANCE        app_inst;
    INT_PTR          ok;

    dialog_owner = WdeGetMainWindowHandle();
    app_inst = WdeGetAppInstance();
    proc_inst = MakeProcInstance ( (FARPROC)WdeLoadCustProc, app_inst );
    ok = JDialogBoxParam( app_inst, "WdeLoadCustom", dialog_owner,
                          (DLGPROC)proc_inst, (LPARAM)(LPVOID)lib );
    FreeProcInstance ( proc_inst );

    if( ok == -1 ) {
        WdeWriteTrail( "WdeLoadMSCustomControls: Dialog not created!" );
        return( FALSE );
    }

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

    if( !HIWORD( (uint_32)lib->info_name ) ) {
        if( !WdeQueryUnsafeMSLoad() ) {
            WdeWriteTrail( "WdeLoadMSCustomControls: User aborted unsafe load!" );
            return( FALSE );
        }
    }

    info_proc = (WdeCustInfoProc)GetProcAddress( lib->inst, lib->info_name );
    style_proc = (WdeCustStyleProc)GetProcAddress ( lib->inst, lib->style_name );
    flags_proc = (WdeCustFlagsProc)GetProcAddress ( lib->inst, lib->flags_name );

    if( info_proc == NULL || style_proc == NULL || flags_proc == NULL ) {
        WdeWriteTrail( "WdeLoadMSCustomControls: Could not get proc address of ordinal!" );
        return( FALSE );
    }

    if( !WdeCreateAndAddCustControl( lib, info_proc, style_proc, flags_proc ) ) {
        WdeWriteTrail( "WdeLoadMSCustomControls: Control not added to list!" );
        return( FALSE );
    }

    WRMemValidate( lib );

    return( TRUE );
}
Ejemplo n.º 4
0
bool WdeSetTestControlDefaults( HWND dialog )
{
    WNDENUMPROC child_proc;
    bool        ret;

    if( dialog != NULL ) {
        child_proc = (WNDENUMPROC)MakeProcInstance( (FARPROC)WdeSetControlEnumProc,
                                                    WdeGetAppInstance() );
        ret = EnumChildWindows( dialog, child_proc, 0 );
        FreeProcInstance( (FARPROC)child_proc );
    }

    return( ret );
}
Ejemplo n.º 5
0
WRFileType WdeSelectFileType( char *name, bool is32bit )
{
    WRFileType      file_type;
    HWND            parent;
    bool            use_wres;
    HELP_CALLBACK   hcb;

    hcb = (HELP_CALLBACK)MakeProcInstance( (FARPROC)WdeHelpRoutine, WdeGetAppInstance() );
    use_wres = WdeGetOption( WdeOptIsWResFmt );
    parent  = WdeGetMainWindowHandle();
    file_type = WRSelectFileType( parent, name, is32bit, use_wres, hcb );
    FreeProcInstance( (FARPROC)hcb );

    return( file_type );
}
Ejemplo n.º 6
0
Bool WdeCreateEditWindows( WdeResInfo *info )
{
    RECT      rect;
    HINSTANCE app_inst;

    if( info == NULL || info->res_win == NULL ) {
        return( FALSE );
    }

    app_inst = WdeGetAppInstance();

    GetClientRect( info->res_win, &rect );

    info->forms_win = CreateWindow( "WdeFormsClass", NULL, WS_CHILD | WS_VISIBLE,
                                    0, 0, rect.right - rect.left, rect.bottom - rect.top,
                                    info->res_win, (HMENU)NULL, app_inst, NULL );

    if( info->forms_win == NULL ) {
        WdeWriteTrail( "WdeCreateEditWindow: failed to create forms window!" );
        return( FALSE );
    }

    GetClientRect( info->forms_win, &rect );

    info->edit_win = CreateWindow( "WdeEditClass", NULL, WS_CHILD | WS_VISIBLE, 0, 0,
                                   rect.right - rect.left, rect.bottom - rect.top,
                                   info->res_win, (HMENU)NULL, app_inst, NULL );

    if( info->edit_win == NULL ) {
        WdeWriteTrail( "WdeCreateEditWindow: failed to create forms window!" );
        return( FALSE );
    }

    SetWindowLong( info->edit_win, 0, (LONG)info );
    SetWindowLong( info->forms_win, 0, (LONG)info );

    SetWindowPos( info->forms_win, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );

    return( TRUE );
}
Ejemplo n.º 7
0
char *WdeGetFileName( WdeGetFileStruct *gf, DWORD flags, WdeGetFileNameAction action )
{
    OPENFILENAME        wdeofn;
    HWND                owner_window;
    DWORD               error;
    char                fn_drive[_MAX_DRIVE];
    char                fn_dir[_MAX_DIR];
    char                fn_name[_MAX_FNAME];
    char                fn_ext[_MAX_EXT];
    char                ext[_MAX_EXT + 1];
    HINSTANCE           app_inst;
    int                 len;
    int                 filter;
    bool                ret;

    if( gf == NULL ) {
        return( NULL );
    }

    owner_window = WdeGetMainWindowHandle();
    app_inst = WdeGetAppInstance();

    if( app_inst == NULL || owner_window == NULL ) {
        return( NULL );
    }

    /* set the initial directory */
    if( *wde_initial_dir == '\0' ) {
        getcwd( wde_initial_dir, MAXFILENAME );
    }

    if( gf->title != NULL ) {
        len = strlen( gf->title );
        if ( len < MAX_NAME ) {
            memcpy( wdefntitle, gf->title, len + 1 );
        } else {
            memcpy( wdefntitle, gf->title, MAX_NAME );
            wdefntitle[MAX_NAME - 1] = 0;
        }
    } else {
        wdefntitle[0] = 0;
    }

    filter = 0;

    if( gf->file_name != NULL && *gf->file_name != '\0' ) {
        _splitpath( gf->file_name, fn_drive, fn_dir, fn_name, fn_ext );
        if( *fn_drive != '\0' || *fn_dir != '\0' ) {
            _makepath( wde_initial_dir, fn_drive, fn_dir, NULL, NULL );
        }
        _makepath( wde_file_name, NULL, NULL, fn_name, fn_ext );
        if( fn_ext[0] != '\0' ) {
            ext[0] = '*';
            strcpy( ext + 1, fn_ext );
            filter = WdeFindFileFilterIndex( gf->filter, ext );
        }
    } else {
        wde_file_name[0] = 0;
    }

    if( filter == 0 ) {
        filter = WdeFindFileFilterIndex( gf->filter, WdeFileFilter );
        if( filter < 1 ) {
            filter = 1;
        }
    }

    // CTL3D no longer requires this
#if !defined( __NT__ )
    flags |= OFN_ENABLEHOOK;
#endif
    /* initialize the OPENFILENAME struct */
    memset( &wdeofn, 0, sizeof( OPENFILENAME ) );

    /* fill in non-variant fields of OPENFILENAME struct */
    wdeofn.lStructSize = sizeof( OPENFILENAME );
    wdeofn.hwndOwner = owner_window;
    wdeofn.hInstance = app_inst;
    wdeofn.lpstrFilter = gf->filter;
    wdeofn.lpstrCustomFilter = NULL;
    wdeofn.nMaxCustFilter = 0;
    wdeofn.nFilterIndex = filter;
    wdeofn.lpstrFile = wde_file_name;
    wdeofn.nMaxFile = MAXFILENAME;
    wdeofn.lpstrFileTitle = wdefntitle;
    wdeofn.nMaxFileTitle = MAXFILENAME;
    wdeofn.lpstrInitialDir = wde_initial_dir;
    wdeofn.lpstrTitle = wdefntitle;
    wdeofn.Flags = flags;
#if !defined( __NT__ )
    wdeofn.lpfnHook = (LPOFNHOOKPROC)MakeProcInstance( (FARPROC)WdeOpenHookProc, app_inst );
#endif

#if 0
    wdeofn.nFileOffset = 0L;
    wdeofn.nFileExtension = 0L;
    wdeofn.lpstrDefExt = NULL;
    wdeofn.lCustData = NULL;
    wdeofn.lpfnHook = NULL;
    wdeofn.lpTemplateName = NULL;
#endif

    if( action == WDEOPENFILE ) {
        ret = GetOpenFileName( (LPOPENFILENAME)&wdeofn );
    } else if( action == WDESAVEFILE ) {
        ret = GetSaveFileName( (LPOPENFILENAME)&wdeofn );
    } else {
        return( NULL );
    }

#ifndef __NT__
    if( wdeofn.lpfnHook != NULL ) {
        FreeProcInstance( (FARPROC)wdeofn.lpfnHook );
    }
#endif

    gf->fn_offset = wdeofn.nFileOffset;
    gf->ext_offset = wdeofn.nFileExtension;

    /* show the dialog box */
    if( !ret ) {
        error = CommDlgExtendedError();
        if( error ) {
            WdeDisplayErrorMsg( WDE_ERRORSELECTINGFILE );
        }
        return( NULL );
    } else {
        memcpy( wde_initial_dir, wde_file_name, wdeofn.nFileOffset );
        if( wde_initial_dir[wdeofn.nFileOffset - 1] == '\\' &&
            wde_initial_dir[wdeofn.nFileOffset - 2] != ':' ) {
            wde_initial_dir[wdeofn.nFileOffset - 1] = '\0';
        } else {
            wde_initial_dir[wdeofn.nFileOffset] = '\0';
        }
        _splitpath( wde_file_name, NULL, NULL, NULL, fn_ext + 1 );
        if( fn_ext[1] != '\0' ) {
            fn_ext[0] = '*';
            WdeSetFileFilter( fn_ext );
        } else {
            char *out_ext;
            out_ext = WdeFindFileFilterFromIndex( gf->filter, wdeofn.nFilterIndex );
            if( out_ext[2] != '*' ) {
                strcat( wde_file_name, &out_ext[1] );
            }
        }
    }

    UpdateWindow( WdeGetMainWindowHandle() );

    return( WdeStrDup( wde_file_name ) );
}
Ejemplo n.º 8
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 );
}
Ejemplo n.º 9
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 *)WRMemAlloc( 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 ) {
        WRMemFree( 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 );
}