⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wdecust.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
        WdeWriteTrail("WdeCreateAndAddCustControl: NULL param!");
        return ( FALSE );
    }

    info_global = (*info_proc) ();

    if ( info_global == NULL ) {
        WdeWriteTrail("WdeCreateAndAddCustControl: Info proc returned NULL!");
        return ( FALSE );
    }

    info_locked = (uint_8 *) GlobalLock ( info_global );
    if ( info_locked == NULL ) {
        WdeWriteTrail("WdeCreateAndAddCustControl: GlobalLock failed!");
        GlobalFree( info_global );
        return ( FALSE );
    }

    control = WdeAllocCustControlFromWDECTLINFO ( (WDECTLINFO *) info_locked,
                                                  lib->ms_lib );
    if ( control == NULL ) {
        WdeWriteTrail("WdeCreateAndAddCustControl: Could alloc control!");
        GlobalUnlock( info_global );
        GlobalFree( info_global );
        return ( FALSE );
    }

    control->lib        = lib;

    control->info_proc  = info_proc;
    control->style_proc = style_proc;
    control->flags_proc = flags_proc;

    WdeAddCustControlToCustLib ( lib, control );

    GlobalUnlock( info_global );

    GlobalFree( info_global );

    WdeMemValidate ( lib );

    return ( TRUE );
}

void WdeAddCustControlToCustLib ( WdeCustLib *lib, WdeCustControl *control )
{
    LIST *end;

    if ( lib->controls == NULL ) {
        ListAddElt( &(lib->controls), (void *) control );
    } else {
        /* make sure item is inserted at end of list */
        WdeListLastElt ( lib->controls, &end );
        ListInsertElt( end, (void *) control );
    }

    WdeMemValidate ( lib );
    WdeMemValidate ( control );

    return;
}

WdeCustLib *WdeAllocCustLib ( void )
{
    WdeCustLib  *lib;

    lib = (WdeCustLib *) WdeMemAlloc ( sizeof(WdeCustLib) );

    if ( lib == NULL ) {
        WdeWriteTrail("WdeAllocCustLib: WdeCustLib alloc failed!");
        return ( NULL );
    }

    memset ( lib, 0, sizeof(WdeCustLib) );

    WdeMemValidate ( lib );

    return ( lib );
}

WdeCustControl *WdeAllocCustControlFromWDECTLINFO ( WDECTLINFO *info,
                                                    BOOL ms_lib )
{
    WdeCustControl  *control;

    control = WdeAllocCustControl ();
    if ( control == NULL ) {
        WdeWriteTrail("WdeAllocCustControlFromWDECTLINFO: "
                      "WdeCustControl alloc failed!");
        return ( NULL );
    }

    control->ms_lib = ms_lib;

    if ( ms_lib ) {
        memcpy ( &(control->control_info.ms),  info, sizeof(CTLINFO) );
    } else {
        memcpy ( &(control->control_info.bor), info, sizeof(WDECTLINFO) );
    }

    return ( control );
}

WdeCustControl *WdeAllocCustControl ( void )
{
    WdeCustControl  *control;

    control = (WdeCustControl *) WdeMemAlloc ( sizeof(WdeCustControl) );

    if ( control == NULL ) {
        WdeWriteTrail("WdeAllocCustControl: WdeCustControl alloc failed!");
        return ( NULL );
    }

    memset ( control, 0, sizeof(WdeCustControl) );

    return ( control );
}

void WdeFreeCustRESProcs ( void )
{
    if ( WdeCustLOADRESInst != NULL ) {
        FreeProcInstance ( (FARPROC) WdeCustLOADRESInst );
    }

    if ( WdeCustEDITRESInst != NULL ) {
        FreeProcInstance ( (FARPROC) WdeCustEDITRESInst );
    }
}

Bool WdeFreeAllCustLibs ( void )
{
    LIST        *llist;
    WdeCustLib  *lib;

    if ( WdeCustomLibList != NULL ) {
        for ( llist = WdeCustomLibList; llist; llist = ListNext(llist) ) {
            lib = (WdeCustLib *) ListElement(llist);
            WdeFreeCustLib ( lib );
        }
        ListFree ( WdeCustomLibList );
        WdeCustomLibList = NULL;
    }

    if ( WdeLibList != NULL ) {
        for ( llist = WdeLibList; llist; llist = ListNext(llist) ) {
            lib = (WdeCustLib *) ListElement(llist);
            WdeFreeCustLib ( lib );
        }
        ListFree ( WdeLibList );
        WdeLibList = NULL;
    }

    return ( TRUE );
}

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 );
}

void WdeFreeCustLibControls ( LIST **control_list )
{
    LIST           *clist;
    WdeCustControl *control;

    if ( (control_list != NULL) && (*control_list != NULL) ) {
        for ( clist = *control_list; clist; clist = ListNext(clist) ) {
            control = (WdeCustControl *) ListElement(clist);
            WdeFreeCustControl ( control );
        }
        ListFree ( *control_list );
        *control_list = NULL;
    } else {
        WdeWriteTrail("WdeFreeCustLibControls: NULL control_list!");
    }
}

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 );
}

void WdeFindClassInAllCustLibs ( char *class, LIST **list )
{
    LIST        *llist;
    WdeCustLib  *lib;

    if ( !list ) {
        return;
    }

    *list = NULL;

    if ( class && WdeCustomLibList ) {
        for ( llist = WdeCustomLibList; llist; llist = ListNext(llist) ) {
            lib = (WdeCustLib *) ListElement(llist);
            WdeFindClassInCustLib ( class, list, lib );
        }
    }

    return;
}

void WdeFindClassInCustLib ( char *class, LIST **list, WdeCustLib *lib )
{
    if ( (lib != NULL) && ( lib->controls != NULL ) ) {
            WdeFindClassInCustLibControls ( class, list, lib->controls );
    }

    return;
}

void WdeFindClassInCustLibControls ( char *class, LIST **list,
                                     LIST *control_list )
{
    LIST           *clist;
    WdeCustControl *control;

    if ( control_list != NULL ) {
        for ( clist = control_list; clist; clist = ListNext(clist) ) {
            control = (WdeCustControl *) ListElement(clist);
            if ( !strcmpi ( class, control->control_info.ms.szClass ) ) {
                ListAddElt( list, (void *) control );
            }
        }
    }

    return;
}

BOOL WdeQueryUnsafeMSLoad ( void )
{
    int         ret;
    char        *text;
    char        *title;

    text = WdeAllocRCString( WDE_MSWARNINGTEXT );
    title = WdeAllocRCString( WDE_MSWARNINGTITLE );

    ret = MessageBox( WdeGetMainWindowHandle(), text, title,
                      MB_APPLMODAL | MB_OKCANCEL | MB_ICONEXCLAMATION );

    if( title ) {
        WdeFreeRCString( title );
    }

    if( text ) {
        WdeFreeRCString( text );
    }

    if ( ret != IDOK ) {
        return ( FALSE );
    }

    return ( TRUE );
}

BOOL WdeQueryAssumeMS ( void )
{
    int         ret;
    char        *text;
    char        *title;

    text = WdeAllocRCString( WDE_BORWARNINGTEXT );
    title = WdeAllocRCString( WDE_BORWARNINGTITLE );

    ret = MessageBox( WdeGetMainWindowHandle(), text, title,
                      MB_APPLMODAL | MB_OKCANCEL | MB_ICONEXCLAMATION );

    if( title ) {
        WdeFreeRCString( title );
    }

    if( text ) {
        WdeFreeRCString( text );
    }

    if ( ret != IDOK ) {
        return ( FALSE );
    }

    return ( TRUE );
}

HGLOBAL WINEXPORT WdeCustLOADRES ( LPCSTR type_name, LPCSTR res_name )
{
    HGLOBAL   res;
    HRSRC     hres;
    HINSTANCE inst;
    BOOL      strange;
    uint_32   res_int;
    char      out[160];

    sprintf ( out, "Request to load type:%lu res:%lu",
              (uint_32) type_name, (uint_32) res_name );
    WdeWriteTrail(out);

    inst = WdeGetAppInstance();

    strange = FALSE;

    hres = (HRSRC) NULL;
    res  = (HGLOBAL) NULL;

    switch ( (uint_32) type_name ) {
        case RT_CURSOR:
            strange = TRUE;
            res = (HRSRC) LoadCursor ( inst, res_name );
            break;

        case RT_BITMAP:
            res_int = ( uint_32 ) res_name;
            if ( ((res_int >> 16) != 0) ||
                 !WdeIsBorBtnIDSupported ( ((uint_16)res_int % 1000) ) ) {
                res_name =
                    MAKEINTRESOURCE((res_int-(res_int%1000)+WDE_PREVIEW_ID));
            }
            hres = FindResource ( inst, res_name, type_name );
            if ( hres != NULL ) {
                res = LoadResource ( inst, hres );
            }
            break;

        case RT_ICON:
            strange = TRUE;
            res = (HRSRC) LoadIcon ( inst, res_name );
            break;

        case RT_MENU:
            strange = TRUE;
            res = (HRSRC) LoadMenu ( inst, res_name );
            break;

        case RT_ACCELERATOR:
            strange = TRUE;
            res = (HRSRC) LoadAccelerators ( inst, res_name );
            break;

        case RT_STRING:
        case RT_DIALOG:
        case RT_FONTDIR:
        case RT_FONT:
        case RT_RCDATA:
        case RT_GROUP_CURSOR:
        case RT_GROUP_ICON:
            WdeWriteTrail("WdeCustLOADRES: Unhandled LOADRES request!");
            break;

        default:
            WdeWriteTrail("WdeCustLOADRES: Unknown LOADRES request!");
            break;
    }

    if ( strange ) {
        WdeWriteTrail("WdeCustLOADRES: Strange LOADRES request!");
        return ( NULL );
    }

    if ( hres != NULL ) {
    }

    if ( res == NULL ) {
        WdeWriteTrail("WdeCustLOADRES: res == NULL!");
    }

    return ( res );
}

BOOL WINEXPORT WdeCustEDITRES ( LPCSTR type_name, LPCSTR res_name )
{
    char      out[160];

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

    sprintf ( out, "Request to edit type:%lu res:%lu",
              (uint_32) type_name, (uint_32) res_name );
    WdeWriteTrail(out);

    return ( FALSE );
}

void WdeFreeSelectWinCBox ( HWND win )
{
    HWND                cbox;
    LRESULT             count;
    uint_32             i;
    WdeCurrCustControl *current;

    cbox = GetDlgItem ( win, IDB_CUST_DESC );

    count = SendMessage ( cbox, CB_GETCOUNT, 0, 0 );

    for( i=0; i<count; i++) {
        current = (WdeCurrCustControl *)
            SendMessage( cbox, CB_GETITEMDATA, (WPARAM)i, 0 );
        if( current != NULL ) {
            WdeMemFree( current );
            SendMessage( cbox, CB_SETITEMDATA, i, (LPARAM) NULL );
        } else {
            WdeWriteTrail( "WdeFreeSelectWinCBox: NULL current!" );
        }
    }

    return;
}

Bool WdeSetSelectWinCBox (HWND cbox, WdeCustControl *control)
{
    WdeCurrCustControl *current;
    uint_16             type;
    LRESULT             index;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -