Exemplo n.º 1
0
Arquivo: dnd.cpp Projeto: EdgarTx/wx
MRESULT CIDropTarget::DragOver ()
{
    char                            zBuffer[128];
    ULONG                           ulBytes;
    USHORT                          uOp = 0;
    USHORT                          uIndicator;
    ULONG                           ulItems;
    ULONG                           i;

    ::DrgAccessDraginfo(m_pDragInfo);
    switch(m_pDragInfo->usOperation)
    {
        case DO_UNKNOWN:
            Free();
            return (MRFROM2SHORT(DOR_NODROPOP, 0));

        case DO_DEFAULT:
            m_pDragItem = ::DrgQueryDragitemPtr(m_pDragInfo, 0);
            ulBytes     = ::DrgQueryStrName( m_pDragItem->hstrContainerName
                                            ,128
                                            ,zBuffer
                                           );
            if (!ulBytes)
                return (MRFROM2SHORT(DOR_NODROPOP, 0));
            else
                uOp = DO_MOVE;
            break;

        case DO_COPY:
        case DO_MOVE:
            uOp = m_pDragInfo->usOperation;
            break;
    }
    uIndicator = DOR_DROP;
    ulItems = (ULONG)::DrgQueryDragitemCount(m_pDragInfo);
    for (i = 0; i < ulItems; i++)
    {
        m_pDragItem = ::DrgQueryDragitemPtr(m_pDragInfo, i);
        if (((m_pDragItem->fsSupportedOps & DO_COPYABLE) &&
             (uOp == (USHORT)DO_COPY))                   ||
            ((m_pDragItem->fsSupportedOps & DO_MOVEABLE) &&
             (uOp == (USHORT)DO_COPY)))
        {
            if (::DrgVerifyRMF(m_pDragItem, "DRM_OS2FILE", "DRF_UNKNOWN"))
                uIndicator = (USHORT)DOR_DROP;
            else
                uIndicator = (USHORT)DOR_NEVERDROP;
        }
    }
    Free();
    return (MRFROM2SHORT(uIndicator, uOp));
} // end of CIDropTarget::DragOver
Exemplo n.º 2
0
long wxListBox::OS2OnMeasure(
  WXMEASUREITEMSTRUCT*              pItem
)
{
    if (!pItem)
        pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM;

    POWNERITEM                      pMeasureStruct = (POWNERITEM)pItem;
    wxScreenDC                      vDc;

    //
    // Only owner-drawn control should receive this message
    //
    wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );

    vDc.SetFont(GetFont());

    wxCoord                         vHeight;
    wxCoord                         vWidth;

    GetSize( &vWidth
            ,NULL
           );

    pMeasureStruct->rclItem.xRight = (USHORT)vWidth;
    pMeasureStruct->rclItem.xLeft  = 0;
    pMeasureStruct->rclItem.yTop   = 0;
    pMeasureStruct->rclItem.yBottom = 0;

    vHeight = (wxCoord)(vDc.GetCharHeight() * 2.5);
    pMeasureStruct->rclItem.yTop  = (USHORT)vHeight;

    return long(MRFROM2SHORT((USHORT)vHeight, (USHORT)vWidth));
} // end of wxListBox::OS2OnMeasure
static MRESULT EXPENTRY
ControllerValueSetSubclassWndProc (HWND hwnd, ULONG msg,
    MPARAM mp1, MPARAM mp2)
{
    switch (msg)
    {
        case DM_DRAGOVER:
        {
            USHORT          usIndicator;
            PDRAGITEM       pditem;
            PDRAGINFO       pdinfo = (PDRAGINFO) PVOIDFROMMP (mp1);

            pfnwpValueSet (hwnd, msg, mp1, mp2);

            assert (DrgAccessDraginfo(pdinfo));

            pditem = DrgQueryDragitemPtr (pdinfo, 0);

            if (DrgVerifyRMF (pditem, 0, "DRF_AIRCRAFT"))
            {
                usIndicator = (pdinfo->usOperation == DO_DEFAULT
                    || pdinfo->usOperation == DO_MOVE) ?
                    DOR_DROP : DOR_NODROP;
            }
            else
                usIndicator = DOR_NEVERDROP;

            return MRFROM2SHORT(usIndicator, DO_MOVE);
        }

    }
    return pfnwpValueSet (hwnd, msg, mp1, mp2);
}
Exemplo n.º 4
0
Arquivo: hin.c Projeto: komh/hanedit2
MRESULT hia_usermCompleteHch(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);
HANCHAR hch;

//  printf("HIAM_COMPLETEHCH\n");

    if (hia->inbuf->newpos == HIABUF_NONE) return 0L;
    hch = HIABufPeekHch(hia->inbuf);
    HIA_NotifyToConnected(hia,HIAN_COMPO_COMPLETE,MPFROM2SHORT(hch,0));
    HIA_NotifyToConnected(hia,HIAN_INSERTHCH,MPFROM2SHORT(hch,0));
    HIABufClear(hia->inbuf);

    return MRFROM2SHORT(hch,0);
}
Exemplo n.º 5
0
Arquivo: hin.c Projeto: komh/hanedit2
MRESULT hia_usermCancelKey(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
HIA *hia = WinQueryWindowPtr(hwnd,WINWORD_INSTANCE);
HANCHAR hch;

//  printf("HIAM_CANCELKEY\n");

    HIABufPop(hia->inbuf);
    hch = HIABufPeekHch(hia->inbuf);
    if (hia->inbuf->newpos)
        HIA_NotifyToConnected(hia,HIAN_COMPO_STEPBACK,
            MPFROM2SHORT(0,hch));
        else
        HIA_NotifyToConnected(hia,HIAN_COMPO_CANCEL,0);
    return MRFROM2SHORT(hch,0);
}
Exemplo n.º 6
0
/*
 * The prototype for ico_wpDragOver was replaced by the following prototype:
 */
SOM_Scope MRESULT  SOMLINK ico_wpDragOver(DDIcon *somSelf, HWND hwndCnr,
                                          PDRAGINFO pdrgInfo)
{
   ULONG  ulItemCnt   = 0;           // Number of items dragged over
   ULONG  ulItem      = 0;           // Item index
   USHORT usDropIndic = DOR_DROP;    // What to do with dragged items
   WPObject* object;
   BOOL success;

   /* DDIconData *somThis = DDIconGetData(somSelf);*/
   DDIconMethodDebug("DDIcon","ico_wpDragOver");

   _Pmpf(("Preforming 'wpDragOve'"));

   ulItemCnt = DrgQueryDragitemCount(pdrgInfo);

   /*
    * Check every dragged item. If one is not a WPS object, do not accept
    */
   for (ulItem=0; ulItem < ulItemCnt; ulItem++)
   {
      DRAGITEM DItem;

      success = DrgQueryDragitem(pdrgInfo, sizeof(DItem), &DItem, ulItem);
      if (!success)
      {
         usDropIndic=DOR_NEVERDROP;
         break;
      }

      object = GetOriginalObject(OBJECT_FROM_PREC((&DItem)->ulItemID));

      /*
       * Check if the item is a WPS object or an icon object. If it is not a WPS
       * object or if it is an icon object, do not accept the drop.
       */
      if(!DrgVerifyRMF(&DItem,"DRM_OBJECT","DRF_OBJECT") || _somIsA(object, _DDIcon))
      {
         usDropIndic=DOR_NEVERDROP;
         break;
      }
   }
return (MRFROM2SHORT (usDropIndic, DO_UNKNOWN));
}
Exemplo n.º 7
0
//
// Return item size
// ----------------
//
long wxCheckListBox::OS2OnMeasure ( WXMEASUREITEMSTRUCT* pItem )
{
    if (!pItem)
        pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM;
    if (wxListBox::OS2OnMeasure(pItem))
    {
        POWNERITEM pStruct = (POWNERITEM)pItem;

        //
        // Save item height
        //
        m_nItemHeight = pStruct->rclItem.yTop - pStruct->rclItem.yBottom;

        //
        // Add place for the check mark
        //
        pStruct->rclItem.xRight += CHECK_MARK_WIDTH;
        return long(MRFROM2SHORT((USHORT)m_nItemHeight, (USHORT)(pStruct->rclItem.xRight - pStruct->rclItem.xLeft)));
    }
    return 0L;
} // end of wxCheckListBox::CreateItem
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
static MRESULT getsize(HWND hwnd)
{
   SLIDERDATA *cfg = WinQueryWindowPtr(hwnd,0);
   return MRFROM2SHORT(cfg->cx,cfg->cy);
}
Exemplo n.º 10
0
MRESULT Window::stdWndProc( HWND hWnd, ULONG iMessage, MPARAM mParam1,
                            MPARAM mParam2, BOOL *returned )
{
  switch( iMessage )
  {
//    case WM_FOCUSCHANGE :
    case WM_SETSELECTION :
    case WM_ACTIVATE :
    {
      if( type != Window::LISTBOX &&
          type != Window::COMBOLISTBOX )
      {
        focus( (BOOL)mParam1 );//SHORT1FROMMP( mParam2 ) );
      }
      break;
    }
    case WM_SETFOCUS :
    {
      if( type != Window::LISTBOX &&
          type != Window::COMBOLISTBOX )
        focusSet( (BOOL)mParam2 );
      break;
    }
    case WM_BUTTON1DOWN :
    {
      if( type == SCROLLBAR )
        setFocus();
      HWND hwnd = WinQueryFocus( HWND_DESKTOP );
      if( mouseListener.getSize() != 0 )
      {
        mouseButtonDown = TRUE;
        WinSetCapture( HWND_DESKTOP, hWnd );
	  		WinStartTimer( Application::hab, hWndClient, 1, 50 );
        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOWN );
      }
      if( hwnd != WinQueryFocus( HWND_DESKTOP ) ) return (MRESULT)TRUE;
      break;
    }
    case WM_BUTTON1UP :
    {
      if( type == LISTBOX ||
          type == COMBOLISTBOX )
      {
        performFocusEvent(
          (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) );
      }
      else
      if( mouseListener.getSize() != 0 )
      {
        mouseButtonDown = FALSE;
        WinStopTimer( Application::hab, hWndClient, 1 );
        WinSetCapture( HWND_DESKTOP, NULLHANDLE );
        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::RELEASE );
//        return (MPARAM)TRUE;
      }
      break;
    }
    case WM_BUTTON2DOWN :
    {
      if( mouseListener.getSize() != 0 )
      {
        WinSetCapture( HWND_DESKTOP, hWnd );
	  		WinStartTimer( Application::hab, hWndClient, 1, 50 );
        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOWN );
      }
      break;
    }
    case WM_BUTTON2UP :
    {
      if( mouseListener.getSize() != 0 )
      {
        WinStopTimer( Application::hab, hWndClient, 1 );
        WinSetCapture( HWND_DESKTOP, NULLHANDLE );
        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::RELEASE );
      }
      break;
    }
    case WM_BUTTON1CLICK :
    {
      if( mouseListener.getSize() != 0 )
      {
				// Check if triple click

				int newTick = WinGetCurrentTime( Application::hab );
				if( newTick - lastTick <= 
            WinQuerySysValue( HWND_DESKTOP, SV_DBLCLKTIME ) )
				{
	        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
		      performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::TRIPLECLICK );
				}
				else
        {
        	Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        	performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::CLICK );
				}
      }
      break;
    }
    case WM_BUTTON2CLICK :
    {
      if( mouseListener.getSize() != 0 )
      {
        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::CLICK );
      }
      break;
    }
    case WM_BUTTON1DBLCLK :
    {
      if( mouseListener.getSize() != 0 )
      {
        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOUBLECLICK );
      }
			lastTick = WinGetCurrentTime( Application::hab );
      break;
    }
    case WM_BUTTON2DBLCLK :
    {
      if( mouseListener.getSize() != 0 )
      {
        Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOUBLECLICK );
      }
      break;
    }
    case WM_MOUSEMOVE :
    {
      if( currentPointer != NULLHANDLE )
        WinSetPointer( HWND_DESKTOP, currentPointer );
      if( mouseListener.getSize() != 0 )
      {
        Point pos( (SHORT)SHORT1FROMMP(mParam1), (SHORT)SHORT2FROMMP(mParam1) );
        performMouseEvent( &pos, 0, AMouseEvent::MOVE );
      }
      if( currentPointer != NULLHANDLE )
       	return (MPARAM)TRUE;
      break;
    }
    case WM_TIMER :
    {
      if( mouseButtonDown )
      {
        POINTL ptl;
        WinQueryPointerPos( HWND_DESKTOP, &ptl );
        WinMapWindowPoints( HWND_DESKTOP, hWnd, &ptl, 1 );

        if( ptl.y < 0 || ptl.y > height )
        {
          Point pos( ptl.x, ptl.y );
          performMouseEvent( &pos, 0, AMouseEvent::MOVE );
        }
      }
      break;
    }
    case WM_SIZE :
    {
      int oldWidth = width, oldHeight = height;
      SWP swp;

      WinQueryWindowPos( hWndFrame, &swp );

      width = swp.cx;
      height = swp.cy;
      size( oldWidth, oldHeight );
      break;
    }
    case WM_HSCROLL :
    {
      int pos = SHORT1FROMMP( mParam2 ), id = SHORT1FROMMP( mParam1 );
      switch( SHORT2FROMMP( mParam2 ) )
      {
        case SB_PAGERIGHT :
        {
          performScrollbarEvent( id, Scrollbar::PAGERIGHT, pos );
          break;
        }
        case SB_PAGELEFT :
        {
          performScrollbarEvent( id, Scrollbar::PAGELEFT, pos );
          break;
        }
        case SB_LINERIGHT :
        {
          performScrollbarEvent( id, Scrollbar::LINERIGHT, pos );
          break;
        }
        case SB_LINELEFT :
        {
          performScrollbarEvent( id, Scrollbar::LINELEFT, pos );
          break;
        }
        case SB_SLIDERTRACK :
        {
          performScrollbarEvent( id, Scrollbar::HORZTRACK, pos );
          break;
        }
        case SB_SLIDERPOSITION :
        {
          performScrollbarEvent( id, Scrollbar::HORZRELEASED, pos );
          break;
        }
      }
      break;
    }
    case WM_SYSCOMMAND :
    {
      // Check if the parent is a dialog, then chain the WM_SYSCOMMAND

      if( parent->getType() == DIALOG )
        WinSendMsg( ((Window *)parent)->getHWND(), WM_SYSCOMMAND, mParam1, mParam2 );
      break;
    }
    case WM_VSCROLL :
    {
      int id = SHORT1FROMMP( mParam1 );
      Scrollbar *scrollbar = (Scrollbar *)getControl( id );
      int pos;
      if( scrollbar )
        pos = scrollbar->convertScrollPosToReal( SHORT1FROMMP( mParam2 ) );
      else
        pos = SHORT1FROMMP( mParam2 );

      switch( SHORT2FROMMP( mParam2 ) )
      {
        case SB_PAGEDOWN :
        {
          performScrollbarEvent( id, Scrollbar::PAGEDOWN, pos );
          break;
        }
        case SB_PAGEUP :
        {
          performScrollbarEvent( id, Scrollbar::PAGEUP, pos );
          break;
        }
        case SB_LINEDOWN :
        {
          performScrollbarEvent( id, Scrollbar::LINEDOWN, pos );
          break;
        }
        case SB_LINEUP :
        {
          performScrollbarEvent( id, Scrollbar::LINEUP, pos );
          break;
        }
        case SB_SLIDERTRACK :
        {
          performScrollbarEvent( id, Scrollbar::VERTTRACK, pos );
          break;
        }
        case SB_SLIDERPOSITION :
        {
          performScrollbarEvent( id, Scrollbar::VERTRELEASED, pos );
          break;
        }
      }
      break;
    }
    case WM_MOVE :
    {
      SWP swp;

      WinQueryWindowPos( hWndFrame, &swp );

      x = swp.x;
      y = swp.y;
      move();
      break;
    }
    case WM_CLOSE :
    {
      if( close() )
        break;
      else
        return (MPARAM)FALSE;
    }
    case WM_COMMAND :
    {
      if( SHORT1FROMMP( mParam2 ) == CMDSRC_PUSHBUTTON )
      {
        Window *control = (Window *)getControl( SHORT1FROMMP(mParam1));
        if( control != NULL )
        {
          if( control->type == PUSHBUTTON )
          {
            control->performButtonEvent( control, control->id );
            return FALSE;
          }
        }
        else
          return FALSE; // In case ESC would close the dialog
      }
      break;
    }
    case WM_CHAR :
    {
      if( type == LISTBOX )
      {
        performFocusEvent(
          (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) );
      }

      if( (SHORT1FROMMP( mParam1 ) & KC_KEYUP) ||
          (SHORT1FROMMP( mParam1 ) & KC_DEADKEY) ||
          (SHORT1FROMMP( mParam1 ) & KC_INVALIDCOMP) )
        break;

/*			if( SHORT1FROMMP( mParam1 ) & KC_COMPOSITE )
				mParam1 = MPFROM2SHORT( SHORT1FROMMP( mParam1 ) & ~KC_VIRTUALKEY,
																SHORT2FROMMP( mParam1 ) );*/

      int modifiers = 0;

      if( SHORT1FROMMP( mParam1 ) & KC_SHIFT )
        modifiers |= KeyDef::SHIFT;

      if( SHORT1FROMMP( mParam1 ) & KC_ALT )
        modifiers |= KeyDef::kALT;

      if( SHORT1FROMMP( mParam1 ) & KC_CTRL)
        modifiers |= KeyDef::CTRL;

      if( SHORT1FROMMP( mParam1 ) & KC_VIRTUALKEY )
      {
        int key = 0, vKey = SHORT2FROMMP( mParam2 );

       // Maybe NumLock is on

        if( SHORT1FROMMP(mParam1) & KC_CHAR &&
            !(vKey == VK_ENTER || vKey == VK_NEWLINE || vKey == VK_TAB ||
              vKey == VK_BACKSPACE ))
          key = SHORT1FROMMP( mParam2 );
        else
        if( vKey == VK_UP )
          key = KeyDef::UP;
        else
        if( vKey == VK_DOWN )
          key = KeyDef::DOWN;
        else
        if( vKey == VK_LEFT )
          key = KeyDef::LEFT;
        else
        if( vKey == VK_RIGHT )
          key = KeyDef::RIGHT;
        else
        if( vKey == VK_PAGEUP )
          key = KeyDef::PAGEUP;
        else
        if( vKey == VK_PAGEDOWN )
          key = KeyDef::PAGEDOWN;
        else
        if( vKey == VK_INSERT )
          key = KeyDef::INSERT;
        else
        if( vKey == VK_DELETE )
          key = KeyDef::kDELETE;
        else
        if( vKey == VK_HOME )
          key = KeyDef::HOME;
        else
        if( vKey == VK_END )
          key = KeyDef::END;
        else
        if( vKey == VK_ESC )
          key = KeyDef::ESCAPE;
        else
        if( vKey == VK_F1 )
          key = KeyDef::F1;
        else
        if( vKey == VK_F2 )
          key = KeyDef::F2;
        else
        if( vKey == VK_F3 )
          key = KeyDef::F3;
        else
        if( vKey == VK_F4 )
          key = KeyDef::F4;
        else
        if( vKey == VK_F5 )
          key = KeyDef::F5;
        else
        if( vKey == VK_F6 )
          key = KeyDef::F6;
        else
        if( vKey == VK_F7 )
          key = KeyDef::F7;
        else
        if( vKey == VK_F8 )
          key = KeyDef::F8;
        else
        if( vKey == VK_F9 )
          key = KeyDef::F9;
        else
        if( vKey == VK_F10 )
          key = KeyDef::F10;
        else
        if( vKey == VK_F11 )
          key = KeyDef::F11;
        else
        if( vKey == VK_F12 )
          key = KeyDef::F12;
        else
        if( vKey == VK_ENTER )
          key = KeyDef::ENTER;
        else
        if( vKey == VK_NEWLINE )
          key = KeyDef::RETURN;
        else
        if( vKey == VK_BACKSPACE )
          key = KeyDef::BACKSPACE;
        else
        if( vKey == VK_TAB )
          key = KeyDef::TAB;
        else
        if( vKey == VK_BACKTAB )
        {
          key = KeyDef::TAB;
          modifiers |= KeyDef::SHIFT;
        }
        else
        if( vKey == VK_SPACE )
          key = KeyDef::SPACE;

	      if( parent->getType() == DIALOG )
  	    	((Dialog *)parent)->focusHotkey( key );

        if( key != 0 )
          if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE);

        // Do not pass up and down key to dialog if this is a combobox (would
        // move focus)

/*        if( getFilterDialogArrows() &&
            (vKey == VK_UP || vKey == VK_DOWN) )
          return (MPARAM)TRUE;*/
      }
      else
      {
        int key = SHORT1FROMMP( mParam2 );
        if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE);
      }
      break;
    }
    case WM_CONTROL :
    {
      Window *control = (Window *)getControl( SHORT1FROMMP(mParam1));
      if( control != NULL )
      {
        if( control->type == Window::LISTBOX ||
            control->type == Window::COMBOLISTBOX )
        {
          switch( SHORT2FROMMP(mParam1) )
          {
            case LN_KILLFOCUS : control->focus( FALSE ); break;
            case LN_SETFOCUS : control->focus( TRUE );break;
            case LN_ENTER :
              control->performSelectionEvent(
                (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) );
              break;
          }
        }
        else
        if( control->type == Window::SCROLLBAR )
        {
          switch( SHORT2FROMMP(mParam1) )
          {
            case SLN_KILLFOCUS : control->focus( FALSE ); break;
            case SLN_SETFOCUS : control->setFocus(); break;
          }
        }
        else
        if( control->type == Window::RADIOBUTTON ||
            control->type == Window::CHECKBOX )
        {
          switch( SHORT2FROMMP( mParam1) )
          {
            case BN_CLICKED :
            case BN_DBLCLICKED :
              control->performButtonEvent( control, control->id );
              break;
          }
        }
      }
      break;
    }
		case DM_DRAGOVER:
		{
			PDRAGINFO pDInfo;
			PDRAGITEM pDItem;
  
	  	if( !acceptDropFiles )
				return MRFROM2SHORT(DOR_NODROPOP, 0);

			pDInfo = (PDRAGINFO)mParam1;
			DrgAccessDraginfo(pDInfo);
			pDItem = DrgQueryDragitemPtr(pDInfo, 0);
			USHORT   usOp = 0, usDrop = DOR_NEVERDROP;

			/* Inspect each item to see if it is acceptable */
			ULONG  ulItems = DrgQueryDragitemCount (pDInfo);
      for (INT i = 0; i < ulItems; i++)
			{
				pDItem = DrgQueryDragitemPtr(pDInfo, i);

				/* The item is acceptable only if it is copyable and the     */
				/* operation is a copy, or it is moveable and the operation  */
				/* is a move, and it can render <DRM_OS2FILE, NULL>          */
				if (pDItem->fsSupportedOps & DO_COPYABLE)
				{
					usOp = DO_COPY;
					/* Only check files, all types */
					if (DrgVerifyRMF(pDItem, "DRM_OS2FILE", 0))
						usDrop = DOR_DROP;
					else
					{
						usDrop = DOR_NEVERDROP;
						break;
					}
				}
				else
				{
					/* Must be a file but not droppable in type op */
					usDrop = DOR_NODROPOP;
          usOp = 0;
					break;
				}
			} /* end for all items dragged  */

			DrgFreeDraginfo(pDInfo);

			return MRFROM2SHORT(usDrop, usOp);
		}
		case DM_DROP:
		{
			PDRAGINFO pDInfo;
			PDRAGITEM pDItem;
			pDInfo = (PDRAGINFO)mParam1;
			DrgAccessDraginfo(pDInfo);
			pDItem = DrgQueryDragitemPtr(pDInfo, 0);
			ULONG  ulItems = DrgQueryDragitemCount (pDInfo);
			ULONG  p;
			char **files;

			files = (char **)malloc( sizeof( char * ) * ulItems );

			for (INT i=0; i < ulItems; i++)
			{
				CHAR    DragSrcPath[CCHMAXPATH], DragSrcName[CCHMAXPATH];
				pDItem = DrgQueryDragitemPtr(pDInfo, i);
				DrgQueryStrName(pDItem->hstrContainerName, sizeof(DragSrcPath), (PSZ)DragSrcPath);
				if (!(PSZ)DragSrcPath)
					break;
				if (DragSrcPath[(strlen(DragSrcPath)-1)] != '\\')
					strcat((PSZ)DragSrcPath, "\\");

				/* Use the dragitem source name, it's the real name */
				DrgQueryStrName(pDItem->hstrSourceName, sizeof(DragSrcName),
																									(PSZ)DragSrcName);
				if (!((PSZ)DragSrcName))
					break;
				strcat((PSZ)DragSrcPath, (PSZ)DragSrcName);
				FILESTATUS3  fsFile;
				DosError(FERR_DISABLEHARDERR);
				APIRET rc = DosQueryPathInfo(DragSrcPath, FIL_STANDARD, &fsFile,
																									sizeof(FILESTATUS3));
				DosError(FERR_ENABLEHARDERR);

				if (!rc && !(fsFile.attrFile & FILE_DIRECTORY))
				{
					files[i] = (char *)malloc( strlen(DragSrcPath) + 1 );
          strcpy( files[i], DragSrcPath );
					DrgSendTransferMsg(pDItem->hwndItem, DM_ENDCONVERSATION,
																			MPFROMLONG(pDItem->ulItemID),
																			MPFROMLONG(DMFL_TARGETSUCCESSFUL));
				}
				else
				{
					DosBeep(100,10);
//					EditorDisplay[BufNum]->DisplayMessage( pszDropNoFile );
				}
			}

			filesDropped( files, ulItems );

			for( i = 0; i < ulItems; i++ )
	      free( (void *)files[i] );

      free( (void *)files );

			DrgFreeDraginfo(pDInfo);
			break;
		}
    case WM_USER + 1 :
    {
      return (MPARAM)execFromMainThread( (int)mParam1, (void *)mParam2 );
    }
    case WM_USER + 2 :
    {
      setFocus();
      break;
    }
  }
  *returned = FALSE;
  return (MRESULT)NULL;
}
Exemplo n.º 11
0
MRESULT wxFrame::OS2WindowProc( WXUINT uMessage,
                                WXWPARAM wParam,
                                WXLPARAM lParam )
{
    MRESULT mRc = 0L;
    bool    bProcessed = false;

    switch (uMessage)
    {
        case WM_CLOSE:
            //
            // If we can't close, tell the system that we processed the
            // message - otherwise it would close us
            //
            bProcessed = !Close();
            break;

        case WM_PAINT:
            bProcessed = HandlePaint();
            mRc = (MRESULT)FALSE;
            break;

         case WM_ERASEBACKGROUND:
            //
            // Returning TRUE to requests PM to paint the window background
            // in SYSCLR_WINDOW. We capture this here because the PS returned
            // in Frames is the PS for the whole frame, which we can't really
            // use at all. If you want to paint a different background, do it
            // in an OnPaint using a wxPaintDC.
            //
            mRc = (MRESULT)(TRUE);
            break;

      case WM_COMMAND:
            {
                WORD                wId;
                WORD                wCmd;
                WXHWND              hWnd;

                UnpackCommand( (WXWPARAM)wParam
                              ,(WXLPARAM)lParam
                              ,&wId
                              ,&hWnd
                              ,&wCmd
                             );

                bProcessed = HandleCommand( wId
                                           ,wCmd
                                           ,(WXHWND)hWnd
                                          );
            }
            break;

        case WM_MENUSELECT:
            {
                WXWORD              wItem;
                WXWORD              wFlags;
                WXHMENU             hMenu;

                UnpackMenuSelect( wParam
                                 ,lParam
                                 ,&wItem
                                 ,&wFlags
                                 ,&hMenu
                                );
                bProcessed = HandleMenuSelect( wItem
                                              ,wFlags
                                              ,hMenu
                                             );
                mRc = (MRESULT)TRUE;
            }
            break;

        case WM_SIZE:
            {
                SHORT               nScxnew = SHORT1FROMMP(lParam); // New horizontal size.
                SHORT               nScynew = SHORT2FROMMP(lParam); // New vertical size.

                lParam = MRFROM2SHORT( nScxnew - 20
                                      ,nScynew - 30
                                     );
            }
            bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
            mRc = (MRESULT)FALSE;
            break;

        case CM_QUERYDRAGIMAGE:
            {
                const wxIcon&           vIcon = GetIcon();
                HPOINTER                hIcon;

                if (vIcon.Ok())
                    hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L);
                else
                    hIcon = (HPOINTER)m_hDefaultIcon;
                mRc = (MRESULT)hIcon;
                bProcessed = mRc != 0;
            }
            break;
    }

    if (!bProcessed )
        mRc = wxWindow::OS2WindowProc( uMessage
                                      ,wParam
                                      ,lParam
                                     );
    return (MRESULT)mRc;
} // wxFrame::OS2WindowProc
Exemplo n.º 12
0
Arquivo: dnd.cpp Projeto: EdgarTx/wx
// #pragma page   "CIDropTarget::Drop"
/////////////////////////////////////////////////////////////////////////////
//
// CIDropTarget::Drop
//
//   Instructs the drop target to paste data that was just now dropped on it.
//
// PARAMETERS
//   pIDataSource -- the data to paste
//   dwKeyState   -- kbd & mouse state
//   pt           -- mouse coordinates
//   pdwEffect    -- effect flag
//
// RETURN VALUE
//  STDMETHODIMP S_OK
//
/////////////////////////////////////////////////////////////////////////////
MRESULT CIDropTarget::Drop ()
{
    char                            zBuffer[128];
    ULONG                           ulBytes;
    USHORT                          uOp = 0;
    USHORT                          uIndicator;
    ULONG                           ulItems;
    ULONG                           i;

    ::DrgAccessDraginfo(m_pDragInfo);
    switch(m_pDragInfo->usOperation)
    {
        case DO_UNKNOWN:
            Free();
            return (MRFROM2SHORT(DOR_NODROPOP, 0));

        case DO_DEFAULT:
            m_pDragItem = ::DrgQueryDragitemPtr(m_pDragInfo, 0);
            ulBytes     = ::DrgQueryStrName( m_pDragItem->hstrContainerName
                                            ,128
                                            ,zBuffer
                                           );
            if (!ulBytes)
                return (MRFROM2SHORT(DOR_NODROPOP, 0));
            else
                uOp = DO_MOVE;
            break;

        case DO_COPY:
        case DO_MOVE:
            uOp = m_pDragInfo->usOperation;
            break;
    }
    uIndicator = DOR_DROP;
    ulItems = (ULONG)::DrgQueryDragitemCount(m_pDragInfo);
    for (i = 0; i < ulItems; i++)
    {
        m_pDragItem = ::DrgQueryDragitemPtr(m_pDragInfo, i);
        if (((m_pDragItem->fsSupportedOps & DO_COPYABLE) &&
             (uOp == (USHORT)DO_COPY))                   ||
            ((m_pDragItem->fsSupportedOps & DO_MOVEABLE) &&
             (uOp == (USHORT)DO_COPY)))
        {
            if (::DrgVerifyRMF(m_pDragItem, "DRM_OS2FILE", "DRF_UNKNOWN"))
                uIndicator = (USHORT)DOR_DROP;
            else
                uIndicator = (USHORT)DOR_NEVERDROP;
        }
    }

    //
    // First ask the drop target if it wants data
    //
    if (m_pTarget->OnDrop( m_pDragInfo->xDrop
                          ,m_pDragInfo->yDrop
                         ))
    {
        wxDragResult                 eRc = wxDragNone;

        //
        // And now it has the data
        //
        eRc = m_pTarget->OnData( m_pDragInfo->xDrop
                                ,m_pDragInfo->yDrop
                                ,eRc
                               );
    }
    //else: OnDrop() returned false, no need to copy data

    //
    // Release the held object
    //
    Free();
    return (MRFROM2SHORT(uIndicator, uOp));
} // end of CIDropTarget::Drop
Exemplo n.º 13
0
/*----------------------------------------------------------------------------*/                   
MRESULT EXPENTRY DLG_MAIN_Proc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)                    
/*----------------------------------------------------------------------------*/                   
/* This dialog proc initializes and handles all messages for the main         */
/* dialog.                                                                    */
/*----------------------------------------------------------------------------*/                   
{                                                                                                  
static HWND  ContextHwnd;  /* Handle of context menu                     */
static SHORT ContextIndx;  /* Index of item context menu was selected on */
                                                                                                   
  switch (msg) {                                                                                   
                                                                                                   
    case WM_INITDLG:                                                                               
      INSERTITEM(LIST, "Listbox item 0");
      INSERTITEM(LIST, "Listbox item 1");
      INSERTITEM(LIST, "Listbox item 2");
      INSERTITEM(LIST, "Listbox item 3");
      INSERTITEM(LIST, "Listbox item 4");
      INSERTITEM(LIST, "Listbox item 5");
      INSERTITEM(LIST, "Listbox item 6");
      INSERTITEM(LIST, "Listbox item 7");
      INSERTITEM(LIST, "Listbox item 8");
      INSERTITEM(LIST, "Listbox item 9");
      INSERTITEM(LIST, "Listbox item 10");
      INSERTITEM(LIST, "Listbox item 11");
      INSERTITEM(LIST, "Listbox item 12");
      INSERTITEM(LIST, "Listbox item 13");
      INSERTITEM(LIST, "Listbox item 14");
      INSERTITEM(LIST, "Listbox item 15");

      /* Add direct-manipulation capability to the listbox */
      DMLBInitialize(CONTROLHWND(LIST), NULLHANDLE);

      /* Load context menu for later use */
      ContextHwnd = WinLoadMenu(hwnd, NULLHANDLE, ID_MENU);

      return FALSE;                                           

    case WM_DESTROY:
      /* Free resources */
      WinDestroyWindow(ContextHwnd);
      break;
                                                              
    case WM_COMMAND:                                          
      switch (SHORT1FROMMP(mp1)) {                            

        /*******************************************************************/
        /* We get WM_COMMAND messages from the context menu.  The variable */
        /* ContextIndx already has the index of the item on which the      */
        /* context menu was requested (or LIT_NONE).                       */
        /*******************************************************************/

        case ID_MENU_EDIT: {  //------- Context menu "Edit" selected -----------
          char Buff[MAX_LEN];
          /* Run edit menu, update list if user selects OK button */
          QUERYITEMTEXT(LIST, ContextIndx, Buff, sizeof(Buff));
          if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff)
              == DID_OK)
            SETITEMTEXT(LIST, ContextIndx, Buff);
          return 0;
          }

        case ID_MENU_DELETE:  //------- Context menu "Delete" selected -----------
          WinSendMsg(CONTROLHWND(LIST), LM_DELETEITEM, MPFROMSHORT(ContextIndx), MPVOID);
          return 0;

        case ID_MENU_INSERT: {//------- Context menu "Insert" selected ----------
          char Buff[MAX_LEN];
          /* Run edit menu, insert into list if user selects OK button */
          Buff[0] = '\0';
          if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff)
              == DID_OK) {
            if (ContextIndx == LIT_NONE)  // Insert at end of list
              ContextIndx = LIT_END;
            else
              ContextIndx++;              // Insert AFTER selected item
            INSERTITEMAT(LIST, ContextIndx, Buff);
          }
          return 0;
          }

        case DID_OK: /*----------~OK (PUSHBUTTON)----------*/ 
          // Let default dialog proc terminate us
          break;                                              
      }                                                       
      break;                                                  
                                                              
    case WM_CONTROL:                                          
      switch SHORT1FROMMP(mp1) {                              
        case LIST: /*----------LIST (LISTBOX)----------*/     
 
          /*******************************************************************/
          /* Notification messages from the listbox come here.  These are    */
          /* the usual PM listbox messages, plus some new ones for DMLB.     */
          /*******************************************************************/
 
          switch (SHORT2FROMMP(mp1)) {
            case LN_SELECT:           
            case LN_ENTER:            
              /* User dbl-clicked an entry or pressed ENTER.  For this sample       */
              /* we do nothing.                                                     */
              return 0;

            case LN_DMLB_QRYDROP:
              /* A listbox item is about to be dropped on this listbox.  We must    */
              /* return a Ok-to-drop  indicator, and tell what to do with the       */
              /* original item (copy or move).  Since we have just one listbox in   */
              /* this sample, MOVE is the only thing that makes sense.              */
              return MRFROM2SHORT(TRUE, DROPMODE_MOVE);

            case LN_DMLB_CONTEXT: {
              /* The user has requested a context menu.  Short 1 of mp2 is the      */
              /* index of the listbox item under the pointer.                       */
              POINTL Point;
              ContextIndx = SHORT1FROMMP(mp2);
              if (ContextIndx == LIT_NONE) {
                // Disable Edit & Delete if pointer was not over a listbox item
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE),   MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
              } else {
                // Otherwise, enable Edit & Delete
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE),   MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED));
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED));
              }
              // It is not technically necessary to select the item on which the context
              // menu was selected, but it provides good visual feedback to the user to
              // show which item the context menu applies to.
              SETSELECTION(LIST, ContextIndx);

              // Popup the context menu at the pointer position.  The menu will
              // send us WM_COMMAND messages if a menu item is selected.
              WinQueryMsgPos((HAB)0, &Point);
              WinPopupMenu(HWND_DESKTOP, hwnd, ContextHwnd, Point.x, Point.y, 0, PU_HCONSTRAIN| PU_VCONSTRAIN
                                                            | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_MOUSEBUTTON3 
                                                            | PU_KEYBOARD );
              return (MRESULT)TRUE;
              }
          }                           
          break;                      
      }                               
      break; /* End of WM_CONTROL */          
                                              
  } /* End of (msg) switch */                 
                                              
  return WinDefDlgProc(hwnd, msg, mp1, mp2);  
                                              
} /* End dialog procedure */                  
Exemplo n.º 14
0
MRESULT EXPENTRY ViceFileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    switch (msg) {
        case WM_INITDLG:
            {
                FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER);
                int i;
                char *szpath;
                const int action = fdlg->ulUser;
                const int nact = (action >> 8) & 0xff;
                const int nsact = (action) & 0xff;

                FillABox(hwnd, action ? nact - 1 : 0);
                FillSBox(hwnd, action ? nsact - 1 : 0);
                FillFBox(hwnd);
                NewFilter(hwnd);

                for (i = 0; i < numfonts; i++) {
                    WinDlgLboxInsertItem(hwnd, DID_FONTNAME_LB, fnames[i]);
                }
                WinDlgLboxSelectItem(hwnd, DID_FONTNAME_LB, 0);

                if (action) {
                    WinEnableControl(hwnd, DID_ACTION_CB, FALSE);
                    WinEnableControl(hwnd, DID_SUBACTION_CB, FALSE);
                }

                if (action || fdlg->fl & FDS_SAVEAS_DIALOG) {
                    WinEnableControl(hwnd, DID_AUTOSTART_PB, FALSE);
                }

                szpath = util_concat(fdlg->pszIDrive, fdlg->szFullFile, NULL);
                *(strrchr(szpath, '\\') + 1) = '\0';

                WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath);
                lib_free(szpath);

                szpath = util_concat(archdep_boot_path(), "\\vice2.dll", NULL);
                if (!GpiLoadFonts(WinQueryAnchorBlock(hwnd), szpath)) {
                    log_debug("dlg-fileio.c: GpiLoadFonts('%s') failed.", szpath);
                    WinEnableControl(hwnd, DID_FONTNAME_LB, FALSE);
                }
                lib_free(szpath);
            }
            return FALSE;
        case WM_DESTROY:
            {
                char *szpath = util_concat(archdep_boot_path(), "\\vice2.dll", NULL);
                LboxFreeContents(WinWindowFromID(hwnd, DID_CONTENTS_LB));
                if (!GpiUnloadFonts(WinQueryAnchorBlock(hwnd), szpath)) {
                    log_debug("dlg-fileio.c: GpiUnloadFonts('%s') failed.", szpath);
                }
                lib_free (szpath);
            }
            break;
        case WM_CONTROL:
            switch (SHORT1FROMMP(mp1)) {
                case DID_ACTION_CB:
                    if (SHORT2FROMMP(mp1) == CBN_ENTER) {
                        FillSBox(hwnd, 0);
                    }
                case DID_SUBACTION_CB:
                    if (SHORT2FROMMP(mp1) == CBN_ENTER) {
                        FillFBox(hwnd);
                    }
                case DID_FFILTER_CB:
                    if (SHORT2FROMMP(mp1) == CBN_ENTER) {
                        NewFilter(hwnd);
                    }
                    return FALSE;
                case DID_DIRECTORY_LB:
                    WinDefFileDlgProc(hwnd, msg, mp1, mp2);
                    if (SHORT2FROMMP(mp1) == LN_SELECT || SHORT2FROMMP(mp1) == LN_ENTER) {
                        char szpath[CCHMAXPATH];
                        const int nr = WinQueryLboxSelectedItem((HWND)mp2);

                        if (nr < 0) {
                            return FALSE;
                        }

                        if (SHORT2FROMMP(mp1) == LN_SELECT && WinQueryFocus(HWND_DESKTOP) == (HWND)mp2) {
                            return FALSE;
                        }

                        if (!GetLboxPath((HWND)mp2, nr, szpath)) {
                            return FALSE;
                        }

                        WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath);
                    }
                    return FALSE;
                case DID_FILENAME_ED:
                    if (WinQueryButtonCheckstate(hwnd, DID_CONTENTS_CB) && SHORT2FROMMP(mp1) == EN_CHANGE) {
                        char szpath[CCHMAXPATH];
                        if (GetFullFile(hwnd, szpath)) {
                            ShowContents(hwnd, szpath);
                        }
                    }
                    break;
                case DID_CONTENTS_CB:
                    {
                        const int state = WinQueryButtonCheckstate(hwnd, DID_CONTENTS_CB);

                        WinEnableControl(hwnd, DID_CONTENTS_LB, state);
                        WinEnableControl(hwnd, DID_FONTNAME_LB, state);
                        if (state) {
                            ContentsUpdate(hwnd);
                        } else {
                            LboxFreeContents(WinWindowFromID(hwnd, DID_CONTENTS_LB));
                        }
                    }
                    return FALSE;
                case DID_FONTNAME_LB:
                    if (SHORT2FROMMP(mp1) != CBN_ENTER) {
                        break;
                    }
                    ContentsUpdate(hwnd);
                    return FALSE;
            }
            break;
        case WM_COMMAND:
            switch (SHORT1FROMMP(mp1)) {
                case DID_DIRUP:
                    {
                        const HWND name = WinWindowFromID(hwnd, DID_FILENAME_ED);
                        const int pos = WinDlgLboxSelectedItem(hwnd, DID_DIRECTORY_LB);
                        char szpath[CCHMAXPATH];
                        char *cpos;
                        int len;

                        if (!pos) {
                            return FALSE;
                        }

                        WinQueryDlgItemText(hwnd, DID_DIR_SELECTED, CCHMAXPATH - 1, szpath);

                        if (strlen(szpath) < 4) {
                            return FALSE;
                        }

                        *strrchr(szpath, '\\') = '\0';
                        cpos = strrchr(szpath,'\\') + 1;

                        len = cpos - szpath + 2;

                        if (len == CCHMAXPATH - 1) {
                            return FALSE;
                        }

                        WinQueryDlgItemText(hwnd, DID_FILENAME_ED, CCHMAXPATH - len - 1, cpos);

                        WinSetWindowText(name, szpath);

                        *cpos = '\0';

                        WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath);

                        //
                        // set focus to entry field and simulate an Apply
                        //
                        WinSetFocus(HWND_DESKTOP, name);
                        WinDefFileDlgProc(hwnd, WM_COMMAND, (MPARAM)DID_OK, MPFROM2SHORT(CMDSRC_PUSHBUTTON, TRUE));
                    }
                    return FALSE;
                case DID_AUTOSTART_PB:
                    {
                        const int pos = WinDlgLboxSelectedItem(hwnd, DID_CONTENTS_LB);
                        FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER);
                        size_t length;
                        char szpath[CCHMAXPATH];

                        if (!GetFullFile(hwnd, szpath)) {
                            return FALSE;
                        }

                        if (autostart_autodetect(szpath, NULL, pos < 0 ? 0 : pos, AUTOSTART_MODE_RUN)) {
                            return FALSE;
                        }

                        length = strrchr(szpath, '\\') - szpath;

                        fdlg->lReturn = DID_OK;

                        if (length > 0) {
                            fdlg->szFullFile[length] = 0;
                        }
                    }
                    break;
            }
            break;
        case WM_MEASUREITEM:
            if (SHORT1FROMMP(mp1) == DID_CONTENTS_LB) {
                return MRFROM2SHORT(9, 9);
            }
            break;
        case WM_DRAWITEM:
            if (SHORT1FROMMP(mp1) == DID_CONTENTS_LB) {
                OWNERITEM *item = (OWNERITEM*)mp2;
                RECTL *rcl = &(item->rclItem);

                if (rcl->yTop-rcl->yBottom == 9) {
                    image_contents_screencode_t *line = (image_contents_screencode_t *)WinLboxItemHandle(item->hwnd, item->idItem);

                    if (line) {
                        LboxDrawLine(hwnd, item, rcl, line);
                    }
                    item->fsState = item->fsStateOld = 0;
                }
                return (MRESULT)TRUE;
            }
            break;
        case FDM_VALIDATE:
            // mp1 = PSZ pszPathName
            // mp2 = USHORT Field name id
            // mr  = TRUE -> Valid name
            {
                const int sact = WinDlgLboxSelectedItem(hwnd, DID_SUBACTION_CB);
                const int act = WinDlgLboxSelectedItem(hwnd, DID_ACTION_CB);
                const FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER);
                char *szpath = (char*)mp1;
                int rc;
                char *slash;

                if (fdlg->fl & FDS_OPEN_DIALOG) {
                    rc = FdmDoLoadAction(hwnd, szpath, act, sact);
                } else {
                    rc = FdmDoSaveAction(hwnd, szpath, act, sact);
                }

                if (rc < 0) {
                    const action_t *action = fdlg->fl & FDS_OPEN_DIALOG ? LoadAction : SaveAction;
                    char *txt = util_concat("The following action couldn't be performed:\n", action[act].type, " ", action[act].subact[sact].action, NULL);
                    HPOINTER hpt = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, 0x101);
#ifdef WATCOM_COMPILE
                    struct _MB2D mbtemp;
                    struct _MB2INFO mb;

                    mb.cb = sizeof(MB2INFO);
                    mb.hIcon = hpt;
                    mb.cButtons = 1;
                    mb.flStyle = MB_CUSTOMICON|WS_VISIBLE;
                    mb.hwndNotify = NULLHANDLE;
                    sprintf(mbtemp.achText,"      OK      ");
                    mbtemp.idButton = 0;
                    mbtemp.flStyle = BS_DEFAULT;
                    mb.mb2d[0] = mbtemp;
#else
                    MB2INFO mb = {
                        sizeof(MB2INFO),
                        hpt,
                        1,
                        MB_CUSTOMICON | WS_VISIBLE,
                        NULLHANDLE,
                        "      OK      ",
                        0,
                        BS_DEFAULT};
#endif
                    WinMessageBox2(HWND_DESKTOP, hwnd, txt, "VICE/2 Error", 0, &mb);
                    lib_free(txt);
                    return FALSE;
                }

                //
                // FIXME! Better solution?
                //
                slash = strrchr(szpath, '\\');
                if (slash) {
                    *slash = '\0';
                }

                chdir(szpath);
            }
            return (MRESULT)TRUE;

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