Пример #1
0
bool UserScreen( void )
{
    if( !WndMain ) return( FALSE );
    FocusWnd = WinQueryFocus( HWND_DESKTOP, 0 );
    ActiveWnd = WinQueryActiveWindow( HWND_DESKTOP, 0 );
    return( FALSE );
}
Пример #2
0
static void internal_ReplayWMCHARRecord()
{
  int i;
  HWND hwndFocus;

  hwndFocus = WinQueryFocus(HWND_DESKTOP);
  for (i=0; i<iNumEventsInRecord; i++)
    WinPostMsg(hwndFocus, WM_CHAR, ampMP1[i], ampMP2[i]);

  iNumEventsInRecord = 0;
}
Пример #3
0
static void MousePressed( vout_display_t *vd, HWND hwnd, unsigned button )
{
    if( WinQueryFocus( HWND_DESKTOP ) != hwnd )
        WinSetFocus( HWND_DESKTOP, hwnd );

    if( !vd->sys->button_pressed )
        WinSetCapture( HWND_DESKTOP, hwnd );

    vd->sys->button_pressed |= 1 << button;

    vout_display_SendEventMousePressed( vd, button );
}
Пример #4
0
bool DebugScreen( void )
{
    if( !WndMain ) return( FALSE );
    if( FocusWnd && WinIsWindow( GUIGetHAB(), FocusWnd ) &&
        FocusWnd != WinQueryFocus( HWND_DESKTOP, 0 ) ) {
        WinSetFocus( HWND_DESKTOP, FocusWnd );
    }
    if( ActiveWnd && WinIsWindow( GUIGetHAB(), ActiveWnd ) &&
        ActiveWnd != WinQueryActiveWindow( HWND_DESKTOP, 0 ) ) {
        WinSetActiveWindow( HWND_DESKTOP, ActiveWnd );
    }
    return( FALSE );
}
Пример #5
0
int dlgFind_SetButtonFocus(HWND hwnd)
{
HWND hwndBtnFind = WinWindowFromID(hwnd,IDB_FIND);
HWND hwndBtnReplace = WinWindowFromID(hwnd,IDB_REPLACE);
HWND hwndBtnReplaceFind = WinWindowFromID(hwnd,IDB_REPLACEFIND);
HWND hwndBtnReplaceAll = WinWindowFromID(hwnd,IDB_REPLACEALL);
HWND hwndBtnClose = WinWindowFromID(hwnd,DID_OK);
HWND hwndFocus;

HWND hwndFind = WinWindowFromID(hwnd,IDHEF_FIND);
int findLen=0;
char *findStr = NULL;

    findLen = WinQueryWindowTextLength(hwndFind);
//  findLen = (int)WinSendMsg(hwndFind,HEM_QUERYTEXTLENGTH,0,0);
    findStr = malloc(findLen+1);
#ifdef DEBUG
    assert(findStr!=NULL);
#endif
    if (findStr==NULL) return 0;
    WinQueryWindowText(hwndFind,findLen+1,findStr);
//  WinSendMsg(hwndFind,HEM_QUERYTEXT,findStr,0);

    hwndFocus = WinQueryFocus(HWND_DESKTOP);
    if ((hwndFocus!=hwndBtnFind)&&
        (hwndFocus!=hwndBtnReplace)&&
        (hwndFocus!=hwndBtnReplaceFind)&&
        (hwndFocus!=hwndBtnReplaceAll)&&
        (hwndFocus!=hwndBtnClose))
        {
        if (strlen(findStr)>0)
            {
            WinEnableWindow(hwndBtnFind,TRUE);
            WinSendMsg(hwndBtnFind,BM_SETDEFAULT,MPFROMLONG(TRUE),0);
            WinSendMsg(hwndBtnClose,BM_SETDEFAULT,MPFROMLONG(FALSE),0);
            } else {
            WinEnableWindow(hwndBtnFind,FALSE);
            dlgFind_SetFound(hwnd,FALSE);
            WinSendMsg(hwndBtnFind,BM_SETDEFAULT,MPFROMLONG(FALSE),0);
            WinSendMsg(hwndBtnClose,BM_SETDEFAULT,MPFROMLONG(TRUE),0);
            }
        return TRUE;
        }
    return FALSE;
}
Пример #6
0
MRESULT clbMnemonic(PCLBOX pclb, ULONG ch) {
   HWND hfocus;
   if ((ch > 0xff || ch == '+' || ch == '-')) {
      if (WinIsChild((hfocus = WinQueryFocus(HWND_DESKTOP)), pclb->hwnd)) {
         switch (ch) {
            case 0x9d00:           // -> simula comando bottone FIND
               EDClbWinProc(pclb->hwnd, WM_COMMAND, (MPARAM)FID_FIND,
                            MPFROM2SHORT(CMDSRC_OTHER, 0));
               break;
            case '+':
               if (pclb->is.addon)
                  EDClbWinProc(pclb->hwnd, WM_COMMAND, (MPARAM)FID_ADD,
                               MPFROM2SHORT(CMDSRC_OTHER, 0));
               break;
            case '-':
               if (pclb->is.remon)
                  EDClbWinProc(pclb->hwnd, WM_COMMAND, (MPARAM)FID_REMOVE,
                               MPFROM2SHORT(CMDSRC_OTHER, 0));
               break;
         } /* endswitch */
      } /* endif */
      return (MRESULT)FALSE;
   } /* endif */
   if (pclb->fl & CLBXS_NOCAPT) return (MRESULT)FALSE;
   if (pclb->fl & CLBXS_CHECK) {
      if (pclb->pfbtn(pclb->hchk, WM_MATCHMNEMONIC, (MPARAM)ch, MPVOID))
         WinSetFocus(HWND_DESKTOP, pclb->hchk);
      return (MRESULT)FALSE;
   } else if (pclb->psz) {
      PSZ pmnemo = strchr(pclb->psz, '~');
      if (!pmnemo) return (MRESULT)FALSE;
      ch = WinUpperChar(pclb->hab, 0, 0, ch);
      return (MRESULT)(ch == WinUpperChar(pclb->hab, 0, 0, *++pmnemo) && ch);
   } else {
      return (MRESULT)FALSE;
   } /* endif */
}
/*--------------------------------------------------
 * Has focus
 *-------------------------------------------------*/
BOOL PMWindow::has_focus() const
{
  return WinQueryFocus( HWND_DESKTOP ) == handle();
}
Пример #8
0
static MRESULT APIENTRY Button1Down ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

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

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  WorkSpace PS ( "HRuler::Button1Down", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::Button1Down: Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * If the mouse isn't touching in the button area, return.                 *
  ***************************************************************************/

  if ( Mouse.y < Rectangle.yTop - ButtonSize.y ) {
     Sys_BeepNote ( ) ;
     return ( MRFROMSHORT ( FALSE ) ) ;
  } /* endif */

 /***************************************************************************
  * If the mouse is beyond the margins, return.                             *
  ***************************************************************************/

  if ( ( Mouse.x < Data->LeftMargin ) OR ( Mouse.x > Data->RightMargin+ButtonSize.x ) ) {
     Sys_BeepNote ( ) ;
     return ( MRFROMSHORT ( FALSE ) ) ;
  } /* endif */

 /***************************************************************************
  * If mouse is touching the left margin button, set mode to MOVELEFT.      *
  ***************************************************************************/

  if ( ( Mouse.x >= Data->LeftMargin ) AND ( Mouse.x <= Data->LeftMargin+ButtonSize.x ) ) {
     Data->Mode = MOVELEFT ;
     Data->Ptr = Data->MarginPtr ;
  } /* endif */

 /***************************************************************************
  * If mouse is touching the right margin button, set mode to MOVERIGHT.    *
  ***************************************************************************/

  else if ( ( Mouse.x >= Data->RightMargin-ButtonSize.x ) AND ( Mouse.x <= Data->RightMargin ) ) {
     Data->Mode = MOVERIGHT ;
     Data->Ptr = Data->MarginPtr ;
  } /* endif */

 /***************************************************************************
  * Else, find which tab-stop, if any, we're touching.                      *
  ***************************************************************************/

  else {
     for ( int i=0; i<Data->TabCount; i++ ) {
        if ( ( Mouse.x >= Data->Tabs[i] ) AND ( Mouse.x <= Data->Tabs[i]+ButtonSize.x ) ) {
           Data->Mode = MOVETAB ;
           Data->TabIndex = USHORT ( i ) ;
           break ;
        } /* endif */
     } /* endfor */

     if ( i >= Data->TabCount ) {
        Data->Mode = SETTAB ;
     } /* endif */

     Data->Ptr = Data->TabstopPtr ;
  } /* endif */

 /***************************************************************************
  * Capture the mouse.                                                      *
  ***************************************************************************/

  Data->Capture = TRUE ;
  Sys_SetCapture ( Window ) ;

 /***************************************************************************
  * Set the new mouse pointer.                                              *
  ***************************************************************************/

  WinSetPointer ( HWND_DESKTOP, Data->Ptr ) ;

 /***************************************************************************
  * Get the keyboard focus.                                                 *
  ***************************************************************************/

  Data->HadFocus = WinQueryFocus ( HWND_DESKTOP ) ;
  Sys_SetFocus ( Window ) ;

 /***************************************************************************
  * Save the current hairline position.                                     *
  ***************************************************************************/

  Data->Tick = TICK(Mouse.x) ;

 /***************************************************************************
  * Draw a hairline showing the current position.                           *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;
  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

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

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Пример #9
0
void fnSaverThread(void *p)
{
  HWND hwndOldFocus;
  HWND hwndParent = (HWND) p;
  HWND hwndOldSysModal;
  HAB hab;
  QMSG msg;
  ULONG ulStyle;

  // Set our thread to slightly more than regular to be able
  // to update the screen fine.
  DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, +5, 0);

  hab = WinInitialize(0);
  hmqSaverThreadMsgQueue = WinCreateMsgQueue(hab, 0);

  if (bOnlyPreviewMode)
  {
    PFNWP pfnOldWindowProc;
    // We should run in preview mode, so the hwndParent we have is not the
    // desktop, but a special window we have to subclass.
    pfnOldWindowProc = WinSubclassWindow(hwndParent,
                                         (PFNWP) fnSaverWindowProc);

    // Initialize window proc (simulate WM_CREATE)
    WinSendMsg(hwndParent, WM_SUBCLASS_INIT, (MPARAM) NULL, (MPARAM) NULL);
    // Also make sure that the window will be redrawn with this new
    // window proc.
    WinInvalidateRect(hwndParent, NULL, FALSE);

    iSaverThreadState = STATE_RUNNING;

#ifdef DEBUG_LOGGING
    AddLog("[fnSaverThread] : Entering message loop (Preview)\n");
#endif

    // Process messages until WM_QUIT!
    while (WinGetMsg(hab, &msg, 0, 0, 0))
      WinDispatchMsg(hab, &msg);

#ifdef DEBUG_LOGGING
    AddLog("[fnSaverThread] : Leaved message loop (Preview)\n");
#endif

    // Uinitialize window proc (simulate WM_DESTROY)
    WinSendMsg(hwndParent, WM_SUBCLASS_UNINIT, (MPARAM) NULL, (MPARAM) NULL);

    // Undo subclassing
    WinSubclassWindow(hwndParent,
                      pfnOldWindowProc);
    // Also make sure that the window will be redrawn with the old
    // window proc.
    WinInvalidateRect(hwndParent, NULL, FALSE);

    iSaverThreadState = STATE_STOPPED_OK;
  } else
  {
    // We should run in normal mode, so create a new window, topmost, and everything else...
    WinRegisterClass(hab, (PSZ) SAVERWINDOW_CLASS,
                     (PFNWP) fnSaverWindowProc,
                     CS_SIZEREDRAW | CS_CLIPCHILDREN | CS_CLIPSIBLINGS, 0);

    hwndOldFocus = WinQueryFocus(HWND_DESKTOP);

    // Create the saver output window so that it will be the child of
    // the given parent window.
    // Make window 'Always on top' because we'll be in real screensaver mode!
    ulStyle = WS_VISIBLE | WS_TOPMOST;
    hwndSaverWindow = WinCreateWindow(HWND_DESKTOP, SAVERWINDOW_CLASS, "Screen saver",
                                      ulStyle,
                                      0, 0,
                                      (int) WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN),
                                      (int) WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN),
                                      HWND_DESKTOP,
                                      HWND_TOP,
                                      0x9fff, // Some ID....
                                      NULL, NULL);
    if (!hwndSaverWindow)
    {
#ifdef DEBUG_LOGGING
      AddLog("[fnSaverThread] : Could not create window!\n");
#endif
      // Yikes, could not create window!
      iSaverThreadState = STATE_STOPPED_ERROR;
    } else
    {
      // Cool, window created!

      // Make sure nobody will be able to switch away of it!
      // We do this by making the window system-modal, and giving it the focus!
      hwndOldSysModal = WinQuerySysModalWindow(HWND_DESKTOP);
      WinSetSysModalWindow(HWND_DESKTOP, hwndSaverWindow);
      WinSetFocus(HWND_DESKTOP, hwndSaverWindow);

      iSaverThreadState = STATE_RUNNING;

#ifdef DEBUG_LOGGING
      AddLog("[fnSaverThread] : Entering message loop (Real)\n");
#endif
      // Process messages until WM_QUIT!
      while (WinGetMsg(hab, &msg, 0, 0, 0))
        WinDispatchMsg(hab, &msg);
#ifdef DEBUG_LOGGING
      AddLog("[fnSaverThread] : Leaved message loop (Real)\n");
#endif

      // Undo system modalling
      WinSetSysModalWindow(HWND_DESKTOP, hwndOldSysModal);

      // Window closed, so destroy every resource we created!
      WinDestroyWindow(hwndSaverWindow);

      // Restore focus to old window
      WinSetFocus(HWND_DESKTOP, hwndOldFocus);

#ifdef DEBUG_LOGGING
      AddLog("[fnSaverThread] : STATE_STOPPED_OK\n");
#endif

      iSaverThreadState = STATE_STOPPED_OK;
    }
  }

  WinDestroyMsgQueue(hmqSaverThreadMsgQueue);
  WinTerminate(hab);

  _endthread();
}
Пример #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;
}
/* This procedure handles the filename options page */ 
MRESULT EXPENTRY fileNameOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  CWDataFolder* thisPtr;
  ULONG ulFlags;

  switch(msg)
    {
    case WM_INITDLG :	
      WinSetWindowULong(hwnd, QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.

      thisPtr=(CWDataFolder*)PVOIDFROMMP(mp2);
      if(!somIsObj(thisPtr))
        return (MRESULT) TRUE;
      if(thisPtr->cwQueryMkisofsFlags()&IDMK_ALLOW32CHARS) {
        WinCheckButton(hwnd,IDRB_32CHARNAMES,1);
        WinCheckButton(hwnd,IDRB_DOSNAMES,0);
      }
      else {
        WinCheckButton(hwnd,IDRB_32CHARNAMES,0);
        WinCheckButton(hwnd,IDRB_DOSNAMES,1);
      }

      /* TRANS.TBL files */
      if(thisPtr->cwQueryMkisofsFlags() & IDMK_TRANSTABLE)
        WinCheckButton(hwnd,IDCB_TRANSTABLE,1);
      else
        WinCheckButton(hwnd,IDCB_TRANSTABLE,0);

      if(((CWDataFolder*)PVOIDFROMMP(mp2))->cwQueryMkisofsFlags()&IDMK_JOLIET)
        WinCheckButton(hwnd,IDCB_JOLIET,1);

      WinShowWindow(WinWindowFromID(hwnd,IDCB_DEEPDIRECTORIES),FALSE);
      
      /* Move default buttons on Warp 4 */
      cwMoveNotebookButtonsWarp4(hwnd, IDPB_FILENAMEHELP, 20);
      return (MRESULT) TRUE;
      /*    case WM_HELP:
			thisPtr=(CWAudioFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_CDRECORDBROWSE),QWL_USER);
			if(!thisPtr)
            break;
			switch(WinQueryWindowUShort(WinQueryFocus(HWND_DESKTOP),QWS_ID))
            {
            case IDEF_CDRECORDOPTIONS:
            return (MRESULT)thisPtr->wpDisplayHelp(IDEF_CDRECORDOPTIONS,AFHELPLIBRARY);
            case IDPB_WIDERRUFEN:
            return (MRESULT)thisPtr->wpDisplayHelp(IDPB_WIDERRUFEN,AFHELPLIBRARY);
            case IDPB_CDRECORDBROWSE:
            return (MRESULT)thisPtr->wpDisplayHelp(IDPB_CDRECORDBROWSE,AFHELPLIBRARY);
            case IDEF_CDRECORDPATH:
            return (MRESULT)thisPtr->wpDisplayHelp(IDEF_CDRECORDPATH,AFHELPLIBRARY);
            default:
            break;
            }
			return (MRESULT)thisPtr->wpDisplayHelp(IDDLG_CDRECORDSETUP,AFHELPLIBRARY);
			break;*/
      /* This prevents switching the notebook page behind the open folder */
    case WM_WINDOWPOSCHANGED:
      {
        MRESULT mr;

        if(WinQueryFocus(HWND_DESKTOP)!=
           WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
          mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
          mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
          return mr;  
        }
        break;
      }
    case WM_FOCUSCHANGE:
      {
        if(!SHORT1FROMMP(mp2)) {
          if(HWNDFROMMP(mp1)==hwnd) {
            MRESULT mr;

            mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
            WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT), WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
            return mr;
          }
        }
        break;
      }
#if 0
    case WM_WINDOWPOSCHANGED:
      {
        /* This prevents switching the notebook page behind the open folder */
        if(!(WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_FLAGS) & FF_ACTIVE))
          mp2=MPFROMLONG(0x80000);
        break;
      }
#endif
    case WM_DESTROY:
      /* The notebook closes and gets destroyed */
      /* Set focus to desktop to prevent PM freeze */
      WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);

      /* Let the WPS save the new instance data */
          //      thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_FILENAMEUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
      if(somIsObj(thisPtr)) {
        ulFlags=0;


        if(WinQueryButtonCheckstate(hwnd,IDCB_JOLIET) &1 )
          ulFlags|=IDMK_JOLIET;
        if(WinQueryButtonCheckstate(hwnd,IDRB_32CHARNAMES) &1 )
          ulFlags|=IDMK_ALLOW32CHARS;
        /* TRANS.TBL files */
        if(WinQueryButtonCheckstate(hwnd,IDCB_TRANSTABLE) &1 )
          ulFlags|=IDMK_TRANSTABLE;

        thisPtr->cwSetMkisofsFlags(ulFlags,
                                   IDMK_ALLOW32CHARS|IDMK_JOLIET| IDMK_TRANSTABLE);
        thisPtr->wpSaveImmediate();
      }
      /* Setup is done */   
      return (MRESULT) TRUE;
    case WM_COMMAND:	
    switch(SHORT1FROMMP(mp1))
      {
      case IDPB_FILENAMEUNDO:
        /* User pressed the UNDO button */
        //thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_FILENAMEUNDO),QWL_USER);
        thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
        if(somIsObj(thisPtr)) {
          ulFlags=thisPtr->cwQueryMkisofsFlags();
          if(ulFlags&IDMK_ALLOW32CHARS) {
            WinCheckButton(hwnd,IDRB_32CHARNAMES,1);
            WinCheckButton(hwnd,IDRB_DOSNAMES,0);
          }
          else {
            WinCheckButton(hwnd,IDRB_32CHARNAMES,0);
            WinCheckButton(hwnd,IDRB_DOSNAMES,1);
          }

          if(ulFlags&IDMK_TRANSTABLE)
            WinCheckButton(hwnd,IDCB_TRANSTABLE,1);
          else
            WinCheckButton(hwnd,IDCB_TRANSTABLE,0);

          if(ulFlags&IDMK_JOLIET)
            WinCheckButton(hwnd,IDCB_JOLIET,1);
          else
            WinCheckButton(hwnd,IDCB_JOLIET,0);
        }
        break;
      default:
        break;
      }
    return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
MRESULT EXPENTRY cdTypeOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  CWDataFolder* thisPtr;
  ULONG ulFlags;
  LONG lSpinValue;
  static HWND hwndStatus;
  int a;
  char chrCD[4];
  char text[CCHMAXPATH];
  char title[CCHMAXPATH];
  char text2[40];

  ULONG rc;
  THISPTR thisPtrStruct;

  switch(msg)
    {
    case WM_INITDLG :	
      WinSetWindowULong(hwnd, QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.

      thisPtr=(CWDataFolder*)PVOIDFROMMP(mp2);
      if(somIsObj(thisPtr)) {
        ulFlags=((CWDataFolder*)PVOIDFROMMP(mp2))->cwQueryCDTypeFlags();
        // enableCDTypeCntrls(hwnd,(CWDataFolder*)PVOIDFROMMP(mp2));
        enableCDTypeCntrls(hwnd,ulFlags);

        /*        if(ulFlags&IDCDT_FIXDISK) 
          WinCheckButton(hwnd,IDCB_FIXDISK,1);*/

        getMessage(title,IDSTRD_BOOTIMAGE,sizeof(title), hDataResource,hwnd);
        getMessage(text2,IDSTRD_BOOTIMAGENAME,sizeof(text2), hDataResource,hwnd);
        sprintf(text,title,text2);
        WinSetWindowText( WinWindowFromID(hwnd,IDST_BOOTIMAGE), text );
        getMessage(title,IDSTRD_BOOTCATALOG,sizeof(title), hDataResource,hwnd);
        getMessage(text2,IDSTRD_BOOTCATALOGNAME,sizeof(text2), hDataResource,hwnd);
        sprintf(text,title,text2);
        WinSetWindowText( WinWindowFromID(hwnd,IDST_BOOTCATALOG), text );
      }

      /* Move default buttons on Warp 4 */
      cwMoveNotebookButtonsWarp4(hwnd, IDPB_CDTYPEHELP, 20);
      return (MRESULT) TRUE;
      /* This prevents switching the notebook page behind the open folder */
    case WM_WINDOWPOSCHANGED:
      {
        MRESULT mr;

        if(WinQueryFocus(HWND_DESKTOP)!=
           WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
          mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
          mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
          return mr;  
        }
        break;
      }
    case WM_FOCUSCHANGE:
      {
        if(!SHORT1FROMMP(mp2)) {
          if(HWNDFROMMP(mp1)==hwnd) {
            MRESULT mr;

            mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
            WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT), WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
            return mr;
          }
        }
        break;
      }
#if 0
    case WM_WINDOWPOSCHANGED:
      {
        /* This prevents switching the notebook page behind the open folder */
        if(!(WinQueryWindowUShort(WinQueryWindow(hwnd, QW_PARENT), QWS_FLAGS) & FF_ACTIVE))
          mp2=MPFROMLONG(0x80000);
        break;
      }
#endif
    case WM_DESTROY:
      /* The notebook closes and gets destroyed */
      /* Set focus to desktop to prevent PM freeze */
      WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);

      /* Let the WPS save the new instance data */
      //      thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_CDTYPEUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd, QWL_USER);
      if(somIsObj(thisPtr)) {
        ulFlags=0;
        if(WinQueryButtonCheckstate(hwnd,IDRB_MULTISESSION)&1) {
          ulFlags|=IDCDT_MULTISESSION;
        }
        if(WinQueryButtonCheckstate(hwnd,IDRB_USERDEFINED)&1)
          ulFlags|=IDCDT_USERDEFINED;

        if(WinQueryButtonCheckstate(hwnd,IDRB_BOOTCD)&1)
          ulFlags|=IDCDT_BOOTCD;
        
        if(WinQueryButtonCheckstate(hwnd,IDRB_TRACKDATA)&1)
          ulFlags|=IDCDT_TRACKDATA;
        else
          if(WinQueryButtonCheckstate(hwnd,IDRB_TRACKMODE2)&1)
            ulFlags|=IDCDT_TRACKMODE2;
          else
            if(WinQueryButtonCheckstate(hwnd,IDRB_TRACKXA1)&1)
              ulFlags|=IDCDT_TRACKXA1;
            else
              if(WinQueryButtonCheckstate(hwnd,IDRB_TRACKXA2)&1)
                ulFlags|=IDCDT_TRACKXA2;
              else
                if(WinQueryButtonCheckstate(hwnd,IDRB_TRACKCDI)&1)
                  ulFlags|=IDCDT_TRACKCDI;
        
        if(WinQueryButtonCheckstate(hwnd,IDCB_FIXDISK)&1)
          ulFlags|=IDCDT_FIXDISK;
        thisPtr->cwSetCDTypeFlags(ulFlags,CDT_ALLFLAGS);
        thisPtr->wpSaveImmediate();
      }
      /* Setup is done */   
      bMultiSessionDone=TRUE;
      return (MRESULT) FALSE;
    case WM_CONTROL:
      //      thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_CDTYPEUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
      if(!somIsObj(thisPtr)) return (MRESULT) TRUE;
      ulFlags=thisPtr->cwQueryCDTypeFlags();/* Get current flags */
      ulFlags&=(IDCDT_ALLTRACKTYPES|IDCDT_FIXDISK);/* Keep the tracktype information */
      switch(SHORT1FROMMP(mp1))
        {
        case IDRB_SINGLESESSION:
          enableCDTypeCntrls(hwnd, ulFlags);
          break;
        case IDRB_MULTISESSION:
          ulFlags|=IDCDT_MULTISESSION;
          enableCDTypeCntrls(hwnd, ulFlags);
          break;
        case IDRB_BOOTCD:
          ulFlags|=IDCDT_BOOTCD;
          enableCDTypeCntrls(hwnd, ulFlags);
          break;
        case IDRB_USERDEFINED:
          ulFlags|=IDCDT_USERDEFINED;
          enableCDTypeCntrls(hwnd, ulFlags);
          break;
#if 0
        case IDRB_SINGLESESSION:
          _showMultiSessionCntrls(hwnd,FALSE);
          _showBootCDCntrls(hwnd, FALSE);
          _showTrackCntrls(hwnd, FALSE);
          _showSingleSessionCntrls(hwnd,TRUE);
          break;
        case IDRB_MULTISESSION:
          _showTrackCntrls(hwnd, FALSE);
          _showBootCDCntrls(hwnd, FALSE);
          _showMultiSessionCntrls(hwnd,TRUE);
          thisPtr->cwEnableMultiSessionCntrls(hwnd,FALSE);
          break;
        case IDRB_BOOTCD:
          _showTrackCntrls(hwnd, FALSE);
          _showMultiSessionCntrls(hwnd,FALSE);
          _showBootCDCntrls(hwnd, TRUE);
          break;
        case IDRB_USERDEFINED:
          _showMultiSessionCntrls(hwnd,FALSE);
          _showBootCDCntrls(hwnd, FALSE);
          _showTrackCntrls(hwnd, TRUE);
          break;
#endif
        default:
          break;
        }
      break;
    case WM_COMMAND:	
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_BOOTCDCONFIGURE:
          //thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_CDTYPEUNDO),QWL_USER);
          thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
          if(!somIsObj(thisPtr)) return (MRESULT) TRUE;

          thisPtrStruct.usSize=sizeof(thisPtrStruct);
          thisPtrStruct.thisPtr=thisPtr;
          if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, _bootCDOptionsDialogProc, hDataResource, 
                         IDDLG_BOOTCDOPTIONS, &thisPtrStruct) == DID_OK )
            {
              getMessage(title,IDSTRD_BOOTIMAGE,sizeof(title), hDataResource,hwnd);
              sprintf(text,title,thisPtr->chrBootImage);
              WinSetWindowText( WinWindowFromID(hwnd,IDST_BOOTIMAGE), text );
              
              getMessage(title,IDSTRD_BOOTCATALOG,sizeof(title), hDataResource,hwnd);
              sprintf(text,title,thisPtr->chrBootCatalog);
              WinSetWindowText( WinWindowFromID(hwnd,IDST_BOOTCATALOG), text );
            }
          break;
        case IDPB_CDTYPEUNDO:
          // thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_CDTYPEUNDO),QWL_USER);
          thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
          /* User pressed the UNDO button */
          if(somIsObj(thisPtr)) {
            //ulFlags=thisPtr->cwQueryCDTypeFlags();
            /* Enable all multisesson controls */
            //  thisPtr->cwEnableMultiSessionCntrls(hwnd,TRUE);
            //            enableCDTypeCntrls(hwnd,thisPtr);
            enableCDTypeCntrls(hwnd, thisPtr->cwQueryCDTypeFlags());
            /*            if(ulFlags&IDCDT_FIXDISK) 
                          WinCheckButton(hwnd,IDCB_FIXDISK,1);
                          else
                          WinCheckButton(hwnd,IDCB_FIXDISK,0);*/
          }
          break;  
        default:
          break;
        }
      return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2); 
}
/* This procedure handles the author settings page */ 
MRESULT EXPENTRY authorOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  CWDataFolder* thisPtr;

  switch(msg)
    {
    case WM_INITDLG :	
      WinSetWindowULong(hwnd, QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
      thisPtr=(CWDataFolder*)PVOIDFROMMP(mp2);
      WinSendMsg(WinWindowFromID(hwnd,IDEF_APPLICATION),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)128),0);
      WinSetWindowText(WinWindowFromID(hwnd,IDEF_APPLICATION),thisPtr->chrApplication);
      WinSendMsg(WinWindowFromID(hwnd,IDEF_PUBLISHER),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)128),0);
      WinSetWindowText(WinWindowFromID(hwnd,IDEF_PUBLISHER),thisPtr->chrPublisher);
      WinSendMsg(WinWindowFromID(hwnd,IDEF_PREPARER),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)128),0);
      WinSetWindowText(WinWindowFromID(hwnd,IDEF_PREPARER),thisPtr->chrPreparer);
      WinSendMsg(WinWindowFromID(hwnd,IDEF_VOLUMENAME),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)32),0);
      WinSetWindowText(WinWindowFromID(hwnd,IDEF_VOLUMENAME),thisPtr->chrVolumeName);

      /* Move default buttons on Warp 4 */
      cwMoveNotebookButtonsWarp4(hwnd, IDPB_AUTHORHELP, 20);
      return (MRESULT) TRUE;
      /* This prevents switching the notebook page behind the open folder */
    case WM_WINDOWPOSCHANGED:
      {
        MRESULT mr;

        if(WinQueryFocus(HWND_DESKTOP)!=
           WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
          mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
          mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
          return mr;  
        }
        break;
      }
    case WM_FOCUSCHANGE:
      {
        if(!SHORT1FROMMP(mp2)) {
          if(HWNDFROMMP(mp1)==hwnd) {
            MRESULT mr;

            mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
            WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT), WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
            return mr;
          }
        }
        break;
      }
    case WM_DESTROY:
      /* The notebook closes and gets destroyed */
      /* Set focus to desktop to prevent PM freeze */
      WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);

      /* Let the WPS save the new instance data */
      //      thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_AUTHORUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
      if(somIsObj(thisPtr)) {
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_APPLICATION),sizeof(thisPtr->chrApplication),thisPtr->chrApplication);
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_PUBLISHER),sizeof(thisPtr->chrPublisher),thisPtr->chrPublisher);
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_PREPARER),sizeof(thisPtr->chrPreparer),thisPtr->chrPreparer);
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_VOLUMENAME),sizeof(thisPtr->chrVolumeName),thisPtr->chrVolumeName);
        thisPtr->wpSaveDeferred();
      }
      /* Setup is done */
      return (MRESULT) TRUE;
    case WM_COMMAND:	
    switch(SHORT1FROMMP(mp1))
      {
      case IDPB_AUTHORUNDO:
        /* User pressed the UNDO button */
        //   thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_AUTHORUNDO),QWL_USER);
        thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
        if(somIsObj(thisPtr)) {
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_APPLICATION),thisPtr->chrApplication);
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_PUBLISHER),thisPtr->chrPublisher);
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_PREPARER),thisPtr->chrPreparer);
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_VOLUMENAME),thisPtr->chrVolumeName);
        }
        break;
      default:
        break;
      }
    return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
Пример #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);
}
MRESULT EXPENTRY specialOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  CWDataFolder* thisPtr;
  ULONG ulFlags;
  LONG lSpinValue;
  static HWND hwndStatus;
  int a;
  char chrCD[4];
  char text[CCHMAXPATH];
  char title[CCHMAXPATH];
  char text2[40];

  ULONG rc;
  THISPTR thisPtrStruct;

  switch(msg)
    {
    case WM_INITDLG :	
      WinSetWindowULong(hwnd, QWL_USER,(ULONG)PVOIDFROMMP(mp2));//Save object ptr.
      thisPtr=(CWDataFolder*)PVOIDFROMMP(mp2);
      if(somIsObj(thisPtr)) {
        ulFlags=((CWDataFolder*)PVOIDFROMMP(mp2))->cwQueryMkisofsFlags();
        
        if(ulFlags & IDMK_SHADOWSINROOTONLY) { 
          WinCheckButton(hwnd,IDRB_SHADOWSINROOTONLY,1);
          enableArchiveCntrls(hwnd, FALSE);
        }
        else {
          WinCheckButton(hwnd,IDRB_FOLLOWALLSHADOWS,1);
          enableArchiveCntrls(hwnd, TRUE);
        }
        /* Use archive bit */
        if(ulFlags & IDMK_USEARCHIVEBIT) 
          WinCheckButton(hwnd, IDCB_USEARCHIVEBIT, 1);
        else
          WinCheckButton(hwnd, IDCB_USEARCHIVEBIT, 0);
        /* Reset archive bit */
        if(ulFlags & IDMK_RESETARCHIVEBIT) 
          WinCheckButton(hwnd, IDCB_RESETARCHIVEBIT,1);
        else
          WinCheckButton(hwnd, IDCB_RESETARCHIVEBIT, 0);
      }
      /* Move default buttons on Warp 4 */
      cwMoveNotebookButtonsWarp4(hwnd, IDPB_SPECIALHELP, 20);
      return (MRESULT) TRUE;
      /* This prevents switching the notebook page behind the open folder */
    case WM_WINDOWPOSCHANGED:
      {
        MRESULT mr;

        if(WinQueryFocus(HWND_DESKTOP)!=
           WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
          mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
          mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
          return mr;  
        }
        break;
      }
    case WM_FOCUSCHANGE:
      {
        if(!SHORT1FROMMP(mp2)) {
          if(HWNDFROMMP(mp1)==hwnd) {
            MRESULT mr;

            mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
            WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT), WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
            return mr;
          }
        }
        break;
      }
    case WM_DESTROY:
      /* The notebook closes and gets destroyed */
      /* Set focus to desktop to prevent PM freeze */
      WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);

      /* Let the WPS save the new instance data */
      //      thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_SPECIALUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
      if(somIsObj(thisPtr)) {
        ulFlags=thisPtr->cwQueryMkisofsFlags();
        if(WinQueryButtonCheckstate(hwnd,IDRB_SHADOWSINROOTONLY) & 1) {
          ulFlags|=IDMK_SHADOWSINROOTONLY;
        }
        else
          ulFlags&=~IDMK_SHADOWSINROOTONLY;
        /* Use archive bit */
        if(WinQueryButtonCheckstate(hwnd, IDCB_USEARCHIVEBIT) & 1) {
          ulFlags|=IDMK_USEARCHIVEBIT;
        }
        else
          ulFlags&=~IDMK_USEARCHIVEBIT;
        /* Reset archive bit */
        if(WinQueryButtonCheckstate(hwnd, IDCB_RESETARCHIVEBIT) & 1) {
          ulFlags|=IDMK_RESETARCHIVEBIT;
        }
        else
          ulFlags&=~IDMK_RESETARCHIVEBIT;

        thisPtr->cwSetMkisofsFlags(ulFlags,MK_ALLFLAGS);
        thisPtr->wpSaveImmediate();
      }
      /* Setup is done */   
    
      return (MRESULT) FALSE;
    case WM_CONTROL:
      switch(SHORT1FROMMP(mp1))
        {
        case IDRB_SHADOWSINROOTONLY:
          enableArchiveCntrls(hwnd, FALSE);
          break;
        case IDRB_FOLLOWALLSHADOWS:
          enableArchiveCntrls(hwnd, TRUE);          
          break;
        default:
          break;
        }
      break;
    case WM_COMMAND:	
      //thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_SPECIALUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
      if(!somIsObj(thisPtr)) 
        return (MRESULT) TRUE;
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_SPECIALUNDO:
          /* User pressed the UNDO button */
          ulFlags=thisPtr->cwQueryMkisofsFlags();
          if(ulFlags & IDMK_SHADOWSINROOTONLY) 
            WinCheckButton(hwnd,IDRB_SHADOWSINROOTONLY,1);
          else
            WinCheckButton(hwnd, IDRB_FOLLOWALLSHADOWS,1);
          /* Use archive bit */
          if(ulFlags & IDMK_USEARCHIVEBIT) 
            WinCheckButton(hwnd, IDCB_USEARCHIVEBIT, 1);
          else
            WinCheckButton(hwnd, IDCB_USEARCHIVEBIT, 0);
          /* Reset archive bit */
          if(ulFlags & IDMK_RESETARCHIVEBIT) 
            WinCheckButton(hwnd, IDCB_RESETARCHIVEBIT,1);
          else
            WinCheckButton(hwnd, IDCB_RESETARCHIVEBIT, 0);          
          break;  
        case IDPB_SPECIALHELP:
          thisPtr->wpDisplayHelp(IDHLP_DATAFOLDERSPECIAL,AFHELPLIBRARY);
          break;
        case IDPB_RESETNOW:
          /* Text: ""
             Title: ""
             */
          rc=messageBox( text, IDSTRD_RESETARCHIVEBITCONFIRM , sizeof(text),
                      title, IDSTRD_RESETARCHIVEBITTITLE, sizeof(title),
                      hDataResource, HWND_DESKTOP, MB_YESNO | MB_ICONQUESTION | MB_MOVEABLE | MB_DEFBUTTON2);          
          if(rc==MBID_YES)
            DosBeep(5000,1000);
          break;
        default:
          break;
        }
      return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2); 
}
MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
   RECTL    clientrect;                     /* Rectangle coordinates        */
   HPS      hpsPaint;
   POINTL   pt;                            /* String screen coordinates    */
   BOOL     Invalid;
   int      Line;
   ERRORID  Err;
   HWND     Focus,Active;
   HMQ      hmqDeb;
   PID      pid,cpid;
   TID      tid,ctid;
   switch( msg )
   {
   case WM_CREATE:
      WinStartTimer(hab,hwnd,1234,500);
      break;                                /* end the application.     */
   case WM_TIMER:
      rc=DosOpen("KBD$", &hKbd, &Action, 0, FILE_NORMAL, FILE_OPEN,
                 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE |
                 OPEN_FLAGS_FAIL_ON_ERROR, 0);
      if (rc) {
         char Buf[80];
         sprintf(Buf,"Open rc = %d",rc);
         WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
                       Buf,
                       "TRAPIT",
                        1234,
                        MB_OK);
      } /* endif */
      Dlen= sizeof(State);
      rc = DosDevIOCtl( hKbd, 4, 0x73, 0, 0, 0, &State, sizeof(State), &Dlen );
      Shift=(USHORT)State;
      DosClose(hKbd);
      Invalid=FALSE;
      if ((State&0x0500)==0x0500) {
         if (Color!=CLR_RED) {
            Color=CLR_RED;
            Invalid=TRUE;
         } /* endif */
         Focus=WinQueryFocus(HWND_DESKTOP);
         Active=WinQueryActiveWindow(HWND_DESKTOP);
         WinQueryWindowProcess(Focus,&pid,&tid);
         hmqDeb=(HMQ)WinQueryWindowULong(Focus,QWL_HMQ);
         if (hmqDeb==hmq) {
            sprintf(Buffer,"Sorry Can't unhang Myself");
         } else {
            DosKillProcess(DKP_PROCESS,pid);
         } /* endif */
      } else {
         if ((State&0x0A00)==0x0A00) {
            if (Color!=CLR_BLUE) {
               Color=CLR_BLUE;
               Invalid=TRUE;
            } /* endif */
            Focus=WinQueryFocus(HWND_DESKTOP);
            Active=WinQueryActiveWindow(HWND_DESKTOP);
            WinQueryWindowProcess(Focus,&pid,&tid);
            hmqDeb=(HMQ)WinQueryWindowULong(Focus,QWL_HMQ);
            if (hmqDeb==hmq) {
               sprintf(Buffer,"Sorry Can't trap Myself");
            } else {
               HENUM hEnum;
               CHAR Class[20];
               HWND Child;
               hEnum = WinBeginEnumWindows(HWND_OBJECT);
               while ( (Child=WinGetNextWindow(hEnum)) != 0) {
                   WinQueryWindowProcess(Child,&cpid,&ctid);
                   if (cpid==pid) {
                       Class[0]=0;
                       WinQueryClassName(Child,sizeof(Class)-1,Class);
                       if (strcmp(Class,"Killer")==0) {
                           if (WinPostMsg(Child,WM_USER+1,0,0)) {
                              DosBeep(1800,80);
                              DosBeep(600,80);
                              DosBeep(1800,80);
                           }
                       } /* endif */
                   } /* endif */
               }
               WinEndEnumWindows(hEnum);
            } /* endif */
         } else {
            if (Color!=CLR_BACKGROUND) {
               Color=CLR_BACKGROUND;
               Invalid=TRUE;
            }
         } /* endif */
      } /* endif */
      if (Invalid) {
            WinInvalidateRect( hwnd, NULL, TRUE );
      } /* endif */
      break;
   case WM_PAINT:
      hpsPaint=WinBeginPaint( hwnd,0, &clientrect );
      WinFillRect( hpsPaint, &clientrect,Color );/* Fill invalid rectangle       */
      pt.x = 10; pt.y = 190;                    /* Set the text coordinates,    */
      GpiCharStringAt( hpsPaint, &pt, (LONG)strlen(Buffer),Buffer);
      for (Line=0;Line<8;Line++ ) {
         pt.x = 10; pt.y = 170-(20*Line);   /* Set the text coordinates,    */
         GpiCharStringAt( hpsPaint, &pt, (LONG)strlen(LabelText[Line]),LabelText[Line]);
      } /* endfor */
      WinEndPaint( hpsPaint );                        /* Drawing is complete   */
      break;
    case WM_CLOSE:
      /******************************************************************/
      /* This is the place to put your termination routines             */
      /******************************************************************/
      WinPostMsg( hwnd, WM_QUIT, 0L, 0L );  /* Cause termination        */
      break;
    default:
      /******************************************************************/
      /* Everything else comes here.  This call MUST exist              */
      /* in your window procedure.                                      */
      /******************************************************************/
      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }
  return FALSE;
}
Пример #17
0
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd, ULONG ulMsg, MPARAM mpParm1, MPARAM mpParm2 )
{
   switch ( ulMsg )
   {
   // For HELP debugging
   #if 0
      case HM_ERROR:
         {
            CHAR     szTempBuffer[256];

            sprintf( szTempBuffer, "Received HM_ERROR message, mp1=0X%8.8X", (ULONG)mpParm1 );
            WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, szTempBuffer, "HM_ERROR", 0, MB_OK );
         }
         break;

      case HM_EXT_HELP_UNDEFINED:
         WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_EXT_HELP_UNDEFINED message", "HM_EXT_HELP_UNDEFINED", 0, MB_OK );
         break;

      case HM_HELPSUBITEM_NOT_FOUND:
         WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_HELPSUBITEM_NOT_FOUND message", "HM_HELPSUBITEM_NOT_FOUND", 0, MB_OK );
         break;
   #endif

      case HM_QUERY_KEYS_HELP:
         return (MRESULT)IDP_KEYS_INFO;
         break;

      case WM_BUTTON1CLICK:
         MoveCursorToPointer( hwndWnd, (*(POINTS *)&mpParm1).x, (*(POINTS *)&mpParm1).y );
         break;

   #if 0
      case WM_BUTTON2CLICK:
         {
            HPS      hpsClient;
            POINTL   ptl;
            INT      xC, yC;


            xC = ( ( (*(POINTS *)&mpParm1).x - cxChar) / cxChar );
            yC = ( ( cyClient - (*(POINTS *)&mpParm1).y ) / cyChar );

            hpsClient = WinGetPS( hwndWnd );
            GpiSetColor( hpsClient, CLR_PALEGRAY );
            if ( xC < 10 )
               GpiSetMix( hpsClient, FM_XOR );
            else if ( xC < 20 )
               GpiSetMix( hpsClient, FM_INVERT );
            else if ( xC < 30 )
               GpiSetMix( hpsClient, FM_NOTXORSRC );
            else if ( xC < 40 )
               GpiSetMix( hpsClient, FM_NOTMASKSRC );
            else if ( xC < 50 )
               GpiSetMix( hpsClient, FM_SUBTRACT );
///            GpiSetBackColor( hpsClient, CLR_PALEGRAY );
///            GpiSetBackMix( hpsClient, BM_OVERPAINT );
///            ptl.x = ( ( (*(POINTS *)&mpParm1).x - cxChar ) / cxChar ) * cxChar + cxChar;
///            ptl.y = ( ( (*(POINTS *)&mpParm1).y - cyClient ) / cyChar - 1 ) * cyChar + cyClient;
            ptl.x = cxChar + ( xC * cxChar );
            ptl.y = cyClient - ( ( yC + 1) * cyChar );
            GpiMove( hpsClient, &ptl );
            ptl.x += cxChar;
            ptl.y += cyChar;
            if ( yC < 5 )
               GpiBox( hpsClient, DRO_FILL, &ptl, 0, 0 );
            else
               GpiBox( hpsClient, DRO_OUTLINE, &ptl, 0, 0 );
///            GpiSetBackColor( hpsClient, CLR_BACKGROUND );
///            GpiSetMix( hpsClient, FM_DEFAULT );
            WinReleasePS( hpsClient );
         }
         break;
   #endif

      case WM_CHAR:
         if ( !( CHARMSG(&ulMsg)->fs & KC_KEYUP ) )
         {
            if ( CHARMSG(&ulMsg)->fs & KC_CHAR )
            {
               ProcessCharMsg( hwndWnd, ulMsg, mpParm1, mpParm2 );
            }
            else if ( CHARMSG(&ulMsg)->fs & KC_VIRTUALKEY )
            {
               if ( !ProcessCursorMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
               {
                  return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
               }
            }
         }
         break;

      case WM_CLOSE:
         if ( QueryAbandonChanges( hwndWnd ) )
            return WinDefWindowProc ( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_COMMAND:
         return ProcessCommandMsg( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_CREATE:
         hwndMenu = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_MENU );
         hwndHScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_HORZSCROLL );
         hwndVScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_VERTSCROLL );
         SetWindowTitle( hwndWnd );
         break;

      case WM_DESTROY:
         ClearFile( hwndWnd );
         break;

      case WM_ERASEBACKGROUND:
         return MRFROMSHORT ( TRUE ) ;

      case WM_HELP:
         ProcessHelpMessage( hwndWnd, mpParm1, mpParm2 );
         break;

      case WM_HSCROLL:
         if ( !ProcessHScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
            return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_PAINT:
         PaintScreen( hwndWnd );
         break;

      case WM_SAVEAPPLICATION:
         SaveSettings( hwndWnd, habAnchor );
         return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      case WM_SETFOCUS:
         if ( SHORT1FROMMP( mpParm2 ) )
            CreateCursor( hwndWnd );
         else
            DestroyCursor( hwndWnd );
         break;

      case WM_SIZE:
         UpdateWindowSize( hwndWnd, SHORT1FROMMP( mpParm2), SHORT2FROMMP( mpParm2 ) );
         if ( hwndWnd == WinQueryFocus( HWND_DESKTOP ) )
         {
            DestroyCursor( hwndWnd );
            CreateCursor( hwndWnd );
         }
         break;

      case WM_VSCROLL:
         if ( !ProcessVScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) )
            return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;

      default:
         return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 );
         break;
   }

   return MRFROMSHORT ( FALSE ) ;
}
Пример #18
0
MRESULT	PDSKeyProc(HWND	hWnd, ULONG msg, MPARAM	mp1, MPARAM mp2)

{

switch ( msg )
   {
		       /* Check	for key	strokes				*/
   case	WM_CHAR	:
		       /* Check	for the	key up flag in which case the	*/
		       /* condition should be ignored			*/

       if ( SHORT1FROMMP(mp1) &	KC_KEYUP )
	   break;
		       /* Check	for virtual keys			*/

       if ( SHORT1FROMMP(mp1) &	KC_VIRTUALKEY )
	   switch ( SHORT2FROMMP(mp2) )
	       {
	       case VK_TAB :

		       /* TAB key pressed, determine which control is	*/
		       /* the next tab stop and	set the	focus on that	*/
		       /* control					*/

		   WinSetFocus(HWND_DESKTOP,
			       WinEnumDlgItem(hWnd,
					      WinQueryFocus(HWND_DESKTOP),
					      EDI_NEXTTABITEM));
		   break;

	       case VK_RIGHT :
	       case VK_DOWN :

		       /* Right	or down	arrow key pressed, determine	*/
		       /* which	control	is the next entry and set the	*/
		       /* focus	on that	control				*/

		   WinSetFocus(HWND_DESKTOP,
			       WinEnumDlgItem(hWnd,
					      WinQueryFocus(HWND_DESKTOP),
					      EDI_NEXTGROUPITEM));
		   break;

	       case VK_BACKTAB :

		       /* Shift+TAB key	pressed, determine which	*/
		       /* control is the previous tab stop and set the	*/
		       /* focus	on that	control				*/

		   WinSetFocus(HWND_DESKTOP,
			       WinEnumDlgItem(hWnd,
					      WinQueryFocus(HWND_DESKTOP),
					      EDI_PREVTABITEM));
		   break;

	       case VK_LEFT :
	       case VK_UP :

		       /* Left or up arrow key pressed,	determine	*/
		       /* which	control	is the previous	entry and set	*/
		       /* the focus on that control			*/

		   WinSetFocus(HWND_DESKTOP,
			       WinEnumDlgItem(hWnd,
					      WinQueryFocus(HWND_DESKTOP),
					      EDI_PREVGROUPITEM));
		   break;
	       }
       break;
		       /* Virtual key not TAB or Shift+TAB, fall	*/
		       /* through to default window procedure		*/

		       /* Default message processing			*/
   default :
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
MRESULT EXPENTRY newProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          WinReleasePS(hps);

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

        WinQueryWindowRect(hwnd, &rcl);

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

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

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

        rcl3=rcl=rcl2;

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

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

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

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

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