Download this source

I take no responsibility for this source. It's freeware, do whatever you like with it.

This source show how to implement sliders in the windowborders. I use BOOPSI-gadgets for this task. I have an offscreen rastport bigger than window that I copy to the window. It's not perfect so I'm looking for someone who can tell what I do wrong.

;
#define INTUI_V36_NAMES_ONLY

#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/gadgetclass.h>
#include <intuition/icclass.h>

#include <clib/macros.h>

#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/layers.h>
#include <proto/utility.h>

#include <string.h>

#define BM_HEIGHT 400
#define BM_WIDTH  600

USHORT width,height;

/* Gadgets IDs */
enum
{
 DUMMY_SLIDER, GAD_VSLIDER, GAD_HSLIDER,
 GAD_COUNT
};

/* Images IDs */
enum
{
 IMG_UP, IMG_DOWN, IMG_LEFT, IMG_RIGHT, IMG_COUNT
};

static ULONG    ImgWidth[IMG_COUNT];
static ULONG    ImgHeight[IMG_COUNT];

struct RastPort rp;
struct TagItem bop2IDCMP[] = {{PGA_Top, ICSPECIAL_CODE },{TAG_DONE}};

void main()
{
  SHORT  rad,x = 0,y = 0;
 BOOL  quit = FALSE;
 ULONG  SizeWidth = 18, SizeHeight = 11; /* Default size */
  ULONG  id;
  struct IntuiMessage *msg;
 struct Screen *scr;
 struct Window *win;
 struct DrawInfo *drawinfo;
 struct Gadget *hslider, *vslider;
  struct RastPort rp;

  if(scr = LockPubScreen (NULL))
  {
    drawinfo = GetScreenDrawInfo (scr);

  if (vslider= NewObject (NULL, PROPGCLASS,
    GA_ID,   GAD_VSLIDER,
   GA_RelRight, - SizeWidth + 5,
    GA_Top,   scr->WBorTop + scr->Font->ta_YSize + 2,
    GA_Width,  SizeWidth - 8,
    GA_RelHeight, - (scr->WBorTop + scr->Font->ta_YSize +
      SizeHeight + ImgHeight[IMG_DOWN] + ImgHeight[IMG_UP] + 4),
   GA_RightBorder, TRUE,
    GA_DrawInfo, drawinfo,
    ICA_TARGET, ICTARGET_IDCMP,
     ICA_MAP, bop2IDCMP,
    PGA_Freedom, FREEVERT,
    PGA_Visible, BM_HEIGHT/2,
    PGA_Total, BM_HEIGHT,
    PGA_Borderless, ((drawinfo->dri_Flags & DRIF_NEWLOOK) && (drawinfo->dri_Depth != 1)),
    PGA_NewLook, TRUE, TAG_DONE))
  {
   if(hslider = NewObject(NULL, PROPGCLASS,
      GA_ID,   GAD_HSLIDER,
      GA_Previous, vslider,
    GA_RelBottom, - SizeHeight + ((SizeHeight > 15) ? 4 : 3),
    GA_Left,  scr->WBorLeft,
    GA_Height,  SizeHeight - ((SizeHeight > 15)  ? 6 : 4),
    GA_RelWidth, - (SizeWidth + ImgWidth[IMG_RIGHT] + ImgWidth[IMG_LEFT] + scr->WBorLeft + 2),
    GA_BottomBorder,TRUE,
    GA_DrawInfo, drawinfo,
      ICA_TARGET, ICTARGET_IDCMP,
       ICA_MAP, bop2IDCMP,
    PGA_Freedom, FREEHORIZ,
      PGA_Visible, BM_WIDTH/2,
      PGA_Total, BM_WIDTH,
     PGA_Borderless, ((drawinfo->dri_Flags & DRIF_NEWLOOK) && (drawinfo->dri_Depth != 1)),
      PGA_NewLook, TRUE, TAG_DONE))
     {
       InitRastPort(&rp);
        if(rp.BitMap = AllocBitMap(BM_WIDTH,BM_HEIGHT,GetBitMapAttr(scr->RastPort.BitMap,BMA_DEPTH),BMF_CLEAR | BMF_MINPLANES,scr->RastPort.BitMap))
       {
      if (win = OpenWindowTags (NULL,
        WA_Top, 0,
        WA_InnerWidth, BM_WIDTH/2,
       WA_InnerHeight, BM_HEIGHT/2,
        WA_PubScreen,  scr,
        WA_Gadgets,   vslider,
        WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_IDCMPUPDATE | IDCMP_REFRESHWINDOW,
        WA_Flags,   WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEGADGET | WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM |
            WFLG_CLOSEGADGET | WFLG_SIMPLE_REFRESH,
        WA_PubScreenFallBack, TRUE,
        WA_AutoAdjust,  TRUE,
        WA_Title, "Test",
       WA_MinWidth,  64,
        WA_MinHeight,  64,
        WA_MaxWidth,  BM_WIDTH,
       WA_MaxHeight,  BM_HEIGHT,
        TAG_DONE))
       {
         WindowLimits(win,0,0, BM_WIDTH + win->BorderLeft + win->BorderRight,
                               BM_HEIGHT + win->BorderTop + win->BorderBottom);
         width = win->GZZWidth;
         height= win->GZZHeight;

            SetAPen(&rp,1);

            for(rad=0;rad < BM_HEIGHT;rad +=10)
            {
              Move(&rp,0,rad);
              Draw(&rp,BM_WIDTH,rad);
            }
            for(rad=0;rad < BM_WIDTH;rad +=10)
            {
              Move(&rp,rad,0);
              Draw(&rp,rad,BM_HEIGHT);
            }

            Move(&rp,0,0);
            Draw(&rp,BM_WIDTH,BM_HEIGHT);


            Move(&rp,BM_WIDTH,0);
            Draw(&rp,0,BM_HEIGHT);

            BltBitMapRastPort(rp.BitMap,0,0,win->RPort,win->BorderLeft,win->BorderTop,width,height,0xC0);
         ScreenToFront(scr);
         while(!quit)
         {
           WaitPort(win->UserPort);
           while(msg = GT_GetIMsg(win->UserPort))
           {
             switch(msg->Class)
             {
                  case IDCMP_REFRESHWINDOW:
                 LockLayer(0,win->RPort->Layer);
                 width = win->GZZWidth;
                 height= win->GZZHeight;
                 BltBitMapRastPort(rp.BitMap,x,
                   (y + height) > BM_HEIGHT?BM_HEIGHT - height:y, 
                   win->RPort,win->BorderLeft,win->BorderTop,width,height,0xC0);
                 UnlockLayer(win->RPort->Layer);
                    SetGadgetAttrs(vslider,win,NULL,PGA_Visible,height,TAG_DONE);
                    SetGadgetAttrs(hslider,win,NULL,PGA_Visible,width ,TAG_DONE);
                    break;

               case IDCMP_CLOSEWINDOW:
                 quit = TRUE;
                 break;

                  case IDCMP_IDCMPUPDATE:
                    if(id = GetTagData(GA_ID, 0, msg->IAddress))
                    {
                      if(id == GAD_HSLIDER)
                      {
                        BltBitMapRastPort(rp.BitMap,msg->Code, (y + height) > BM_HEIGHT?BM_HEIGHT - height:y, win->RPort,win->BorderLeft,win->BorderTop, width,height, 0xC0);
                        x = msg->Code;
                      }
                      if(id == GAD_VSLIDER)
                      {
                        BltBitMapRastPort(rp.BitMap,x,msg->Code, win->RPort,win->BorderLeft,win->BorderTop, width,height, 0xC0);
                        y = msg->Code;
                      }
                    }
                }
                GT_ReplyIMsg(msg);
              }
            }
              CloseWindow(win);
            }
          ScreenToBack(scr);
            FreeBitMap(rp.BitMap);
         }
       DisposeObject(hslider);
      }
     DisposeObject(vslider); 
   }
    UnlockPubScreen (NULL, scr);
  }
}