/* Dialog-Procedure f�r die AboutBox (OS/2-Standard) */
MRESULT EXPENTRY AboutBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,MPARAM mp2)
{
   HWND  TextPos;
   IString textstr;
   SHORT i;
   ULONG   ulScrWidth, ulScrHeight;
   RECTL   Rectl;
   SWP     Swp;
   HPS     hps;

   switch(msg) {
   case WM_PAINT:
      hps = WinBeginPaint (hwnd,0,0);
      WinQueryWindowRect (hwnd, &Rectl);
      WinFillRect (hps, &Rectl, SYSCLR_DIALOGBACKGROUND);
      Rectl.yTop -= WinQuerySysValue(HWND_DESKTOP,SV_CYTITLEBAR),

      WinDrawBorder (hps, &Rectl,
          WinQuerySysValue(HWND_DESKTOP,SV_CXDLGFRAME),
          WinQuerySysValue(HWND_DESKTOP,SV_CYDLGFRAME),
          CLR_DARKGRAY, CLR_WHITE, DB_RAISED);
      GpiMove (hps, (PPOINTL)&Rectl);
      Rectl.xRight--;
      Rectl.yTop--;
      WinQueryWindowPos (WinWindowFromID (hwnd, IDD_ACOPYRIGHTFRAME), &Swp);
      Rectl.xLeft   = Swp.x-1;
      Rectl.yBottom = Swp.y-1;
      Rectl.xRight  = Swp.x + Swp.cx + 1;
      Rectl.yTop    = Swp.y + Swp.cy + 1;
      WinDrawBorder (hps, &Rectl, 1L, 1L,
          CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
      WinQueryWindowPos (WinWindowFromID (hwnd, IDD_APROGRAMFRAME), &Swp);
      Rectl.xLeft   = Swp.x-1;
      Rectl.yBottom = Swp.y-1;
      Rectl.xRight  = Swp.x + Swp.cx + 1;
      Rectl.yTop    = Swp.y + Swp.cy + 1;
      WinDrawBorder (hps, &Rectl, 1L, 1L,
          CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
      WinEndPaint (hps);
      break;
   case WM_COMMAND:
     /* no matter what the command, close the dialog */
      WinDismissDlg(hwnd, TRUE);
      break;

   default:
      return(WinDefDlgProc(hwnd, msg, mp1, mp2));
   }
   return(MPVOID);
}  /* AboutBoxWndProc() */
// disegna il controllo groupbox
MRESULT PaintGroupBox(HWND hwnd) {
   PCTL pgb = stGetData(hwnd);
   if (pgb) {
      RECTL rcl = {0, 0, pgb->wr.cx, pgb->wr.cy};
      HPS hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
      ULONG brd = pgb->fl & 0x7;
      ULONG frm = brd;
      GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
      // disegna bordo groupbox
      WinDrawBorder(hps, &rcl, brd, brd, 0, 0,
                    (pgb->fl & CCTL_RAISED? 0x400: 0x800));
      // se necessario disegnare anche frame
      if (pgb->fl & CCTL_FRAME6) {
         frm = brd * ((pgb->fl & 0x38) >> 3);
         rcl.xLeft = frm;
         rcl.yBottom = frm;
         rcl.xRight -= frm; 
         rcl.yTop -= frm; 
         WinDrawBorder(hps, &rcl, brd, brd, 0, 0,
                       (pgb->fl & CCTL_RAISED? 0x800: 0x400));
      } /* endif */
      // se il testo Š presente
      if (pgb->psz) {
         // cancella background
         rcl.xLeft = frm;
         rcl.yBottom = pgb->wr.cy - pgb->cyFont - 2 * frm - 2;
         rcl.xRight = pgb->wrtxt.cx + 2 * frm + 3;
         rcl.yTop = pgb->wr.cy - frm;
         WinFillRect(hps, &rcl, pgb->lbkgnd);
         // disegna testo
         rcl.yBottom += 2;
         WinDrawText(hps, -1, pgb->psz, &rcl, pgb->lfgnd, pgb->lbkgnd,
                     DT_CENTER | DT_TOP | DT_MNEMONIC | DT_EXTERNALLEADING |
                     ((pgb->fl & WS_DISABLED)? DT_HALFTONE: 0));
         // disegna bordo inferiore e a destra del testo
         rcl.yBottom -= 2;
         GpiSetColor(hps, (pgb->fl & CCTL_RAISED? pgb->lshadow: pgb->lhilite));
         GpiMove(hps, (PPOINTL)&rcl);
         rcl.xLeft = rcl.xRight;
         rcl.yTop -= 1;
         GpiPolyLine(hps, 2, (PPOINTL)&rcl);
      } /* endif */
      WinEndPaint(hps);
   } /* endif */
static MRESULT handleDragLeave(HWND hwnd, MPARAM mp1, MPARAM mp2)
{
  RECTL rectl;
  SWP swp;
  HPS hps;

  /* Remove target emphasis here */
  hps=DrgGetPS(hwnd);
  WinDrawBorder(hps,&rclDrawn, 2, 2, 0, 0, DB_STANDARD|DB_PATINVERT);  
  DrgReleasePS(hps);
  bDrawn=FALSE; 
  return (MRESULT) FALSE;
}
/*@ XToolBar::Draw(void)
@group display
@remarks Redraw the toolbar.
*/
void XToolBar::Draw(void)
{
   RECTL rect;
   WinQueryWindowRect(winhandle, &rect);
   HPS hps = WinGetPS(winhandle);
   GpiCreateLogColorTable(hps, LCOL_RESET, LCOLF_RGB, 0,0,NULL);
   WinFillRect( hps, &rect, SYSCLR_BUTTONMIDDLE);
   WinDrawBorder(hps, &rect, 1,1,0,0,DB_PATCOPY|DB_RAISED);
   HENUM e;
   HWND hwnd;

   e = WinBeginEnumWindows(winhandle);
   while ((hwnd = WinGetNextWindow(e)) != 0)
      WinInvalidateRegion(hwnd, NULLHANDLE, TRUE);
   WinEndEnumWindows(e);
}
/*------------------------------------------------------------------------*/
MRESULT EXPENTRY SplashWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
   static HBITMAP hbm;
   static SWP     swp;
   HPS    hps;
   RECTL  rcl;

   switch(msg)
   {
      case WM_CREATE:
         hps = WinGetPS (hwnd);
         hbm = GpiLoadBitmap(hps,
                             (HMODULE)0L,
                             IDB_LOGO,
                             (ULONG)0,
                             (ULONG)0);
         WinReleasePS (hps);

         WinQueryWindowPos(hwnd, (PSWP)&swp);
         return (MRESULT)0;

      case WM_PAINT:
         hps = WinBeginPaint (hwnd, 
                              NULLHANDLE,  /* Get a cached PS */
                              (RECTL *)0);
         GpiErase (hps);
         
         GpiCreateLogColorTable (hps, LCOL_RESET, LCOLF_RGB,
                                 0L, 0L, NULL) ;
         rcl.xLeft   = 0;
         rcl.yBottom = 0;
         rcl.xRight  = swp.cx;
         rcl.yTop    = swp.cy;

         if ( hbm )
            WinDrawBitmap(hps,hbm, NULL, (PPOINTL) &rcl,
                          CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH );

         WinDrawBorder(hps, &rcl,2L,2L,0L, 0L, DB_DEPRESSED);
         WinEndPaint(hps);
         return (MRESULT)0;


   }
   return( WinDefWindowProc(hwnd, msg, mp1, mp2) );
}
MRESULT drawSlider(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, USHORT id)
{
  POWNERITEM poi;

  RECTL rcl;
  POINTL ptl= {0};

  poi=(POWNERITEM)PVOIDFROMMP(mp2);

  switch(poi->idItem)
    {
    case SDA_SLIDERARM:

      WinFillRect(poi->hps,&poi->rclItem, CLR_RED);
      WinDrawBorder(poi->hps,&poi->rclItem, 2, 2, 0, 0 ,0x0400);

      return (MRESULT) TRUE;
      break;
    case SDA_BACKGROUND:
      {
        HPS hps;

        WinFillRect(poi->hps,&poi->rclItem, CLR_WHITE);

        return (MRESULT) TRUE;
      }
    case SDA_SLIDERSHAFT:
      {
        HPS hps;
        RECTL rcl;
        MRESULT mr;

        WinFillRect(poi->hps,&poi->rclItem, CLR_BLUE);

        return (MRESULT)TRUE;
      }
    default:
      return (MRESULT)TRUE;
    }

  /* Done */
  return (MRESULT)TRUE;
}
static MRESULT handleDragOver(HWND hwnd, MPARAM mp1, MPARAM mp2)
{
  MRESULT mResult;
  ULONG ulNumberOfObjects;
  PDRAGINFO pDragInfo;
  HPS hps;
  RECTL rectl;
  SWP swp;

  mResult = MRFROM2SHORT( DOR_NODROPOP, DO_LINK);
  
  /* Get access to the dragInfo */
  pDragInfo=(PDRAGINFO)mp1;
  DrgAccessDraginfo(pDragInfo);
  /* Get number of items */
  ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo);

  if(ulNumberOfObjects>1) {
    /* Free the draginfo */
    DrgFreeDraginfo(pDragInfo);
    return MRFROM2SHORT( DOR_NODROPOP, DO_LINK);
  }

  switch(pDragInfo->usOperation)
    {
    case DO_DEFAULT:
    case DO_LINK:
      if(!bDrawn) {
        POINTL ptl;
        launchPad * lp;
        
        ptl.x=SHORT1FROMMP(mp2);
        ptl.y=SHORT2FROMMP(mp2);
        /* Pos in window coords */
        WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);

        hps=DrgGetPS(hwnd);
        WinQueryWindowPos(hwnd,&swp);

        rectl.xLeft=swp.cx;//-swp.cy;

        lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
        if(lp) {
          if(lp->lpQueryNumObjects()==0) {
            rectl.xLeft=0;
          }
        }
        
        rectl.yTop=swp.cy-1;    
        rectl.yBottom=1;
        if(ptl.x<rectl.xLeft) {
          int numB;

          numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta);
          rectl.xLeft=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB);
          rectl.xLeft*=(swp.cy+xButtonDelta);
          rectl.xLeft-=(xButtonDelta)-xButtonOffset+xButtonDelta;
          rectl.xRight=rectl.xLeft+(xButtonDelta*2);
        }
        else {
          rectl.xRight=swp.cx-1;
        }
        rclDrawn=rectl;
        WinDrawBorder(hps,&rectl, 2, 2, 0, 0, DB_STANDARD|DB_PATINVERT);  
        bDrawn=TRUE; 
        
        DrgReleasePS(hps);
      }
      mResult = MRFROM2SHORT( DOR_DROP, DO_LINK);
      break;
    default:
      break;
    }

  /* Free the draginfo */
  DrgFreeDraginfo(pDragInfo);

  return mResult;
}
Example #8
0
void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg )
{
    HDC         prev_hdc;
    PAINTSTRUCT *prev_ps;
    gui_row_num row_num;
    PAINTSTRUCT ps;
    WPI_RECT    fill_area;
#ifdef __OS2_PM__
    ULONG       flags;
    RECTL       client;
#endif

    isdlg=isdlg;
    /* save old state */
    prev_hdc = wnd->hdc;
    prev_ps = wnd->ps;

    /* Setup Paint */
    wnd->ps = &ps;
    wnd->hdc = _wpi_beginpaint( hwnd, NULLHANDLE, wnd->ps );
    _wpi_torgbmode( wnd->hdc );
    _wpi_getpaintrect( wnd->ps, &fill_area );
#ifdef __OS2_PM__
    fill_area = *(wnd->ps);
    if( isdlg ) {
        _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10);
    }
    WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) );
#endif
#if defined( __NT__ )
    if( isdlg ) {
        _wpi_fillrect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ),
                       wnd->bk_brush );
    }
#endif
    if( wnd->font != NULL ) {
        wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font );
    } else {
        wnd->prev_font = NULL;
    }

    /* send paint to app */
    GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num );
    if( row_num.num > 0 ) {
        GUIEVENTWND( wnd, GUI_PAINT, &row_num );
    }

    /* finish painting */
    if( wnd->prev_font != NULL ) {
        _wpi_getoldfont( wnd->hdc, wnd->prev_font );
        wnd->prev_font = NULL;
    }

#ifdef __OS2_PM__
    if( isdlg ) {
        flags = DB_AREAATTRS | DB_DLGBORDER;
  #ifdef _M_I86
        if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) {
  #else
        if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) {
  #endif
        //if( _wpi_getfocus() != hwnd ) {
            flags |= DB_PATINVERT;
        }
        WinQueryWindowRect( hwnd, &client );
        WinDrawBorder( wnd->hdc, &client, 1, 1, 0, 0, flags );
    }
#endif

    _wpi_endpaint( hwnd, wnd->hdc, wnd->ps );

    /* restore old state */
    wnd->hdc = prev_hdc;
    wnd->ps = prev_ps;
}

#else

// this is some experimental PM stuff
void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg )
{
    HDC         prev_hdc;
    PAINTSTRUCT *prev_ps;
    gui_row_num row_num;
    PAINTSTRUCT ps;
    PAINTSTRUCT fill_area;

    // experimenal stuff
    HPS                 hps;
    RECTL               client;
    LONG                width, height;
    ULONG               flags;
    int                 compat_created;
    gui_paint_info      *pinfo;

    // figure out which paint info to use
    if( !isdlg && wnd->root == hwnd ) {
        pinfo = &wnd->root_pinfo;
    } else {
        pinfo = &wnd->hwnd_pinfo;
    }
    pinfo->in_use++;
    compat_created = FALSE;

    /* save old state */
    prev_hdc = wnd->hdc;
    prev_ps = wnd->ps;
    if( isdlg ) {
        _wpi_getclientrect( hwnd, &client );
    } else {
        WinQueryWindowRect( hwnd, &client );
    }
    width = client.xRight - client.xLeft;
    height = client.yTop - client.yBottom;

    wnd->ps = &ps;
    //hps = _wpi_beginpaint( hwnd, pinfo->normal_pres, wnd->ps );
    hps = _wpi_beginpaint( hwnd, NULL, wnd->ps );
    if( pinfo->compatible_pres == (WPI_PRES)NULL ) {
        compat_created = TRUE;
        pinfo->compatible_pres = _wpi_createcompatiblepres( hps, GUIMainHInst, &pinfo->compatible_hdc );
        pinfo->draw_bmp = _wpi_createcompatiblebitmap( hps, width, height );
        pinfo->old_bmp = _wpi_selectbitmap( pinfo->compatible_pres, pinfo->draw_bmp );
    }

    // the condition is here VERY conservative!!
    // its gains have to analyzed
    if( compat_created || pinfo->force_count ) {
        wnd->hdc = pinfo->compatible_pres;
        //wnd->hdc = hps;
        _wpi_torgbmode( wnd->hdc );
        fill_area = *(wnd->ps);
        if( isdlg ) {
            _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10);
        }
        WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) );
        wnd->prev_font = NULL;
        if( wnd->font != NULL ) {
            wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font );
        }

        /* send paint to app */
        GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num );
        if( row_num.num > 0 ) {
            GUIEVENTWND( wnd, GUI_PAINT, &row_num );
        }

        /* finish painting */
        if( wnd->prev_font != NULL ) {
            _wpi_getoldfont( wnd->hdc, wnd->prev_font );
            wnd->prev_font = NULL;
        }

        if( pinfo->force_count ) {
            //pinfo->force_count--;
        }
    }

    //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height,
    //       wnd->hdc, 0, 0, SRCCOPY );

    if( pinfo->in_use == 1 ) {
        //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height,
        //               wnd->hdc, 0, 0, SRCCOPY );
        _wpi_bitblt( hps, ps.xLeft, ps.yBottom,
                     ps.xRight - ps.xLeft,
                     ps.yTop - ps.yBottom,
                     wnd->hdc,
                     ps.xLeft, ps.yBottom,
                     SRCCOPY );
        if( pinfo->delete_when_done ) {
            GUIFreePaintHandles( pinfo, TRUE );
        }
    }

    if( isdlg ) {
        flags = DB_AREAATTRS | DB_DLGBORDER;
  #ifdef _M_I86
        if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) {
  #else
        if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) {
  #endif
        //if( _wpi_getfocus() != hwnd ) {
            flags |= DB_PATINVERT;
        }
        WinQueryWindowRect( hwnd, &client );
        WinDrawBorder( hps, &client, 1, 1, 0, 0, flags );
    }

    _wpi_endpaint( hwnd, hps, wnd->ps );

    /* restore old state */
    wnd->hdc = prev_hdc;
    wnd->ps = prev_ps;

    if( pinfo->in_use ) {
        pinfo->in_use--;
    }
}

#endif

void GUIInvalidatePaintHandles( gui_window *wnd )
{
    GUIFreeWndPaintHandles( wnd, FALSE );
}
/* This Proc handles the on-the-fly data CD writing */
MRESULT EXPENTRY waveinfoStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH*2 +10];
  char title[CCHMAXPATH];
  SWCNTRL swctl;
  PID pid;
  int a;


  switch (msg)
    {
    case WM_PAINT:
      {
        HPS hps;
        RECTL rcl, rclSource;
        POINTL ptl;
        LONG lTemp;
        BOOL bUseCustomPainting=TRUE;
        LONG lWidthX;
        LONG lWidthY;
        LONG  lColor;
        ULONG attrFound;


        if(bUseCustomPainting) {
          //          if(allBMPs[CTRLIDX_BG].hbm) {
          if(1) {
            hps=WinBeginPaint(hwnd, NULLHANDLE, &rcl);
            rclSource.xLeft=0;
            rclSource.yBottom=0;
#if 0
            rclSource.yTop=allBMPs[CTRLIDX_BG].bmpInfoHdr.cy;
            rclSource.xRight=allBMPs[CTRLIDX_BG].bmpInfoHdr.cx;
            lTemp=rcl.xLeft/rclSource.xRight;
            ptl.x=lTemp*rclSource.xRight;
            lTemp=rcl.yBottom/rclSource.yTop;
            lTemp*=rclSource.yTop;
#endif

            //    rcl.yBottom+=4;
            rclSource=rcl;
            rcl.yTop+=4;
            WinFillRect(hps, &rclSource, CLR_RED);

            /* Border */
            lWidthX=WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER);
            lWidthY=WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER);

            GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
#if 0
        if ( (WinQueryPresParam(hwnd, PP_BACKGROUNDCOLOR, 0, &attrFound, sizeof(attrFound),
                                                &lColor, QPF_PURERGBCOLOR)) == 0 )
           lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
#endif

            WinQueryWindowRect(hwnd, &rcl);
            ptl.x=1;
            ptl.y=0;
            GpiMove(hps, &ptl);
            GpiSetColor(hps, CLR_BLACK);
            ptl.x=rcl.xRight-1;
            GpiLine(hps,&ptl);
            ptl.y=rcl.yTop-1;
            GpiLine(hps,&ptl);
            GpiSetColor(hps, SYSCLR_SHADOW);
            ptl.x=rcl.xLeft;
            GpiLine(hps,&ptl);
            ptl.y=0;
            GpiLine(hps,&ptl);

            rcl.yTop-=1;
            rcl.yBottom+=1;
            rcl.xLeft+=1;
            rcl.xRight-=1;

            WinDrawBorder( hps,&rcl, 1, 1, 0, 0, 0x400);
            rcl.yTop-=1;
            rcl.yBottom+=1;
            rcl.xLeft+=1;
            rcl.xRight-=1;

            /* Get active border color */
            if(WinQueryActiveWindow(HWND_DESKTOP)==hwnd) {
              if ( (WinQueryPresParam(hwnd, PP_BORDERCOLOR, 0, &attrFound, sizeof(attrFound),
                                      &lColor, QPF_PURERGBCOLOR)) == 0 )
                lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
            }
            else {
              /* Inactive border color */
              if ( (WinQueryPresParam(hwnd, PP_INACTIVECOLOR, 0, &attrFound, sizeof(attrFound),
                                      &lColor, QPF_PURERGBCOLOR)) == 0 )
                lColor = WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0);
            }
            /*            Get Border size */
            WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP(&ptl),0);

            WinDrawBorder(hps,&rcl, ptl.x-2, ptl.y-2, lColor, 0, 0);

#if 0
            while(ptl.x<rcl.xRight) {
              ptl.y=lTemp;
              while(ptl.y<rcl.yTop) {/* y direction */
                //DosBeep(5000,100);
                WinDrawBitmap(hps, allBMPs[CTRLIDX_BG].hbm,
                              &rclSource, 
                              (PPOINTL)&ptl,
                              0, 0,
                              DBM_IMAGEATTRS);
                ptl.y+=allBMPs[CTRLIDX_BG].bmpInfoHdr.cy;
                //DosSleep(200);
              };
              ptl.x+=allBMPs[CTRLIDX_BG].bmpInfoHdr.cx; 
            };
#endif
            WinEndPaint(hps);
            return (MRESULT)0;
          }
        }
        break;
      }

    case WM_DRAWITEM:
      switch(SHORT1FROMMP(mp1))
        {
        case SLIDERID:
          return drawSlider(hwnd, msg, mp1, mp2, SHORT1FROMMP(mp1));
        default:
          break;
        }              
      break;
    case WM_INITDLG:
      /* Add switch entry */
      memset(&swctl,0,sizeof(swctl));
      WinQueryWindowProcess(hwnd,&pid,NULL);
      swctl.hwnd=hwnd;
      swctl.uchVisibility=SWL_VISIBLE;
      swctl.idProcess=pid;
      swctl.bProgType=PROG_DEFAULT;
      swctl.fbJump=SWL_JUMPABLE;
      WinAddSwitchEntry(&swctl);

#if 0      
      WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, "",
                     "",
                     0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
#endif
      //      oldProc=WinSubclassWindow(WinWindowFromID(hwnd, IDST_TEXT), newProc);
      hwndNew=WinCreateWindow(hwnd, CLASS_NAME, "Title", WS_VISIBLE |WS_TABSTOP, 10,50, SLIDERID, 40, 
                              hwnd, HWND_TOP, SLIDERID, NULLHANDLE, NULLHANDLE);
      WinShowWindow(hwnd, TRUE);
      //      WinQueryWindowPos(hwndNew,&swpSl);
      return (MRESULT) TRUE;
      /* WM_APPTERMINATENOTIFY messages are sent from the helper programs e.g. format checker. */
    case WM_CLOSE:
      WinDismissDlg(hwnd,0);
      return FALSE;
    case WM_CONTROL:
      {
        switch(SHORT2FROMMP(mp1))
          {
          case SLN_SLIDERTRACK:
            {
              switch(SHORT1FROMMP(mp1))
                {
                case SLIDERID:
                  DosBeep(5000, 10);
                  break;
                default:
                  break;
                }/* switch */
              return (MRESULT) 0;
              break;
            }
          case SLN_CHANGE:
            {
              switch(SHORT1FROMMP(mp1))
                {
                case SLIDERID:
                  DosBeep(500, 100);
                  break;
                default:
                  break;
                }/* switch */
              return (MRESULT)TRUE;
            }
          default:
            break;
          }/* switch */
        break;
      }/* WM_CONTROL */
      
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case DID_OK:
          /* User pressed the OK button */
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          break;
        case IDPB_RIGHT:
          WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
                      SLM_SETSLIDERINFO,
                      MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                      MPFROMLONG( (LONG) 70 ));
          
          break;
        case IDPB_LEFT:
          WinPostMsg( WinWindowFromID(hwnd, SLIDERID),
                      SLM_SETSLIDERINFO,
                      MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                      MPFROMLONG( (LONG) 20 ));
          
          break;
        case IDPB_SIZE:
          {
            SWP swp;
              RXSTRING arg[2];                       /* argument string for REXX  */
              RXSTRING rexxretval;                /* return value from REXX    */
              APIRET   rc;                        /* return code from REXX     */
              SHORT    rexxrc = 0;                /* return code from function */
              char chrThis[20];
              char chrHwnd[20];

              char    *str = "These words will be swapped"; /* text to swap   */

#if 0
              RexxRegisterFunctionExe("CWRXFunc1", (PFN)rexxFunc1);
              

              sprintf(chrThis, "%d",123);
              sprintf(chrHwnd, "%d", WinQueryWindow(hwnd,QW_PARENT));

              /* By setting the strlength of the output RXSTRING to zero, we   */
              /* force the interpreter to allocate memory and return it to us. */
              /* We could provide a buffer for the interpreter to use instead. */
              rexxretval.strlength = 0L;          /* initialize return to empty*/
              
              MAKERXSTRING(arg[0], chrHwnd, strlen(chrHwnd));/* create input argument     */
              MAKERXSTRING(arg[1], chrThis, strlen(chrThis));/* create input argument     */

              /* Here we call the interpreter.  We don't really need to use    */
              /* all the casts in this call; they just help illustrate         */
              /* the data types used.                                          */
              rc=RexxStart((LONG)      2,             /* number of arguments   */
                           (PRXSTRING)  &arg,          /* array of arguments    */
                           (PSZ)        "G:\\Projects_working\\mmclasses-0.3.0\\testfunc.cwr",/* name of REXX file     */
                           (PRXSTRING)  0,             /* No INSTORE used       */
                           (PSZ)        "CWRXX",         /* Command env. name     */
                           (LONG)       RXSUBROUTINE,  /* Code for how invoked  */
                           (PRXSYSEXIT) 0,             /* No EXITs on this call */
                           (PSHORT)     &rexxrc,       /* Rexx program output   */
                           (PRXSTRING)  &rexxretval ); /* Rexx program output   */

              sprintf(text,"rc: %d, function return code: %d, %s ", 
                      rc, (int) rexxrc, rexxretval.strptr);

              WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_OK|MB_MOVEABLE);
              
              DosFreeMem(rexxretval.strptr);          /* Release storage       
                                                         given to us by REXX.  */
              
#endif

              //            WinQueryWindowPos(hwndNew,&swp);
              //    WinSetWindowPos(hwndNew, NULLHANDLE, 0, 0, swp.cx-30, swp.cy+10,SWP_SIZE);
          break;
          }
        default:
          break;
        }
      return (MRESULT) FALSE;
    default:
      break;
    }/* switch */
  
  return WinDefDlgProc( hwnd, msg, mp1, mp2);
}
// -------------------------------------------------------------------------
MRESULT EXPENTRY ClientWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  #define DB_RAISED    0x0400
  #define DB_DEPRESSED 0x0800

  switch (msg) {
    case WM_CREATE:
      break;
    case WM_CONTROL:
      if ( SHORT1FROMMP(mp1) == FID_MENU ){
        if ( SHORT2FROMMP(mp1) == UCN_ITEMSELECTED ){
          PUCMITEM pucmi = (PUCMITEM)mp2;
          if (pucmi) {
            HWND hwndOwner = OWNERWND(hwnd);
            WinSendMsg( hwndOwner, WM_COMMAND,
                        MPFROMSHORT(pucmi->usId), MPFROMSHORT(CMDSRC_MENU) );
          }
        }
      }
      break;

    case WM_PAINT:
      {
      RECTL rcl;
      HPS hPS = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)0 );
      WinQueryWindowRect( hwnd, &rcl );
      rcl.yBottom = rcl.yTop - 8;
      GpiErase( hPS );
      WinDrawBorder( hPS, &rcl, 2, 2, CLR_DARKGRAY, CLR_PALEGRAY, DB_RAISED );
      WinEndPaint( hPS );
      }
      break;

    case WM_BUTTON1DOWN :
    case WM_BUTTON2DOWN :
      {
      TRACKINFO track;
      SWP       swp;
      RECTL     rclOld;
      HWND      hwndMenu = WinWindowFromID(hwnd, ID_TOOLS);

      WinSetWindowPos( hwndMenu, HWND_TOP, 0, 0, 0, 0, SWP_MOVE );
      RECTL rcl;
      WinQueryWindowRect( hwnd, &rcl );
      rcl.yBottom = rcl.yTop - 8;
      HPS hps = WinGetPS( hwnd );
      WinDrawBorder( hps, &rcl, 2, 2, CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED );
      WinReleasePS( hps );

      #define BORDER 2
      track.cxBorder = track.cyBorder = BORDER;
      track.cxGrid = track.cyGrid = 1;
      track.cxKeyboard = track.cyKeyboard = 4;

      WinQueryWindowPos( hwnd, &swp );
      rclOld.xLeft = swp.x - BORDER;
      rclOld.yBottom = swp.y - BORDER;
      rclOld.xRight = swp.x + swp.cx + BORDER;
      rclOld.yTop = swp.y + swp.cy + BORDER;
      track.rclTrack = rclOld;

      WinQueryWindowRect( PARENTWND(hwnd), &track.rclBoundary );

      track.ptlMinTrackSize.x = track.ptlMinTrackSize.y = 1;  //2*BOXLET_SIZE;
      track.ptlMaxTrackSize   = *(PPOINTL)&track.rclBoundary.xRight;
      track.fs = TF_MOVE;

      if (  WinTrackRect( PARENTWND(hwnd), NULLHANDLE, &track) )
        WinSetWindowPos( hwnd, HWND_TOP,
                         track.rclTrack.xLeft+BORDER, track.rclTrack.yBottom+BORDER,
                         0, 0, SWP_MOVE );
      WinInvalidateRect(hwnd, &rcl, TRUE);
      }
      break;

    default:
      return(WinDefWindowProc(hwnd, msg, mp1, mp2));
  }
  return 0;
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static INT aiPuzzle[NUMROWS][NUMCOLS],
                iBlankRow, iBlankCol, cxSquare, cySquare ;
     CHAR       szNum[10] ;
     HPS        hps ;
     HWND       hwndFrame ;
     INT        iRow, iCol, iMouseRow, iMouseCol, i ;
     POINTL     ptl ;
     RECTL      rcl, rclInvalid, rclIntersect ;
     SIZEL      sizl ;

     switch (msg)
          {
          case WM_CREATE:
                              // Calculate square size in pixels

               hps = WinGetPS (hwnd) ;
               sizl.cx = sizl.cy = 0 ;
               GpiSetPS (hps, &sizl, PU_LOENGLISH) ;
               ptl.x = SQUARESIZE ;
               ptl.y = SQUARESIZE ;
               GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ;
               WinReleasePS (hps) ;

               cxSquare = ptl.x ;
               cySquare = ptl.y ;

                              // Calculate client window size and position

               rcl.xLeft   = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) -
                                           NUMCOLS * cxSquare) / 2 ;
               rcl.yBottom = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) -
                                           NUMROWS * cySquare) / 2 ;
               rcl.xRight  = rcl.xLeft   + NUMCOLS * cxSquare ;
               rcl.yTop    = rcl.yBottom + NUMROWS * cySquare ;

                              // Set frame window position and size

               hwndFrame = WinQueryWindow (hwnd, QW_PARENT) ;
               WinCalcFrameRect (hwndFrame, &rcl, FALSE) ;
               WinSetWindowPos  (hwndFrame, NULLHANDLE,
                                 rcl.xLeft, rcl.yBottom,
                                 rcl.xRight - rcl.xLeft,
                                 rcl.yTop - rcl.yBottom,
                                 SWP_MOVE | SWP_SIZE | SWP_ACTIVATE) ;

                              // Initialize the aiPuzzle array

               WinSendMsg (hwnd, WM_COMMAND, MPFROMSHORT (IDM_NORMAL), NULL) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, &rclInvalid) ;

                              // Draw the squares

               for (iRow = NUMROWS - 1 ; iRow >= 0 ; iRow--)
                    for (iCol = 0 ; iCol < NUMCOLS ; iCol++)
                         {
                         rcl.xLeft   = cxSquare * iCol ;
                         rcl.yBottom = cySquare * iRow ;
                         rcl.xRight  = rcl.xLeft   + cxSquare ;
                         rcl.yTop    = rcl.yBottom + cySquare ;

                         if (!WinIntersectRect (0, &rclIntersect,
                                                &rcl, &rclInvalid))
                              continue ;

                         if (iRow == iBlankRow && iCol == iBlankCol)
                              WinFillRect (hps, &rcl, CLR_BLACK) ;
                         else
                              {
                              WinDrawBorder (hps, &rcl, 5, 5,
                                             CLR_PALEGRAY, CLR_DARKGRAY,
                                             DB_STANDARD | DB_INTERIOR) ;

                              WinDrawBorder (hps, &rcl, 2, 2,
                                             CLR_BLACK, 0L, DB_STANDARD) ;

                              sprintf (szNum, "%d", aiPuzzle[iRow][iCol]) ;

                              WinDrawText (hps, -1, szNum,
                                           &rcl, CLR_WHITE, CLR_DARKGRAY,
                                           DT_CENTER | DT_VCENTER) ;
                              }
                         }
               WinEndPaint (hps) ;
               return 0 ;

          case WM_BUTTON1DOWN:
               iMouseCol = MOUSEMSG(&msg)->x / cxSquare ;
               iMouseRow = MOUSEMSG(&msg)->y / cySquare ;

                              // Check if mouse was in valid area

               if ( iMouseRow < 0          || iMouseCol < 0           ||
                    iMouseRow >= NUMROWS   || iMouseCol >= NUMCOLS    ||
                   (iMouseRow != iBlankRow && iMouseCol != iBlankCol) ||
                   (iMouseRow == iBlankRow && iMouseCol == iBlankCol))
                         break ;

                              // Move a row right or left

               if (iMouseRow == iBlankRow)
                    {
                    if (iMouseCol < iBlankCol)
                         for (iCol = iBlankCol ; iCol > iMouseCol ; iCol--)
                              aiPuzzle[iBlankRow][iCol] =
                                   aiPuzzle[iBlankRow][iCol - 1] ;
                    else
                         for (iCol = iBlankCol ; iCol < iMouseCol ; iCol++)
                              aiPuzzle[iBlankRow][iCol] =
                                   aiPuzzle[iBlankRow][iCol + 1] ;
                    }
                              // Move a column up or down
               else
                    {
                    if (iMouseRow < iBlankRow)
                         for (iRow = iBlankRow ; iRow > iMouseRow ; iRow--)
                              aiPuzzle[iRow][iBlankCol] =
                                   aiPuzzle[iRow - 1][iBlankCol] ;
                    else
                         for (iRow = iBlankRow ; iRow < iMouseRow ; iRow++)
                              aiPuzzle[iRow][iBlankCol] =
                                   aiPuzzle[iRow + 1][iBlankCol] ;
                    }
                              // Calculate invalid rectangle

               rcl.xLeft   = cxSquare *  min (iMouseCol, iBlankCol) ;
               rcl.yBottom = cySquare *  min (iMouseRow, iBlankRow) ;
               rcl.xRight  = cxSquare * (max (iMouseCol, iBlankCol) + 1) ;
               rcl.yTop    = cySquare * (max (iMouseRow, iBlankRow) + 1) ;

                              // Set new array and blank values

               iBlankRow = iMouseRow ;
               iBlankCol = iMouseCol ;
               aiPuzzle[iBlankRow][iBlankCol] = 0 ;

                              // Invalidate rectangle

               WinInvalidateRect (hwnd, &rcl, FALSE) ;
               break ;

          case WM_CHAR:
               if (!(CHARMSG(&msg)->fs & KC_VIRTUALKEY) ||
                     CHARMSG(&msg)->fs & KC_KEYUP)
                         return 0 ;

                              // Mimic a WM_BUTTON1DOWN message

               iMouseCol = iBlankCol ;
               iMouseRow = iBlankRow ;

               switch (CHARMSG(&msg)->vkey)
                    {
                    case VK_LEFT:   iMouseCol++ ;  break ;
                    case VK_RIGHT:  iMouseCol-- ;  break ;
                    case VK_UP:     iMouseRow-- ;  break ;
                    case VK_DOWN:   iMouseRow++ ;  break ;
                    default:        return 0 ;
                    }
               WinSendMsg (hwnd, WM_BUTTON1DOWN,
                           MPFROM2SHORT (iMouseCol * cxSquare,
                                         iMouseRow * cySquare), NULL) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                              // Initialize aiPuzzle array

                    case IDM_NORMAL:
                    case IDM_INVERT:
                         for (iRow = 0 ; iRow < NUMROWS ; iRow++)
                              for (iCol = 0 ; iCol < NUMCOLS ; iCol++)
                                   aiPuzzle[iRow][iCol] = iCol + 1 +
                                        NUMCOLS * (NUMROWS - iRow - 1) ;

                         if (COMMANDMSG(&msg)->cmd == IDM_INVERT)
                              {
                              aiPuzzle[0][NUMCOLS-2] = NUMCOLS * NUMROWS - 2 ;
                              aiPuzzle[0][NUMCOLS-3] = NUMCOLS * NUMROWS - 1 ;
                              }
                         aiPuzzle[iBlankRow = 0][iBlankCol = NUMCOLS - 1] = 0 ;
                         WinInvalidateRect (hwnd, NULL, FALSE) ;
                         return 0 ;

                              // Randomly scramble the squares

                    case IDM_SCRAMBLE:
                         WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (
                                        HWND_DESKTOP, SPTR_WAIT, FALSE)) ;

                         srand ((int) WinGetCurrentTime (0)) ;

                         for (i = 0 ; i < SCRAMBLEREP ; i++)
                              {
                              WinSendMsg (hwnd, WM_BUTTON1DOWN,
                                   MPFROM2SHORT (rand() % NUMCOLS * cxSquare,
                                        iBlankRow * cySquare), NULL) ;
                              WinUpdateWindow (hwnd) ;

                              WinSendMsg (hwnd, WM_BUTTON1DOWN,
                                   MPFROM2SHORT (iBlankCol * cxSquare,
                                        rand() % NUMROWS * cySquare), NULL) ;
                              WinUpdateWindow (hwnd) ;
                              }
                         WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (
                                        HWND_DESKTOP, SPTR_ARROW, FALSE));
                         return 0 ;
                    }
               break ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
Example #12
0
MRESULT EXPENTRY EDBarWinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   switch (msg) {
      // creazione: memorizza testo controllo
      case WM_CREATE: {
         PBARDATA pbd;
         // allocate structure for caching some control data
         if (!(pbd = (PBARDATA)malloc(sizeof(BARDATA)))) return NULL;
         // se presente testo lo azzera
         if (strlen(((PCREATESTRUCT)mp2)->pszText))
            *((PCREATESTRUCT)mp2)->pszText = 0;
         // copy some data
         pbd->fl = ((PCREATESTRUCT)mp2)->flStyle;
         // se bordo non specificato usa il valore 1
         if (!(pbd->fl & CCTL_BORDER7)) pbd->fl |= CCTL_BORDER1;
         if (pbd->fl & BARS_VERTICAL) {          // verticale
            pbd->szl.cx = 2 * (pbd->fl & 0x7);
            pbd->szl.cy = ((PCREATESTRUCT)mp2)->cy;
         } else {                               // orizzontale
            pbd->szl.cx = ((PCREATESTRUCT)mp2)->cx;
            pbd->szl.cy = 2 * (pbd->fl & 0x7);
         } /* endif */
         WinSetWindowBits(hwnd, QWL_STYLE, SS_GROUPBOX, 0xffff);
         WinSetWindowPos(hwnd, 0, 0, 0, pbd->szl.cx, pbd->szl.cy,
                         SWP_SIZE | SWP_NOADJUST);
         WinSetWindowPtr(hwnd, cbWCstc, (PVOID)pbd);
         break;
      }
      // se il controllo Š ridimensionato memorizza nuove dimensioni
      case WM_ADJUSTWINDOWPOS:
         if (((PSWP)mp1)->fl & SWP_SIZE) {
            PBARDATA pbd = (PBARDATA)stGetData(hwnd);
            if (pbd) {
               if (pbd->fl & BARS_VERTICAL) {         // verticale
                  ((PSWP)mp1)->cx = pbd->szl.cx;
                  pbd->szl.cy = ((PSWP)mp1)->cy;
               } else {                               // orizzontale
                  pbd->szl.cx = ((PSWP)mp1)->cx;
                  ((PSWP)mp1)->cy = pbd->szl.cy;
               } /* endif */
            } /* endif */
         } // end if
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
      // sostituisce totalmente procedura controllo statico
      case WM_PAINT: {
         PBARDATA pbd = (PBARDATA)stGetData(hwnd);
         HPS hps;
         RECTL rcl = {0, 0, pbd->szl.cx, pbd->szl.cy};;
         if (pbd &&
             NULLHANDLE != (hps = WinBeginPaint(hwnd, NULLHANDLE, NULL))) {
            WinDrawBorder(hps, &rcl, pbd->fl & 0x7, pbd->fl & 0x7, 0, 0,
                          (pbd->fl & CCTL_RAISED? 0x400: 0x800));
            WinEndPaint(hps);
         } // end if
         return (MRESULT)FALSE;
      } // end case WM_PAINT
      case WM_DESTROY: {
         PBARDATA pbd = (PBARDATA)stGetData(hwnd);
         if (pbd) free(pbd);
      }  break;
   } /* endswitch */
   return pfnwpWCstc(hwnd, msg, mp1, mp2); // default static controls proc
}  
MRESULT EXPENTRY OSARecordEventsDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   Environment    *ev;
   PRECORDER_PARM     prec;
   HWND            hwndButton;
   CHAR            szTemp[CCHMAXPATH];
   PSZ             pszBuffer,pszTemp;
   SWP             swp;
   PSWP            pswpNew, pswpOld;
   MRESULT         result;
   OSAError        retVal = noErr;

   switch(msg)
   {
      case WM_INITDLG:
         prec = (PRECORDER_PARM) calloc(1,sizeof(RECORDER_PARM));
         prec->pmp =  (PMAIN_PARM) mp2;
         prec->hwnd = hwnd;
         prec->pmp->hwndRecordEvent = hwnd;
         InitRecorder(prec);
         break;

      case WM_ADD_RECORDEDEVENT:
         prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER );
         AddRecordedEvents(prec, (OSAEvent *) mp1);
         break;

      case WM_WINDOWPOSCHANGED:
         pswpNew = (PSWP) mp1;
         pswpOld = pswpNew + 1;
         hwndButton = WinWindowFromID(hwnd, IDD_ODRECSTATUS);
         WinQueryWindowPos(hwndButton, &swp);
         WinSetWindowPos(hwndButton,
                         HWND_TOP,
                         swp.x,
                         swp.y+(pswpNew->cy - pswpOld->cy),
                         0,
                         0,
                         SWP_MOVE );
         hwndButton = WinWindowFromID(hwnd, IDD_ODDISPLAYEVENTS);
         WinQueryWindowPos(hwndButton, &swp);
         WinSetWindowPos(hwndButton,
                         HWND_TOP,
                         0,
                         0,
                         swp.cx+(pswpNew->cx - pswpOld->cx),
                         swp.cy+(pswpNew->cy - pswpOld->cy),
                         SWP_SIZE );
         result = WinDefDlgProc(hwnd, msg, mp1, mp2);
         WinInvalidateRect(hwnd, NULL, TRUE);
         return result;
         break;

      case WM_PAINT: {
         SWP Pos, DlgPos;
         HPS Hps;
         RECTL Rect;

         /* First let dialog do normal painting */
         WinDefDlgProc(hwnd, msg, mp1, mp2);

         /* Paint recessed frame around the status line */
         Hps = WinGetPS(hwnd);
         WinQueryWindowPos(WinWindowFromID(hwnd, IDD_ODRECSTATUS), &Pos);
         WinQueryWindowPos(hwnd, &DlgPos);
         Rect.xLeft = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME);
         Rect.xRight= DlgPos.cx - Rect.xLeft;
         Rect.yBottom = Pos.y - 1;
         Rect.yTop    = Pos.y + Pos.cy + 1;
         #define DB_RAISED    0x0400  // Undocumented borders
         #define DB_DEPRESSED 0x0800
         WinDrawBorder(Hps, &Rect, 1, 1, 0, 0, DB_DEPRESSED);
         WinReleasePS(Hps);
         return 0;
         }

      case WM_COMMAND:
         switch (SHORT1FROMMP (mp1)){
            case IDD_ODRECSTART:
               prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER );
               StartRecorder(prec);
               WinSetWindowText(prec->hwndStatus, "recording...");
               break;
            case IDD_ODRECSTOP:
               prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER );
               StopRecorder(prec);
               strcpy(szTemp,prec->szTitle);
               WinSetWindowText(prec->hwndStatus, "idl...");
               break;
            case IDD_ODRECCANCEL:
               prec = (PRECORDER_PARM) WinQueryWindowULong( hwnd, QWL_USER );
               if(prec->recording)
                 StopRecorder(prec);
               // Save window size/pos info
               WinQueryWindowPos(hwnd, &swp);
               prec->pmp->Profile.testrec_cx = swp.cx;
               prec->pmp->Profile.testrec_cy = swp.cy;
               prec->pmp->Profile.testrec_x = swp.x;
               prec->pmp->Profile.testrec_y = swp.y;
               WinQueryWindowPos(prec->hwndStatus, &swp);
               prec->pmp->Profile.testrecStat_cx = swp.cx;
               prec->pmp->Profile.testrecStat_cy = swp.cy;
               prec->pmp->Profile.testrecStat_x = swp.x;
               prec->pmp->Profile.testrecStat_y = swp.y;
               prec->pmp->hwndRecordEvent = NULL;
               free((PVOID)prec);
               WinDismissDlg(hwnd, TRUE);
               break;
            default:
               ;
         } /* endswitch */
         break;

      case WM_CLOSE:
         WinPostMsg(hwnd, WM_COMMAND, MPFROMSHORT(IDD_ODRECCANCEL), NULL);
         break;
      default:
         return(WinDefDlgProc(hwnd, msg, mp1, mp2));
   }
   return (MRESULT)NULL;
}   /*  end of OSAScriptEditorDlgProc()  */
static MRESULT EXPENTRY launchPadWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  WPFolder* thisPtr;
  launchPad * lp;
  LPObject *lpo;
  static USHORT id=0;//Initialisation new in V1.00a 

  switch(msg)
    {
#if 0
    case DM_ENDCONVERSATION:
    case DM_DRAGFILECOMPLETE:
    case DM_DROPNOTIFY:
    case DM_FILERENDERED:
    case DM_RENDERCOMPLETE:

break;
      return (MRESULT)FALSE;
    case WM_ENDDRAG:

      break;
      return (MRESULT)TRUE;
#endif
    case WM_PAINT:
      {
      RECTL rcl;
      launchPad * lp;

      HPS hps=WinBeginPaint(hwnd,NULLHANDLE, &rcl);
      WinFillRect(hps, &rcl, SYSCLR_DIALOGBACKGROUND);
      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()==0) {
          WinQueryWindowRect(hwnd,&rcl);
          WinDrawBorder(hps,&rcl,1,1,SYSCLR_WINDOWFRAME,SYSCLR_DIALOGBACKGROUND, DB_STANDARD);
        }
      }
      WinEndPaint(hps);
      return (MRESULT) 0;
      }
    case DM_DRAGOVER:
      return handleDragOver(hwnd, mp1, mp2);
    case DM_DROP:
      {
        ULONG ulCount;
        ULONG ulNumberOfObjects;
        PDRAGITEM pDragItem;
        SOMClass *folderClass;
        WPObject * wpObject;
        PDRAGINFO pDragInfo;
       
        TRY_LOUD(LP_FRAMEDROP) { 
          /* A new object dropped on the launchpad */
          pDragInfo=(PDRAGINFO)mp1;
          if(DrgAccessDraginfo(pDragInfo)) {
            /* Get number of items */
            ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo);           
            if(ulNumberOfObjects>1){
              /* Free the draginfo */
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
            else { 
              ulCount=0;
              
              pDragItem=DrgQueryDragitemPtr( pDragInfo, ulCount);
              wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, ulCount)->ulItemID);
              lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
              if(lp) {
                if(somIsObj(wpObject)) {
  
                  POINTL ptl;
                  int numB;
                  SWP swp;
                  
                  WinQueryWindowPos(hwnd,&swp);
                  ptl.x=pDragInfo->xDrop;
                  ptl.y=pDragInfo->yDrop;
                  /* Pos in window coords */
                  WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
                  numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta);
                  numB=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB);

                  /* Do a link */
                  lp->lpAddButton(wpObject, numB);
                  handleDragLeave(hwnd, mp1, mp2);
                }
              }
              DrgDeleteDraginfoStrHandles(pDragInfo);
              DrgFreeDraginfo(pDragInfo);
            }
          }
          handleDragLeave(hwnd, mp1, mp2);
        }
        CATCH(LP_FRAMEDROP)
          {
          } END_CATCH;
          
          break;
      }
    case DM_DRAGLEAVE:
      return handleDragLeave(hwnd, mp1, mp2);
      break;
    case WM_COMMAND:
      if(SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON) {
        /* It's a push button */
        lpo=(LPObject*)WinQueryWindowULong(WinWindowFromID(hwnd,SHORT1FROMMP(mp1)),QWL_USER);
        if(lpo) {
          if(somIsObj(lpo->wpObject))
            lpo->wpObject->wpViewObject(NULLHANDLE, OPEN_DEFAULT,0);
        }
      }
      return (MRESULT)FALSE;
      /***********************************************/
      /* Stuff for fly over help                     */ 
    case WM_MOUSEMOVE:
      launchPad * lp;

      lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
      if(lp) {
        if(lp->lpQueryNumObjects()!=0) {
          break;
        }
      }
      
#if 0
      tempID=WinQueryWindowUShort(hwnd,QWS_ID);/*  get the id of the window under the pointer  */  			
      if(id!=tempID) {	// New Button?	
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay
        id=tempID;  // Save ID 
      }
      else {
        if(!hwndBubbleWindow)
          WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay	
      }
#endif
      if(!hwndBubbleWindow)
        WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 2,(ULONG)iTBFlyOverDelay); // New timer for delay	

      break;
    case WM_DESTROY:
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running
      if(hwndBubbleWindow)
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
      hwndBubbleWindow=0;
      /* Stop delay timer if running */
      WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd, 2);			
      break;

    case WM_NEWBUBBLE:
      ULONG bubbleEnabled;
      HWND hwndStore;
      POINTL ptl;
      RECTL  rclWork;
      LONG  ulWinTextLen;
      POINTL aptlPoints[TXTBOX_COUNT];
      LONG   deltaX,deltaY;
      HPS  hps;
      RECTL   rcl;
  
      /*  we have to build a new information window  */
      if(hwndBubbleWindow){// if(){...} new in V1.00a 
        WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
        hwndBubbleWindow=NULL;
      }
      // Query the pointer position
      WinQueryPointerPos(HWND_DESKTOP,&ptl);
      WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
      WinQueryWindowRect(hwnd,&rclWork);				
      if(!hwndBubbleWindow 
         && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)
         && bTBFlyOverEnabled) {
        
        static HWND hwndBubbleClient;
        ULONG style=FCF_BORDER|FCF_NOBYTEALIGN;
        char winText[255];
        
        /* Get window text for size calculating */
            lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER);
        if(lp) {
          strncpy(winText, lp->lpQueryFlyOverText(), sizeof(winText));
          winText[sizeof(winText)-1]=0;
        }

        ulWinTextLen=(LONG)strlen(winText); // Query text length
        
        /* Delete 'Returns' in object title */
        char *pBuchst;
        char *pRest;
        pRest=winText;
        while((pBuchst=strchr(pRest,13))!=NULL) {
          *pBuchst=' ';
          pBuchst++;
          if(*pBuchst==10)
            *pBuchst=' ';
          pRest=pBuchst;
        }
        
        /* Create help window */
        hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP,
                                            0,
                                            &style,
                                            WC_STATIC,
                                            "",
                                            SS_TEXT|DT_CENTER|DT_VCENTER,
                                            NULLHANDLE,
                                            400,
                                            &hwndBubbleClient);

        hwndShadow=WinCreateWindow(HWND_DESKTOP,
                                   WC_STATIC,
                                   "",
                                   SS_TEXT|DT_CENTER|DT_VCENTER,
                                   0, 0,
                                   0, 0,
                                   hwndBubbleWindow,
                                   hwndBubbleWindow,
                                   401,
                                   NULLHANDLE,
                                   NULLHANDLE);
        oldProc=WinSubclassWindow(hwndShadow, shadowProc);

        // Set the font for the help
        WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE,
                        sizeof(chrTBFlyFontName),
                        chrTBFlyFontName);
        /* Calculate text size in pixel */
        hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL);
        GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints);
        WinEndPaint(hps);
        
        /* Set colors */
        WinSetPresParam(hwndBubbleClient,
                        PP_BACKGROUNDCOLOR,sizeof(rgbTBFlyBackground) ,
                        &rgbTBFlyBackground );
        WinSetPresParam(hwndBubbleClient,
                        PP_FOREGROUNDCOLOR,sizeof(rgbTBFlyForeground) ,
                        &rgbTBFlyForeground );
        
        /* Calculate bubble positon and show bubble */
        WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window
        WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size
        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x 
          > rcl.xRight 
          ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7 
	      : deltaX=0 ;
        
        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y 
          > rcl.yTop 
          ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7
	      : deltaY=0 ;		
        WinSetWindowPos(hwndBubbleWindow,
                        HWND_TOP,
                        ptl.x+xVal+deltaX,ptl.y+yVal+deltaY,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);

        WinSetWindowPos(hwndShadow,
                        hwndBubbleWindow,
                        ptl.x+xVal+deltaX+5
                        ,ptl.y+yVal+deltaY-5,  
                        aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8,
                        aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2,
                        SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW);
        
        /* Set bubble text */
        WinSetWindowText(hwndBubbleClient,winText);
        WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35); 
      } // end if(!hwndBubbleWindow)
      break;
    case WM_TIMER:
      switch (SHORT1FROMMP(mp1))
        {
        case 1: //Intervall timer
          {
            POINTL ptl;
            RECTL  rclWork;

            /* Test pointer position */
            WinQueryPointerPos(HWND_DESKTOP, &ptl);
            WinMapWindowPoints(HWND_DESKTOP, hwnd,&ptl, 1);
            WinQueryWindowRect(hwnd, &rclWork);
            if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              {	// Window has changed				 
                WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 1);  // stop the running timer
                if(hwndBubbleWindow) 
                  WinDestroyWindow(hwndBubbleWindow);/*  close the bubblewindow  */
                hwndBubbleWindow=0;
                id=0;
              }			 			
          break;
          }
        case 2:// delay over
          {//our own timer.
            POINTL ptl;
            RECTL  rclWork;

            WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 2);//Stop the delay timer
            /* Check the pointer position */
            WinQueryPointerPos(HWND_DESKTOP,&ptl);
            WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
            WinQueryWindowRect(hwnd,&rclWork);
            if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl))
              WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window
            return (MRESULT)FALSE;
          }
        default:
          break;
        }
      break;
    default:
      break;    
    }
  return pfnwpOldLPProc(hwnd, msg, mp1, mp2);
}
MRESULT EXPENTRY newProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{

  switch (msg)
    {      
    case WM_CREATE:
      {
        PCREATESTRUCT pCreate=PVOIDFROMMP(mp2);

        /* Initialize the slider data */
        WinSetWindowUShort(hwnd, SLIDERARMWITH,20);
        WinSetWindowUShort(hwnd, SLIDERARMHEIGHT,10);
        /* Dimensions of slider. The slider active area is smaller than the window to
           allow drawing of active state. */
        WinSetWindowULong(hwnd, SLIDERCX,pCreate->cx-4);
        WinSetWindowULong(hwnd, SLIDERCY,pCreate->cy-4);
        WinSetWindowULong(hwnd, SLIDERX,2);
        WinSetWindowULong(hwnd, SLIDERY,2);
        WinSetWindowULong(hwnd, SLIDERARMPOS, 0);
        WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
        return (MRESULT)0;
      }
    case WM_SIZE:
      WinSetWindowULong(hwnd, SLIDERCX, SHORT1FROMMP(mp2)-4);
      WinSetWindowULong(hwnd, SLIDERCY, SHORT2FROMMP(mp2)-4);
      WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
      return (MRESULT)0;
    case WM_BUTTON1DOWN:
      {
        SHORT x=SHORT1FROMMP( mp1);
        SHORT y=SHORT2FROMMP( mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);

        if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
           && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
          WinSetWindowUShort(hwnd, PTRPOSINSLARM, x-lPos);
        }
        WinSetFocus(HWND_DESKTOP, hwnd);
      break;
      }
    case WM_FOCUSCHANGE:
      {
        HPS hps;
        RECTL rcl;
        POINTL ptl;

        if(SHORT1FROMMP(mp2)) {
          hps=WinGetPS(hwnd);
          WinQueryWindowRect(hwnd, &rcl);        
          GpiSetLineType(hps, LINETYPE_DOT);
          ptl.x=rcl.xLeft;
          ptl.y=rcl.yBottom;
          GpiMove(hps,&ptl);
          ptl.x=rcl.xRight-1;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yTop-1;
          GpiLine(hps,&ptl);
          ptl.x=rcl.xLeft;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yBottom;
          GpiLine(hps,&ptl);
          WinReleasePS(hps);
        }
        else {
          WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
        }

        break;
      }
    case WM_CHAR:
      if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
        /* We have the focus */
        if((SHORT1FROMMP(mp1) & (KC_VIRTUALKEY))==(KC_VIRTUALKEY)) {
          LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
          USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
          ULONG ulCx=WinQueryWindowULong(hwnd, SLIDERCX);
#if 0
          FILE* file;
          file=fopen("d:\\md.log","a");
          fprintf(file,"0x%x 0x%x \n",SHORT1FROMMP(mp1),SHORT2FROMMP(mp1) );
          fclose(file);
#endif
          /*(KC_KEYUP|KC_PREVDOWN|KC_VIRTUALKEY)*/
          switch(SHORT2FROMMP(mp2))
            {
            case VK_RIGHT:

              if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
                lPos+=2;
                if(lPos>ulCx-usWidth)
                  lPos=ulCx-usWidth;
                else {
                  WinPostMsg( hwnd,
                              SLM_SETSLIDERINFO,
                              MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                              MPFROMLONG( (LONG) lPos ));
                  if(SHORT1FROMMP(mp1) & KC_LONEKEY)
                    /* Post SLN_CHANGE notification */
                    WinPostMsg( WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
                                MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                                MPFROMLONG(lPos));
                  else
                    /* Post SLN_SLIDERTRACK notification */
                    WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL,
                               MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
                               MPFROMLONG(lPos));
                  
                }
                WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
              }
              return (MRESULT)TRUE;
            case VK_LEFT:
              if(SHORT1FROMMP(mp1) & (KC_KEYUP|KC_PREVDOWN)) {
                lPos-=2;
                if(lPos<0) {
                  lPos=0;
                }
                else {
                  WinPostMsg( hwnd,
                              SLM_SETSLIDERINFO,
                              MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE),
                              MPFROMLONG( (LONG) lPos ));
                  /* Post SLN_CHANGE notification */
                  WinPostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
                             MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                   MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));

                }
                WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
              }
              return (MRESULT)TRUE;
            default:
              break;
            }
        }
      }
      break;
    case WM_BUTTON1MOTIONSTART:
      {
        SHORT x=SHORT1FROMMP( mp1);
        SHORT y=SHORT2FROMMP( mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);

        if(x<lPos+usWidth && y<WinQueryWindowUShort(hwnd, SLIDERY)+WinQueryWindowUShort(hwnd, SLIDERCY)
           && y>WinQueryWindowUShort(hwnd, SLIDERY)) {
          WinSetWindowULong(hwnd, SLDRAGGING, TRUE);
          WinSetCapture(HWND_DESKTOP, hwnd);
        }
        break;
      }
    case WM_BUTTON1MOTIONEND:
      if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
        WinSetWindowULong(hwnd, SLDRAGGING,FALSE);
        WinSetCapture(HWND_DESKTOP, NULLHANDLE);
        /* Post SLN_CHANGE notification */
        WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_CHANGE),
                   MPFROMLONG(WinQueryWindowULong(hwnd, SLIDERARMPOS)));
      }
      break;
    case SLM_SETSLIDERINFO:
      switch(SHORT1FROMMP(mp1))
        {
          case SMA_SLIDERARMPOSITION:
            /*  SMA_RANGEVALUE only for now !! */
            if(SHORT2FROMMP(mp1)==SMA_RANGEVALUE) {
              WinSetWindowULong(hwnd, SLIDERARMPOS, LONGFROMMP(mp2));
              WinInvalidateRect(hwnd, NULLHANDLE,TRUE);
              return (MRESULT)0;
            }
            break;
        default:
          break;
        }
      break;
    case WM_MOUSEMOVE:
      if(WinQueryWindowULong(hwnd, SLDRAGGING)) {
        HPS hps;
        RECTL rcl, rcl2, rcl3;
        LONG lTemp;
        SHORT x=SHORT1FROMMP(mp1);
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
       
        lTemp=lPos;
     
        rcl.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
        rcl.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
        rcl.xRight=rcl.xLeft+WinQueryWindowULong(hwnd, SLIDERCX);
        rcl.yTop=rcl.yBottom+WinQueryWindowULong(hwnd, SLIDERCY);

        rcl2=rcl3=rcl;
        rcl.xLeft=x-WinQueryWindowUShort(hwnd, PTRPOSINSLARM);
        if(rcl.xLeft<rcl2.xLeft)/* Make sure we stop at the left border */
          rcl.xLeft=rcl2.xLeft;

        rcl.xRight=rcl.xLeft+usWidth;
        if(rcl.xRight>rcl2.xRight)
          {/* Make sure we stop at the right border */
            rcl.xRight=rcl2.xRight;
            rcl.xLeft=rcl.xRight-usWidth;
          }
        lPos=rcl.xLeft-WinQueryWindowULong(hwnd, SLIDERX);/* Save position zero based */
        WinSetWindowULong(hwnd, SLIDERARMPOS, lPos);
        if(lPos!=lTemp) {
          BOOL rc;

          hps=WinGetPS(hwnd);
          /* Paint Background not necessary here */

          /* Shaft */
          /* Left part */
          rcl3.xRight=rcl.xLeft;
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl3;
            oi.idItem=SDA_SLIDERSHAFT;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            WinFillRect(hps, &rcl3, CLR_GREEN);

          /* Right part */
          rcl3.xRight=rcl2.xRight;
          rcl3.xLeft=rcl.xRight;
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl3;
            oi.idItem=SDA_SLIDERSHAFT;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            WinFillRect(hps, &rcl3, CLR_WHITE);

          /* Paint Slider */
          rc=FALSE;
          if(USERSLIDER) {
            OWNERITEM oi={0};
            oi.hwnd=hwnd;
            oi.hps=hps;
            oi.fsState=SLS_OWNERDRAW;/* More to come */
            oi.rclItem=rcl;
            oi.idItem=SDA_SLIDERARM;
            rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                                MPFROMP(&oi) );
          }
          if(!rc)
            {
              WinFillRect(hps,&rcl, CLR_BLUE);
              WinDrawBorder(hps, &rcl, 2, 2, 0, 0 ,0x0400);
            }

          WinReleasePS(hps);

          /* Post SLN_SLIDERTRACK notification */
          WinPostMsg(WinQueryWindow(hwnd, QW_PARENT),WM_CONTROL, MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), SLN_SLIDERTRACK),
                     MPFROMLONG(lPos));
        }
      }
      break;
    case WM_PAINT:
      {
        HPS hps, hps2;
        RECTL rcl, rcl2, rcl3;
        POINTL ptl;
        LONG  lPos=WinQueryWindowULong(hwnd, SLIDERARMPOS);
        USHORT usWidth=WinQueryWindowUShort(hwnd, SLIDERARMWITH);
        BOOL rc;

        WinQueryWindowRect(hwnd, &rcl);

        /* Shaft */
        rcl2.xLeft=WinQueryWindowULong(hwnd, SLIDERX);
        rcl2.yBottom=WinQueryWindowULong(hwnd, SLIDERY);
        rcl2.xRight=rcl2.xLeft+WinQueryWindowULong(hwnd, SLIDERCX)-1;
        rcl2.yTop=rcl2.yBottom+WinQueryWindowULong(hwnd, SLIDERCY)-1;

        /* Background */
        hps2=WinGetPS(hwnd);
        GpiExcludeClipRectangle(hps2,&rcl2);
        WinFillRect(hps2, &rcl, CLR_PALEGRAY);
        WinReleasePS(hps2);
        rcl2.yTop+=1;
        rcl2.xRight+=1;

        hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE);
        /* Focus */
        if(WinQueryFocus(HWND_DESKTOP)==hwnd) {
          GpiSetLineType(hps, LINETYPE_DOT);
          ptl.x=rcl.xLeft;
          ptl.y=rcl.yBottom;
          GpiMove(hps,&ptl);
          ptl.x=rcl.xRight-1;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yTop-1;
          GpiLine(hps,&ptl);
          ptl.x=rcl.xLeft;
          GpiLine(hps,&ptl);
          ptl.y=rcl.yBottom;
          GpiLine(hps,&ptl);
        }

        rcl3=rcl=rcl2;

        /* Arm pos */        
        rcl2.xLeft+=lPos;
        /* Arm size */        
        rcl2.xRight=rcl2.xLeft+usWidth;
        
        /* Shaft */
        /* Left part */
        rcl3.xRight=rcl2.xLeft;
        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl3;
          oi.idItem=SDA_SLIDERSHAFT;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                    MPFROMP(&oi) );
        }
        if(!rc)
          WinFillRect(hps, &rcl3, CLR_GREEN);

        /* Right part */
        rcl3.xRight=rcl.xRight;
        rcl3.xLeft=rcl2.xRight;
        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl3;
          oi.idItem=SDA_SLIDERSHAFT;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                              MPFROMP(&oi) );
        }
        if(!rc)
          WinFillRect(hps, &rcl3, CLR_WHITE);

        rc=FALSE;
        if(USERSLIDER) {
          OWNERITEM oi={0};
          oi.hwnd=hwnd;
          oi.hps=hps;
          oi.fsState=SLS_OWNERDRAW;/* More to come */
          oi.rclItem=rcl2;
          oi.idItem=SDA_SLIDERARM;
          rc=(BOOL)WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_DRAWITEM, MPFROMSHORT(WinQueryWindowUShort(hwnd, QWS_ID)),
                              MPFROMP(&oi) );
        }
        if(!rc)
          {
            WinFillRect(hps,&rcl2, CLR_BLUE);        
            WinDrawBorder(hps, &rcl2, 2, 2, 0, 0 ,0x0400);
          }

        WinEndPaint(hps);
        return (MRESULT)0;
      }
      break;
    default:
      break;
    }

  return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
Example #16
0
File: ktbhelp.c Project: komh/ktb
static
MRESULT EXPENTRY helpWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    static CHAR szText[ 256 ] = "";
    static HPS hps = NULLHANDLE;
    static USHORT width = 0, height = 0;

    switch( msg )
    {
        case WM_CREATE :
        {
            FONTMETRICS fm;

            strcpy( szText, (( PCREATESTRUCT )mp2 )->pszText );

            hps = WinGetPS( hwnd );
            GpiQueryFontMetrics( hps, sizeof( fm ), &fm );
            width = fm.lAveCharWidth;
            height = fm.lMaxAscender + fm.lMaxDescender;

            return MRFROMSHORT( FALSE );
        }

        case WM_DESTROY :
            WinReleasePS( hps );

            return MRFROMSHORT( FALSE );

        case WM_SETWINDOWPARAMS :
        {
            PWNDPARAMS  pwp;

            pwp = ( PWNDPARAMS )mp1;
            if( pwp->fsStatus & WPM_TEXT )
                strcpy( szText, pwp->pszText );

            return MRFROMSHORT( TRUE );
        }

        case WM_PAINT :
        {
            RECTL   rcl;

            WinBeginPaint( hwnd, hps, NULL );

            WinQueryWindowRect( hwnd, &rcl );

            WinDrawBorder( hps, &rcl, 1, 1, CLR_BLACK, CLR_YELLOW, DB_INTERIOR );
            WinDrawText( hps, -1, szText, &rcl, CLR_BLACK, CLR_YELLOW,
                         DT_CENTER | DT_VCENTER );

            WinEndPaint( hps );

            return MRFROMSHORT( 0 );
        }

        case WM_QUERY_CHAR_WIDTH :
            return MRFROMSHORT( width );

        case WM_QUERY_CHAR_HEIGHT :
            return MRFROMSHORT( height );
    }

    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
MRESULT EXPENTRY AboutDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    BOOL    bHandled = TRUE;
    MRESULT mReturn  = 0;
    ULONG   ulScrWidth, ulScrHeight;
    RECTL   Rectl;
    SWP     Swp;
    HPS     hps;

    switch (msg)
    {           
        case WM_INITDLG:
            /* Center dialog on screen */
            ulScrWidth  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
            ulScrHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
            WinQueryWindowRect (hWnd, &Rectl);
            WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight)/2,
                (ulScrHeight-Rectl.yTop)/2, 0, 0, SWP_MOVE | SWP_ACTIVATE);

            /* Set application title */
            WinSetDlgItemText (hWnd, 10001, (PSZ)mp2);
            break;

        case WM_PAINT:
            hps = WinBeginPaint (hWnd,0,0);
            WinQueryWindowRect (hWnd, &Rectl);
            WinFillRect (hps, &Rectl, CLR_PALEGRAY);
            WinDrawBorder (hps, &Rectl, 
                WinQuerySysValue(HWND_DESKTOP,SV_CXDLGFRAME), 
                WinQuerySysValue(HWND_DESKTOP,SV_CYDLGFRAME), 
                CLR_DARKGRAY, CLR_WHITE, DB_RAISED);
            GpiMove (hps, (PPOINTL)&Rectl);
            Rectl.xRight--;
            Rectl.yTop--;
            GpiBox (hps, DRO_OUTLINE, (PPOINTL)&Rectl.xRight, 0L, 0L);
            WinQueryWindowPos (WinWindowFromID (hWnd, 10002), &Swp);
            Rectl.xLeft   = Swp.x-1;
            Rectl.yBottom = Swp.y-1;
            Rectl.xRight  = Swp.x + Swp.cx + 1;
            Rectl.yTop    = Swp.y + Swp.cy + 1;
            WinDrawBorder (hps, &Rectl, 1L, 1L,
                CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
            WinQueryWindowPos (WinWindowFromID (hWnd, 10003), &Swp);
            Rectl.xLeft   = Swp.x-1;
            Rectl.yBottom = Swp.y-1;
            Rectl.xRight  = Swp.x + Swp.cx + 1;
            Rectl.yTop    = Swp.y + Swp.cy + 1;
            WinDrawBorder (hps, &Rectl, 1L, 1L,
                CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
            WinEndPaint (hps);
            break;

		  case WM_COMMAND:
            WinDismissDlg (hWnd, DID_OK);
            break;

        default:
            bHandled = FALSE;
            break;
    }

    if (!bHandled)
        mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);

    return (mReturn);
}