MRESULT EXPENTRY
NewFrameProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
  PFNWP   oldFrameProc ;

     /* ------- get original frame procedure  --------- */
  oldFrameProc = (PFNWP) WinQueryWindowULong( hwnd, QWL_USER );

  switch (msg) {
    case WM_QUERYFRAMECTLCOUNT :
         {
           USHORT   itemCount ;
           
                /* ---- get count of original frame controls --- */
           itemCount = SHORT1FROMMR( oldFrameProc( hwnd, msg, mp1, mp2 ));
                /* ------- add 1 for new toolbar control  ------ */
           return ( (MRESULT) ++itemCount );  
         }

    case WM_FORMATFRAME :
       {
         PSWP     pSWP ;
         PRECTL   pFrameRect ;
         USHORT   itemCount ;

         pFrameRect = PVOIDFROMMP( mp2 );
         pSWP = PVOIDFROMMP( mp1 );
           /* ---- run regular processing on original controls --- */
         itemCount = SHORT1FROMMR( oldFrameProc( hwnd, msg, mp1, mp2 ));

         /* ---- get size values for 2nd menu bar  -------- */
         pSWP[ itemCount ].fl = SWP_SIZE;
         pSWP[ itemCount ].cy =  pSWP[(itemCount-1)].cy ;  /* set some */
         pSWP[ itemCount ].cx =  pSWP[(itemCount-1)].cx ;  /*  defaults */
         pSWP[ itemCount ].hwndInsertBehind = HWND_TOP ;
         pSWP[ itemCount ].hwnd = hwndMenuBar ;
         WinSendMsg( hwndMenuBar,                 /* let the menu code make */
                     WM_ADJUSTWINDOWPOS,          /*  the actual size       */
                     MPFROMP( pSWP+itemCount ),   /*  adjustments           */
                     (MPARAM) 0L );

          /* ------ position menu directly below other menu  ------- */
         pSWP[itemCount].x = pSWP[(itemCount-2)].x ; 
         pSWP[itemCount].y = pSWP[(itemCount-2)].y - pSWP[itemCount].cy ;
         pSWP[itemCount].fl = pSWP[(itemCount-2)].fl ;
          /* --------  adjust client window size for 2nd menu ------- */
         pSWP[(itemCount-1)].cy -= pSWP[itemCount].cy ;
          /* --------  return total count of frame controls   ------- */
         return( MRFROMSHORT( ++itemCount )  );
       }
       break;

    default:
      return oldFrameProc(hwnd,msg,mp1,mp2);

  } /* end of switch () */

  return( FALSE );

} /* end of NewFrameProc */
Пример #2
0
static MRESULT APIENTRY InitDlg ( HWND Window, ULONG msg, MPARAM mp1, MPARAM mp2 ) {

  /**************************************************************************
   * Get parameters from initialization message.                            *
   **************************************************************************/

   PDATEFMT_PARMS Parms = PDATEFMT_PARMS ( PVOIDFROMMP ( mp2 ) ) ;

   Sys_SetWindowData ( Window, Parms ) ;

  /**************************************************************************
   * Fill the entry field.                                                  *
   **************************************************************************/

   Sys_SendMessage ( CHILD(Window,IDD_DATEFMT_ENTRY), EM_SETTEXTLIMIT, MPFROMLONG(sizeof(Parms->Format)-1), 0 ) ;

   char Local [sizeof(Parms->Format)] ;
   LocalDateFormat ( Local, Parms->Format ) ;
   Sys_SetWindowText ( CHILD(Window,IDD_DATEFMT_ENTRY), Local ) ;

  /**************************************************************************
   * Return no error.                                                       *
   **************************************************************************/

   return ( Dialog_Processor ( Window, msg, mp1, mp2 ) ) ;
}
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);
}
Пример #4
0
/****************************************************************************
   SysMenu Dialog Procedure
*****************************************************************************/
MRESULT EXPENTRY SysMenuProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    {
        BOOL    Handled = TRUE;
        MRESULT mReturn  = 0;
        RECTL   Rectl;
        POINTL  Pointl;
        ULONG   temp;
        HPS     hps;
        HBITMAP hbm;

        switch (msg)
            {
                case    WM_PAINT:
                    hps = WinBeginPaint(hWnd, 0, 0);
                    WinQueryWindowRect(hWnd,&Rectl);
                    WinFillRect(hps, &Rectl, CLR_BLACK);
                    hbm = PointerInfo.hbmMiniColor;
                    WinInflateRect(hab, &Rectl, -1L, -1L);
                    WinDrawBitmap(hps, hbm, NULL, (PPOINTL)&Rectl, 0L, 0L, DBM_NORMAL);
                    WinEndPaint(hps);
                    break;
                case WM_ERASEBACKGROUND:
                    WinFillRect((HPS)LONGFROMMP(mp1),PVOIDFROMMP(mp2),CLR_BLACK);
                    mReturn = MRFROMLONG(1L);
                    break;
                default:
                    Handled = FALSE;
                    break;
            }
        if (!Handled) mReturn =  (*SysMenuDefProc)(hWnd, msg, mp1, mp2);
        return (mReturn);
    }
Пример #5
0
static MRESULT APIENTRY InitDlg ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) {

 /***************************************************************************
  * Get parameters from initialization message.                             *
  ***************************************************************************/

  PPROFILE_PARMS Parms = (PPROFILE_PARMS) ( PVOIDFROMMP ( mp2 ) ) ;

  WinSetWindowPtr ( hwnd, QWL_USER, Parms ) ;

 /***************************************************************************
  * Set the dialog help instance.                                           *
  ***************************************************************************/

  WinSetWindowUShort ( hwnd, QWS_ID, Parms->id ) ;
  if ( Parms->hwndHelp ) {
    WinAssociateHelpInstance ( Parms->hwndHelp, hwnd ) ;
  }

 /***************************************************************************
  * Set the entry field contents.                                           *
  ***************************************************************************/

  WinSetDlgItemText ( hwnd, Parms->id+ENTRY, Parms->Path ) ;

 /***************************************************************************
  * Return no error.                                                        *
  ***************************************************************************/

  return ( MRFROMSHORT ( FALSE ) ) ;
}
Пример #6
0
MRESULT EXPENTRY fnwpCOMeventStatesDlg(HWND hwnd,USHORT msg,
                                         MPARAM mp1,MPARAM mp2)
  {
  WORD *pwEvent;
  WORD wEvent;

  switch (msg)
    {
    case WM_INITDLG:
//      CenterDlgBox(hwnd);
      WinSetFocus(HWND_DESKTOP,hwnd);
      pwEvent = PVOIDFROMMP(mp2);
      if (*pwEvent & 0x0001)
        CheckButton(hwnd,CEV_BIT0,TRUE);
      if (*pwEvent & 0x0002)
        CheckButton(hwnd,CEV_BIT1,TRUE);
      if (*pwEvent & 0x0004)
        CheckButton(hwnd,CEV_BIT2,TRUE);
      if (*pwEvent & 0x0008)
        CheckButton(hwnd,CEV_BIT3,TRUE);
      if (*pwEvent & 0x0010)
        CheckButton(hwnd,CEV_BIT4,TRUE);
      if (*pwEvent & 0x0020)
        CheckButton(hwnd,CEV_BIT5,TRUE);
      if (*pwEvent & 0x0040)
        CheckButton(hwnd,CEV_BIT6,TRUE);
      if (*pwEvent & 0x0080)
        CheckButton(hwnd,CEV_BIT7,TRUE);
      if (*pwEvent & 0x0100)
        CheckButton(hwnd,CEV_BIT8,TRUE);
      break;
//    case WM_BUTTON1DOWN:
//      WinDismissDlg(hwnd,TRUE);
//      return(FALSE);
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case DID_HELP:
          DisplayHelpPanel(HLPP_COM_EVENT_BITS);
          return((MRESULT)FALSE);
        case DID_CLEAR:
          if (GetCOMevent(&stIOctl,hCom,&wEvent) != NO_ERROR)
            {
            WinPostMsg(hwndStatAll,UM_KILL_MONITOR,(MPARAM)0L,(MPARAM)0L);
            WinPostMsg(hwndStatDev,UM_KILL_MONITOR,(MPARAM)0L,(MPARAM)0L);
            }
        case DID_OK:
        case DID_CANCEL:
          break;
        default:
          return WinDefDlgProc(hwnd,msg,mp1,mp2);
        }
      WinDismissDlg(hwnd,TRUE);
      return((MRESULT)TRUE);
    default:
      return(WinDefDlgProc(hwnd,msg,mp1,mp2));
    }
  return FALSE;
  }
Пример #7
0
// Top-level notebook dialog procedure -- for WM_INITDLG, expects mp2 to be a
// pointer to a notebook header structure which defines the notebook
MRESULT EXPENTRY NotebookDlgProc(HWND hDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
	int nPage;
	PNBHDR pNotebookHdr;

	if (msg != WM_INITDLG)
		pNotebookHdr = (PNBHDR)WinQueryWindowULong(hDlg, QWL_USER);

	switch(msg) {
	case WM_INITDLG:

		pNotebookHdr = (PNBHDR)(PVOIDFROMMP(mp2));
		pNotebookHdr->hwndNB = WinWindowFromID(hDlg, pNotebookHdr->ulNotebookID);

		// Save upper-level dialog handle for use by page dialog code
		pNotebookHdr->hwndNBDlg = hDlg;

		// Save header pointer in window data so WM_SIZE code can use it
		WinSetWindowULong(hDlg, QWL_USER, (ULONG)pNotebookHdr);

		// Create the notebook
		if (!CreateNotebook(pNotebookHdr)) {
			WinDismissDlg(hDlg, 0);
			return 0;
		}

		// Post a message to open the notebook after initialization is complete
		WinPostMsg(hDlg, WM_OPEN_NOTEBOOK, MP0, MP0);
		break;

	case WM_OPEN_NOTEBOOK:

		// Select the first page, and set the notebook size
		TurnToFirstPage(pNotebookHdr->hwndNB);
		SetNotebookSize(pNotebookHdr);
		break;

	case WM_CONTROL:
		// If user selected a new page, switch to it
		if (((ULONG)pNotebookHdr != 0L) && (SHORT1FROMMP(mp1) == pNotebookHdr->ulNotebookID) && (SHORT2FROMMP(mp1) == BKN_PAGESELECTED))
			SetNBPage(hDlg, (PPAGESELECTNOTIFY)mp2);
		break;

	case WM_CLOSE_NOTEBOOK:
		// clear the notebook page array dialog handles to show the pages are no longer in use
		for (nPage = 0; (nPage < pNotebookHdr->nPages); nPage++)
			pNotebookHdr->PageArray[nPage].hwndPageDlg = (HWND)0L;
		WinDismissDlg(hDlg, 0);
		break;

	default:
		return WinDefDlgProc(hDlg, msg, mp1, mp2);
	}

	return 0;

}
Пример #8
0
MRESULT EXPENTRY OS2Factory::OS2FrameProc( HWND hwnd, ULONG msg,
                                           MPARAM mp1, MPARAM mp2 )
{
    // Get pointer to thread info: should only work with the parent window
    intf_thread_t *p_intf = (intf_thread_t *)WinQueryWindowPtr( hwnd, 0 );

    OS2Factory *pFactory = (OS2Factory*)OS2Factory::instance( p_intf );

    if( msg == WM_ADJUSTWINDOWPOS )
    {
        PSWP pswp = ( PSWP )PVOIDFROMMP( mp1 );
        if( pswp->fl & ( SWP_MINIMIZE | SWP_RESTORE ))
        {
            // propagate to all the owned windows
            HENUM henum = WinBeginEnumWindows( HWND_DESKTOP );
            HWND  hwndNext;
            while(( hwndNext = WinGetNextWindow( henum )) != NULLHANDLE )
            {
                if( WinQueryWindow( hwndNext, QW_OWNER ) ==
                        pFactory->m_hParentClientWindow )
                    WinSetWindowPos( hwndNext, 0, 0, 0, 0, 0,
                                     pswp->fl &
                                         ( SWP_MINIMIZE | SWP_RESTORE ));
            }
        }
    }
    else if( msg == WM_SYSCOMMAND )
    {
        // If closing parent window
        if( SHORT1FROMMP(mp1) == SC_CLOSE )
        {
            libvlc_Quit( p_intf->p_libvlc );

            return 0;
        }
        else if( SHORT1FROMMP(mp1) == SC_MINIMIZE )
        {
            pFactory->minimize();

            return 0;
        }
        else if( SHORT1FROMMP(mp1) == SC_RESTORE )
        {
            pFactory->restore();

            return 0;
        }
        else
        {
            msg_Dbg( p_intf, "WM_SYSCOMMAND %i", (SHORT1FROMMP(mp1)));
        }
    }

    return pFactory->m_pfnwpOldFrameProc( hwnd, msg, mp1, mp2 );
}
Пример #9
0
/*
** dialog to set read/write timeouts
*/
MRESULT EXPENTRY fnwpHdwTimeoutDlg(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2)
  {
  static DCB stComDCB;
  static bAllowClick;
  static COMCTL *pstComCtl;

  switch (msg)
    {
    case WM_INITDLG:
//      CenterDlgBox(hwnd);
//      WinSetFocus(HWND_DESKTOP,hwnd);
      bAllowClick = FALSE;
      pstComCtl = PVOIDFROMMP(mp2);
      if (GetDCB(pstComCtl->pstIOctl,pstComCtl->hCom,&stComDCB))
        {
        WinDismissDlg(hwnd,FALSE);
        return(FALSE);
        }
      if (pstComCtl->pszPortName != NULL)
        WinSetWindowText(hwnd,pstComCtl->pszPortName);
      WinPostMsg(hwnd,UM_INITLS,(MPARAM)0L,(MPARAM)0L);
      break;
    case UM_INITLS:
      FillHdwTimeoutDlg(hwnd,&stComDCB);
      bAllowClick = TRUE;
      break;
    case WM_CONTROL:
      if (SHORT2FROMMP(mp1) == BN_CLICKED)
        if (bAllowClick)
          if (!TCHdwTimeoutDlg(hwnd,SHORT1FROMMP(mp1)))
            return(FALSE);
      break;
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case DID_OK:
          UnloadHdwTimeoutDlg(hwnd,&stComDCB);
          SendDCB(pstComCtl->pstIOctl,pstComCtl->hCom,&stComDCB);
          WinDismissDlg(hwnd,TRUE);
          break;
        case DID_CANCEL:
          WinDismissDlg(hwnd,FALSE);
          break;
        case DID_HELP:
          DisplayHelpPanel(pstComCtl);
          break;
        default:
          return WinDefDlgProc(hwnd,msg,mp1,mp2);
        }
      break;
    default:
      return(WinDefDlgProc(hwnd,msg,mp1,mp2));
    }
  return FALSE;
  }
Пример #10
0
/*
 *  FUNCTION:   DragWndProc
 *
 *  DESCRIPTION:
 * 
 *    Window procedure for drag window
 * 
 */
MRESULT EXPENTRY DragWndProc( HWND hwnd, ULONG msg,
                                   MPARAM mp1, MPARAM mp2 )
{
    PDRAGSTRUCT     pDragData;
    PDRAGTRANSFER   pDragTrans;
    ULONG           cbLength;
    PSZ             pBuffer;
    PSZ             pBufferEnd;
    M_SrcTransient  *somSelfClass;

	switch (msg)
	{
		case WM_CREATE:

            // Set the window pointer to our data structure
			WinSetWindowPtr(hwnd, QWL_USER, (PVOID)mp1);
            break;

        case DM_RENDER:

            // Retrieve the window pointer
			pDragData = (PDRAGSTRUCT) WinQueryWindowPtr(hwnd, QWL_USER);
			if (pDragData == NULL)
				{
				break;
				}

            // Get the DRAGTRANSFER structure
            pDragTrans = (PDRAGTRANSFER) PVOIDFROMMP(mp1);

            // Extract the target foldername and perform a copy
            // ******************************************************
            // The following few lines seem to be a bit dodgy.  If you are
            // reading this (and you are!!), and you know a better way of
            // getting object pointers to class objects etc., please send
            // me some info on CIS - 100241,1425.  I do a lot of that stuff
            // and would appreciate it if anyone could tell me how to do
            // it "cleaner"
            cbLength = DrgQueryStrName(pDragTrans->hstrRenderToName, cbLength, pBuffer);
            pBuffer = new char[cbLength+1];
            cbLength = DrgQueryStrName(pDragTrans->hstrRenderToName, cbLength, pBuffer);
            pBuffer[cbLength] = '\0';
            pBufferEnd = strrchr(pBuffer, '\\');
            pBufferEnd[0] = '\0';
            somSelfClass = (M_SrcTransient *)pDragData->somSelf->somGetClass();
            pDragData->somSelf->wpCopyObject(
                somSelfClass->wpclsQueryFolder(pBuffer, FALSE), FALSE);
            delete pBuffer;
            break;

    }   /* end switch(msg) */

	return (WinDefWindowProc(hwnd, msg, mp1, mp2) );
    
}
Пример #11
0
MRESULT EXPENTRY fnwpCOMstatusStatesDlg(HWND hwnd,USHORT msg,
                                         MPARAM mp1,MPARAM mp2)
  {
  WORD *pwEvent;

  switch (msg)
    {
    case WM_INITDLG:
//      CenterDlgBox(hwnd);
      WinSetFocus(HWND_DESKTOP,hwnd);
      pwEvent = PVOIDFROMMP(mp2);
      if (*pwEvent & 0x0001)
        CheckButton(hwnd,CST_BIT0,TRUE);
      if (*pwEvent & 0x0002)
        CheckButton(hwnd,CST_BIT1,TRUE);
      if (*pwEvent & 0x0004)
        CheckButton(hwnd,CST_BIT2,TRUE);
      if (*pwEvent & 0x0008)
        CheckButton(hwnd,CST_BIT3,TRUE);
      if (*pwEvent & 0x0010)
        CheckButton(hwnd,CST_BIT4,TRUE);
      if (*pwEvent & 0x0020)
        CheckButton(hwnd,CST_BIT5,TRUE);
      if (*pwEvent & 0x0040)
        CheckButton(hwnd,CST_BIT6,TRUE);
      if (*pwEvent & 0x0080)
        CheckButton(hwnd,CST_BIT7,TRUE);
      break;
//    case WM_BUTTON1DOWN:
//      WinDismissDlg(hwnd,TRUE);
//      return(FALSE);
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case DID_HELP:
          DisplayHelpPanel(HLPP_COM_STATUS_BITS);
          return((MRESULT)FALSE);
        case DID_OK:
        case DID_CANCEL:
          break;
        default:
          return WinDefDlgProc(hwnd,msg,mp1,mp2);
        }
      WinDismissDlg(hwnd,TRUE);
      return((MRESULT)TRUE);
    default:
      return(WinDefDlgProc(hwnd,msg,mp1,mp2));
    }
  return FALSE;
  }
Пример #12
0
static MRESULT APIENTRY SetRuler ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

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

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * If ruler parameters have changed, save them and invalidate the window. *
   **************************************************************************/

   PHORZRULER_SETPARMS Parms = PHORZRULER_SETPARMS ( PVOIDFROMMP ( mp1 ) ) ;

   if ( ( Data->Metric      != Parms->Metric      )
      OR ( Data->fxZoom      != Parms->fxZoom      )
      OR ( Data->TopLeft     != Parms->TopLeft     )
      OR ( Data->PageWidth   != Parms->PageWidth   )
      OR ( Data->LeftMargin  != Parms->LeftMargin  )
      OR ( Data->RightMargin != Parms->RightMargin )
      OR ( Data->TabCount    != Parms->TabCount    )
      OR memcmp ( Data->Tabs, Parms->Tabs, sizeof(Data->Tabs) ) ) {

      #ifdef DEBUG
         Log ( "HRuler::SetRuler: Setting Margins to %i, %i.", Parms->LeftMargin, Parms->RightMargin ) ;
      #endif
      Data->Metric      = Parms->Metric ;
      Data->fxZoom      = Parms->fxZoom ;
      Data->TopLeft     = Parms->TopLeft ;
      Data->PageWidth   = Parms->PageWidth ;
      Data->LeftMargin  = Parms->LeftMargin ;
      Data->RightMargin = Parms->RightMargin ;
      Data->TabCount    = Parms->TabCount ;
      memcpy ( Data->Tabs, Parms->Tabs, sizeof(Data->Tabs) ) ;
      Sys_InvalidateWindow ( Window ) ;

   } /* endif */

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

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

  RECTL rcl;
  POINTL ptl= {0};

  poi=(POWNERITEM)PVOIDFROMMP(mp2);

  switch(poi->idItem)
    {
    case SDA_SLIDERARM:

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

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

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

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

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

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

  /* Done */
  return (MRESULT)TRUE;
}
Пример #14
0
MRESULT EXPENTRY GenDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PPREF_GEN pgen;

   switch (msg) {

      case WM_INITDLG:
         pgen = (PPREF_GEN)PVOIDFROMMP(mp2);
         InitGeneralPage(hwnd, pgen);
         break;
      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == CBOX_DEF_LEN &&
             SHORT2FROMMP(mp1) == BN_CLICKED)
            WinEnableControl(hwnd, SPIN_SUBJ_LEN,
                         !WinQueryButtonCheckstate(hwnd, CBOX_DEF_LEN));
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
         case BTN_FONT: {
            char achFont[FACESIZE];  // buffer usato per i dati del nuovo font
            if (ShowFontDlg(hwnd, achFont))
               WinSetDlgItemText(hwnd, TXT_FONT, achFont);
            }
            break;
         case BTTN_UNDO:
            InitGeneralPage(hwnd, pgen);
            break;
         case BTTN_DEFAULT:
            SetGeneralDefault(hwnd, pgen);
            break;
         default:
           break;
         } /* endswitch */
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
         break;
   } /* endswitch */
   return (MRESULT) FALSE;
}
Пример #15
0
MRESULT EXPENTRY SelDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PPREF_SEL psel;

   switch (msg) {
      case WM_INITDLG:
         psel = (PPREF_SEL)PVOIDFROMMP(mp2);
         InitSelectionPage(hwnd, psel);
         break;
      case WM_CONTROL:
         if (SHORT1FROMMP(mp1) == CBOX_EXT_SEL &&
             SHORT2FROMMP(mp1) == BN_CLICKED) {
            WinEnableControl(hwnd, CBOX_SEL_ALL_INDIR,
                         WinQueryButtonCheckstate(hwnd, CBOX_EXT_SEL));
         } else if (SHORT1FROMMP(mp1) == CBOX_FILE_WIN &&
                    SHORT2FROMMP(mp1) == BN_CLICKED) {
            WinEnableControl(hwnd, CBOX_ONLY_DIR,
                         WinQueryButtonCheckstate(hwnd, CBOX_FILE_WIN));
         } /* endif */
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
            case BTTN_UNDO:
               InitSelectionPage(hwnd, psel);
               break;
            case BTTN_DEFAULT:
               SetSelectionDefault(hwnd);
               break;  
            default:
               break;
         } /* endswitch */
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
         break;
   } /* endswitch */
   return (MRESULT) FALSE;
}
Пример #16
0
static MRESULT APIENTRY InitDlg ( HWND Window, MESG msg, MPARAM1 mp1, MPARAM2 mp2 ) {

  /**************************************************************************
   * Get parameters from initialization message.                            *
   **************************************************************************/

   PTABS_PARMS Parms = PTABS_PARMS ( PVOIDFROMMP ( mp2 ) ) ;

   Sys_SetWindowData ( Window, Parms ) ;

  /**************************************************************************
   * Set the current measurement units.                                     *
   **************************************************************************/

   ResourceString English ( Parms->Library, IDS_UNITS_ENGLISH ) ;
   ResourceString Metric ( Parms->Library, IDS_UNITS_METRIC ) ;

   Sys_SetWindowText ( CHILD(Window,IDD_TABS_UNITS), Parms->Metric ? PSZ(Metric) : PSZ(English) ) ;

  /**************************************************************************
   * Set the page size.                                                     *
   **************************************************************************/

   ResourceString Margins ( Parms->Library, IDS_TABS_MARGINS ) ;
   char String1 [20] ;  FormatDecimal ( String1, Parms->LeftMargin, 1000, 3 ) ;
   char String2 [20] ;  FormatDecimal ( String2, Parms->RightMargin, 1000, 3 ) ;
   char Text [100] ;
   sprintf ( Text, PCHAR(Margins), String1, String2 ) ;
   Sys_SetWindowText ( CHILD(Window,IDD_TABS_SIZE), Text ) ;

  /**************************************************************************
   * Return no error.                                                       *
   **************************************************************************/

   return ( Dialog_Processor ( Window, msg, mp1, mp2 ) ) ;
}
Пример #17
0
//Called before the default wnd procedure if you wish to provide additional
//  functionality.  (i.e. modify what happens with mouse clicks, drag/drop, etc...
BOOL CBZPluginWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2,
                        PVOID pData, PFNWP pfnOrigWndProc, MRESULT *rc)
{
  USHORT      mId;
  PLUGINSHARE *pPluginData = (PLUGINSHARE *)pData;
  


  switch (msg)
    {
    case WM_PAINT:
        {
          PLUGINSHARE *pCBZData = (PLUGINSHARE *)pData;

            BOOL    bActive = FALSE;
            PSPAINT psP;
 
            mId = WinQueryWindowUShort(hwnd, QWS_ID);

            //paint the MinMax menu!
            if (mId == FID_MINMAX)
            {
              HPS hps;
              RECTL rcl;
         
              hps = WinBeginPaint(hwnd, NULLHANDLE,&rcl);


              if(WinSendMsg(hwnd,MM_QUERYITEMRECT,MPFROM2SHORT(SC_CLOSE,FALSE),&rcl))
                {
                  if(pPluginData->hbmActiveClose==NULLHANDLE)
                    if (!CreateImages(pPluginData))
                      return FALSE;
                  // rcl.yBottom-=1;    
                  memset(&psP,0,sizeof(psP));
                  psP.hwnd=hwnd;
                  psP.hps=hps;
                  psP.hpsWin=hps;
                  psP.rectlWindow=rcl;
                  psP.rectlUpdate=rcl;
                  
                  DrawImage(&psP, pPluginData->hbmActiveClose, 0, pPluginData);              
                }

                if(WinSendMsg(hwnd,MM_QUERYITEMRECT,MPFROM2SHORT(SC_MINIMIZE,FALSE),&rcl))
                {
                    //draw MinimizeButton

                  if(pPluginData->hbmActiveMinimize==NULLHANDLE)
                    if (!CreateImages(pPluginData))
                      return FALSE;
                  memset(&psP,0,sizeof(psP));
                  psP.hwnd=hwnd;
                  psP.hps=hps;
                  psP.hpsWin=hps;
                  psP.rectlWindow=rcl;
                  psP.rectlUpdate=rcl;
                  
                  DrawImage(&psP, pPluginData->hbmActiveMinimize, 0, pPluginData);
                }

                if(WinSendMsg(hwnd,MM_QUERYITEMRECT,MPFROM2SHORT(SC_MAXIMIZE,FALSE),&rcl))
                {
                    //draw MaximizeButton
                  if(pPluginData->hbmActiveMaximize==NULLHANDLE)
                    if (!CreateImages(pPluginData))
                      return FALSE;
                  //  rcl.yBottom-=1;    
                  memset(&psP,0,sizeof(psP));
                  psP.hwnd=hwnd;
                  psP.hps=hps;
                  psP.hpsWin=hps;
                  psP.rectlWindow=rcl;
                  psP.rectlUpdate=rcl;
                  
                  DrawImage(&psP, pPluginData->hbmActiveMaximize, 0, pPluginData);
                }

                if(WinSendMsg(hwnd,MM_QUERYITEMRECT,MPFROM2SHORT(SC_RESTORE,FALSE),&rcl))
                {
                    //draw RestoreButton
                  if(pPluginData->hbmActiveRestore==NULLHANDLE)
                    if (!CreateImages(pPluginData))
                      return FALSE;
                  //  rcl.yBottom-=1;    
                  memset(&psP,0,sizeof(psP));
                  psP.hwnd=hwnd;
                  psP.hps=hps;
                  psP.hpsWin=hps;
                  psP.rectlWindow=rcl;
                  psP.rectlUpdate=rcl;
         
                  DrawImage(&psP, pPluginData->hbmActiveRestore, 0, pPluginData);

                }

                if(WinSendMsg(hwnd,MM_QUERYITEMRECT,MPFROM2SHORT(SC_HIDE,FALSE),&rcl))
                {
                    //draw HideButton
                  if(pPluginData->hbmActiveHide==NULLHANDLE)
                    if (!CreateImages(pPluginData))
                      return FALSE;
                  // rcl.yBottom-=1;    
                  memset(&psP,0,sizeof(psP));
                  psP.hwnd=hwnd;
                  psP.hps=hps;
                  psP.hpsWin=hps;
                  psP.rectlWindow=rcl;
                  psP.rectlUpdate=rcl;
         
                  DrawImage(&psP, pPluginData->hbmActiveHide, 0, pPluginData);
                }
                WinEndPaint(hps);
                return TRUE;              
            
            }
        }

      return FALSE;
    case MM_INSERTITEM:
      {
        PMENUITEM pmi;
        MENUITEM mi;

        pmi=(PMENUITEM) PVOIDFROMMP(mp1);
        
        *rc = pfnOrigWndProc(hwnd, msg, mp1, mp2);
        
        if (pmi->id == SC_RESTORE)
          {
            if (pPluginData->hbmActiveRestore != NULLHANDLE) {
              pmi->afStyle|=MIS_OWNERDRAW;
              WinSendMsg(hwnd,MM_SETITEM,MPFROM2SHORT(0,FALSE),pmi);
            }
          }
        else if (pmi->id == SC_MAXIMIZE)
          {
            if (pPluginData->hbmActiveMaximize != NULLHANDLE) {
              pmi->afStyle|=MIS_OWNERDRAW;
              WinSendMsg(hwnd,MM_SETITEM,MPFROM2SHORT(0,FALSE),pmi);
            }
          }
        else if (pmi->id == SC_HIDE)
          {
            if (pPluginData->hbmActiveHide != NULLHANDLE) {
              pmi->afStyle|=MIS_OWNERDRAW;
              WinSendMsg(hwnd,MM_SETITEM,MPFROM2SHORT(0,FALSE),pmi);
            }
          }
        else if (pmi->id == SC_MINIMIZE)
          {
            if (pPluginData->hbmActiveMinimize != NULLHANDLE) {
              pmi->afStyle|=MIS_OWNERDRAW;
              WinSendMsg(hwnd,MM_SETITEM,MPFROM2SHORT(0,FALSE),pmi);
            }
          }
        else if (pmi->id == SC_CLOSE)
          {
            if (pPluginData->hbmActiveClose != NULLHANDLE) {
              pmi->afStyle|=MIS_OWNERDRAW;
              WinSendMsg(hwnd,MM_SETITEM,MPFROM2SHORT(0,FALSE),pmi);
            }
          }        
        return TRUE;
      }
      break;
    default:
      break;
    }

  return FALSE; //false indicates that we haven't processed the message!
}
Пример #18
0
MRESULT EXPENTRY DetailsDllWndProc (HWND hDlg, USHORT Msg, MPARAM mp1, MPARAM mp2)

{
static PSHORT pDetailEntry;
CHAR   TitleStr[41];


switch (Msg)
  {
  case WM_INITDLG:
       pDetailEntry = PVOIDFROMMP (mp2);

       strcpy (TitleStr, "Details ");
       strcat (TitleStr, pShowTableData[*pDetailEntry].Name);
       WinSetWindowText (hDlg, TitleStr);


       /*--- get current libpath --*/

       if (!GetLibPath (Libpath, MAX_LIBPATH_SIZE, ErrorStr))
         {
         WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
		        ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
         WinDismissDlg (hDlg, FALSE);
         break;
         }


       /*--- fill exported procedures ---*/

       if (!_FillExportedProcedures (hDlg, *pDetailEntry, ErrorStr))
         {
         WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
		        ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
         WinDismissDlg (hDlg, FALSE);
         break;
         }


       /*--- fill imported modules ---*/

       if (!_FillImportedModules (hDlg, *pDetailEntry, ErrorStr))
         {
         WinMessageBox (HWND_DESKTOP, hWndFrame, ErrorStr,
		        ApplTitle, 0, MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL);
         WinDismissDlg (hDlg, FALSE);
         break;
         }


       CenterDialog (HWND_DESKTOP, hDlg);

       WinSetFocus (HWND_DESKTOP, WinWindowFromID (hDlg, LID_DETAILS_DLL_EXP_RES));
       return ((MRESULT) TRUE);


  case WM_COMMAND:
        switch (SHORT1FROMMP(mp1))
	 {
	 case DID_CANCEL:
	      WinDismissDlg (hDlg, FALSE);
	      break;
	 }
       break;


  default:
       return WinDefDlgProc (hDlg, Msg, mp1, mp2);
  }


return NULL;
}
Пример #19
0
// ---------------------------------------------------------------------------
// Main Frame window proc
// ---------------------------------------------------------------------------
MRESULT EXPENTRY wxFrameMainWndProc( HWND   hWnd,
                                     ULONG  ulMsg,
                                     MPARAM wParam,
                                     MPARAM lParam )
{
    MRESULT  rc = (MRESULT)0;
    bool     bProcessed = false;
    wxFrame* pWnd  = NULL;

    pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd);
    switch (ulMsg)
    {
        case WM_QUERYFRAMECTLCOUNT:
            if(pWnd && pWnd->m_fnOldWndProc)
            {
                USHORT              uItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));

                rc = MRFROMSHORT(uItemCount);
            }
            break;

        case WM_FORMATFRAME:
/////////////////////////////////////////////////////////////////////////////////
// Applications that subclass frame controls may find that the frame is already
// subclassed the number of frame controls is variable.
// The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
// subclassed by calling the previous window procedure and modifying its result.
////////////////////////////////////////////////////////////////////////////////
            {
                int                 nItemCount;
                int                 i;
                PSWP                pSWP = NULL;
                RECTL               vRectl;
                RECTL               vRstb;
                RECTL               vRtlb;
                int                 nHeight = 0;
                int                 nHeight2 = 0;
                int                 nWidth = 0;

                pSWP = (PSWP)PVOIDFROMMP(wParam);
                nItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));
                if(pWnd->m_frameStatusBar)
                {
                    ::WinQueryWindowRect(pWnd->m_frameStatusBar->GetHWND(), &vRstb);
                    pWnd->m_frameStatusBar->GetSize(NULL, &nHeight);
                }
                if(pWnd->m_frameToolBar)
                {
                    ::WinQueryWindowRect(pWnd->m_frameToolBar->GetHWND(), &vRtlb);
                    pWnd->m_frameToolBar->GetSize(&nWidth, &nHeight2);
                }
                ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl);
                ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2);
                ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE);
                ::WinMapWindowPoints(HWND_DESKTOP, pWnd->m_hFrame, (PPOINTL)&vRectl, 2);
                for(i = 0; i < nItemCount; i++)
                {
                    if(pWnd->m_hWnd && pSWP[i].hwnd == pWnd->m_hWnd)
                    {
                        if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_TOP)
                        {
                            pSWP[i].x    = vRectl.xLeft;
                            pSWP[i].y    = vRectl.yBottom + nHeight;
                            pSWP[i].cx   = vRectl.xRight - vRectl.xLeft;
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2);
                        }
                        else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_BOTTOM)
                        {
                            pSWP[i].x    = vRectl.xLeft;
                            pSWP[i].y    = vRectl.yBottom + nHeight + nHeight2;
                            pSWP[i].cx   = vRectl.xRight - vRectl.xLeft;
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2);
                         }
                        else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_LEFT)
                        {
                            pSWP[i].x    = vRectl.xLeft + nWidth;
                            pSWP[i].y    = vRectl.yBottom + nHeight;
                            pSWP[i].cx   = vRectl.xRight - (vRectl.xLeft + nWidth);
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - nHeight;
                        }
                        else
                        {
                            pSWP[i].x    = vRectl.xLeft;
                            pSWP[i].y    = vRectl.yBottom + nHeight;
                            pSWP[i].cx   = vRectl.xRight - (vRectl.xLeft + nWidth);
                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - nHeight;
                        }
                        pSWP[i].fl   = SWP_SIZE | SWP_MOVE | SWP_SHOW;
                        pSWP[i].hwndInsertBehind = HWND_TOP;
                    }
                }
                bProcessed = true;
                rc = MRFROMSHORT(nItemCount);
            }
            break;

       default:
            if(pWnd && pWnd->m_fnOldWndProc)
                rc = pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam);
            else
                rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
    }
    return rc;
} // end of wxFrameMainWndProc
Пример #20
0
MRESULT EXPENTRY ToolBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
    if (msg == WM_CREATE) {
        WinSetWindowPtr(hwnd, QWL_USER, PVOIDFROMMP(mp1));
    } else {
        ToolBarData *td = (ToolBarData *)WinQueryWindowPtr(hwnd, QWL_USER);
        ToolBarItem *items = td->pItems;

        switch (msg) {
        case WM_DESTROY:
            free(td);
            free(items);
            break;

        case WM_PAINT:
        {
            HPS hps;
            RECTL rcl;
            POINTL ptl;
            SWP swp;
            int xpos, ypos, item;

            WinQueryWindowPos(hwnd, &swp);

            hps = WinBeginPaint(hwnd, 0, &rcl);

            /* top outside 3D border */
            if (rcl.yBottom < 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.x = rcl.xLeft;
                ptl.y = 0;
                GpiMove(hps, &ptl);
                ptl.x = Min(rcl.xRight, swp.cx - 2);
                GpiLine(hps, &ptl);
            }

            /* bottom outside 3D border */
            if (rcl.yTop >= swp.cy - 1 - 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.x = Max(rcl.xLeft, 1);
                ptl.y = swp.cy - 1;
                GpiMove(hps, &ptl);
                ptl.x = rcl.xRight;
                GpiLine(hps, &ptl);
            }

            /* 3D corners */
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = 0;
            ptl.y = 0;
            GpiSetPel(hps, &ptl);
            ptl.x = swp.cx - 1;
            ptl.y = swp.cy - 1;
            GpiSetPel(hps, &ptl);

            /* bottom space */
            if (rcl.yBottom < TYBORDER - 1) {
                for (ptl.y = 1; ptl.y < TYBORDER - 2; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* top space */
            if (rcl.yTop >= swp.cy - TYBORDER + 2) {
                for (ptl.y = swp.cy - TYBORDER + 2; ptl.y < swp.cy - 1; ptl.y++) {
                    ptl.x = Max(rcl.xLeft, 1);
                    GpiMove(hps, &ptl);
                    ptl.x = Min(rcl.xRight, swp.cx - 1);
                    GpiLine(hps, &ptl);
                }
            }

            /* left outside 3D border */
            if (rcl.xLeft < 1) {
                GpiSetColor(hps, CLR_WHITE);
                ptl.y = Max(1, rcl.yBottom);
                ptl.x = 0;
                GpiMove(hps, &ptl);
                ptl.y = rcl.yTop;
                GpiLine(hps, &ptl);
            }

            /* right outside 3D border */
            if (rcl.xRight >= swp.cx - 1) {
                GpiSetColor(hps, CLR_DARKGRAY);
                ptl.y = rcl.yBottom;
                ptl.x = swp.cx - 1;
                GpiMove(hps, &ptl);
                ptl.y = Min(swp.cy - 2, rcl.yTop);
                GpiLine(hps, &ptl);
            }

            /* left border */
            if (rcl.xLeft < TXBORDER - 2) {
                GpiSetColor(hps, CLR_PALEGRAY);
                for (ptl.x = 1; ptl.x < TXBORDER - 2; ptl.x++) {
                    ptl.y = Max(1, rcl.yBottom);
                    GpiMove(hps, &ptl);
                    ptl.y = Min(swp.cy - 2, rcl.yTop);
                    GpiLine(hps, &ptl);
                }
            }

            /* draw toolbar items */
            xpos = TXBORDER;
            ypos = TYBORDER;

            for (item = 0; item < td->ulCount; item++) {
                if (items[item].ulType == tiBITMAP) {
                    if (rcl.xRight >= xpos - 2 && rcl.xLeft <= xpos + TXICON + 1) {
                        GpiSetColor(hps, CLR_BLACK);
                        ptl.x = xpos - 2;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXICON + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_OUTLINE, &ptl, 0, 0);
                        if (item == td->ulDepressed && (items[item].ulFlags & tfDEPRESSED)) {
                            ptl.x = xpos + 1;
                            ptl.y = ypos - 1;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_DARKGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON;
                            GpiLine(hps, &ptl);
                            ptl.y--;
                            GpiMove(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                        } else {
                            ptl.x = xpos;
                            ptl.y = ypos;
                            WinDrawBitmap(hps,
                                          items[item].hBitmap,
                                          0,
                                          &ptl,
                                          0, 0,
                                          (items[item].ulFlags & tfDISABLED) ? DBM_INVERT: DBM_NORMAL);

                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x = xpos - 1;
                            ptl.y = ypos - 1;
                            GpiSetPel(hps, &ptl);
                            GpiSetColor(hps, CLR_WHITE);
                            ptl.y++;
                            GpiMove(hps, &ptl);
                            ptl.y = ypos + TYICON;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos + TXICON - 1;
                            GpiLine(hps, &ptl);
                            GpiSetColor(hps, CLR_PALEGRAY);
                            ptl.x++;
                            GpiSetPel(hps, &ptl);
                            ptl.y--;
                            GpiSetColor(hps, CLR_DARKGRAY);
                            GpiMove(hps, &ptl);
                            ptl.y = ypos - 1;
                            GpiLine(hps, &ptl);
                            ptl.x = xpos;
                            GpiLine(hps, &ptl);
                        }
                    }
                    xpos += TXICON + 3;
                } else if (items[item].ulType == tiSEPARATOR) {
                    if (rcl.xRight >= xpos - 1 && rcl.xLeft <= xpos + TXSEPARATOR + 1) {
                        GpiSetColor(hps, CLR_PALEGRAY);
                        ptl.x = xpos - 1;
                        ptl.y = ypos - 2;
                        GpiMove(hps, &ptl);
                        ptl.x = xpos + TXSEPARATOR + 1;
                        ptl.y = ypos + TYICON + 1;
                        GpiBox(hps, DRO_FILL, &ptl, 0, 0);
                    }
                    xpos += TXSEPARATOR + 3;
                }
            }
            GpiSetColor(hps, CLR_PALEGRAY);
            ptl.x = xpos - 1;
            ptl.y = ypos - 2;
            GpiMove(hps, &ptl);
            ptl.x = swp.cx - 2;
            ptl.y = swp.cy - TYBORDER + 1;
            GpiBox(hps, DRO_FILL, &ptl, 0, 0);

            WinEndPaint(hps);
        }
        break;

        case WM_ADJUSTWINDOWPOS:
        {
            PSWP pswp = (PSWP)PVOIDFROMMP(mp1);
            pswp->cy = TYBORDER + TYICON + TYBORDER;
        }
        break;

        case WM_BUTTON1DOWN:
        case WM_BUTTON1DBLCLK:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                        rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                        td->pItems[item].ulType == tiBITMAP &&
                        (td->pItems[item].ulFlags & tfDISABLED) == 0)
                {
                    td->ulDepressed = item;
                    td->pItems[item].ulFlags |= tfDEPRESSED;
                    WinInvalidateRect(hwnd, &rcl, FALSE);
                    WinSetCapture(HWND_DESKTOP, hwnd);
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_MOUSEMOVE:
        {
            STARTFUNC("ToolBarProc[WM_MOUSEMOVE]");
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            LOG << "Depressed: " << td-> ulDepressed << ENDLINE;
            for (item = 0; item < td->ulCount; item++) {
                LOG << "Checking item " << item << ENDLINE;
                LOG << "  pItem -> " << (void*)(td->pItems + item) << ENDLINE;
                if (item == td->ulDepressed) {
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y)
                    {
                        if ((td->pItems[item].ulFlags & tfDEPRESSED) == 0) {
                            td->pItems[item].ulFlags |= tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    } else {
                        if (td->pItems[item].ulFlags & tfDEPRESSED) {
                            td->pItems[item].ulFlags &= ~tfDEPRESSED;
                            WinInvalidateRect(hwnd, &rcl, FALSE);
                        }
                    }
                    break;
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
        }
        break;

        case WM_BUTTON1UP:
        {
            int item;
            POINTL ptl;
            RECTL rcl;

            if (td->ulDepressed == -1)
                break;

            ptl.x = (LONG) SHORT1FROMMP(mp1);
            ptl.y = (LONG) SHORT2FROMMP(mp1);

            rcl.yBottom = TYBORDER - 1;
            rcl.yTop = TYBORDER + TYICON + 1;
            rcl.xLeft = TXBORDER - 1;
            rcl.xRight = TXBORDER + TXICON + 1;

            for (item = 0; item < td->ulCount; item++) {
                if (item == td->ulDepressed) {
                    WinSetCapture(HWND_DESKTOP, (HWND)0);
                    if (rcl.xLeft <= ptl.x && rcl.yBottom <= ptl.y &&
                            rcl.xRight >= ptl.x && rcl.yTop >= ptl.y &&
                            td->pItems[item].ulFlags & tfDEPRESSED)
                    {
                        td->pItems[item].ulFlags &= ~tfDEPRESSED;
                        WinInvalidateRect(hwnd, &rcl, FALSE);

                        // message
                        WinPostMsg(WinQueryWindow(hwnd, QW_OWNER), WM_COMMAND, MPFROM2SHORT(td->pItems[item].ulCommand, 0), MPFROM2SHORT(CMDSRC_OTHER, TRUE));

                        break;
                    }
                }
                if (td->pItems[item].ulType == tiBITMAP) {
                    rcl.xLeft += TXICON + 3;
                    rcl.xRight += TXICON + 3;
                } else if (td->pItems[item].ulType == tiSEPARATOR) {
                    rcl.xLeft += TXSEPARATOR + 3;
                    rcl.xRight += TXSEPARATOR + 3;
                }
            }
            td->ulDepressed = -1;
        }
        break;
        }
    }
    return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
MRESULT EXPENTRY
NewFrameProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 )
{
  PFNWP   pfnwpOldFrameProc ;

     /* ------- get original frame procedure  --------- */
  pfnwpOldFrameProc = (PFNWP) WinQueryWindowULong( hwnd, QWL_USER );

  switch (msg) {
    case WM_QUERYFRAMECTLCOUNT :
         {
          USHORT   usItemCount ;

                /* ---- get count of original frame controls --- */
          usItemCount = SHORT1FROMMR( pfnwpOldFrameProc( hwnd,
                                                         msg,
                                                         mp1, mp2 ));
                /* ------- add 1 for new toolbar control  ------ */
          return ( (MRESULT) ++usItemCount );
         }

    case WM_FORMATFRAME :
       {
         PSWP     pSWP ;               // pointer to array of frame ctl SWPs
         USHORT   usItemCount ;        // count of original frame controls
         USHORT   usNewMenuIndex ;     // index of new menu SWP
         USHORT   usToolBarIndex ;     // index of Tool Bar menu SWP
         USHORT   usClientIndex ;      // index of client window SWP
         USHORT   usVertScrollIndex ;  // index of vertical scrollbar SWP
         HWND     hwndVertScroll ;     // hwnd of vertical scrollbar

            /* ------- get a pointer to the SWP array ---------- */
         pSWP = PVOIDFROMMP( mp1 );

           /* ---- run regular processing for original controls --- */
           /*
            *  Note that the original frame proc will setup all
            *  the SWP sturctures for the standard frame window
            *  controls starting at the beginning of the array.
            *  A count of how many SWP structures were initialized
            *  is returned.
            *  All SWP structures for new controls that are to be
            *  added ( in our case, 1 ) will be uninitialized and
            *  at the end of the array. The start of the uninitialied
            *  SWP structure start at an index equal to the returned
            *  count.
            */
         usItemCount = SHORT1FROMMR( pfnwpOldFrameProc( hwnd,
                                                        msg,
                                                        mp1, mp2 ));

            /* ------------- locate SWP for 1st menu  ---------- */
            /*
             *  We will use the settings of the 1st menu to help initialize
             *  the SWP for the second menu. We look for the proper SWP
             *  by scanning the array for the matching hwnd.
             */
         for ( usToolBarIndex = 0;
               usToolBarIndex < usItemCount;
               usToolBarIndex++) {
            if (pSWP[usToolBarIndex].hwnd == hwndToolBar){
               break;
            }
         } // end of for( usToolBarIndex...

            /* ------------- locate SWP for client window  ---------- */
            /*
             *  We will need to adjust the vertical height of the client
             *  window to make room for the second menu. We look for the
             *  proper SWP by scanning the array for a matching hwnd.
             */
         for ( usClientIndex = 0;
               usClientIndex < usItemCount;
               usClientIndex++){
            if (pSWP[usClientIndex].hwnd == hwndClient ){
               break;
            }
         } // end of for ( usClientIndex...

            /* --- locate SWP for vert scroll (if exists) --- */
            /*
             *  First we will check if this window has a vert. scroll bar.
             *  We will need to adjust the vertical height of the scroll
             *  bar to make room for the second menu. We look for the
             *  proper SWP by scanning the array for a matching hwnd.
             */

         if ( ( hwndVertScroll =
                    WinWindowFromID( hwnd, FID_VERTSCROLL)) != NULLHANDLE ){
            for ( usVertScrollIndex = 0;
                  usVertScrollIndex < usItemCount;
                  usVertScrollIndex++){
               if (pSWP[usVertScrollIndex].hwnd == hwndVertScroll ){
                  break;
               }
            } // end of for ( usClientIndex...
         } // end of if (( hwndVertScroll...


          /* ------ the new SWP starts after standard control SWPs ----- */
         usNewMenuIndex = usItemCount ;

          /* ---- get size values for 2nd menu bar  -------- */
         pSWP[ usNewMenuIndex ].fl = SWP_SIZE;
         pSWP[ usNewMenuIndex ].cx =  pSWP[usToolBarIndex].cx ;  // set some
         pSWP[ usNewMenuIndex ].cy =  pSWP[usToolBarIndex].cy ;  // defaults
         pSWP[ usNewMenuIndex ].hwndInsertBehind = HWND_TOP ;
         pSWP[ usNewMenuIndex ].hwnd = hwndMenuBar ;

           /* -- get the menu code to make the actual size adjustments -- */
         WinSendMsg( hwndMenuBar,
                     WM_ADJUSTWINDOWPOS,
                     MPFROMP( pSWP+usNewMenuIndex ),
                     (MPARAM) 0L );

         /* ------ position menu directly below other menu  ------- */
         pSWP[usNewMenuIndex].x = pSWP[usToolBarIndex].x ;
         pSWP[usNewMenuIndex].y = pSWP[usToolBarIndex].y -
                                               pSWP[usNewMenuIndex].cy ;
         pSWP[usNewMenuIndex].fl = pSWP[usToolBarIndex].fl ;

         /* --------  adjust client window size for 2nd menu ------- */
         pSWP[usClientIndex].cy -= pSWP[usNewMenuIndex].cy ;

         /* -------- adjust vertical scroll size for 2nd menu  ----- */
         if ( hwndVertScroll != NULLHANDLE ){
             pSWP[usVertScrollIndex].cy -= pSWP[usNewMenuIndex].cy ;
         }

         /* ---  return total count of controls ( +1 for 2nd menu ) --- */
         return( MRFROMSHORT( ++usItemCount )  );
       }
       break;

    default:
      return( pfnwpOldFrameProc(hwnd,msg,mp1,mp2) );

  } /* end of switch () */

  return( FALSE );

} /* end of NewFrameProc */
Пример #22
0
static MRESULT APIENTRY Create ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

  /**************************************************************************
   * Allocate instance data.                                                *
   **************************************************************************/

   PDATA Data = PDATA ( malloc ( sizeof(DATA) ) ) ;

   if ( Data == NULL ) {
      Log ( "ERROR: Unable to allocate instance memory for horizontal ruler." ) ;
      return ( MRFROMSHORT ( 1 ) ) ;
   } /* endif */

   Sys_SetWindowData ( Window, Data ) ;

  /**************************************************************************
   * Grab any parameters from the WM_CREATE message.                        *
   **************************************************************************/

   PHORZRULER_PARMS Parms = PHORZRULER_PARMS ( PVOIDFROMMP ( mp1 ) ) ;

   Data->IniData = Parms->IniData ;
   Data->MainWindow = Parms->MainWindow ;

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

   WinOpenWindowDC ( Window ) ;
   Data->pDevice = new DeviceContext ( "HRuler", Window ) ;

  /**************************************************************************
   * Load the pointers.                                                     *
   **************************************************************************/

   Data->MarginPtr = WinLoadPointer ( HWND_DESKTOP, 0, ID_MARGIN ) ;
   Data->TabstopPtr = WinLoadPointer ( HWND_DESKTOP, 0, ID_TABSTOP ) ;

  /**************************************************************************
   * Perform all other instance initializations.                            *
   **************************************************************************/

   Data->Metric = FALSE ;
   Data->fxZoom = MAKEFIXED ( 1, 0 ) ;
   Data->PageWidth = 9000 ;
   Data->TopLeft = 9000 ;
   Data->LeftMargin = 0 ;
   Data->RightMargin = 9000 ;
   Data->TabCount = 0 ;
   memset ( Data->Tabs, 0, sizeof(Data->Tabs) ) ;
   Data->Tick = 0 ;
   Data->Capture = FALSE ;
   Data->Mode = NOTMOVING ;
   Data->SettingFont = FALSE ;

  /**************************************************************************
   * Success?  Return no error.                                             *
   **************************************************************************/

   return ( MRFROMSHORT ( 0 ) ) ;
}
Пример #23
0
/*--------------------------------------------------------------------------------------*\
 * Procedure to write to logfile.                                                       *
 * Req:                                                                                 *
 *      ulMsg ......... Message ID                                                      *
 *      mpParam ....... Pointer to parameter                                            *
 * Ref:                                                                                 *
 *      pucSD2Logfile . Pointer to name of logfile                                      *
 * Returns:                                                                             *
 *      TRUE/FALSE .... If called sucessfully/unsucessfully                             *
\*--------------------------------------------------------------------------------------*/
BOOL    UPS_LogfileIO(ULONG ulMsg, MPARAM mpParam)
{
FILE            *Logfile;
DATETIME        *pDT=PVOIDFROMMP(mpParam);

if((Logfile=fopen(pucSD2Logfile, "a"))==NULL)
    return(FALSE);                      /* Error, couldn't open logfile */
switch(ulMsg)
{
case LF_POWERFAILED:
    {                                   /* Line power failed */
    fprintf(Logfile, "*********************************************************************\n");
    fprintf(Logfile, "*** SD/2 detected: Line power failed at:   %4d/%02d/%02d at %02d:%02d:%02d ***\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    fprintf(Logfile, "*********************************************************************\n");
    break;
    }
case LF_POWERRETURNED:
    {                                   /* Line power returned */
    fprintf(Logfile, "*********************************************************************\n");
    fprintf(Logfile, "*** SD/2 detected: Line power returned at: %4d/%02d/%02d at %02d:%02d:%02d ***\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    fprintf(Logfile, "*********************************************************************\n\n");
    break;
    }
case LF_UPS_ALERTSTARTTIME:
    {                                   /* Planned Alert will start at... */
    fprintf(Logfile, "    Planning Alert start at:               %4d/%02d/%02d at %02d:%02d:%02d\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    break;
    }

case LF_UPS_ALERTSHUTDOWNTIME:
    {                                   /* Planned user configurable program will be started at...*/
    fprintf(Logfile, "    Planning User-Application start at:    %4d/%02d/%02d at %02d:%02d:%02d\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    break;
    }

case LF_UPS_SHUTDOWNTIME:
    {                                   /* Planned OS/2 DosShutdown will be called at...*/
    fprintf(Logfile, "    Planning OS/2 ShutDown at:             %4d/%02d/%02d at %02d:%02d:%02d\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    break;
    }

case LF_UPS_ALERTSTART:
    {                                   /* Alert will start at...*/
    fprintf(Logfile, "    Alert started at:                      %4d/%02d/%02d at %02d:%02d:%02d\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    break;
    }
case LF_UPS_ALERTSHUTDOWN:
    {                                   /* The user configurable program will be started at...*/
    fprintf(Logfile, "    User-Application started at:           %4d/%02d/%02d at %02d:%02d:%02d\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    break;
    }
case LF_UPS_SHUTDOWN:
    {                                   /* OS/2 DosShutdown will be called at...*/
    fprintf(Logfile, "    OS/2 ShutDown started at:              %4d/%02d/%02d at %02d:%02d:%02d\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    break;
    }
case LF_INIFILE_MISSING:
    {                                   /* SD/2 profile is missing or defective */
    fprintf(Logfile, "\n+-------------------------------------------------------------------+\n");
    fprintf(Logfile, "| ! SD/2 detected: Profile defective at:   %4d/%02d/%02d at %02d:%02d:%02d ! |\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    fprintf(Logfile, "| ! Creating default SHUTDOWN.INI - please adjust immediately!    ! |\n");
    fprintf(Logfile, "+-------------------------------------------------------------------+\n\n");
    break;
    }
case LF_INIFILE_PROBLEM:
    {                                   /* SD/2 profile can't be accessed */
    fprintf(Logfile, "\n+-------------------------------------------------------------------+\n");
    fprintf(Logfile, "| ! SD/2 detected: Profile defective at:   %4d/%02d/%02d at %02d:%02d:%02d ! |\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    fprintf(Logfile, "| ! Can't access SHUTDOWN.INI - Serious problem, please correct!  ! |\n");
    fprintf(Logfile, "+-------------------------------------------------------------------+\n\n");
    break;
    }
case LF_PARALLEL_INITIALIZED:
    {                                   /* UPS <-> SD/2 interface at parallel port */
    fprintf(Logfile, "\n*********************************************************************\n");
    fprintf(Logfile, "*** Parallel port initialized for UPS <-> SD/2 communication      ***\n");
    fprintf(Logfile, "*** Current System Date & Time is:         %4d/%02d/%02d at %02d:%02d:%02d ***\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    fprintf(Logfile, "*********************************************************************\n\n");
    break;
    }
case LF_SERIAL_INITIALIZED:
    {                                   /* UPS <-> SD/2 interface at serial port */
    fprintf(Logfile, "\n*********************************************************************\n");
    fprintf(Logfile, "*** Serial port initialized for UPS <-> SD/2 communication        ***\n");
    fprintf(Logfile, "*** Current System Date & Time is:         %4d/%02d/%02d at %02d:%02d:%02d ***\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    fprintf(Logfile, "*********************************************************************\n\n");
    break;
    }
case LF_UPS_PASSWORD_USED:
    {                                   /* The program was invoked with the undocumented
                                           commandline option [-|/]IBMSERVICE */
    fprintf(Logfile, "\n+-------------------------------------------------------------------+\n");
    fprintf(Logfile, "| ! SD/2 detected: Service applied at:     %4d/%02d/%02d at %02d:%02d:%02d ! |\n",
        pDT->year, pDT->month, pDT->day, pDT->hours, pDT->minutes, pDT->seconds);
    fprintf(Logfile, "| !                                                               ! |\n");
    fprintf(Logfile, "| ! The configuration service option is used. Please be sure that ! |\n");
    fprintf(Logfile, "| ! all changes of the configuration correspond to their equiva-  ! |\n");
    fprintf(Logfile, "| ! lent settings of the UPS control logic.                       ! |\n");
    fprintf(Logfile, "| ! Warning! SD/2 and the UPS control logic may not operate       ! |\n");
    fprintf(Logfile, "| ! correctly, if this service isn't performed by IBM!            ! |\n");
    fprintf(Logfile, "+-------------------------------------------------------------------+\n\n");
    break;
    }
}
fclose(Logfile);
return(TRUE);
}
Пример #24
0
MRESULT EXPENTRY MaskDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   static PMASKSEL pmask;
   static BOOL flag = FALSE;   // TRUE se Š stato aggiunto o tolto un elemento
   static int idx;             // posizione item selezionato o di inserzione

   switch (msg) {
      case WM_INITDLG: {
         CHAR buf[FACESIZE];
         PSZ pszCur;
         int len;
         pmask = (PMASKSEL)PVOIDFROMMP(mp2);      // recupera indirizzo dati
         // imposta il font della barra del titolo:
         PrfQueryProfileString(HINI_USERPROFILE, "PM_SystemFonts",
                               "WindowTitles", "9.WarpSans", buf, FACESIZE);
         WinSetPresParam(WinWindowFromID(hwnd, FID_TITLEBAR), PP_FONTNAMESIZE,
                         sstrlen(buf) + 1, (PVOID)(buf));
         WinSetWindowPos(hwnd, HWND_BOTTOM, pmask->pos.x, pmask->pos.y, 0, 0,
                         SWP_MOVE | SWP_SHOW);    // visualizza la finestra
         pszCur = pmask->pszExt;
         DlgEFSetTxtLimit(hwnd, COMBO_MASK, 63);
         // riempie la listbox
         while (len = sstrlen(pszCur)) {
            DlgLboxInsertItem(hwnd, COMBO_MASK, LIT_SORTASCENDING, pszCur);
            pszCur += len + 1;
         } /* endwhile */
         } // end case WM_INITDLG:
         break;
      case WM_CONTROL:
         switch (SHORT2FROMMP(mp1)) {
            case CBN_EFCHANGE: {          // cambiamento testo
               BOOL enable;
               // pulsante OK abilitato se c'e' testo nell' entrifield
               enable = WinQueryDlgItemTextLength(hwnd, COMBO_MASK);
               WinEnableControl(hwnd, MASK_OK, enable);
               // pulsante ADD abilitato se c'Š testo non gi… presente
               WinQueryDlgItemText(hwnd, COMBO_MASK, 64, pmask->achSel);
               idx = isInListBox(hwnd, pmask->achSel, COMBO_MASK); 
               WinEnableControl(hwnd, MASK_STORE, enable && (idx < 0));
               // pulsante REMOVE abilitato se testo EF == item lista
               WinEnableControl(hwnd, MASK_DEL, idx >= 0);
               } // end case CBN_EFCHANGE:
               break;
            case CBN_LBSELECT:            // selezione item
               idx = isInListBox(hwnd, pmask->achSel, COMBO_MASK);
               WinEnableControl(hwnd, MASK_DEL, idx >= 0);
               break;
            default:
              break;
         } /* endswitch */
         break;
      case WM_COMMAND:
         switch (LOUSHORT(mp1)) {
            case MASK_OK:
               WinQueryDlgItemText(hwnd, COMBO_MASK, 64, pmask->achSel);
               if (flag)    // eventualmente aggiorna lista filespec
                  ProcMaskDlgExit(hwnd, pmask);
               SaveMaskDlgPos(hwnd, pmask);
               WinDismissDlg(hwnd, TRUE);
               break;
            case MASK_STORE:
               flag = TRUE;
               DlgLboxInsertItem(hwnd, COMBO_MASK, LIT_SORTASCENDING,
                                 pmask->achSel);
               DlgLboxSelectItem(hwnd, COMBO_MASK, -idx - 1);
               WinEnableControl(hwnd, MASK_STORE, FALSE);
               break;
            case MASK_DEL:
               flag = TRUE;
               idx = DlgLboxQuerySelectedItem(hwnd, COMBO_MASK);
               DlgLboxDeleteItem(hwnd, COMBO_MASK, idx);
               WinSetDlgItemText(hwnd, COMBO_MASK, "");
               break;
            default: 
               if (flag)    // eventualmente aggiorna lista filespec
                  ProcMaskDlgExit(hwnd, pmask);
               SaveMaskDlgPos(hwnd, pmask);
               WinDismissDlg(hwnd, FALSE);
               break;
         } /* endswitch */
         break;
      case WM_CLOSE:
         if (flag)    // eventualmente aggiorna lista filespec
            ProcMaskDlgExit(hwnd, pmask);
         SaveMaskDlgPos(hwnd, pmask);
         WinDismissDlg(hwnd, FALSE);
         break;
      default: 
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
   } // end switch
   return (MRESULT) FALSE;
}
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);
}
/****************************************************************\
 *  Main client window procedure
 *--------------------------------------------------------------
 *
 *  Name:   MainWndProc(hwnd, msg, mp1, mp2)
 *
 *  Purpose: Processes the messages sent to the main client
 *              window.  This routine processes the basic
 *              messages all client windows should process
 *              and passes all others onto WinDefWindowProc.
 *
 *  Usage:  Called for each message placed in the main
 *          window's message queue
 *
 *  Method: a switch statement branches to the routines to be
 *          performed for each message processed.
 *
 *  Returns:  Return values are determined by each message
 *
\****************************************************************/
MRESULT EXPENTRY MainWndProc(HWND   hwnd,    /* handle of window */
                             ULONG  msg,     /* id of message */
                             MPARAM mp1,     /* first message parameter */
                             MPARAM mp2)     /* second message parameter */
{
   QDATA   *pqdataQ;

   switch(msg)
   {
      case WM_CREATE:
         return InitMainWindow(hwnd, mp1, mp2);
         break;

      case WM_PAINT:
         MainPaint(hwnd, SvrQMsgs, iIndex, sTotalMsgs);
         break;

      case WM_SIZE:
         MainSize(hwnd, sTotalMsgs, mp1, mp2);
         break;

      case WM_HSCROLL:
         MainHorizScroll(hwnd, mp2);
         break;

      case WM_VSCROLL:
         MainVertScroll(hwnd, mp2);
         break;

      case WM_CHAR:
         switch (SHORT2FROMMP(mp2))
         {
            case VK_LEFT:
            case VK_RIGHT:
               return MainCharHScroll (hwnd, msg, mp1, mp2) ;
            case VK_UP:
            case VK_DOWN:
            case VK_PAGEUP:
            case VK_PAGEDOWN:
               return MainCharVScroll (hwnd, msg, mp1, mp2) ;
         }
         break ;

      case WM_COMMAND:
         MainCommand(mp1, mp2);
         break;

      case HM_QUERY_KEYS_HELP:
         return (MRESULT)PANEL_HELPKEYS;   /* return id of key help panel */
         break ;

      case WM_NEWQMSG:
         /* copy message into circular array, with index being next free spot in array */
         pqdataQ = (QDATA *)PVOIDFROMMP(mp1);
         sprintf(SvrQMsgs[iIndex],
                 "Process ID: %03lu, Priority: %02hu,  Message: %s",
                 pqdataQ->pidProcess,
                 pqdataQ->usPriority,
                 pqdataQ->pszMsg);

         /* increment index, or reset to 0 as appropriate */
         iIndex = (iIndex < MAX_MESSAGES - 1) ? iIndex + 1 : 0;

         /* increment total message count until buffer is filled */
         sTotalMsgs = min(MAX_MESSAGES, sTotalMsgs + 1);

         MainUpdateMsg(hwnd, SvrQMsgs, iIndex, sTotalMsgs);
         break;

      case WM_MSG:
         MessageBox(hwndMain, (ULONG)SHORT1FROMMP(mp1), MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL, TRUE);
         break;

      case WM_CLOSE:
         DosWriteQueue(hqQ, WM_CLOSE, 0UL, NULL, 15UL);

         /* process the WM_CLOSE */

   /*--------------------------------------------------*\
    *      Any messages not processed are passed on
    *      to WinDefWindowProc.
   \*--------------------------------------------------*/

      default:
         return WinDefWindowProc(hwnd, msg, mp1, mp2);
         break;
   }

   return MRFROMLONG(0L);     /* all window procedures should return 0 as a default */

}   /* MainWndProc() */
Пример #27
0
MRESULT EXPENTRY scbProcedure(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   switch(msg)
   {
   case WM_CREATE:
      create(hwnd,PVOIDFROMMP(mp2));
      return WinDefWindowProc(hwnd, msg, mp1, mp2);

   case 0x041E:
      selectBitmap(hwnd, BITMAP_MOUSEOVER);
      return WinDefWindowProc(hwnd, msg, mp1, mp2);

   case 0x041F:
      selectBitmap(hwnd, BITMAP_NORMAL);
      return WinDefWindowProc(hwnd, msg, mp1, mp2);

   case WM_BUTTON1DOWN:
      selectBitmap(hwnd, BITMAP_PRESS);
      break;

   case WM_BUTTON1UP:
      selectBitmap(hwnd, BITMAP_MOUSEOVER);
      break;

   case WM_DESTROY:
      destroy(hwnd); /* Limpa bitmaps */
      return WinDefWindowProc(hwnd, msg, mp1, mp2);

   case WM_PAINT:
      paint(hwnd);
      break;

   case WM_WINDOWPOSCHANGED:
      ajustBackground(hwnd,PVOIDFROMMP(mp1));
      return WinDefWindowProc(hwnd, msg, mp1, mp2);

   case WMSKN_AJUSTSIZEPOS:
      sizePos(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1),SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
      break;

   case WMSKN_QUERYPOS:
      return getpos(hwnd);

   case WMSKN_QUERYSIZE:
      return getsize(hwnd);

   case WMSKN_AJUSTPOS:
      reposic(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1));
      break;

   case WMSKN_SETIMAGE:                 /* MP1=XBITMAP, MP2=ID */
      loadImage(hwnd,SHORT1FROMMP(mp2),PVOIDFROMMP(mp1));
      break;

   case WMSKN_SETLIMITS:
      setLimits(hwnd,LONGFROMMP(mp1),LONGFROMMP(mp2));
      break;

   case WMSKN_SETVALUE:
      setValue(hwnd,LONGFROMMP(mp1));
      break;

   case WMSKN_UP:
      moveCursor(hwnd, -1);
      break;

   case WMSKN_DOWN:
      moveCursor(hwnd, 1);
      break;

   case WMSKN_CONNECT:
      doConnect(hwnd,LONGFROMMP(mp1),LONGFROMMP(mp2));
      break;

   case WM_BEGINDRAG:
      DBGMessage("Iniciou drag&drop");
      ((SLIDERDATA *) WinQueryWindowPtr(hwnd,0))->drag = TRUE;
      WinSetCapture(HWND_DESKTOP,hwnd);
      break;

   case WM_ENDDRAG:
      DBGMessage("Terminou drag&drop");
      ((SLIDERDATA *) WinQueryWindowPtr(hwnd,0))->drag = FALSE;
      WinSetCapture(HWND_DESKTOP,NULLHANDLE);
      break;

   case WM_MOUSEMOVE:
      if(((SLIDERDATA *) WinQueryWindowPtr(hwnd,0))->drag)
         mouseMove(hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
      break;

   default:
      return WinDefWindowProc(hwnd, msg, mp1, mp2);

   }
   return 0;
}
/*����������������������������������������������������������������������������*/
 MRESULT FilterDlgProc(          HWND    hwnd,
                        register ULONG   message,
                                 MPARAM  lParam1,
                                 MPARAM  lParam2 )

  {
     /*���������������������������������������������������������������������Ŀ*/
     /*� Local Variables                                                     �*/
     /*�����������������������������������������������������������������������*/
     MRESULT            dpResult = NULL;

     register USHORT    pbSelected;
     CHAR               sFilterItem[128];
     PMSG_ITEM          pMsg;

     static PSPY_DATA   pSpyData = NULL;

     HWND               hwndLB;                /* HWND of message listbox */

    /*����������������������������������������������������������������������Ŀ*/
    /*� Process the message                                                  �*/
    /*������������������������������������������������������������������������*/
    switch (message)                          /* Switch off of the message ID */
    {
        /*������������������������������������������������������������������Ŀ*/
        /*� One of our pushbuttons was pressed...                            �*/
        /*��������������������������������������������������������������������*/
        case WM_COMMAND:

          switch( pbSelected = LOUSHORT( lParam1 ) )
          {
              /*������������������������������������������������������������Ŀ*/
              /*� Process selected items                                     �*/
              /*��������������������������������������������������������������*/
              default:
              {
                USHORT        curItem,            /* current list item        */
                              nSelected;          /* Number of items selected */

                MSG_COLOR     color = GetColor( hwnd, pSpyData);

                /*����������������������������������������������������������Ŀ*/
                /*� Obtain HWND of message listbox once for performance      �*/
                /*������������������������������������������������������������*/
                hwndLB = WinWindowFromID(hwnd, IDD_FILTER);

                /************************************************************
                * "Lock" the ListBox to minimize performance impact
                ************************************************************/
                WinLockWindowUpdate(HWND_DESKTOP,     /* Desktop */
                                    hwndLB);          /* Lockee  */

                /************************************************************
                * Process the "selected" ListBox items
                ************************************************************/
                for(nSelected = 0,                    /* Initialize */
                    curItem   = SHORT1FROMMR(WinSendMsg(hwndLB,
                                                        LM_QUERYSELECTION,
                                                        MPFROMSHORT(LIT_FIRST),
                                                        NULL) );

                    curItem != (USHORT)LIT_NONE;      /* While      */

                    nSelected++,                     /* Iterate     */
                    curItem   = SHORT1FROMMR(WinSendMsg(hwndLB,
                                                        LM_QUERYSELECTION,
                                                        MPFROMSHORT(curItem),
                                                        NULL) )
                   )
                {
                  /*��������������������������������������������������������Ŀ*/
                  /*� Locate specific MSG item for this selected item        �*/
                  /*����������������������������������������������������������*/
                  pMsg = PVOIDFROMMR( WinSendMsg(hwndLB,
                                                 LM_QUERYITEMHANDLE,
                                                 MPFROMSHORT(curItem),
                                                 NULL) );

                  /*��������������������������������������������������������Ŀ*/
                  /*� Perform action on this selected item                   �*/
                  /*����������������������������������������������������������*/
                  switch( pbSelected )
                  {
                    /*********************************************************
                    * Delete this MSG's definition
                    **********************************************************/
                    case ID_PB_F_DELETE:

                         DeleteMsg(pSpyData, pMsg->Msg);

                         WinSendMsg(hwndLB,
                                    LM_DELETEITEM,
                                    MPFROMSHORT(curItem),
                                    MPFROMP(NULL));

                         curItem = (USHORT)( (curItem == 0)
                                             ? LIT_FIRST
                                             : (curItem - 1) );
                    break;

                    /*********************************************************
                    * Mark that this MSG can NOT be "spied" / act as "trigger"
                    **********************************************************/
                    case ID_PB_F_EXCLUDE:

                         IncludeMsg(pSpyData, pMsg->Msg, BOOL_FALSE, color);

                         WinSendMsg(hwndLB,
                                    LM_SETITEMTEXT,
                                    MPFROMSHORT(curItem),
                                    MPFROMP(FormatMSG(pMsg, sFilterItem)));
                    break;

                    /*********************************************************
                    * Mark that this MSG can be "spied" / act as "trigger"
                    **********************************************************/
                    case ID_PB_F_INCLUDE:

                         IncludeMsg(pSpyData, pMsg->Msg, BOOL_TRUE, color);

                         WinSendMsg(hwndLB,
                                    LM_SETITEMTEXT,
                                    MPFROMSHORT(curItem),
                                    MPFROMP(FormatMSG(pMsg, sFilterItem)));
                    break;

                    /*********************************************************
                    * Set FREEZE "trigger"
                    **********************************************************/
                    case ID_PB_F_FREEZE:

                         pMsg->TriggerFreeze  = BOOL_TRUE;
                         pMsg->TriggerThaw    = BOOL_FALSE;

                         WinSendMsg(hwndLB,
                                           LM_SETITEMTEXT,
                                           MPFROMSHORT(curItem),
                                           MPFROMP(FormatMSG(pMsg, sFilterItem)));

                         if (color != Color_Asis)
                           pMsg->ClrFG = color;
                    break;

                    /*********************************************************
                    * Set THAW "trigger"
                    **********************************************************/
                    case ID_PB_F_THAW:

                         pMsg->TriggerThaw    = BOOL_TRUE;
                         pMsg->TriggerFreeze  = BOOL_FALSE;

                         WinSendMsg(hwndLB,
                                    LM_SETITEMTEXT,
                                    MPFROMSHORT(curItem),
                                    MPFROMP(FormatMSG(pMsg, sFilterItem)));

                         if (color != Color_Asis)
                           pMsg->ClrFG = color;
                    break;

                    /*********************************************************
                    * Remove FREEZE and THAW "triggers"
                    **********************************************************/
                    case ID_PB_F_NO_TRIGGER:

                         pMsg->TriggerFreeze  =
                         pMsg->TriggerThaw    = BOOL_FALSE;

                         WinSendMsg(hwndLB,
                                    LM_SETITEMTEXT,
                                    MPFROMSHORT(curItem),
                                    MPFROMP(FormatMSG(pMsg, sFilterItem)));

                         if (color != Color_Asis)
                           pMsg->ClrFG = color;
                    break;

                    /*********************************************************
                    * Reset MSG unique data
                    **********************************************************/
                    case ID_PB_F_RESET:

                         pMsg->aulTimes[MSG_TIMES_SINCE] = 0;

                         if (color != Color_Asis)
                           pMsg->ClrFG = color;
                    break;
                  }
                }

                /************************************************************
                * Finally, "unlock" the ListBox so it is only redrawn once
                ************************************************************/
                WinLockWindowUpdate(HWND_DESKTOP, NULLHANDLE);

                /************************************************************
                * Make "noise" if no items were selected...
                ************************************************************/
                if (nSelected == 0)
                  WinAlarm(HWND_DESKTOP, WA_ERROR);
              }
              break;

              /*������������������������������������������������������������Ŀ*/
              /*� User cancelled dialog                                      �*/
              /*��������������������������������������������������������������*/
              case DID_CANCEL:

                   WinDismissDlg(hwnd, 0);              /* Close dialog */
              break;
          }
        break;                                          /* Break WM_COMMAND             */

        /*������������������������������������������������������������������Ŀ*/
        /*� WM_CLOSE:                                                        �*/
        /*� - Call WinDismissDlg to close the dialog box                     �*/
        /*��������������������������������������������������������������������*/

        case WM_CLOSE:                                  /* Close Dialog Box.    */

             WinDismissDlg( hwnd, 0);

        break;

        /*������������������������������������������������������������������Ŀ*/
        /*� WM_INITDLG:                                                      �*/
        /*� - Init pointer to data pointed to by WinDlgBox                   �*/
        /*� - Init global handle of this dlg                                 �*/
        /*�                                                                  �*/
        /*� - MP2 = PSPY_DATA                                                �*/
        /*��������������������������������������������������������������������*/
        case WM_INITDLG:
        {
               register USHORT  list_index;

               /*�����������������������������������������������������������Ŀ*/
               /*� Locate "SPY" data to utilize                              �*/
               /*�������������������������������������������������������������*/
               pSpyData = PVOIDFROMMP(lParam2);

               /*�����������������������������������������������������������Ŀ*/
               /*� Obtain HWND of message listbox once for performance       �*/
               /*�������������������������������������������������������������*/
               hwndLB = WinWindowFromID(hwnd, IDD_FILTER);

              /*������������������������������������������������������������Ŀ*/
              /*� Set listbox FONT to current non-proportional value         �*/
              /*��������������������������������������������������������������*/
              SetListboxFont(hwndLB, (PSZ) pSpyData->pfnLB);

              /************************************************************
              * "Lock" the ListBox to minimize performance impact
              ************************************************************/
              WinLockWindowUpdate(HWND_DESKTOP,     /* Desktop */
                                  hwndLB);          /* Lockee  */

              /*�����������������������������������������������������������Ŀ*/
              /*� Add all Messages to list box                              �*/
              /*�������������������������������������������������������������*/
              for( /* Initialize */  pMsg = ProcessFirstMsg(pSpyData); /* start @ first MSG */
                   /* Terminate  */  pMsg != NULL;                     /* stop at End-Of-Table */
                   /* Iterate    */  pMsg = ProcessNextMsg(pSpyData)   /* try the next MSG */
                 )
              {
                list_index = (USHORT)
                    WinSendMsg(hwndLB,
                               LM_INSERTITEM,
                               MPFROMSHORT(LIT_SORTASCENDING),
                               MPFROMP(FormatMSG(pMsg, sFilterItem)) );

                WinSendMsg(hwndLB,                    /* Window Handle              */
                           LM_SETITEMHANDLE,          /* Message                    */
                           MPFROMSHORT(list_index),   /* Index of list item         */
                           MPFROMP(pMsg));            /* Handle of list item        */
              }

              /************************************************************
              * Finally, "unlock" the ListBox so it is only redrawn once
              ************************************************************/
              WinLockWindowUpdate(HWND_DESKTOP, NULLHANDLE);

              /************************************************************
              * Other dialog set-up
              ************************************************************/
              SetColors( hwnd, pSpyData );      /* load colors       */

              CenterDialog(hwnd);               /* Center the Dialog */
        }
        break;

        /*������������������������������������������������������������������Ŀ*/
        /*� We don't need to handle any other messages...                    �*/
        /*�                                                                  �*/
        /*� If this isn't an IPF message, let PM do it's default "thing"     �*/
        /*��������������������������������������������������������������������*/
        default:
             if ( !HandleIPF(hwnd, message, lParam1, lParam2, &dpResult) )
               dpResult = WinDefDlgProc(hwnd,       /* Dialog Handle                */
                                        message,    /* Message                      */
                                        lParam1,    /* First parameter for message. */
                                        lParam2);   /* Second parameter for message.*/

      } /* End MSG switch */

   /*�����������������������������������������������������������������������Ŀ*/
   /*� Exit                                                                  �*/
   /*�������������������������������������������������������������������������*/
   return( dpResult );
}
BOOL NextBar::OCommand(ULONG msg, MPARAM mp1, MPARAM mp2)
{
 switch(msg)
  {
    case WM_CREATE:
      if (setup.floating)
        floatTimer.setNotify(hwnd).start();
      break;

    case WM_TOOLBAR_RESET:
      resetToolBar();
      break;

    case WM_CFG_CANCELED: {
      pNextBarEvent actual = (pNextBarEvent) PVOIDFROMMP(mp1);
      if (actual)
         events.del(actual);
      break; }
 
    case WM_SAVE_BUTTONS:
      saveProfile();
      resetToolBar();
      break;

    case WM_CONTROL:
      switch(SHORT1FROMMP(mp1))
       {
        case OBUTTONBAR_MOVEOVER:
          selectedButton = SHORT2FROMMP(mp1);
          break;

        case OBUTTONBAR_BUTTON2DOWN:
          selectedButton = SHORT2FROMMP(mp1);
          WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(NHX_DEL_BUTTON, FALSE),
                     MPFROM2SHORT(MIA_DISABLED, (selectedButton == NHX_MAIN) ? MIA_DISABLED : ~MIA_DISABLED));
          WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(NHX_CFG_BUTTON, FALSE),
                     MPFROM2SHORT(MIA_DISABLED, (selectedButton == NHX_MAIN) ? MIA_DISABLED : ~MIA_DISABLED));
          WinPopupMenu(frame, frame, menu, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), NHX_CFG_BUTTON,
                     PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1 |
                     PU_POSITIONONITEM | PU_HCONSTRAIN | PU_VCONSTRAIN);
          break;
       }
      break;

    case WM_TIMER:
      if (setup.floating)
        WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
      break;

    case WM_COMMAND: {
       ULONG command = SHORT1FROMMP(mp1);
       pNextBarEvent actual = events.getItem(selectedButton - NHX_FIRST_BUTTON);

       switch(command)
        {
         case NHX_MAIN:
            closeFolders(TRUE);
            break;
 
         case NHX_INFOMNU: {
            pNextBarInfoDlg  dlg = new NextBarInfoDlg;
            dlg->createDlg();
            break; }

         case NHX_FLOAT:
            if (setup.floating) {
               setup.floating = FALSE;
               floatTimer.stop(); }
            else {
               setup.floating = TRUE;
               floatTimer.setNotify(hwnd).start(); }
            WinCheckMenuItem(menu, NHX_FLOAT, setup.floating);
            break;

         case NHX_QUIT:
            WinPostMsg(hwnd, WM_CLOSE, NULL, NULL);
            break;

         case NHX_MOVE:
            trackButtons();
            break;

         case NHX_SENKRECHT:
            setNewStyle(OButtonBar::up2down);
            break;

         case NHX_WAAGERECHT:
            setNewStyle(OButtonBar::left2right);
            break;

         case NHX_NORMICONS:
            setup.large = FALSE;
            setNewStyle(setup.style);
            break;

         case NHX_LARGEICONS:
            setup.large = TRUE;
            setNewStyle(setup.style);
            break;

         case NHX_ADD_BUTTON: {
            pNextBarEvent aNew = new NextBarEvent;
            pNextBarDlg   dlg = new NextBarDlg(aNew, NULL, TRUE);

            events.addAfter(actual, aNew);
            dlg->createDlg();
            break; }

         case NHX_DEL_BUTTON:
            events.del(actual);
            resetToolBar();
            break;

         case NHX_CFG_BUTTON: {
            pOGraphicsButton button = nxButtons->buttons.getItem(selectedButton - NHX_FIRST_BUTTON + 1);
            pNextBarDlg dlg = new NextBarDlg(actual, button, FALSE);
            dlg->createDlg();
            break; }

         case NHX_HELP:
            helpRequest(PANEL_MAIN);
            break;

         default:
            if (actual)  
              actual->startEvent();
            break;
         }
       break; }

    case WM_SIZE:
      if (nxButtons)
        WinSetWindowPos(nxButtons->frame, HWND_TOP, 0, 0,
            (setup.style == OButtonBar::left2right) ?  SHORT1FROMMP(mp2) : buttonSize,
            (setup.style == OButtonBar::left2right) ?  buttonSize : SHORT2FROMMP(mp2),
             SWP_MOVE | SWP_SIZE);
      break;

    case WM_CLOSE:
      WinQueryWindowPos(frame, &setup.position);
      strcpy(setup.bubbleFont, nxButtons->bubbleHelpWin.pparms.Font); 
      ini->write("NextHand", "NextInfo 1.5", &setup, sizeof(NextInfo));
      ini->close();
      hideFrame();
      OApp::currentOApp->forceQuit();
      break;

    default:
       return(FALSE);
   }
 return(TRUE);
}
Пример #30
0
 MRESULT EXPENTRY icqFrameWindow(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
    switch(msg)
    {
    case WM_DDE_INITIATEACK:
       return (MRESULT) icqDDEInitiateAck(hwnd, (HWND)mp1, (PDDEINIT)mp2);

    case WM_DDE_DATA:
       DBGMessage("WM_DDE_DATA");
       icqDDEData(hwnd, (PDDESTRUCT) mp2);
       break;

    case WM_CLOSE:
       DBGMessage("WM_CLOSE");
       close(hwnd);
       break;

    case WM_CREATE:
       icqskin_cfgWindow(hwnd,ICQFRAME,0);
       break;

    case WM_DESTROY:
       destroy(hwnd);
       break;

    case WM_ERASEBACKGROUND:
       erase(hwnd,(HPS) mp1, (PRECTL) mp2);
       break;

    case WM_SIZE:
       resize(hwnd,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       broadcast(hwnd,WMICQ_AUTOSIZE,0,0);
       break;

    case WM_PAINT:
       paint(hwnd);
       break;

    case WM_SETICON:
       WinSendMsg(WinQueryWindow(hwnd,QW_PARENT),msg,mp1,mp2);
       break;

    case WM_COMMAND:
       action(hwnd,SHORT1FROMMP(mp1), SHORT1FROMMP(mp2));
       break;

    case WM_PRESPARAMCHANGED:
       ppchanged(hwnd,LONGFROMMP(mp1));
       break;

    case WM_SETWINDOWPARAMS:
       return setparm(hwnd, PVOIDFROMMP(mp1), mp2);

    case WMICQ_SETNAME:
//       strncpy( ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name, (const char *) mp1, 19);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->name = (const char *) mp1;
       break;

    case WMICQ_SETICQHANDLE:
       DBGTracex(mp1);
       ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq = (HICQ) mp1;
       break;

    case WMICQ_GETICQHANDLE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq;

    case WMICQ_SETBUTTONTBL:
       setbuttons(hwnd,(const struct icqButtonTable *) mp1, (int) mp2);
       break;

    case WMICQ_QUERYPALLETE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal;

    case WMICQ_EVENT:  // MP1 = type,code,user  MP2 = parm
       event(hwnd,CHAR3FROMMP(mp1),CHAR4FROMMP(mp1),SHORT1FROMMP(mp1),(ULONG) mp2);
       break;

    case WMICQ_SELECTPAL:
       icqskin_loadPallete( (HPS) mp1, 0, ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->pal);
       break;

    case 0x041E:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case 0x041F:
       return WinDefWindowProc(hwnd, msg, mp1, mp2);

    case WM_BEGINDRAG:
       return beginDrag(hwnd, (POINTS *) &mp1);

    case WM_ENDDRAG:
       return endDrag(hwnd);

    case WM_TIMER:
       timer(hwnd);
       break;

#ifdef SKINNED_GUI
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) ((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->bg;
#else
    case WMICQ_QUERYBGIMAGE:
       return (MRESULT) NO_IMAGE;
#endif

    case WM_OWNERPOSCHANGE:
       DBGMessage("WM_OWNERPOSCHANGE");
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WM_MOUSEMOVE:
       if(WinQueryCapture(HWND_DESKTOP) == hwnd);
          saveMouse(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1));
       return WinDefWindowProc(hwnd,msg,mp1,mp2);

    case WMICQ_CLEAR:
       clearSkin( (ICQFRAME *) WinQueryWindowPtr(hwnd,0));
       break;

    case WMICQ_LOADSKIN:
       loadSkin(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_SKINCHILDS:
       loadSkin4Childs(hwnd,(const char *) mp1, (SKINFILESECTION *) mp2);
       break;

    case WMICQ_RESTORE:
       restoreWindow(hwnd,(const char *) mp1,SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
       break;

    case WMICQ_STORE:
       storeWindow(hwnd,(const char *) mp1);
       break;

    case WMICQ_CONFIGURE:
       configure(hwnd,(int) mp1);
       break;

    case WMICQ_SETMSGCHILD:
       createchild(hwnd, (const MSGCHILD *) mp1, SHORT1FROMMP(mp2));
       break;

    case WMICQ_SKINELEMENT:
       skinElement(hwnd,(HWND) mp1, (const char **) mp2);
       break;

    case WMICQ_DRAWCONTENTS:
       break;

    case WMICQ_AUTOSIZE:
       autoSize(hwnd);
       break;

    case WMICQ_SIZEBUTTONS:
       return (MRESULT) sizeButtonBar(hwnd,SHORT1FROMMP(mp1),SHORT2FROMMP(mp1),(const USHORT *) mp2);

    case WMICQ_INVALIDATE:
       DBGMessage("WMICQ_INVALIDATE");
       WinInvalidateRect(hwnd,NULL,TRUE);
       break;

    /*---[ SysTray ]--------------------------------------------*/

    case WM_BUTTON2CLICK | 0x2000:
       icqShowPopupMenu(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq, 0, ICQMNU_MODES, 0, 0);
       return (MRESULT) TRUE;

    case WM_BUTTON1CLICK | 0x2000:
       openMessage(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    case WM_TRAYEXIT:	// When tray exits/crashes, it posts WM_TRAYEXIT (0xCD20) to all tray windows.
       icqDisableSysTray(((ICQFRAME *) WinQueryWindowPtr(hwnd,0))->icq);
       return (MRESULT) TRUE;

    /*---[ Default window processing ]--------------------------*/

    default:
       return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
    return 0;
 }