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

📄 wdeftrak.c

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:

BOOL WdeTrakCopyObject ( WdeTrakObject *obj, WdeTrakObject **new,
                           WdeTrakObject *handle )
{
    if (new == NULL) {
        WdeWriteTrail("WdeTrakCopyObject: Invalid new object!");
        return ( FALSE );
    }

    *new = (WdeTrakObject *) WdeMemAlloc ( sizeof(WdeTrakObject) );

    if ( *new == NULL ) {
        WdeWriteTrail("WdeTrakCopyObject: Object malloc failed");
        return ( FALSE );
    }

    (*new)->dispatcher    = obj->dispatcher;
    (*new)->object_id     = obj->object_id;

    if ( handle ==  NULL ) {
        (*new)->object_handle = *new;
    } else {
        (*new)->object_handle = handle;
    }

    if (!CopyObject(obj->control, &((*new)->control), (*new)->object_handle)) {
        WdeWriteTrail("WdeTrakCopyObject: Control not created!");
        WdeMemFree ( (*new) );
        return ( FALSE );
    }

    return ( TRUE );
}

BOOL WdeTrakIdentify ( WdeTrakObject *obj, OBJ_ID *id, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(p2);

    *id = obj->object_id;

    return ( TRUE );
}

BOOL WdeTrakGetWndProc( WdeTrakObject *obj, WNDPROC *proc, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(obj);
    _wde_touch(p2);

    *proc = WdeTrakSuperClassProc;

    return ( TRUE );
}

BOOL WdeTrakGetWindowClass ( WdeTrakObject *obj, char **class, void *p2 )
{
    /* touch unused vars to get rid of warning */
    _wde_touch(obj);
    _wde_touch(p2);

    *class = WTRACKBAR_CLASS;

    return ( TRUE );
}

BOOL WdeTrakDefine ( WdeTrakObject *obj, POINT *pnt, void *p2 )
{
    WdeDefineObjectInfo  o_info;

    /* touch unused vars to get rid of warning */
    _wde_touch(pnt);
    _wde_touch(p2);

    o_info.obj       = obj->object_handle;
    o_info.obj_id    = obj->object_id;
    o_info.mask      = WS_VISIBLE | WS_DISABLED |
                        WS_TABSTOP | WS_GROUP | WS_BORDER;
    o_info.set_func  = (WdeSetProc)WdeTrakSetDefineInfo;
    o_info.get_func  = (WdeGetProc)WdeTrakGetDefineInfo;
    o_info.hook_func = WdeTrakDefineHook;
    o_info.win       = NULL;

    return ( WdeControlDefine ( &o_info ) );
}

void WdeTrakSetDefineInfo ( WdeDefineObjectInfo *o_info, HWND hDlg )
{
#ifdef __NT__XX
    DialogStyle mask;

    // set the style controls
    mask = GETCTL_STYLE( o_info->info.c.info ) & 0x000000ff;
    if ( mask & TBS_AUTOTICKS ) {
        CheckDlgButton ( hDlg, IDB_TBS_AUTOTICKS, 1);
    }
    if ( mask & TBS_BOTH ) {
        CheckDlgButton ( hDlg, IDB_TBS_BOTH, 1);
    }
    else if ( mask & TBS_NOTICKS ) {
        CheckDlgButton ( hDlg, IDB_TBS_NOTICKS, 1);
    } else {
        CheckDlgButton ( hDlg, IDB_TBS_ONESIDE, 1);
    }

    if ( mask & TBS_VERT ) {
        CheckDlgButton ( hDlg, IDB_TBS_VERT, 1);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_RIGHT), TRUE);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_LEFT), TRUE);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_TOP), FALSE);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_BOTTOM), FALSE);
    } else {
        CheckDlgButton ( hDlg, IDB_TBS_HORZ, 1);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_RIGHT), FALSE);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_LEFT), FALSE);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_TOP), TRUE);
        EnableWindow ( GetDlgItem(hDlg, IDB_TBS_BOTTOM), TRUE);
    }

    if ( mask & TBS_TOP ) {
        CheckDlgButton ( hDlg, IDB_TBS_TOP, 1);
        CheckDlgButton ( hDlg, IDB_TBS_LEFT, 1);
    } else {
        CheckDlgButton ( hDlg, IDB_TBS_BOTTOM, 1);
        CheckDlgButton ( hDlg, IDB_TBS_RIGHT, 1);
    }

    if ( mask & TBS_ENABLESELRANGE ) {
        CheckDlgButton ( hDlg, IDB_TBS_ENABLESELRANGE, 1);
    }
    if ( mask & TBS_FIXEDLENGTH ) {
        CheckDlgButton ( hDlg, IDB_TBS_FIXEDLENGTH, 1);
    }
    if ( mask & TBS_NOTHUMB ) {
        CheckDlgButton ( hDlg, IDB_TBS_NOTHUMB, 1);
    }

    // set the extended style controls only
    WdeEXSetDefineInfo( o_info, hDlg );
#else
    _wde_touch(o_info);
    _wde_touch(hDlg);
#endif
}

void WdeTrakGetDefineInfo ( WdeDefineObjectInfo *o_info, HWND hDlg )
{
#ifdef __NT__XX
    DialogStyle mask = 0;
    BOOL        vert = FALSE;

    // get the track bar settings
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_AUTOTICKS ) ) {
        mask |= TBS_AUTOTICKS;
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_BOTH ) ) {
        mask |= TBS_BOTH;
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_NOTICKS ) ) {
        mask |= TBS_NOTICKS;
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_VERT ) ) {
        mask |= TBS_VERT;
        vert = TRUE;
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_TOP ) ) {
        if (!vert) {
            mask |= TBS_TOP;
        }
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_LEFT ) ) {
        if (vert) {
            mask |= TBS_LEFT;
        }
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_ENABLESELRANGE ) ) {
        mask |= TBS_ENABLESELRANGE;
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_FIXEDLENGTH ) ) {
        mask |= TBS_FIXEDLENGTH;
    }
    if ( IsDlgButtonChecked ( hDlg, IDB_TBS_NOTHUMB ) ) {
        mask |= TBS_NOTHUMB;
    }

    SETCTL_STYLE( o_info->info.c.info,
                  ( GETCTL_STYLE(o_info->info.c.info) & 0xffff0000 ) | mask );

    // get the extended control settings
    WdeEXGetDefineInfo ( o_info, hDlg );
#else
    _wde_touch(o_info);
    _wde_touch(hDlg);
#endif
}

BOOL WdeTrakDefineHook( HWND hDlg, UINT message,
                        WPARAM wParam, LPARAM lParam, DialogStyle mask )
{
#ifdef __NT__XX
    BOOL processed;
    BOOL flag;
    WORD wp;

    /* touch unused vars to get rid of warning */
    _wde_touch(mask);
    _wde_touch(lParam);

    processed = FALSE;

    if ( ( message == WM_COMMAND ) &&
         ( GET_WM_COMMAND_CMD(wParam,lParam) == BN_CLICKED ) ) {
        wp = LOWORD ( wParam );
        switch ( wp ) {
           case IDB_TBS_ONESIDE:
                if (IsDlgButtonChecked(hDlg,IDB_TBS_VERT)) {
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_RIGHT), TRUE );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_LEFT), TRUE );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_TOP), FALSE );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_BOTTOM), FALSE );
                } else {
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_RIGHT), FALSE );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_LEFT), FALSE );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_TOP), TRUE );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_BOTTOM), TRUE );
                }
                processed = TRUE;
                break;

           case IDB_TBS_BOTH:
           case IDB_TBS_NOTICKS:
                flag = TRUE;
                if (IsDlgButtonChecked(hDlg, IDB_TBS_BOTH) ||
                    IsDlgButtonChecked(hDlg, IDB_TBS_NOTICKS)) {
                    flag = FALSE;
                }
                EnableWindow ( GetDlgItem(hDlg, IDB_TBS_RIGHT), flag );
                EnableWindow ( GetDlgItem(hDlg, IDB_TBS_LEFT), flag );
                EnableWindow ( GetDlgItem(hDlg, IDB_TBS_TOP), flag );
                EnableWindow ( GetDlgItem(hDlg, IDB_TBS_BOTTOM), flag );
                processed = TRUE;
                break;

           case IDB_TBS_VERT:
                if (IsDlgButtonChecked(hDlg, IDB_TBS_ONESIDE)) {
                    flag = FALSE;
                    if (IsDlgButtonChecked(hDlg, IDB_TBS_VERT)) {
                        flag = TRUE;
                    }
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_RIGHT), flag );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_LEFT), flag );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_TOP), !flag );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_BOTTOM), !flag );
                }
                processed = TRUE;
                break;

           case IDB_TBS_HORZ:
                if (IsDlgButtonChecked(hDlg, IDB_TBS_ONESIDE)) {
                    flag = TRUE;
                    if (IsDlgButtonChecked(hDlg, IDB_TBS_HORZ)) {
                        flag = FALSE;
                    }
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_RIGHT), flag );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_LEFT), flag );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_TOP), !flag );
                    EnableWindow ( GetDlgItem(hDlg, IDB_TBS_BOTTOM), !flag );
                }
                processed = TRUE;
                break;

        }
    }

    return ( processed );
#else
    _wde_touch(hDlg);
    _wde_touch(message);
    _wde_touch(wParam);
    _wde_touch(lParam);
    _wde_touch(mask);
    return ( FALSE );
#endif
}

LRESULT WINEXPORT WdeTrakSuperClassProc( HWND hWnd, UINT message,
                                         WPARAM wParam,
                                         LPARAM lParam )
{
    if( !WdeProcessMouse( hWnd, message, wParam, lParam ) ) {
        return( CallWindowProc( WdeOriginalTrakProc,
                                 hWnd, message, wParam, lParam ) );
    }
    return( FALSE );
}


⌨️ 快捷键说明

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