예제 #1
0
static MRESULT APIENTRY Destroy ( HWND Window, MESG, MPARAM1, MPARAM2 ) {

  /**************************************************************************
   * Find the instance data.                                                *
   **************************************************************************/

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * Discard the pointers.                                                  *
   **************************************************************************/

   WinDestroyPointer ( Data->MarginPtr ) ;
   WinDestroyPointer ( Data->TabstopPtr ) ;

  /**************************************************************************
   * Destroy the device context object for the window.                      *
   **************************************************************************/

   delete Data->pDevice ;

  /**************************************************************************
   * Release the instance data.                                             *
   **************************************************************************/

   free ( Data ) ;

  /**************************************************************************
   * We're done.                                                            *
   **************************************************************************/

   return ( MRFROMSHORT ( 0 ) ) ;
}
OIcon& OIcon::destroy()
{
    if (hptr)
        WinDestroyPointer(hptr);

    return(*this);
}
예제 #3
0
QCursorData::~QCursorData()
{
    delete bm;
    delete bmm;
    if (hptr && !isSysPtr)
        WinDestroyPointer(hptr);
}
예제 #4
0
 int icqskin_setFrameIcon(hWindow hwnd, SKINDATA *skn, USHORT id)
 {
    ICQFRAME *cfg = WinQueryWindowPtr(hwnd, QWL_USER);

    if(!cfg || cfg->sz < sizeof(ICQFRAME))
    {
       DBGMessage("Invalid frame window when setting icon");
       icqWriteSysLog(skn->icq,PROJECT,"Invalid frame window when setting icon");
       return -1;
    }

    DBGTrace(cfg->iconID);
    DBGTrace(id);

    if(cfg->iconID == id)
       return 0;

    DBGTrace(id);

    if(cfg->icon)
    {
       WinDestroyPointer(cfg->icon);
       cfg->icon = NULLHANDLE;
    }

    cfg->icon   = icqskin_CreatePointer(skn, id);
    cfg->iconID = id;

    WinSendMsg(hwnd,WM_SETICON,(MPARAM) cfg->icon, 0);

    return 0;
 }
예제 #5
0
 static void destroy(HWND hwnd)
 {
    ICQMSGDIALOG *cfg = WinQueryWindowPtr(hwnd,0);

	icqskin_destroyMsgWindow(cfg);
    icqskin_terminateMessageEditor(cfg->fr.icq, hwnd);

    DBGTracex(cfg->msgIn);

    if(cfg->msgIn)
       WinDestroyPointer(cfg->msgIn);

    if(cfg->msgOut)
       WinDestroyPointer(cfg->msgOut);

 }
static void DestroyIcon(HPOINTER hIcon, bool fWpsIcon)
{
  if (fWpsIcon)
    WinDestroyPointer(hIcon);
  else
    WinFreeFileIcon(hIcon);

  return;
}
예제 #7
0
 static void destroy(HWND hwnd)
 {
    ICQFRAME *cfg = WinQueryWindowPtr(hwnd,0);

    DBGPrint("Window \"%s\" destroyed",cfg->name);

    if(WinQueryCapture(HWND_DESKTOP) == hwnd)
       WinSetCapture(HWND_DESKTOP,NULLHANDLE);

    if(!cfg || cfg->sz != sizeof(ICQFRAME))
       return;

    clearSkin(cfg);

    if(cfg->icon)
       WinDestroyPointer(cfg->icon);

    cfg->sz = 0;
    free(cfg);
 }
예제 #8
0
MRESULT EXPENTRY
fnwpWxTaskWidget( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  MRESULT mrc = 0;
  // get widget data from QWL_USER (stored there by WM_CREATE)
  PXCENTERWIDGET pWidget = (PXCENTERWIDGET)WinQueryWindowPtr( hwnd, QWL_USER );
  // this ptr is valid after WM_CREATE

  switch( msg )
  {
    /*
     * WM_CREATE:
     *      as with all widgets, we receive a pointer to the
     *      XCENTERWIDGET in mp1, which was created for us.
     *
     *      The first thing the widget MUST do on WM_CREATE
     *      is to store the XCENTERWIDGET pointer (from mp1)
     *      in the QWL_USER window word by calling:
     *
     *          WinSetWindowPtr(hwnd, QWL_USER, mp1);
     *
     *      We could use XCENTERWIDGET.pUser for allocating
     *      another private memory block for our own stuff,
     *      for example to be able to store fonts and colors.
     *      We ain't doing this in the minimal sample.
     */

    case WM_CREATE:
      WinSetWindowPtr(hwnd, QWL_USER, mp1);
      pWidget = (PXCENTERWIDGET)mp1;
      if(( !pWidget ) || ( !pWidget->pfnwpDefWidgetProc )) {
        // shouldn't happen... stop window creation!!
        mrc = (MPARAM)TRUE;
      }

      hwndMenu = WinCreateWindow( hwnd, WC_MENU, 0, 0, 0, 0, 0, 0,
                                  hwnd, HWND_TOP, ID_MENU_TASKS, 0, 0 );

      ico_tasks  = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_TASKS  );
      ico_detach = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_DETACH );
      ico_dos    = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_DOS    );
      ico_os2fs  = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_OS2FS  );
      ico_os2vio = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_OS2VIO );
      ico_pm     = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_PM     );
      break;

    /*
     * WM_BUTTON1CLICK:
     *      clicked on the window
     */

    case WM_BUTTON1CLICK:
    {
      mrc = (MPARAM)WgtControl( pWidget, mp1, mp2 );

      RECTL  rcl;
      POINTL ptl;
      SWP    swp;

      // Check if Ctrl is pressed
      if( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 ) {
        bType = TRUE;
      } else {
        bType = FALSE;
      }

      // Fill it with items
      FillMenu( hwndMenu );

      // Place popup according to xCenter position
      if( pWidget->pGlobals->ulPosition == XCENTER_BOTTOM )
      {
        WinQueryWindowRect( hwnd, &rcl );
        ptl.y = rcl.yTop + 1;
        ptl.x = rcl.xLeft;
        WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 0 );
      }
      else
      {
        WinQueryWindowRect( hwnd, &rcl );
        ptl.y = rcl.yBottom;
        ptl.x = rcl.xLeft;
        WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 0 );
        memset( &swp, 0, sizeof(SWP));
        swp.fl = SWP_SIZE;
        WinSendMsg( hwndMenu, WM_ADJUSTWINDOWPOS, MPFROMP(&swp), 0 );
        ptl.y -= swp.cy;
      }

      // Show menu
      WinPopupMenu( hwnd, hwnd, hwndMenu, ptl.x, ptl.y, 0,
                    PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_HCONSTRAIN | PU_VCONSTRAIN );
      break;
    }

    case WM_COMMAND:
    {
      char      szPid[1024];
      MENUITEM  mi;
      SHORT     id;
      TASKDATA* data;

      // Get menu id and data
      id = SHORT1FROMMP(mp1);
      WinSendMsg( hwndMenu, MM_QUERYITEM, MPFROM2SHORT( id, FALSE ), MPFROMP( &mi ));
      data = (TASKDATA*)mi.hItem;

      // Is it "our" item ??
      if( id >= ID_ITEM_FIRST && id < 10000 )
      {
        if( bType )
        {
          // Ctrl was pressed on icon, kill pid
          if( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 )
          {
            // Ctrl was pressed on menu item, use external kill
            sprintf( szPid, "Kill this process (%d) using fastio$ ?", data->pid );

            if( WinMessageBox( HWND_DESKTOP, hwnd, szPid, "xCenter", 0,
                               MB_ICONQUESTION | MB_YESNO    |
                               MB_APPLMODAL    | MB_MOVEABLE | MB_DEFBUTTON2 ) == MBID_YES )
            {
              DosKillFastIo( data->pid );
            }
          } else {
            sprintf( szPid, "Are you sure that you want to kill this process (%d)?", data->pid );

            if( WinMessageBox( HWND_DESKTOP, hwnd, szPid, "xCenter", 0,
                               MB_ICONQUESTION | MB_YESNO    |
                               MB_APPLMODAL    | MB_MOVEABLE | MB_DEFBUTTON2) == MBID_YES )
            {
              DosKillProcess( DKP_PROCESS, data->pid );
            }
          }
        } else {
          // No Ctrl, its a switch to task
          SwitchTo( data );
        }
      } else {
        // Its Ulrichs menu, forward
        mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
      }

      break;
    }

    /*
     * WM_CONTROL:
     *      process notifications/queries from the XCenter.
     */

    case WM_CONTROL:
      mrc = (MPARAM)WgtControl( pWidget, mp1, mp2 );
      break;

    /*
     * WM_PAINT:
     *      well, paint the widget.
     */

    case WM_PAINT:
      WgtPaint( hwnd, pWidget );
      break;

    /*
     * WM_PRESPARAMCHANGED:
     *      A well-behaved widget would intercept
     *      this and store fonts and colors.
     */

    case WM_PRESPARAMCHANGED:
      break;

    case WM_MEASUREITEM:
      return MeasureMenuItem((POWNERITEM)mp2 );

    case WM_DRAWITEM:
      return DrawMenuItem((POWNERITEM)mp2 );

    /*
     * WM_DESTROY:
     *      clean up. This _must_ be passed on to
     *      ctrDefWidgetProc.
     */

    case WM_DESTROY:
      // If we had any user data allocated in WM_CREATE
      // or elsewhere, we'd clean this up here.
      // We _MUST_ pass this on, or the default widget proc
      // cannot clean up.
      WinDestroyWindow ( hwndMenu   );
      WinDestroyPointer( ico_tasks  );
      WinDestroyPointer( ico_detach );
      WinDestroyPointer( ico_dos    );
      WinDestroyPointer( ico_os2fs  );
      WinDestroyPointer( ico_os2vio );
      WinDestroyPointer( ico_pm     );

      mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
      break;

    default:
      mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
  }

  return (mrc);
}
예제 #9
0
MRESULT EXPENTRY EDImgWinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   // alla creazione estrae dal testo del controllo il nome della libreria
   // e l'ID della risorsa da cui ricavare l'immagine
   switch (msg) {
      case WM_CREATE: {
         LHANDLE himg;        // handle immagine
         PSZ psz;             // per ricavare nome modulo e id risorsa
         ULONG idres;         // id risorsa
         HLIB hlib;
         HAB hab;
         SIZEL szl;
   
         hab = WinQueryAnchorBlock(hwnd);
         // cerca primo tab lo cambia in 0 e carica lib
         if (!(psz = memchr((PVOID)((PCREATESTRUCT)mp2)->pszText, '\t', 9)))
            goto error0;
         *psz = 0;                          
         if (!(hlib = WinLoadLibrary(hab, ((PCREATESTRUCT)mp2)->pszText)))
            goto error0;
         // ottiene handle e dimensione immagine
         if (!(idres = strtoul(++psz, NULL, 10))) goto error1;
         if (((PCREATESTRUCT)mp2)->flStyle & (ESI_PTR | ESI_ICON | ESI_MINI)) {
            if (!(himg = WinLoadPointer(HWND_DESKTOP, hlib, idres)))
               goto error1;
            if (((PCREATESTRUCT)mp2)->flStyle & ESI_PTR) {          // pointer
               szl.cx = WgetSysValue(SV_CXPOINTER);
               szl.cy = WgetSysValue(SV_CYPOINTER);
            } else if (((PCREATESTRUCT)mp2)->flStyle & ESI_ICON) {  // icona
               szl.cx = WgetSysValue(SV_CXICON);
               szl.cy = WgetSysValue(SV_CYICON);
            } else {                               // minicona
               szl.cx = WgetSysValue(SV_CXICON) / 2;
               szl.cy = WgetSysValue(SV_CYICON) / 2;
            } // end if
         } else {                                  // bitmap
            if (!(himg = WloadBitmap(hwnd, hlib, idres)))
               goto error1;                                   
            if (!WqueryBitmapSize(himg, &szl))
               goto error2;
         } // end if
         WinDeleteLibrary(hab, hlib);
         // memorizza handle immagine
         WinSetWindowULong(hwnd, cbWCstc, (ULONG)himg);
         *((PCREATESTRUCT)mp2)->pszText = 0;
         //break;
         WinSetWindowPos(hwnd, 0, 0, 0, szl.cx, szl.cy, SWP_SIZE|SWP_NOADJUST);
         break;
         
         error2: GpiDeleteBitmap(himg);
         error1: WinDeleteLibrary(hab, hlib);
         error0: return (MRESULT)TRUE;
      } // end case WM_CREATE
      case WM_ADJUSTWINDOWPOS:    // default window processing
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
      case WM_PAINT: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         ULONG flStyle = WinQueryWindowULong(hwnd, QWL_STYLE);
         HPS hps;
         hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
         if (flStyle & (ESI_PTR | ESI_ICON | ESI_MINI)) {
            WinDrawPointer(hps, 0, 0, himg,
                           (flStyle & ESI_MINI? DP_MINI: DP_NORMAL));
         } else {
            POINTL ptl = {0,0};
            WinDrawBitmap(hps, himg, NULL, &ptl, 0, 0, DBM_NORMAL);
         } // end if
         WinEndPaint(hps);
         return (MRESULT)FALSE;
      }  // end case WM_PAINT
      // restituisce handle immagine corrente
      case SM_QUERYHANDLE:
         return (MPARAM)WinQueryWindowULong(hwnd, cbWCstc);
      // memorizza nuovo handle immagine, forza repaint e restituisce
      // handle precedente immagine
      case SM_SETHANDLE: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         if (!WinSetWindowULong(hwnd, cbWCstc, (ULONG)mp1))
            return NULLHANDLE;
         WinRefreshWin(hwnd);
         return (MRESULT)himg;
      } // end case SM_SETHANDLE
      case WM_MATCHMNEMONIC:
         return (MRESULT)FALSE;
      case WM_DESTROY: {
         LHANDLE himg = (LHANDLE)WinQueryWindowULong(hwnd, cbWCstc);
         if (WinQueryWindowULong(hwnd, QWL_STYLE) &
                                (ESI_PTR | ESI_ICON | ESI_MINI)) {
            WinDestroyPointer(himg);
         } else {
            GpiDeleteBitmap(himg);
         } // end if
      }  break;
   } /* endswitch */
   return pfnwpWCstc(hwnd, msg, mp1, mp2); // default static controls processing
}
Container::~Container(void)
{
    // remove *all* records from the container with no arrange
    //    WinSendMsg(cont,CM_REMOVERECORD,MPFROMP((PRECORDCORE)CMA_FIRST),MPFROM2SHORT(0,0));
    if (no_delete)
        WinSendMsg(cont,CM_REMOVERECORD,MPFROMP((PRECORDCORE)CMA_FIRST),MPFROM2SHORT(0,CMA_FREE));
    
    WinDestroyPointer(icon_jpeg); 
    WinDestroyPointer(icon_avi); 
    WinDestroyPointer(icon_au); 
    WinDestroyPointer(icon_bmp); 
    WinDestroyPointer(icon_fli); 
    WinDestroyPointer(icon_gif); 
    WinDestroyPointer(icon_midi); 
    WinDestroyPointer(icon_mp3); 
    WinDestroyPointer(icon_mpeg); 
    WinDestroyPointer(icon_pcx); 
    WinDestroyPointer(icon_tga); 
    WinDestroyPointer(icon_tiff); 
    WinDestroyPointer(icon_wav); 
    WinDestroyPointer(icon_html); 
    WinDestroyPointer(icon_png); 
    WinDestroyPointer(icon_dunno); 
    WinDestroyPointer(icon_host_o);
    WinDestroyPointer(icon_host_c);
    WinDestroyPointer(icon_group_o);
    WinDestroyPointer(icon_group_c);
    WinDestroyPointer(icon_server);
}
예제 #11
0
/*----------------------------------------------------------------------*/
MRESULT EXPENTRY DMLBSubclassListboxProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
/*----------------------------------------------------------------------*/
/* This window procedure is used to subclass a standard PM listbox      */
/* control.  This procedure will intercept certain mouse events on the  */
/* listbox to implement direct-manipulation functions.                  */
/*----------------------------------------------------------------------*/
{
SHORT    Item;          /* Listbox item number                          */
DMLBData  *InstData;     /* This instance-specific data (per listbox)    */

   /* The lisbox window pointer is to our instance data. */

   InstData = WinQueryWindowPtr(hwnd, QWL_USER);
     
   switch (msg) {
      /* Since this is just a subclass setup after the listbox window */
      /* is created, we never get a WM_CREATE message here.           */

      case WM_DESTROY:
           /* The listbox window is being destroyed.  Cleanup any     */
           /* resources we have allocated in this subclass.           */
           if (InstData->DragMIcon != NULLHANDLE) {
             WinDestroyPointer(InstData->DragMIcon);
             WinDestroyPointer(InstData->DragCIcon);
             WinDestroyPointer(InstData->NorthIcon);
             WinDestroyPointer(InstData->SouthIcon);
             WinDestroyPointer(InstData->DragNoDrp);
             WinDestroyPointer(InstData->DeletIcon);
             InstData->DragMIcon = NULLHANDLE;
           }
           /* Cleanup other resources */
           if (InstData->Dragging) {
             WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID);
           }
           /* Release instance data */
           free(InstData);
           WinSetWindowPtr(hwnd, 0L, NULL);
           break;

      case WM_TIMER:
           /* We get timer messages during dragging to implement */
           /* auto-scrolling of listbox when pointer is placed   */
           /* north or south of the listbox while dragging.      */

           if (!InstData->Dragging)  /* Ignore if not dragging   */
             break;

           if (SHORT1FROMMP(mp1)==DRAG_TIMERID) {
             switch (InstData->PrevLocation) { // Last known location of the pointer
               case POINT_INSIDE:
               case POINT_OUTSIDE:
                 /* Do nothing */
                 break;

               case POINT_NORTH:
                 /* Scroll up one item */
                 Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX,  0L, 0L);
                 if ((Item != LIT_NONE) && (Item != 0))
                    WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item-1), 0L);
                 break;

               case POINT_SOUTH:
                 /* Scroll down one item */
                 Item = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYTOPINDEX,  0L, 0L);
                 if (Item != LIT_NONE)
                    WinPostMsg(InstData->TargetHwnd, LM_SETTOPINDEX, MPFROMSHORT(Item+1), 0L);
                 break;
             } /* switch on PrevLocation */
             return 0;
           }
           break;

      case WM_CONTEXTMENU: {
           SHORT CursorIndx, Max;

           /* User requested context menu... notify our owner.          */

           /* First find out what item the pointer is over.             */
           Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L );
           CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER);
           if ((Max == 0) || (CursorIndx+1 > Max))
             CursorIndx = LIT_NONE;

           /* Tell our owner about it */
           return WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                      MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_CONTEXT),
                      MPFROMSHORT(CursorIndx));
           }
 
      case WM_MOUSEMOVE:
           /* Monitor the position of the mouse relative to the listbox */
           /* so we can set the pointer icon correctly and note the     */
           /* position for use during WM_TIMER processing.              */

           if (!InstData->Dragging)   /* Ignore if not dragging */
             break;

           DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));

           /* Set pointer icon appropriate for location */
           if (InstData->DragMIcon == NULLHANDLE) {
             // Load all the pointers (one time only)
             InstData->DragMIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGMOVE);
             InstData->DragCIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGCOPY);
             InstData->DragNoDrp= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRAGNONE);
             InstData->NorthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGNORTH);
             InstData->SouthIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGSOUTH);
             InstData->DeletIcon= WinLoadPointer(HWND_DESKTOP, InstData->ResHMod, ID_DMLB_DRGDEL);
           }
           switch (InstData->PrevLocation) {
             case POINT_INSIDE:
               switch (InstData->TargetDropMode) {
               case DROPMODE_MOVE:
                 WinSetPointer(HWND_DESKTOP, InstData->DragMIcon); // Use MOVE pointer 
                 break;
               case DROPMODE_COPY:
                 WinSetPointer(HWND_DESKTOP, InstData->DragCIcon); // Use COPY pointer
                 break;
               case DROPMODE_DELETE:
                 WinSetPointer(HWND_DESKTOP, InstData->DeletIcon); // Use DELETE pointer
                 break;
               }
               break;
             case POINT_OUTSIDE:
               WinSetPointer(HWND_DESKTOP, InstData->DragNoDrp);   // No-drop pointer
               break;
             case POINT_NORTH:
               WinSetPointer(HWND_DESKTOP, InstData->NorthIcon);   // Scroll-up pointer
               break;
             case POINT_SOUTH:
               WinSetPointer(HWND_DESKTOP, InstData->SouthIcon);   // Scroll-down poineter
               break;
           }
 
           return (MRESULT)TRUE;  /* Note we processed the message */

      case WM_BEGINDRAG:
           {
           SHORT  Max;
           SHORT i, CursorIndx, hit;

           /* User started dragging with the pointer on our window */

           Max = (SHORT)WinSendMsg( hwnd, LM_QUERYITEMCOUNT, 0L, 0L );

           /* If we are currently dragging, cancel it (should not happen) */
 
           if ( InstData->Dragging ) {
             InstData->Dragging = FALSE;
             WinSetCapture( HWND_DESKTOP, NULLHANDLE );
             return (MRESULT)FALSE;
           }

           /* Get index of item under the mouse pointer and check */
           /* for reasonable numeric bounds.                      */
 
           CursorIndx = DMLBLocateListboxItem(hwnd, hwnd, SHORT2FROMMP(mp1), LLI_UNDER);
           if ((Max == 0) || (CursorIndx+1 > Max)) {
             DosBeep( 440L, 50L );  // Don't allow drag if not on a listbox item
             return (MRESULT)FALSE;
           }

           /* Since we currently support dragging only a single item, */
           /* de-select all items and just select the one under the   */
           /* pointer.  To support multiple-drag we would probably    */
           /* need to notify the owner so they could set the selection*/
           /* status of all items to be dragged (which may or may not */
           /* include the item under the pointer).                    */

           WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPVOID);
           WinSendMsg(hwnd, LM_SELECTITEM, MPFROMSHORT(CursorIndx), MPFROMSHORT(TRUE));

           /* Note we are now dragging and capture the pointer. */
 
           InstData->Dragging = TRUE;
           WinSetCapture( HWND_DESKTOP, hwnd );
           InstData->PrevLocation = POINT_INSIDE;
           WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID, WinQuerySysValue(HWND_DESKTOP, SV_SCROLLRATE));
           return (MRESULT)TRUE;
           break;
           }
 
      case WM_ENDDRAG:
            {
            SHORT DropIndx, CurrIndx;
            SHORT SourceMax, TargetMax;      /* Num of items in source/target listbox */
            char  *CopyText;                 /* Text to be copied/moved */
            USHORT CopyTextLen;              /* Length of text */
            void   *CopyHand;                /* Handle of item to be copied/moved */
            BOOL  SameList = FALSE;          /* Source and target are same listbox */
 
            if (!InstData->Dragging)         /* Ignore if we are not dragging */
              return (MRESULT)FALSE;
 
            /* Clear dragging indicators and release pointer */

            InstData->Dragging = FALSE;
            WinSetCapture( HWND_DESKTOP, NULLHANDLE );
            WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,DRAG_TIMERID);

            /* See if what is under the pointer will accept the drop */
            DMLBCheckTargetLocation(hwnd, InstData, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
            if (InstData->PrevLocation != POINT_INSIDE)
              return (MRESULT)TRUE;  /* Ignore drop outside a good listbox */

            if (hwnd == InstData->TargetHwnd)  // Source and target are same listbox
              SameList = TRUE;

            SourceMax = (SHORT)WinSendMsg(hwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1;
            TargetMax = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_QUERYITEMCOUNT, 0L, 0L ) -1;

            /* Get drop point and original selected point */

            DropIndx = DMLBLocateListboxItem(InstData->TargetHwnd, hwnd, SHORT2FROMMP(mp1), LLI_INSERTPOINT);
            CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L);

            /* Prevent move onto same item as source, in same listbox           */
            /* being careful of DropIndx > SourceMax when drop after last item. */
            if ((InstData->TargetDropMode==DROPMODE_MOVE) &&
                (SameList) &&
                ((min(DropIndx,SourceMax) == CurrIndx) || (DropIndx == CurrIndx+1))) {
              DosBeep( 700L, 50L );  /* Don't drop before or after original */
              return (MRESULT)TRUE;
            }

            /* Make a copy of original to insert */

            CopyTextLen = (SHORT)WinSendMsg(hwnd,LM_QUERYITEMTEXTLENGTH,MPFROMSHORT(CurrIndx), 0L) + 1;
            CopyText = malloc(CopyTextLen);
            WinSendMsg(hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(CurrIndx, CopyTextLen), MPFROMP(CopyText));
            CopyHand = WinSendMsg(hwnd, LM_QUERYITEMHANDLE, MPFROMSHORT(CurrIndx), 0L);

            /* Insert before insertion point, or at end of list */
            if (DropIndx > TargetMax)
              DropIndx = LIT_END;

            /* Disable update during insert/delete for smoother visual and */
            /* prevent ownerdraw from occuring before new handles are set. */

            WinEnableWindowUpdate(hwnd, FALSE);
            WinEnableWindowUpdate(InstData->TargetHwnd, FALSE);
            
            /* Insert into target list */
            if (InstData->TargetDropMode != DROPMODE_DELETE) {
              DropIndx = (SHORT)WinSendMsg(InstData->TargetHwnd, LM_INSERTITEM, MPFROMSHORT(DropIndx), MPFROMP(CopyText));
              WinSendMsg(InstData->TargetHwnd, LM_SETITEMHANDLE, MPFROMSHORT(DropIndx), MPFROMP(CopyHand));
            }
            free(CopyText);

            /* Tell owner of originating listbox what we are doing.  We must notify */
            /* the owner before we delete items because they may keep dynamic data  */
            /* in the item handles that has to be freed.  The item in question is   */
            /* the currently selected item in the listbox.                          */

            switch (InstData->TargetDropMode) {
              case DROPMODE_MOVE:
                 if (!SameList)
                   WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                           MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE_MOVE),
                           MPFROMHWND(InstData->TargetHwnd));
                 break;
              case DROPMODE_DELETE:
                 WinSendMsg(WinQueryWindow(hwnd, QW_OWNER), WM_CONTROL,
                           MPFROM2SHORT(WinQueryWindowUShort(hwnd, QWS_ID), LN_DMLB_DELETE),
                           MPFROMHWND(InstData->TargetHwnd));
                 break;
            }

            /* If this is a move, delete original.  If it is in the same  */
            /* listbox as target, get new index since it may have         */
            /* changed due to inserted copy.                              */

            if ((InstData->TargetDropMode == DROPMODE_MOVE) || (InstData->TargetDropMode == DROPMODE_DELETE)) {
              CurrIndx = (SHORT)WinSendMsg(hwnd, LM_QUERYSELECTION, MPFROMSHORT(LIT_FIRST), 0L);
              WinSendMsg(hwnd, LM_DELETEITEM, MPFROMSHORT(CurrIndx), 0L);
            }

            /* Select the newly inserted item.  If the old copy was             */
            /* above it in the same list, then the item number has changed by 1 */

            if ((DropIndx > CurrIndx) && (SameList) && (InstData->TargetDropMode==DROPMODE_MOVE))
              DropIndx--;
            if (InstData->TargetDropMode != DROPMODE_DELETE) {
              WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
              WinSendMsg(InstData->TargetHwnd, LM_SELECTITEM, MPFROMSHORT(DropIndx), MPFROMSHORT(TRUE));
            }

            WinEnableWindowUpdate(hwnd, TRUE);
            WinEnableWindowUpdate(InstData->TargetHwnd, TRUE);

            /* Notify target of inserted items if necessary */

            switch (InstData->TargetDropMode) {
              case DROPMODE_MOVE:
                if (SameList)
                   WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_REORDERED),
                         MPFROMHWND(hwnd));
                else
                   WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_MOVE),
                         MPFROMHWND(hwnd));
                break;
              case DROPMODE_COPY:
                WinSendMsg(WinQueryWindow(InstData->TargetHwnd, QW_OWNER), WM_CONTROL,
                         MPFROM2SHORT(WinQueryWindowUShort(InstData->TargetHwnd, QWS_ID), LN_DMLB_INSERT_COPY),
                         MPFROMHWND(hwnd));
                break;
            }

            return (MRESULT)TRUE;
            }
 
      }
 
   /* Call previous window procedure to process this message */
   return ( (*(InstData->OldProcAddr)) ( hwnd, msg, mp1, mp2 )  );
   }
예제 #12
0
파일: Driver.C 프로젝트: ErisBlastar/osfree
MRESULT	EXPENTRY DriverWndProc(HWND hWnd, ULONG	msg, MPARAM mp1, MPARAM	mp2)

{
CHAR	     szFile[CCHMAXPATH];   /* File HOlder			*/
FILEFINDBUF3 findbuf;		   /* File Find	Buffer			*/
FONTMETRICS  fm;		   /* Font Metrics Structure		*/
HDIR	     hDir = (HDIR)HDIR_CREATE; /* Directory Handle		*/
HPS	     hPS;		   /* Presentation Space Handle		*/
HWND	     hwndListBox;	   /* List Box Window Handle		*/
LISTBOXCDATA lbwcd;		   /* List Box Window Control Data	*/
POWNERITEM   poi;		   /* Owner Item			*/
RECTL	     rcl;		   /* Client Window Rectangle		*/
ULONG	     ulFileCnt = 1UL;	   /* File Counter Holder		*/
register INT i,	k, n;		   /* Loop Counter			*/

switch ( msg )
   {
		       /* Perform window initialization			*/
   case	WM_CREATE :
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);
       WinSetPointer(HWND_DESKTOP, hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
       memset(&lbwcd, 0, sizeof(LISTBOXCDATA));
       lbwcd.cb	= sizeof(LISTBOXCDATA);
       lbwcd.ulVersion = LBV_110;
       lbwcd.vdata.lbcd1_1.flExtStyles = LSXS_CHECKBOX | LSXS_EDITABLE;

       hwndList1 = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   10L,	10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndListx = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   125L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndList2 = WinCreateWindow(hWnd, "ListBoxWindow", "", WS_VISIBLE, 10L, 190L, 250L, 200L, hWnd,
				   HWND_TOP, 1025UL, (PVOID)&lbwcd, (PVOID)NULL);

       WinSendMsg(hwndList1, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_SINGLECLICK),
		  MPFROMP("ahooga.wav"));
       WinSendMsg(hwndListx, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_DOUBLECLICK),
		  MPFROMP("flush.wav"));

       hwndListA = WinCreateWindow(hWnd, WC_LISTBOX, "", LS_OWNERDRAW |	LS_HORZSCROLL |	LS_MULTIPLESEL | WS_VISIBLE,
				   275L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1026UL, (PVOID)NULL, (PVOID)NULL);

		       /* Sub-class the	default	window procedure with	*/
		       /* new one which	will handle specific messages	*/
		       /* allowing better control over the sizing frame	*/

       hwndListB = WinCreateWindow(hWnd, WC_LISTBOX, "", WS_VISIBLE | LS_EXTENDEDSEL, 275L, 190L, 250L,	200L, hWnd,
				   HWND_TOP, 1027UL, (PVOID)NULL, (PVOID)NULL);

       for ( i = 0; i <	10; i++	)
	   {
	   sprintf(szFile, "Item %04d Item %04d Item %04d", i, i, i);
	       WinSendMsg(hwndListx, LM_INSERTITEM,
			  MPFROMLONG(LIT_END),
			  MPFROMP(szFile));
	   }

       n = (INT)WinSendMsg(hwndList2, LMX_CALCLINECOUNT, MPFROMLONG(175L), 0L);

       k = 0;

       WinSendMsg(hwndList2, LM_SETITEMHEIGHT, MPFROMLONG(36L),	0L);

       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndList2, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       if ( ++k	> n )
		   WinSendMsg(hwndList2, LM_SETTOPINDEX, MPFROMLONG(k -	n), 0L);
	       WinSendMsg(hwndListB, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       break;

   case	WM_BUTTON1DOWN :
       WinEnableWindowUpdate(hwndListA,	FALSE);
       WinEnableWindowUpdate(hwndList1,	FALSE);

       WinSendMsg(hwndListA, LM_DELETEALL, 0L, 0L);
       WinSendMsg(hwndList1, LM_DELETEALL, 0L, 0L);
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       WinShowWindow(hwndListA,	TRUE);
       WinShowWindow(hwndList1,	TRUE);

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       }
	   --i;
	   }
       break;

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
		       /* Process double click on a List Box		*/

	   case	LN_SELECT :
	       switch (	SHORT1FROMMP(mp1) )
		   {
		   case	1024UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_NOTE);	  */
		       break;

		   case	1027UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_ERROR);  */
		       break;
		   }
	       break;
	   }
       break;


   case	WM_MEASUREITEM :
       GpiQueryFontMetrics(hPS = WinGetPS(hWnd), sizeof(FONTMETRICS), &fm);
       WinReleasePS(hPS);
       return(MRFROMLONG(fm.lMaxBaselineExt));

		       /* Draw a list box item				*/
   case	WM_DRAWITEM :

       if ( SHORT1FROMMP(mp1) == 1024 )
	   hwndListBox = hwndList1;
       else
	   if (	SHORT1FROMMP(mp1) == 1026 )
	       hwndListBox = hwndListA;

		       /* Point	to Owner Item information		*/

       poi = (POWNERITEM)mp2;
       GpiCreateLogColorTable(poi->hps,	0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXTLENGTH,
				      MPFROMLONG(poi->idItem), 0L));

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXT,
				      MPFROM2SHORT(poi->idItem,	CCHMAXPATH),
				      MPFROMP(szFile)));

		       /* Check	to see if item to be drawn or		*/
		       /* highlighted					*/

       if ( poi->fsState != poi->fsStateOld )
	   {
	   WinFillRect(poi->hps, &poi->rclItem,	RGBCLR_DIALOGBACKGROUND);

	   if (	poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);

		       /* Set item highlighting	by inverting the items	*/
		       /* rectangle colour				*/

	   WinInvertRect(poi->hps, &poi->rclItem);

	   if (	!poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);
	   poi->fsState	= poi->fsStateOld = 0;
	   }
       else
	   {
		       /* Item needs to	be drawn, get item rectangle	*/
		       /* item position					*/

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

	   WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
		       RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER	|
		       DT_ERASERECT);
	   }
       return(MRFROMLONG(TRUE));

   case	WM_BUTTON1DBLCLK :
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       }
	   --i;
	   }
       break;

   case	WM_BUTTON2DOWN :

       for ( i = 0; i <	5; i++ )
	   WinSendMsg(hwndListx, LM_DELETEITEM,	MPFROMSHORT(2),	0L);

#if 0
       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(LIT_NONE), MPFROMLONG(TRUE));

       i = LIT_FIRST;
       while ( (i = (INT)LONGFROMMR(WinSendMsg(hwndList1, LM_QUERYSELECTION, MPFROMLONG(i), 0L))) != LIT_NONE )
	   WinSendMsg(hwndList1, LM_SELECTITEM,	MPFROMLONG(i), MPFROMLONG(FALSE));
#endif
       break;
		       /* Erase	background				*/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)mp1, &rcl, SYSCLR_DIALOGBACKGROUND);
       break;
		       /* Paint	the main client	window			*/
   case	WM_PAINT :
       WinSetPointer(HWND_DESKTOP, hptrWait);

       WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL,	&rcl), &rcl, SYSCLR_DIALOGBACKGROUND);

       WinEndPaint(hPS);
       WinSetPointer(HWND_DESKTOP, hptrArrow);
       break;
		       /* Close	Down					*/
   case	WM_CLOSE :

       WinPostMsg(hWnd,	WM_QUIT, 0L, 0L);
       break;

   case	WM_DESTROY :
       WinDestroyPointer(hptrArrow);
       WinDestroyPointer(hptrWait);
       break;
		       /* Default message processing			*/
   default:
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
예제 #13
0
MRESULT EXPENTRY wpCD(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
	switch (msg)
	{
		case WM_INITDLG:
		{
			ULONG rc, i;
			HFILE CDDevice;
			ULONG action;
			ULONG len;
			struct
			{
				USHORT CountCD;
				USHORT FirstCD;
			} CDInfo;
			FIELDINFO *firstFieldInfo, *posFieldInfo, *splitFieldInfo;
			FIELDINFOINSERT fieldInfoInsert;
			CNRINFO cnrInfo;
			cnrInfo.cb = sizeof(cnrInfo);

			firstFieldInfo = posFieldInfo = allocaFieldInfo(hwnd, CT_TRACK, NUM_FIELDS);
			posFieldInfo->flData = CFA_BITMAPORICON | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Icon";
			posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,hptrIcon);
			fieldInfo[0] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Filename";
			posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,pszIcon);
			fieldInfo[1] = posFieldInfo;

			cnrInfo.pFieldInfoLast = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Track #";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,track);
			fieldInfo[2] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Type";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,typepointer);
			fieldInfo[3] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Time";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,timepointer);
			fieldInfo[4] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Size";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,size);
			fieldInfo[5] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "MP3 Size";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,mp3size);
			fieldInfo[6] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Title";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,titleptr);
			fieldInfo[7] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Artist";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,artistptr);
			fieldInfo[8] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Album";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,albumptr);
			fieldInfo[9] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Year";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,yearptr);
			fieldInfo[10] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Genre";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,genreptr);
			fieldInfo[11] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Comment";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,commentptr);
			fieldInfo[12] = posFieldInfo;

			fieldInfoInsert.cb = sizeof(fieldInfoInsert);
			fieldInfoInsert.pFieldInfoOrder = (FIELDINFO *) CMA_FIRST;
			fieldInfoInsert.fInvalidateFieldInfo = TRUE;
			fieldInfoInsert.cFieldInfoInsert = NUM_FIELDS;

			insertFieldInfo(hwnd, CT_TRACK, firstFieldInfo, &fieldInfoInsert);

			cnrInfo.xVertSplitbar = 100;
			cnrInfo.flWindowAttr = CV_DETAIL | CA_DETAILSVIEWTITLES;
			WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo),
				MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR | CMA_FLWINDOWATTR));


			loadConfig(CFGFILE, &grabbers, &countGrabbers);
			for(i = 0; i < countGrabbers; i++)
				insertItemText(hwnd,CB_GRABBER,LIT_END,grabbers[i].id);
			selectItem(hwnd,CB_GRABBER,0);

			setText(hwnd, EF_TITLE, "Title");

			/* wohw, this is too powerful, need cooling */

			len = sizeof(CDInfo);
			if(!DosOpen("\\DEV\\CD-ROM2$", &CDDevice, &action, 0,
							FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
							OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL))
			{
				if(!DosDevIOCtl(CDDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, len, &len))
				{
					for(i = 0; i < CDInfo.CountCD; i++)
					{
						char driveLetter[3] = { (char) ('A' + CDInfo.FirstCD + i), ':', 0};
						insertItemText(hwnd,CB_DRIVE,LIT_END,driveLetter);
					}
				}
				DosClose(CDDevice);
			}

			selectItem(hwnd,CB_DRIVE,0);

			wpCT = WinSubclassWindow(WinWindowFromID(hwnd,CT_TRACK),wpCTTrack);

			dataIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_DATA);
			trackIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_TRACK);
			loadIni(hwnd);
			return 0;
		}
		case WM_COMMAND:
			return processCommand(hwnd,mp1,mp2);
		case WM_CONTROL:
			return processControl(hwnd,mp1,mp2);
		case WM_ADJUSTFRAMEPOS:
		{
			SWP *pos = (SWP*) PVOIDFROMMP(mp1);
			static int bitRateCheck = 0;
			if(pos->fl & SWP_SIZE)
			{
				SWP ctpos;
				WinQueryWindowPos(WinWindowFromID(hwnd, CT_TRACK), &ctpos);
				WinSetWindowPos  (WinWindowFromID(hwnd, CT_TRACK), 0, 0, ctpos.y,
									  pos->cx, pos->cy - ctpos.y,
									  SWP_SIZE | SWP_SHOW | SWP_MOVE);
			}

			if((pos->fl & SWP_SHOW) && bitRateChanged != bitRateCheck)
			{
				bitRateCheck = bitRateChanged;
				refreshFieldInfo(hwnd, CT_TRACK);
			}
			break;
		}

		case WM_MENUEND:
			removeSourceEmphasis(HWNDFROMMP(mp2),&sourceEmphasisInfo);
			return 0;

		case WM_CLOSE:
		{
			WinDestroyPointer(dataIco);
			WinDestroyPointer(trackIco);
			free(grabbers);
			saveIni(hwnd);

			/* delete all current records */
			CDTRACKRECORD *record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, NULL, CMA_FIRST);
			while(record && record != (CDTRACKRECORD *) -1)
			{
				free(record->record.pszIcon);
				record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, (RECORDCORE *) record, CMA_NEXT);
			}

			removeRecords(hwnd, CT_TRACK, NULL, 0);

			removeFieldInfo(hwnd,CT_TRACK, NULL, 0);
			return 0;
		}

		case WM_CHAR:
			if(SHORT2FROMMP(mp2) == VK_ESC)
				return 0;
			else
				break;

		/* back from worker thread */
		case DLGCD_REFRESH:
			dlgcd_refresh2(mp1,mp2);
			return 0;

      case CDDB_FUZZYMATCH:
		{
			CDDBQUERY_DATA *matches = (CDDBQUERY_DATA *) mp1,
								*chosen	= (CDDBQUERY_DATA *) mp2;
         FUZZYMATCHCREATEPARAMS data = {matches,chosen};

			WinDlgBox(HWND_DESKTOP, hwnd, wpMatch, NULLHANDLE, DLG_MATCH, &data);
              
			return 0;
		}

	}

	return WinDefDlgProc( hwnd, msg, mp1, mp2 );
}