コード例 #1
0
/**************************************************************************\
*                                                                          *
*       ROUTINE:    EntryFieldSubProc                                      *
*                                                                          *
*       COMMENT:    "Alarm..." dialog                                      *
* This procedure filter messages for the entry field and make it a time    *
* entry field. It doesn't allow for illigal characters according to the    *
* current selection. It doesn't allow modification of the time separator.  *
* It works only for hours and minutes. The entry field has to be limited   *
* to 5 characters.                                                         *
*                                                                          *
*                                                                          *
*       RETURNS:    MRESULT, 0 or return value from WinDefDlgProc          *
*                                                                          *
\**************************************************************************/
MRESULT EXPENTRY EntryFieldSubProc(HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2)
{
   USHORT usSelect, fsKeyFlags, usLast;
   UCHAR usChr1;
   UCHAR uchHourMinutes[6];
   BOOL bValid;

   if ((usMsg > WM_MOUSEFIRST) && (usMsg < WM_MOUSELAST))
   {
      MRESULT mresult = pfnwpEntryField(hwnd, usMsg, mp1, mp2);
      MRESULT mresultSel = pfnwpEntryField(hwnd, EM_QUERYSEL, (PLONG)NULL, (PLONG)NULL);

      usSelect = LOUSHORT(mresultSel);
      usLast   = HIUSHORT(mresultSel);
      if ((usSelect == 2))
         pfnwpEntryField(hwnd, EM_SETSEL, MPFROM2SHORT(3, 3), NULL);
      if ((usSelect == 5))
         pfnwpEntryField(hwnd, EM_SETSEL, MPFROM2SHORT(4, 4), NULL);
      return mresult;
   }

   switch (usMsg)
   {
   case WM_SETFOCUS:
      pfnwpEntryField(hwnd, usMsg, mp1, mp2);
      if (SHORT1FROMMP(mp2))
          pfnwpEntryField(hwnd,
                          EM_SETINSERTMODE,
                          MPFROMSHORT(FALSE),
                          (MPARAM)NULL);
      return MPVOID;

   case WM_CHAR:
      fsKeyFlags = SHORT1FROMMP(mp1);    /* key flags             */
      if (!(fsKeyFlags & KC_KEYUP))
      {
         usSelect = (USHORT)WinSendMsg(hwnd, EM_QUERYSEL, MPVOID, MPVOID);
         if (fsKeyFlags & KC_VIRTUALKEY)
         {
            switch(SHORT2FROMMP(mp2))
            {
            case VK_UP:
            case VK_DOWN:
               break;

            case VK_LEFT:
               if (usSelect == 3)
                   pfnwpEntryField(hwnd, usMsg, mp1, mp2);
               return pfnwpEntryField(hwnd, usMsg, mp1, mp2);
               break;

            case VK_RIGHT:
               if (usSelect == 4)
               {
                  return MPVOID;
               }
               if (usSelect == 1)
                  pfnwpEntryField(hwnd, usMsg, mp1, mp2);
               return pfnwpEntryField(hwnd, usMsg, mp1, mp2);
               break;

            case VK_DELETE:
            case VK_BACKSPACE:
            case VK_INSERT:
               return MPVOID;

            case VK_SPACE:
               switch (usSelect)
               {
               case 0:   /*  Hours most significant digit   */
                  if (bTwelveHourFormat)
                  {
                     return pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                  }

               default:
                  return MPVOID;
               }

            default:
               return pfnwpEntryField(hwnd, usMsg, mp1, mp2);
               break;
            }
         }
         else
         {
            if (fsKeyFlags & KC_CHAR)
            {
               bValid = FALSE;
               WinQueryWindowText(hwnd, sizeof(uchHourMinutes), uchHourMinutes);
               usChr1 = (UCHAR)CHAR1FROMMP(mp2);
               switch (usSelect)
               {
               case 0:   /* Hours most significant digit */
                  if (bTwelveHourFormat)
                  {
                     if ((usChr1 > '1') || (usChr1 < '0'))
                     {
                         return MPVOID;
                     }
                     else
                     {
                         pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                         bValid = TRUE;
                     }
                  }
                  else
                  {
                     if ((usChr1 > '2') || (usChr1 < '0'))
                     {
                         return MPVOID;
                     }
                     else
                     {
                         pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                         bValid = TRUE;
                     }
                  }
                  if (bValid)
                  {
                     uchHourMinutes[0] = usChr1;
                     uchHourMinutes[1] = '0';
                     WinSetWindowText(hwnd, uchHourMinutes);
                     pfnwpEntryField(hwnd, EM_SETSEL, MPFROM2SHORT(1,1),(PLONG)NULL);
                  }
                  return MPVOID;
                  break;

               case 1:
                  if (bTwelveHourFormat)
                  {
                     if ((uchHourMinutes[0] == '0') || (uchHourMinutes[0] == ' '))
                     {
                        if ((usChr1 > '9') || (usChr1 < '0'))
                        {
                           return MPVOID;
                        }
                        else
                        {
                           pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                           bValid = TRUE;
                        }
                   }
                   else
                   {    /* probably 1  */
                      if ((usChr1 > '2') || (usChr1 < '0'))
                      {
                         return MPVOID;
                      }
                      else
                      {
                         pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                         bValid = TRUE;
                      }
                   }
               }
                else
                {
                   if (uchHourMinutes[0] < '2')
                   {
                      if ((usChr1 > '9') || (usChr1 < '0'))
                      {
                         return MPVOID;
                      }
                      else
                      {
                         pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                         bValid = TRUE;
                      }
                   }
                   else
                   {
                      if ((usChr1 > '4') || (usChr1 < '0'))
                      {
                         return MPVOID;
                      }
                      else
                      {
                         pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                         bValid = TRUE;
                      }
                   }
                }
                /*  Fill the entry field as if a time separator is in also */
                if (bValid)
                {
                   mp2 = (MPARAM)(((ULONG)mp2 & 0xffffff00) | szTimeSep[0]);
                   return pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                }
                break;

            case 3:   /* minutes left digit, 0-5 */
               if ((usChr1 > '5') || (usChr1 < '0'))
               {
                  return MPVOID;
               }
               else
                  return pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                  break;

            case 4:   /*minutes right digit, 0-9*/
               if ((usChr1 > '9') || (usChr1 < '0'))
               {
                  return MPVOID;
               }
               else
               {
                  pfnwpEntryField(hwnd, usMsg, mp1, mp2);
                  return pfnwpEntryField(hwnd, EM_SETSEL, MPFROM2SHORT(4,4), MPVOID);
               }
               break;
            }
         }
      }
   }

   default:
      return pfnwpEntryField(hwnd, usMsg, mp1, mp2);
   }
}
コード例 #2
0
/**************************************************************************\
*                                                                          *
*       ROUTINE:    ClkTicksDlgProc ( )                                    *
*                                                                          *
*       COMMENT:    "Ticks..." dialog                                      *
*                                                                          *
*       RETURNS:    MRESULT, 0 or return value from WinDefDlgProc          *
*                                                                          *
\**************************************************************************/
MRESULT EXPENTRY ClkTicksDlgProc(HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2)
{
   static USHORT usMajorTickSel;
   static USHORT usMinorTickSel;

   switch (usMsg)
   {
   case WM_INITDLG:

      /* show the current major tick preference */
      WinSendMsg(WinWindowFromID(hwnd,
                                 (CLKTM_MAJOR | cp.usMajorTickPref)),
                                 BM_SETCHECK,
                                 MPFROM2SHORT(TRUE, NULL),
                                 MPVOID);

      /* show the current minor tick preference */
      WinSendMsg(WinWindowFromID(hwnd,
                                 (CLKTM_MINOR | cp.usMinorTickPref)),
                                 BM_SETCHECK,
                                 MPFROM2SHORT(TRUE, 0),
                                 MPVOID);

      /* load the selection values from the preferences */
      usMajorTickSel = cp.usMajorTickPref;
      usMinorTickSel = cp.usMinorTickPref;

      /* let the default dialog procedure handle anything else */
      break;

   case WM_COMMAND:
       switch (LOUSHORT(mp1))
       {
       case DID_OK:
           /* store away selections as preferences */
          cp.usMajorTickPref = usMajorTickSel;
          cp.usMinorTickPref = usMinorTickSel;

          /* repaint with the new preferences */
          WinInvalidateRect(hwndFrame, NULL, TRUE);

       case DID_CANCEL:
          WinDismissDlg(hwnd, TRUE);
       }

       return NULL;

   case WM_CONTROL:
      if (SHORT2FROMMP(mp1) == BN_CLICKED)
      {
         USHORT usButtonID = SHORT1FROMMP(mp1);

         switch (usButtonID & 0xff00)
         {
         case CLKTM_MAJOR:
            usMajorTickSel = LOBYTE(usButtonID);
            break;

         case CLKTM_MINOR:
            usMinorTickSel = LOBYTE(usButtonID);
            break;
         }
      }
      /* fall through to the default control processing */
   }

   return WinDefDlgProc(hwnd, usMsg, mp1, mp2);
}
コード例 #3
0
/*--------------------------------------------------
  This function backs the File/New... dialog box.

  The current fractal type is set during initialization.
  The user may select from the list box.
  The result is returned on OK or double-click in the list box.

  Help sends an appropriate message using the
  SMPLHELP system.
 --------------------------------------------------*/
MRESULT EXPENTRY SelFractalDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {
     SHORT i, isSelected;

     switch (msg)
          {
          case WM_INITDLG:

               CenterDialogBox(hwnd);

               InitNewParms(&npTempParms);
               /* Load the list box from the list of names */
               WinSendDlgItemMsg (hwnd, IDD_SET_FRACTTYPE_LB,
                          LM_DELETEALL, MPFROMP(NULL), MPFROMP(NULL) );

               isSelected = MANDEL;  /* default? */

               for (i = 0; i < CountFractalList; i++)
                   {
                   WinSendDlgItemMsg (hwnd, IDD_SET_FRACTTYPE_LB,
                          LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
                          MPFROMP(fractalspecific[asFracTypeList[i]].name) );
                   if (asFracTypeList[i] == npTempParms.iFractType ||
                       fractalspecific[asFracTypeList[i]].tofloat == npTempParms.iFractType)
                        isSelected = i;
                   }

               /* Flag the current Fractal Type in the list box */
               WinSendDlgItemMsg (hwnd, IDD_SET_FRACTTYPE_LB,
                          LM_SELECTITEM, MPFROMSHORT (isSelected),
                                 MPFROMSHORT(TRUE) ) ;
               /* and put it near the middle */
               WinSendDlgItemMsg (hwnd, IDD_SET_FRACTTYPE_LB,
                          LM_SETTOPINDEX,
                          MPFROMSHORT(max(isSelected-4, 0) ),
                          MPFROMP(NULL) ) ;

               return 0;

          case WM_CONTROL:
               {
               SHORT sWho = SHORT1FROMMP(mp1);
               SHORT sWhat = SHORT2FROMMP(mp1);

               switch (sWho)
                    {
                    case IDD_SET_FRACTTYPE_LB:
                         switch (sWhat)
                              {
                              case LN_ENTER:
                                   /* fake the OK button on double click */
                                   WinSendMsg(hwnd, WM_COMMAND,
                                   MPFROMSHORT(DID_OK),
                                   MPFROM2SHORT(CMDSRC_PUSHBUTTON, FALSE) ) ;
                              return 0;

                              }
                    }
               break;
               }

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    DLF dlf;
                    HFILE hfDummy;

                    case DID_OK:
                         isSelected = (SHORT) WinSendDlgItemMsg(hwnd,
                             IDD_SET_FRACTTYPE_LB, LM_QUERYSELECTION,
                             MPFROMSHORT(0), MPFROMP(NULL) );
                         npTempParms.iFractType = asFracTypeList[isSelected];
                         npTempParms.mxXL = fractalspecific[npTempParms.iFractType].xmin;
                         npTempParms.mxXR = fractalspecific[npTempParms.iFractType].xmax;
                         npTempParms.mxYT = fractalspecific[npTempParms.iFractType].ymax;
                         npTempParms.mxYB = fractalspecific[npTempParms.iFractType].ymin;
                         npTempParms.param[0] = fractalspecific[npTempParms.iFractType].paramvalue[0];
                         npTempParms.param[1] = fractalspecific[npTempParms.iFractType].paramvalue[1];
                         npTempParms.param[2] = fractalspecific[npTempParms.iFractType].paramvalue[2];
                         npTempParms.param[3] = fractalspecific[npTempParms.iFractType].paramvalue[3];
                         npTempParms.trigndx[0] = SIN;
                         npTempParms.trigndx[1] = SQR;
                         npTempParms.trigndx[2] = SINH;
                         npTempParms.trigndx[3] = COSH;

                         /* zoom out to maximum range */
                         npTempParms.XL = npTempParms.mxXL;
                         npTempParms.XR = npTempParms.mxXR;
                         npTempParms.YT = npTempParms.mxYT;
                         npTempParms.YB = npTempParms.mxYB;
                         npTempParms.XCenter = (npTempParms.XL + npTempParms.XR)/2.0;
                         npTempParms.YCenter = (npTempParms.YT + npTempParms.YB)/2.0;

                         /* handle special fractal types */
                         npTempParms.fNewParms = FALSE;       /* assume cancel below */
                         switch (npTempParms.iFractType)
                            {
                            case IFS:
                                 /* get the file name for IFS */
                                 SetupDLF (&dlf, DLG_OPENDLG, &hfDummy,
                                     "\\*.ifs", szTitleBar,
                                     szIFSTitle, szIFSHelp);
                                 _fstrcpy(dlf.szOpenFile, npTempParms.szIfsFileName);

                                 if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) )
                                    {
                                    /* close the dummy file handle */
                                    DosClose(hfDummy);
                                    /* set the name */
                                    _fstrcpy(npTempParms.szIfsFileName, dlf.szOpenFile);
                                    /* flag OK */
                                    npTempParms.fNewParms = TRUE;
                                    }
                                 break;

                            case IFS3D:
                                 /* get the file name for IFS3D */
                                 SetupDLF (&dlf, DLG_OPENDLG, &hfDummy,
                                     "\\*.ifs", szTitleBar,
                                     szIFS3DTitle, szIFS3DHelp);
                                 _fstrcpy(dlf.szOpenFile, npTempParms.szIfs3dFileName);

                                 if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) )
                                    {
                                    /* close the dummy file handle */
                                    DosClose(hfDummy);
                                    /* set the name */
                                    _fstrcpy(npTempParms.szIfs3dFileName, dlf.szOpenFile);
                                    /* flag OK */
                                    npTempParms.fNewParms = TRUE;
                                    }
                                 break;

                            case FORMULA:
                            case FFORMULA:
                                 /* get the name of the Formula file */
                                 SetupDLF (&dlf, DLG_OPENDLG, &hfDummy,
                                     "\\*.frm", szTitleBar,
                                     szFormTitle, szFormHelp);
                                 _fstrcpy(dlf.szOpenFile, npTempParms.szFormFileName);

                                 if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) )
                                    {

                                    /* close the dummy file handle */
                                    DosClose(hfDummy);
                                    /* set the name */
                                    _fstrcpy(npTempParms.szFormFileName, dlf.szOpenFile);
                                    /* read the formula names */
                                    get_formula_names(&gs);
                                    /* now select */
                                    _fstrcpy(gs.szSelected, npTempParms.szFormName);
                                    gs.pszTitle = szSelFormula;
                                    if (WinDlgBox (HWND_DESKTOP, hwnd, SelWhatDlgProc,
                                              (HMODULE) 0, IDD_SEL_LIST, &gs) )
                                       {
                                       /* set the name selected */
                                       _fstrcpy(npTempParms.szFormName, gs.szSelected );
                                       /* flag OK */
                                       npTempParms.fNewParms = TRUE;
                                       }
                                    }
                                 break;

                            case LSYSTEM:
                                 /* get the name of the L-System Formula file */
                                 SetupDLF (&dlf, DLG_OPENDLG, &hfDummy,
                                     "\\*.l", szTitleBar,
                                     szLsysTitle, szLsysHelp);
                                 _fstrcpy(dlf.szOpenFile, npTempParms.szLSysFileName);

                                 if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) )
                                    {

                                    /* close the dummy file handle */
                                    DosClose(hfDummy);
                                    /* set the name */
                                    _fstrcpy(npTempParms.szLSysFileName, dlf.szOpenFile);
                                    /* read the formula names */
                                    get_lsys_name(&gs);
                                    /* now select */
                                    _fstrcpy(gs.szSelected, npTempParms.szLSysName);
                                    if (WinDlgBox (HWND_DESKTOP, hwnd, SelWhatDlgProc,
                                              (HMODULE) 0, IDD_SEL_LIST, &gs) )
                                       {
                                       /* set the name selected */
                                       _fstrcpy(npTempParms.szLSysName, gs.szSelected );
                                       npTempParms.fNewParms = TRUE;
                                       }
                                    }
                                 break;

                            default:
                                 /* just flag OK */
                                 npTempParms.fNewParms = TRUE;
                                 break;
                            }

                         npNewParms = npTempParms;
                         WinDismissDlg (hwnd, npNewParms.fNewParms) ;
                         return 0 ;

                    case DID_CANCEL:
                         npTempParms.fNewParms = FALSE;
                         WinDismissDlg (hwnd, FALSE) ;
                         return 0 ;
                    }
               break ;

          case WM_HELP:
               SimpleHelp(hab, hwnd, szTitleBar,
                       (HMODULE) 0, IDT_TEXT, IDT_HELP_TYPES);

               return 0;

               break;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #4
0
/**************************************************************************\
*                                                                          *
*       ROUTINE:    ClkColorsDlgProc ( )                                   *
*                                                                          *
*       COMMENT:    "Clock Color Preferences" Dialog                       *
*                                                                          *
*       RETURNS:    MRESULT, 0 or return value from WinDefDlgProc          *
*                                                                          *
\**************************************************************************/
MRESULT EXPENTRY ClkColorsDlgProc(HWND hwnd, ULONG usMsg, MPARAM mp1, MPARAM mp2)
{
   static USHORT usCheckedPartID = 0, usCheckedColorID = 0;
   static LONG clrBackgroundNew;
   static LONG clrFaceNew;
   static LONG clrHourHandNew;
   static LONG clrMinuteHandNew;
   static LONG *pclrNew;

   switch (usMsg)
   {
      USHORT usButtonID;
      HWND hwndButton;
      HPS hpsT;
      RECTL rclButton, rclButtonInterior;

   case WM_INITDLG:
      hpsT = WinGetPS(hwnd);

      GpiCreateLogColorTable(hpsT, LCOL_RESET, LCOLF_RGB, 0L, 0L, NULL);

      /* Load the new values from the current ones.    */
      clrBackgroundNew = GpiQueryColorIndex(hpsT, 0L, cp.clrBackground);

      clrFaceNew       = GpiQueryColorIndex(hpsT, 0L, cp.clrFace      );
      clrHourHandNew   = GpiQueryColorIndex(hpsT, 0L, cp.clrHourHand  );
      clrMinuteHandNew = GpiQueryColorIndex(hpsT, 0L, cp.clrMinuteHand);

      WinReleasePS(hpsT);

      /* click the "Background" radio button */
      WinPostMsg(WinWindowFromID(hwnd,
                                 CLKCLR_BACKGROUND),
                                 BM_CLICK,
                                 MPFROMSHORT(TRUE),
                                 MPVOID);

      /* Let the default dialog procedure handle anything else.   */
      break;

   case WM_COMMAND:
      switch (LOUSHORT(mp1))
      {
         case DID_OK:
            hpsT = WinGetPS(hwnd);

            GpiCreateLogColorTable(hpsT, LCOLF_RGB, 0L, 0L, 0L, NULL);

              /*
               * Uupdate the one the user has selected.
               */
            switch(usCheckedPartID)
            {
            case CLKCLR_BACKGROUND:
               cp.clrBackground = GpiQueryRGBColor(hpsT, 0L, clrBackgroundNew);
               break;

            case CLKCLR_FACE:
               cp.clrFace = GpiQueryRGBColor(hpsT, 0L, clrFaceNew);
               break;

            case CLKCLR_HOURHAND:
               cp.clrHourHand = GpiQueryRGBColor(hpsT, 0L, clrHourHandNew);
               break;

            case CLKCLR_MINUTEHAND:
               cp.clrMinuteHand = GpiQueryRGBColor(hpsT, 0L, clrMinuteHandNew);
               break;
            }
            WinReleasePS(hpsT);

              /* repaint with the new colors */
            WinInvalidateRect(hwndFrame, NULL, TRUE);

         case DID_CANCEL:
            WinDismissDlg(hwnd, TRUE);
      }
      return NULL;

   case WM_CONTROL:
      usButtonID = SHORT1FROMMP(mp1);

      /* selecting a new object */
      if (usButtonID & CLKCLR_OBJECTS)
      {
         MRESULT rc;

         switch (usButtonID)
         {
            case CLKCLR_BACKGROUND:
               pclrNew = &clrBackgroundNew;
               break;
            case CLKCLR_FACE:
               pclrNew = &clrFaceNew;
               break;
            case CLKCLR_HOURHAND:
               pclrNew = &clrHourHandNew;
               break;
            case CLKCLR_MINUTEHAND:
               pclrNew = &clrMinuteHandNew;
         }
         usCheckedPartID = usButtonID;

          /* click the button for the new object's current color */
         rc = WinSendMsg(WinWindowFromID(hwnd,
                                         (CLKCLR_BUTTONSHIFT + *pclrNew)),
                                         BM_CLICK,
                                         MPFROMSHORT(TRUE), MPVOID);
         break;
      }

      switch (SHORT2FROMMP(mp1))
      {
      case BN_CLICKED:
         *pclrNew = (LONG)usButtonID - CLKCLR_BUTTONSHIFT;

           /* Turn off the check state of the previously checked
            * button and turn on the check state of the button
            * just clicked.
            */
         WinCheckButton(hwnd, usCheckedColorID, FALSE);
         WinCheckButton(hwnd, usButtonID, TRUE);
         usCheckedColorID = usButtonID;
         break;

      case BN_PAINT:

              /* Fill only the interior of the button, so we don't
               * conflict with the focus indicator */
         hwndButton = ((PUSERBUTTON) mp2) -> hwnd;
         WinQueryWindowRect(hwndButton, &rclButton);
         rclButton.xLeft++;
         rclButton.yBottom++;
         rclButton.xRight--;
         rclButton.yTop--;
         WinFillRect(((PUSERBUTTON) mp2)->hps,
                       &rclButton,
                       (LONG)usButtonID - CLKCLR_BUTTONSHIFT);

         /* Hollow out those buttons which aren't checked */
         if (!WinQueryButtonCheckstate(hwnd, usButtonID))
         {
            rclButtonInterior.xLeft   = rclButton.xLeft   + 4;
            rclButtonInterior.yBottom = rclButton.yBottom + 4;
            rclButtonInterior.xRight  = rclButton.xRight  - 4;
            rclButtonInterior.yTop    = rclButton.yTop    - 4;
            WinFillRect(((PUSERBUTTON)mp2)->hps,
                          &rclButtonInterior, SYSCLR_WINDOW);
         }
         break;
      }
      /* fall through to the default control processing */
   }
   return WinDefDlgProc(hwnd, usMsg, mp1, mp2);
}
コード例 #5
0
ファイル: dlg-joystick.c プロジェクト: martinpiper/VICE
static MRESULT EXPENTRY pm_calibrate(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    static int joy1 = TRUE;

    switch (msg)
    {
    case WM_INITDLG:
        {
            int j1, j2;

            resources_get_int("JoyDevice1", &j1);
            resources_get_int("JoyDevice2", &j2);
            WinSendMsg(hwnd, WM_PROCESS,
                       (void*)!!((j1|j2)&JOYDEV_HW1),
                       (void*)!!((j1|j2)&JOYDEV_HW2));
        }
        break;

    case WM_COMMAND:
        {
            int cmd = LONGFROMMP(mp1);
            switch (cmd)
            {
            case ID_START:
            case ID_RESET:
            case ID_STOP:
                if (joy1) set_joyA_autoCal(NULL,   (void*)(cmd!=ID_STOP));
                else      set_joyB_autoCal(NULL,   (void*)(cmd!=ID_STOP));
                WinSendMsg(hwnd, WM_ENABLECTRL, 0, (void*)(cmd!=ID_STOP));
                WinSendMsg(hwnd, WM_FILLSPB, 0, 0);
                return FALSE;
            }
            break;
        }
    case WM_CONTROL:
        {
            int ctrl = SHORT1FROMMP(mp1);
            switch (ctrl)
            {
            case RB_JOY1:
            case RB_JOY2:
                if (!(ctrl==RB_JOY1 && joy1) && !(ctrl==RB_JOY2 && !joy1))
                {
                    joy1 = !joy1;
                    WinSendMsg(hwnd, WM_ENABLECTRL, 0, (void*)(get_joy_autoCal(joy1?0:1)));
                    WinSendMsg(hwnd, WM_FILLSPB, 0, 0);
                }
                break;
            case SPB_UP:
            case SPB_DOWN:
            case SPB_LEFT:
            case SPB_RIGHT:
                if (SHORT2FROMMP(mp1)==SPBN_ENDSPIN)
                {
                    const ULONG val = WinGetSpinVal((HWND)mp2);
                    resources_set_int(ctrl==SPB_UP  ? (joy1?"joyAup"  :"joyBup")  :
                                        ctrl==SPB_DOWN? (joy1?"joyAdown":"joyBdown"):
                                        ctrl==SPB_LEFT? (joy1?"joyAleft":"joyBleft"):
                                        (joy1?"joyAright":"joyBright"), val);
                }
                break;
            }
            break;
        }
    case WM_PROCESS:
        if (((int)mp1^(int)mp2)&1)
            joy1 = (int)mp1;

        WinCheckButton(hwnd, joy1?RB_JOY1:RB_JOY2, 1);
        WinEnableControl(hwnd, RB_JOY1, (ULONG)mp1);
        WinEnableControl(hwnd, RB_JOY2, (ULONG)mp2);

        WinSendMsg(hwnd, WM_ENABLECTRL, (void*)(!mp1 && !mp2),
                   (void*)get_joy_autoCal(joy1?0:1));
        WinSendMsg(hwnd, WM_FILLSPB, 0, 0);
        break;
    case WM_SETJOY:
        {
            ULONG state1 = mp1?1:0;
            ULONG state2 = mp2?1:0;
            WinEnableControl(hwnd, RB_JOY1, state1);
            WinEnableControl(hwnd, RB_JOY2, state2);
            WinSendMsg(hwnd, WM_PROCESS, (void*)state1, (void*)state2);
        }
        break;
    case WM_ENABLECTRL:
        WinEnableControl(hwnd, ID_START,  mp1?FALSE: !mp2);
        WinEnableControl(hwnd, ID_STOP,   mp1?FALSE:!!mp2);
        WinEnableControl(hwnd, ID_RESET,  mp1?FALSE:!!mp2);
        WinEnableControl(hwnd, SPB_UP,    mp1?FALSE: !mp2);
        WinEnableControl(hwnd, SPB_DOWN,  mp1?FALSE: !mp2);
        WinEnableControl(hwnd, SPB_LEFT,  mp1?FALSE: !mp2);
        WinEnableControl(hwnd, SPB_RIGHT, mp1?FALSE: !mp2);
        return FALSE;
    case WM_FILLSPB:
        {
            int val;
            resources_get_int(joy1?"JoyAup":"JoyBup", &val);
            WinSetDlgSpinVal(hwnd, SPB_UP, val);
            resources_get_int(joy1?"JoyAdown":"JoyBdown", &val);
            WinSetDlgSpinVal(hwnd, SPB_DOWN, val);
            resources_get_int(joy1?"JoyAleft":"JoyBleft", &val);
            WinSetDlgSpinVal(hwnd, SPB_LEFT, val);
            resources_get_int(joy1?"JoyAright":"JoyBright", &val);
            WinSetDlgSpinVal(hwnd, SPB_RIGHT,val);
        }
        return FALSE;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
コード例 #6
0
ファイル: ddbufdlg.c プロジェクト: OS2World/APP-COMM-ComScope
MRESULT EXPENTRY fnwpReceiveBuffDlgProc(HWND hwndDlg,USHORT msg,MPARAM mp1,MPARAM mp2)
  {
  ULONG ulTemp;
  char acBuffer[15];
  static NBKPAGECTL *pstPage;
  static COMDCB *pstComDCB;
  LONG lTemp;
  static int iResDevider = 1;
  static BOOL bNotFirst;

  switch (msg)
    {
    case WM_INITDLG:
      if (lYScr < 768)
        iResDevider = 2;
      if (!bInsertNewDevice)
        WinSetDlgItemText(hwndDlg,DID_INSERT,"S~ave");
//        ControlEnable(hwndDlg,DID_INSERT,FALSE);
//      CenterDlgBox(hwndDlg);
//      WinSetFocus(HWND_DESKTOP,hwndDlg);
      pstPage = PVOIDFROMMP(mp2);
      pstComDCB = (COMDCB *)pstPage->pVoidPtrOne;
//      pstPage->bDirtyBit = FALSE;
      bNotFirst = FALSE;
//      lXonHysteresis = (pstComDCB->wReadBufferLength - pstComDCB->wXonThreshold - pstComDCB->wXoffThreshold);
//      WinSetDlgItemText(hwndDlg,PCFG_BUFF_NAME,"~Receive buffer");
      WinSetDlgItemText(hwndDlg,PCFG_BUFF_NAME,"Receive buffer");
      WinSetDlgItemText(hwndDlg,ST_TITLE,"Receive Buffer Length Configuration");
      InitReadBufferSize(hwndDlg,ulReadBuffLen,iResDevider);
      return (MRESULT) TRUE;
    case WM_COMMAND:
      switch (SHORT1FROMMP(mp1))
        {
        case DID_INSERT:
           WinPostMsg(hwndNoteBookDlg,UM_CLOSE,(MPARAM)0,(MPARAM)0);
           break;
        case DID_CANCEL:
          WinPostMsg(hwndNoteBookDlg,WM_COMMAND,MPFROMSHORT(DID_CANCEL),(MPARAM)0);
           return(FALSE);
        case DID_HELP:
           WinPostMsg(hwndNoteBookDlg,WM_COMMAND,MPFROMSHORT(DID_HELP),(MPARAM)0);
        case DID_UNDO:
          pstPage->bDirtyBit = FALSE;
          ulReadBuffLen = ulOrgReadBuffLen;
          WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,SLM_SETSLIDERINFO,
                            MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE),MPFROMSHORT((ulReadBuffLen / 256) - 4));
          WinSetDlgItemText(hwndDlg,PCFG_BUFF_DATA,
                           ltoa(ulReadBuffLen,acBuffer,10));
          return(FALSE);
        }
      break;
    case UM_SET_FOCUS:
      WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwndDlg,SHORT1FROMMP(mp1)));
      break;
    case UM_SAVE_DATA:
       pstComDCB->wReadBufferLength = ulReadBuffLen;
       return((MRESULT)TRUE);
    case WM_CONTROL:
      switch (SHORT2FROMMP(mp1))
        {
        case SLN_SLIDERTRACK:
        case SLN_CHANGE:
          if (bNotFirst)
            pstPage->bDirtyBit = TRUE;
          else
            bNotFirst = TRUE;
          ulTemp = (ULONG)WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,
                                            SLM_QUERYSLIDERINFO,
                                            MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
                                            NULL);
          ulReadBuffLen = ((ulTemp * 256 * iResDevider) + MIN_READ_BUFF_LEN);
          WinSetDlgItemText(hwndDlg,PCFG_BUFF_DATA,ltoa(ulReadBuffLen,acBuffer,10));
          if (SHORT2FROMMP(mp1) != SLN_CHANGE)
            break;
          if (ulReadBuffLen >= MAX_READ_BUFF_LEN)
            ulReadBuffLen = (USHORT)0xffff;
          if (lXoffThreshold != 0)
            if ((lXonHysteresis + lXoffThreshold) >= ulReadBuffLen)
              if (lXonHysteresis > lXoffThreshold)
                {
                lTemp = (lXonHysteresis / lXoffThreshold);
                if (lTemp <= 0)
                  lTemp = 1;
                while ((lXonHysteresis + lXoffThreshold) >= ulReadBuffLen)
                  {
                  lXonHysteresis -= lTemp;
                  lXoffThreshold--;
                  }
                }
              else
                {
                lTemp = (lXoffThreshold / lXonHysteresis);
                if (lTemp <= 0)
                  lTemp = 1;
                while ((lXonHysteresis + lXoffThreshold) >= ulReadBuffLen)
                  {
                  lXonHysteresis--;
                  lXoffThreshold -= lTemp;
                  }
                }
          break;
        }
      return (MRESULT) TRUE;
    }
  return(WinDefDlgProc(hwndDlg,msg,mp1,mp2));
  }
コード例 #7
0
/*--------------------------------------------------
  This function backs the Options/Set Palette... dialog box.

  This dialog effects immediate change to the display
  by allowing the user to select from the palettes that
  may be available to him.

  Note that a richer (more colors) palette will be attempted
  to be translated by the GPI bitmap handling.  The result
  will be as good as the driver/display combination is capable of.

  Help sends an appropriate message using the
  SMPLHELP system.
 --------------------------------------------------*/
MRESULT EXPENTRY SetPaletteDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {

     switch (msg)
          {
          case WM_INITDLG:

               CenterDialogBox(hwnd);

               /* Flick the button showing where we are now. */
               WinSendDlgItemMsg (hwnd, cp.sCurrentPalette,
                          BM_SETCHECK, MPFROMSHORT(1), MPFROMP(NULL) );
               WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd,
                           cp.sCurrentPalette) );

               /* If we are running 2-color, turn off the
                  16-color, 256-color, and physical options.
                  They are inappropriate for 2-color mode */
               if (cp.colors < 16)
                  {
                  WinEnableWindow ( WinWindowFromID(hwnd, IDD_PAL_VGA16), FALSE);
                  WinEnableWindow ( WinWindowFromID(hwnd, IDD_PAL_VGA256), FALSE);
                  WinEnableWindow ( WinWindowFromID(hwnd, IDD_PAL_PHYS), FALSE);
                  }

               /* If we have read a user palette, turn on the user_palette
                  button.   */

               if (cp.fHaveUserPalette)
                  {
                  WinEnableWindow ( WinWindowFromID(hwnd, IDD_PAL_USER), TRUE);
                  }

               /* and go away */
               return ((MRESULT) TRUE);

          case WM_CONTROL:
               {
               SHORT sWho = SHORT1FROMMP(mp1);
               SHORT sWhat = SHORT2FROMMP(mp1);

               /* switch the palette pointer */
               /* save new state for next time */
               switch (sWhat)
                     {
                     case BN_CLICKED:
                          switch (sWho)
                               {
                               case IDD_PAL_BW:
                                    cp.pbmiMemory = &bmiColorTableBW;
                                    cp.sCurrentPalette = IDD_PAL_BW;
                                    break;
                               case IDD_PAL_WB:
                                    cp.pbmiMemory = &bmiColorTableWB;
                                    cp.sCurrentPalette = IDD_PAL_WB;
                                    break;
                               case IDD_PAL_VGA16:
                                    cp.pbmiMemory = &bmiColorTableVGA16;
                                    cp.sCurrentPalette = IDD_PAL_VGA16;
                                    break;
                               case IDD_PAL_VGA256:
                                    cp.pbmiMemory = &bmiColorTableVGA256;
                                    cp.sCurrentPalette = IDD_PAL_VGA256;
                                    break;
                               case IDD_PAL_PHYS:
                                    cp.pbmiMemory = &bmiColorTablePhys;
                                    cp.sCurrentPalette = IDD_PAL_PHYS;
                                    break;
                               case IDD_PAL_USER:
                                    cp.pbmiMemory = &bmiColorTableUser;
                                    cp.sCurrentPalette = IDD_PAL_USER;
                                    break;
                               }

                          /* now hose the display */
                          cp.fNewBits = TRUE;
                          WinInvalidateRect(cp.hwnd, NULL, FALSE);

                          /* and go away */
                          return 0;
                     }
               }

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case DID_OK:
                    case DID_CANCEL:
                         /* any exit is an exit */
                         WinDismissDlg (hwnd, TRUE) ;
                         return 0 ;
                    }
               break ;

          case WM_HELP:
               SimpleHelp(hab, hwnd, szTitleBar,
                       (HMODULE) 0, IDT_TEXT, IDT_HELP_OPERATE);

               return 0;

               break;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #8
0
MRESULT EXPENTRY main_proc(
    HWND                hwnd,
    ULONG               msg,
    MPARAM              mp1,
    MPARAM              mp2
) {
    if( msg == WM_CREATE ) {

        PCREATESTRUCT   pcreate;

        pcreate = ( CREATESTRUCT * ) mp2;
        Draw_area.xRight = pcreate->x + pcreate->cx;
        Draw_area.yTop = pcreate->y + pcreate->cy;
        Draw_area.yBottom = pcreate->y;
        Draw_area.xLeft = pcreate->x;
//      WinQueryWindowRect( hwnd, &Draw_area );

    } else if( msg == WM_COMMAND || ( msg == WM_CONTROL &&
                                SHORT2FROMMP( mp1 ) != BN_PAINT ) ) {

        switch( SHORT1FROMMP( mp1 ) ) {

        case IDM_EXIT:
            new_display();
            WinPostMsg( hwnd, WM_QUIT, 0L, 0L );
            return( NULL );

        case IDM_ROTATE_LEFT:
            new_display();
            add_wrap( THREE_D_HORZ_ANGLE, -15, 0, 360 );
            break;
        case IDM_ROTATE_RIGHT:
            new_display();
            add_wrap( THREE_D_HORZ_ANGLE, 15, 0, 360 );
            break;
        case IDM_ROTATE_UP:
            new_display();
            add_range( THREE_D_VERT_ANGLE, 5, -90, 90 );
            break;
        case IDM_ROTATE_DOWN:
            new_display();
            add_range( THREE_D_VERT_ANGLE, -5, -90, 90 );
            break;
        case IDM_MOVE_IN:
            new_display();
            add_range(THREE_D_ZOOM, 10, 5, 200 );
            break;
        case IDM_MOVE_OUT:
            new_display();
            add_range( THREE_D_ZOOM, -10, 5, 200 );
            break;
        case IDM_MORE_PERSPECTIVE:
            new_display();
            add_range( THREE_D_PERSPECTIVE, 10, 5, 200 );
            break;
        case IDM_LESS_PERSPECTIVE:
            new_display();
            add_range( THREE_D_PERSPECTIVE, -10, 5, 200 );
            break;
        case IDM_MORE_CONTRAST:
            new_display();
            add_range( THREE_D_CONTRAST, 10, 0, 100 );
            break;
        case IDM_LESS_CONTRAST:
            new_display();
            add_range( THREE_D_CONTRAST, -10, 0, 100 );
            break;
        case IDM_MORE_BRIGHTNESS:
            new_display();
            add_range( THREE_D_BRIGHTNESS, 10, 0, 100 );
            break;
        case IDM_LESS_BRIGHTNESS:
            new_display();
            add_range( THREE_D_BRIGHTNESS, -10, 0, 100 );
            break;
        case IDM_LIGHT_HORZ_LEFT:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 1 );
            break;
        case IDM_LIGHT_HORZ_MIDDLE:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 2 );
            break;
        case IDM_LIGHT_HORZ_RIGHT:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 3 );
            break;
        case IDM_LIGHT_VERT_TOP:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_VERT, 1 );
            break;
        case IDM_LIGHT_VERT_MIDDLE:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_VERT, 2 );
            break;
        case IDM_LIGHT_VERT_BOTTOM:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_VERT, 3 );
            break;
        case IDM_LIGHT_DEPTH_FRONT:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 1 );
            break;
        case IDM_LIGHT_DEPTH_MIDDLE:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 2 );
            break;
        case IDM_LIGHT_DEPTH_BACK:
            new_display();
            three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 3 );
            break;
        default:
            ;
        }
        WinInvalidateRect( hwnd, &Draw_area,
                        SHORT1FROMMP( mp1 ) >= IDM_FIRST_REQUIRING_CLEAR );

    } else if( msg == WM_DESTROY ) {
        WinPostMsg( hwnd, WM_QUIT, 0L, 0L );
        return( 0 );

    } else if( msg == WM_PAINT ) {
        draw_stuff( hwnd );
        if( Auto_run ) {
            if( Auto_run == 5 ) {
                WinPostMsg( hwnd, WM_QUIT, 0L, 0L );
            } else {
                long count;
                int will_be_one;
                will_be_one = 1;
                for(count = 0; count < 1000000; ++ count ) will_be_one ^= 1;

                Auto_run += will_be_one;
                WinPostMsg( hwnd, WM_COMMAND,
                        MPFROMSHORT( IDM_ROTATE_LEFT ), 0L );
            }
        }
        return( 0 );

    } else if( msg == WM_SIZE ) {
        WinQueryWindowRect( hwnd, &Draw_area );
        Draw_area.yTop -= Button_height;
        WinInvalidateRect( hwnd, NULL, TRUE );
        return( 0 );

    } else if( msg == WM_MEASUREITEM ) {
        return( (MRESULT) measure_button( hwnd, mp1, mp2 ) );

    } else if( msg == WM_CONTROL && SHORT2FROMMP( mp1 ) == BN_PAINT ) {
        draw_button( mp1, mp2 );
        return( (MRESULT) TRUE );

    }

    return( (MRESULT) WinDefWindowProc( hwnd, msg, mp1, mp2 ) );
}
コード例 #9
0
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Installer_ClientWindowProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 switch( Message )
  {
   // Выполняем действия при создании окна.
   case WM_CREATE:
    {
     WinPostMsg( Window, MY_CREATE, 0, 0 );
    }
   return 0;

   case MY_CREATE:
    {
     // Задаем заголовок окна приложения.
     if( Installer.Code_page == RUSSIAN ) strcpy( Installer.Frame_window_title, StrConst_RU_Title );
     else strcpy( Installer.Frame_window_title, StrConst_EN_Title );

     WinSetWindowText( Installer.Frame_window, Installer.Frame_window_title );

     // Устанавливаем картинку в левом верхнем углу окна.
     WinSendMsg( Installer.Frame_window, WM_SETICON, (MPARAM) WinLoadPointer( HWND_DESKTOP, NULLHANDLE, 1 ), 0 );

     // Задаем расположение окна.
     {
      INT X_Screen = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
      INT Y_Screen = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );

      INT Window_width  = X_Screen / 3; if( X_Screen < 1024 ) Window_width  *= 1.25;
      INT Window_height = Y_Screen / 3; if( X_Screen < 1024 ) Window_height *= 1.25;

      INT Window_position_X = ( X_Screen - Window_width ) / 2;
      INT Window_position_Y = ( Y_Screen - Window_height ) / 2 + ( Y_Screen - Window_height ) / 4 / 2;

      WinSetWindowPos( Installer.Frame_window, HWND_TOP, Window_position_X, Window_position_Y, Window_width, Window_height, SWP_ZORDER | SWP_MOVE | SWP_SIZE | SWP_NOADJUST );
      WinSetActiveWindow( HWND_DESKTOP, Installer.Frame_window );
     }

     // Добавляем его в список окон.
     {
      SWCNTRL Task; HSWITCH Switch_handle = NULLHANDLE;

      bzero( &Task, sizeof( SWCNTRL ) );
      Task.hwnd = Installer.Frame_window;
      Task.hwndIcon = (HPOINTER) WinSendMsg( Installer.Frame_window, WM_QUERYICON, 0, 0 );
      WinQueryWindowProcess( Installer.Frame_window, &Task.idProcess, NULL );
      strcpy( Task.szSwtitle, Installer.Frame_window_title );

      Task.uchVisibility = SWL_VISIBLE;
      Task.fbJump = SWL_JUMPABLE;

      Switch_handle = WinCreateSwitchEntry( Installer.Application, &Task );
      WinChangeSwitchEntry( Switch_handle, &Task );
     }

     // Создаем поля ввода в окне рабочей области.
     ClientWindow_CreatePage( Installer.Client_window );
    }
   return 0;

   // Передвигаем поля ввода.
   case MY_APPLY_LAYOUT:
    {
     LitApplyLayout( &Client_Window.Layout );
    }
   return 0;

   // Включаем и отключаем поля ввода.
   case MY_ENABLE_BUTTONS:
    {
     ULONG Action = (ULONG) First_parameter;

     WinEnableWindow( WinWindowFromID( WinWindowFromID( Window, Client_Window.Settings.Buttons_brick_ID ), Client_Window.Settings.Install_button_ID ), Action );
     WinEnableWindow( WinWindowFromID( WinWindowFromID( Window, Client_Window.Settings.Buttons_brick_ID ), Client_Window.Settings.Remove_button_ID ), Action );
     WinEnableWindow( WinWindowFromID( WinWindowFromID( Window, Client_Window.Settings.Buttons_brick_ID ), Client_Window.Settings.Cancel_button_ID ), Action );

     if( !Action )
      WinSendMsg( WinWindowFromID( Installer.Frame_window, FID_SYSMENU ), MM_SETITEMATTR, MPFROM2SHORT( SC_CLOSE, INCLUDE_SUBMENUS ), MPFROM2SHORT( MIA_DISABLED, MIA_DISABLED ) );
     else
      WinSendMsg( WinWindowFromID( Installer.Frame_window, FID_SYSMENU ), MM_SETITEMATTR, MPFROM2SHORT( SC_CLOSE, INCLUDE_SUBMENUS ), MPFROM2SHORT( MIA_DISABLED, 0 ) );
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == Client_Window.Settings.Install_button_ID )
      {
       StartInstallerThread( NIA_INSTALL );
      }

     if( WM_Control_Button_ID == Client_Window.Settings.Remove_button_ID )
      {
       StartInstallerThread( NIA_REMOVE );
      }

     if( WM_Control_Button_ID == Client_Window.Settings.Cancel_button_ID )
      {
       WinPostMsg( Installer.Frame_window, WM_SYSCOMMAND, (MPARAM) SC_CLOSE, 0 );
      }
    }
   return 0;

   // Закрашиваем пространство окна.
   case WM_PAINT:
    {
     RECT Rectangle = {0};
     HPS Presentation_space = WinBeginPaint( Window, 0, &Rectangle );

     if( Presentation_space )
      {
       LONG Color_table[ 256 ]; bzero( Color_table, sizeof( Color_table ) );
       GpiQueryLogColorTable( Presentation_space, 0, 0, 256, Color_table );

       LONG Color_index = ( 256 - 1 );
       WinQueryPresParam( Window, PP_BACKGROUNDCOLOR, 0, NULL, sizeof( Color_table[ Color_index ] ), &Color_table[ Color_index ], QPF_NOINHERIT );
       GpiCreateLogColorTable( Presentation_space, 0, LCOLF_CONSECRGB, 0, 256, Color_table );

       WinFillRect( Presentation_space, &Rectangle, Color_index );
       WinEndPaint( Presentation_space );
      }
    }
   return 0;

   // Сообщаем окну рамки, что содержимое окна рабочей области закрашивать не следует.
   case WM_ERASEBACKGROUND:
   return (MPARAM) 0;

   // Выполняем действия при нажатии на кнопку закрытия окна.
   case WM_CLOSE:
    {
     // Убираем окно приложения из списка окон.
     WinRemoveSwitchEntry( WinQuerySwitchHandle( Installer.Frame_window, 0 ) );

     // Передаем сообщение обработчику.
     WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
コード例 #10
0
ファイル: dlg-color.c プロジェクト: BigBoss21X/vice-emu
static MRESULT EXPENTRY pm_color(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    switch (msg) {
        case WM_INITDLG:
            {
                int val;
                SetSliderTxt(hwnd, ID_SATURATION, 0, "0");
                SetSliderTxt(hwnd, ID_SATURATION, 100, "1.0");
                SetSliderTxt(hwnd, ID_SATURATION, 200, "2.0");
                resources_get_int("ColorSaturation", &val);
                SetSliderPos(hwnd, ID_SATURATION, val / 10);
                resources_get_int("ColorContrast", &val);
                SetSliderPos(hwnd, ID_CONTRAST, val / 10);
                resources_get_int("ColorBrightness", &val);
                SetSliderPos(hwnd, ID_BRIGHTNESS, val / 10);
                resources_get_int("ColorGamma", &val);
                SetSliderPos(hwnd, ID_GAMMA, val / 10);
                resources_get_int("PALScanLineShade", &val);
                SetSliderPos(hwnd, ID_SCANLINE, val / 5);
                resources_get_int("PALBlur", &val);
                SetSliderPos(hwnd, ID_BLUR, val / 5);
                resources_get_int("ColorTint", &val);
                SetSliderPos(hwnd, ID_TINT, val / 10);
                resources_get_int("PALOddLinePhase", &val);
                SetSliderPos(hwnd, ID_ODDLINE_PHASE, val / 10);
                resources_get_int("PALOddLineOffset", &val);
                SetSliderPos(hwnd, ID_ODDLINE_OFFSET, val / 10);
            }
            break;
        case WM_COMMAND:
            if (LONGFROMMP(mp1) != ID_DEFAULT) {
                break;
            }
            canvas_set_value("ColorSaturation", 1000);
            canvas_set_value("ColorContrast", 1000);
            canvas_set_value("ColorBrightness", 1000);
            canvas_set_value("ColorGamma", 880);
            canvas_set_value("PALScanLineShade", 667);
            canvas_set_value("PALBlur", 500);
            canvas_set_value("ColorTint", 1000);
            canvas_set_value("PALOddLinePhase", 1250);
            canvas_set_value("PALOddLineOffset", 750);
            SetSliderPos(hwnd, ID_SATURATION, 100);
            SetSliderPos(hwnd, ID_CONTRAST, 100);
            SetSliderPos(hwnd, ID_BRIGHTNESS, 100);
            SetSliderPos(hwnd, ID_GAMMA, 88);
            SetSliderPos(hwnd, ID_SCANLINE, 133);
            SetSliderPos(hwnd, ID_BLUR, 100);
            SetSliderPos(hwnd, ID_TINT, 100);
            SetSliderPos(hwnd, ID_ODDLINE_PHASE, 125);
            SetSliderPos(hwnd, ID_ODDLINE_OFFSET, 75);
            return FALSE;
        case WM_CONTROL:
            if (SHORT2FROMMP(mp1) != SLN_CHANGE && SHORT2FROMMP(mp1) != SLN_SLIDERTRACK) {
                break;
            }
            switch (SHORT1FROMMP(mp1)) {
                case ID_SATURATION:
                canvas_set_value("ColorSaturation", (int)mp2 * 10);
                break;
                case ID_CONTRAST:
                    canvas_set_value("ColorContrast", (int)mp2 * 10);
                    break;
                case ID_BRIGHTNESS:
                    canvas_set_value("ColorBrightness", (int)mp2 * 10);
                    break;
                case ID_GAMMA:
                    canvas_set_value("ColorGamma", (int)mp2 * 10);
                    break;
                case ID_SCANLINE:
                    canvas_set_value("PALScanLineShade", (int)mp2 * 5);
                    break;
                case ID_BLUR:
                    canvas_set_value("PALBlur", (int)mp2 * 5);
                    break;
                case ID_TINT:
                    canvas_set_value("ColorTint", (int)mp2 * 10);
                    break;
                case ID_ODDLINE_PHASE:
                    canvas_set_value("PALOddLinePhase", (int)mp2 * 10);
                    break;
                case ID_ODDLINE_OFFSET:
                    canvas_set_value("PALOddLineOffset", (int)mp2 * 10);
                    break;
            }
            break;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
コード例 #11
0
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Mouse_Clipboard_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Mouse_clipboard;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( MouseMapper.Settings.Use_middle_button_for_CopyPaste ) Value = 1;
     WinSendDlgItemMsg( Window, Mouse_Clipboard.Settings.Use_MB_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
     WinEnableWindow( WinWindowFromID( Window, Mouse_Clipboard.Settings.Mouse_cmbox_ID ), Value );

     BYTE Enabled = 1;
     if( WinQuerySysValue( QueryDesktopWindow(), SV_CMOUSEBUTTONS ) != 3 ) Enabled = 0;

     WinEnableWindow( WinWindowFromID( Window, Mouse_Clipboard.Settings.Use_MB_ID ), Enabled );
     WinEnableWindow( WinWindowFromID( Window, Mouse_Clipboard.Settings.Mouse_cmbox_ID ), Enabled );

     if( MouseMapper.Settings.Use_middle_button_for_CopyPaste )
      {
       INT Selected_string = MouseMapper.Settings.Use_middle_button_for_CopyPaste - 1;
       WinSendDlgItemMsg( Window, Mouse_Clipboard.Settings.Mouse_cmbox_ID, LM_SELECTITEM, MPFROMLONG( Selected_string ), MPFROMLONG( 1 ) );
      }
    }
   return 0;

   // Распознаем настройки.
   case SM_RECOGNIZE_SELECTION:
    {
     LONG Selected_string = (LONG) WinSendDlgItemMsg( Window, Mouse_Clipboard.Settings.Mouse_cmbox_ID, LM_QUERYSELECTION, (MPARAM) LIT_CURSOR, 0 );
     if( Selected_string != LIT_NONE ) MouseMapper.Settings.Use_middle_button_for_CopyPaste = Selected_string + 1;
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Mouse_Clipboard.Settings.Use_MB_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) MouseMapper.Settings.Use_middle_button_for_CopyPaste = 0;
           else MouseMapper.Settings.Use_middle_button_for_CopyPaste = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Mouse_Clipboard.Settings.Mouse_cmbox_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case CBN_ENTER:
          {
           WinSendMsg( Window, SM_RECOGNIZE_SELECTION, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Use middle button for CopyPaste", &MouseMapper.Settings.Use_middle_button_for_CopyPaste, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
コード例 #12
0
WPI_MRESULT CALLBACK GUIWindowProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam,
                                    WPI_PARAM2 lparam )
{
    gui_window          *wnd;
    gui_window          *root;
    WORD                param;
    WPI_POINT           currentpoint;
    gui_coord           point;
    gui_coord           size;
    WPI_MRESULT         ret;
    WPI_MINMAXINFO _W386FAR *info;
    WPI_RECT            rect;
    HWND                parent;
    CREATESTRUCT FAR    *lpcs;
    wmcreate_info _W386FAR *wmcreateinfo;
    gui_create_info     *createinfo;
    bool                use_defproc;
    unsigned            control_id;
    HWND                win;
#ifndef __OS2_PM__
    gui_key_state       key_state;
    RECT                rc;
#endif

    root = NULL;
    ret = 0L;
    use_defproc = FALSE;
    if( msg == WM_CREATE ) {
        lpcs = ( CREATESTRUCT FAR * )MK_FP32( (void *)lparam );
        wmcreateinfo = (wmcreate_info _W386FAR *)MK_FP32( _wpi_getcreateparms( lpcs ) );
        if ( wmcreateinfo != NULL ) {
            wnd = wmcreateinfo->wnd;
            createinfo = wmcreateinfo->info;
            if( wnd->hwnd == NULLHANDLE ) {
#ifdef __OS2_PM__
                if( wnd->root_frame != NULLHANDLE && wnd->root == NULLHANDLE ) {
                    wnd->root = hwnd;
                } else {
                    wnd->hwnd = hwnd;
                }
#else
                if( _wpi_getparent( hwnd ) == HWND_DESKTOP ) {
                    wnd->root       = hwnd;
                    wnd->root_frame = hwnd;
                } else {
                    wnd->hwnd       = hwnd;
                    wnd->hwnd_frame = hwnd;
                }
#endif
            }
            DoSetWindowLong( hwnd, wnd );
        }
    }
    wnd = GUIGetWindow( hwnd );
    if( wnd == NULL ) {
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    }

    if( GUIMDIProcessMessage( wnd, hwnd, msg, wparam, lparam, &ret ) ) {
        return( ret );
    }

    if( wnd->root == hwnd ) {
        /* message for root window */
        switch( msg ) {
        case WM_CREATE :
#ifdef __OS2_PM__
            wnd->root_pinfo.normal_pres =
                _wpi_createos2normpres( GUIMainHInst, hwnd );
#endif
            _wpi_getclientrect( wnd->root_frame, &wnd->root_client );
            if( CreateBackgroundWnd( wnd, createinfo ) ) {
                return( 0 );
            }
            return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
            break;
        case WM_DESTROY :
            wnd->flags |= DOING_DESTROY;
            GUICloseToolBar( wnd );
            //ret =  _wpi_defwindowproc( hwnd, msg, wparam, lparam );
            //wnd->root       = NULL;
            //wnd->root_frame = NULL;
            return( 0L );
        }
    } else if( ( wnd->root != NULLHANDLE ) && ( hwnd == wnd->hwnd ) ) {
        /* message for container window */
        switch( msg ) {
        case WM_SIZE :
            if( !_wpi_isiconic( _wpi_getframe( hwnd ) ) ) {
                size.x = _wpi_getwmsizex( wparam, lparam );
                size.y = _wpi_getwmsizey( wparam, lparam );
                GUIDoResize( wnd, hwnd, &size );
            }
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
            break;
        case WM_MOVE :
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
            break;
        case WM_VSCROLL :
        case WM_HSCROLL :
        case WM_CLOSE :
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
            break;
        }
    }

    switch( msg ) {
    case WM_CREATE :
#ifdef __OS2_PM__
        wnd->hwnd_pinfo.normal_pres =
            _wpi_createos2normpres( GUIMainHInst, hwnd );
#endif
        NumWindows++; // even if -1 is returned, window will get WM_DESTROY
        win = GUIGetParentFrameHWND( wnd );
        if( (  wnd->root_frame != NULLHANDLE ) ||
            ( createinfo->style & GUI_POPUP ) ) {
            if( !GUIAddToSystemMenu( wnd, win, 0, NULL,
                                     createinfo->style ) ) {
                return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
            }
        } else {
            if( !GUIAddToSystemMenu( wnd, win, createinfo->num_menus,
                                createinfo->menu, createinfo->style ) ) {
                return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
            }
        }
        _wpi_getclientrect( hwnd, &wnd->hwnd_client );
        GUISetRowCol( wnd, NULL );
        if( ( hwnd == wnd->hwnd ) && ( wnd->root == NULLHANDLE ) ) {
            GUIMDINewWindow( hwnd );
        }
        if( GUIEVENTWND( wnd, GUI_INIT_WINDOW, NULL ) ) {
            wnd->flags |= SENT_INIT;
            GUISetScroll( wnd ); /* initalize scroll ranges */
            GUIBringToFront( wnd );
            return( 0 );
        } else {
            /* app decided not to create window */
            return( (WPI_MRESULT)WPI_ERROR_ON_CREATE );
        }
        break;
#if defined(__NT__) || defined(WILLOWS)
    case WM_CTLCOLORBTN :
    case WM_CTLCOLORDLG :
    //case WM_CTLCOLORLISTBOX :
    case WM_CTLCOLORSTATIC :
    //case WM_CTLCOLOREDIT :
        ret = (WPI_MRESULT)GUICtl3dCtlColorEx( msg, wparam, lparam );
        if( ret == (HBRUSH)NULL ) {
            SetBkColor( (HDC)wparam, GetNearestColor( (HDC)wparam,
                        GUIGetBack( wnd, GUI_BACKGROUND ) ) );
            ret = (WPI_MRESULT)wnd->bk_brush;
        }
        return( ret );
#elif !defined( __OS2_PM__ )
    case WM_CTLCOLOR :
        switch( HIWORD( lparam ) ) {
        case CTLCOLOR_BTN :
        case CTLCOLOR_DLG :
        case CTLCOLOR_EDIT :
        case CTLCOLOR_LISTBOX :
        case CTLCOLOR_MSGBOX :
        case CTLCOLOR_STATIC :
            ret = (WPI_MRESULT)GUICtl3dCtlColorEx( msg, wparam, lparam );
            if( ret == (HBRUSH)NULL ) {
                SetBkColor( (HDC)wparam, GetNearestColor( (HDC)wparam,
                            GUIGetBack( wnd, GUI_BACKGROUND ) ) );
                ret = (WPI_MRESULT)wnd->bk_brush;
            }
            break;
        }
        return( ret );
#endif
#ifndef __OS2_PM__
    case WM_INITMENUPOPUP :
        return( GUIProcessInitMenuPopup( wnd, hwnd, msg, wparam, lparam ) );

    case WM_MENUSELECT :
        return( GUIProcessMenuSelect( wnd, hwnd, msg, wparam, lparam ) );
#endif
    case WM_GETMINMAXINFO :
        info = (WPI_MINMAXINFO _W386FAR *)MK_FP32( (void *)lparam );
        ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam );
        if( wnd->root == NULLHANDLE ) {
            parent = _wpi_getparent( hwnd );
            _wpi_getclientrect( parent, &rect );
            _wpi_setmaxposition( *info, 0, 0 );
            _wpi_setmaxtracksize( info, _wpi_getwidthrect( rect ),
                             _wpi_getheightrect( rect ) );
        }
        return( ret );
    case WM_ERASEBKGND:
#ifdef __OS2_PM__
        //GUIInvalidatePaintHandles( wnd );
        return( (WPI_MRESULT)TRUE );
#else
        if( !_wpi_isiconic( hwnd ) ) {
            GetClientRect( hwnd, &rc );
            FillRect( (HDC)wparam, &rc, wnd->bk_brush );
        }
        use_defproc = TRUE;
        break;
#endif
#if !defined(__OS2_PM__) && !defined(WILLOWS)
    case WM_PAINTICON :
    {
        HICON   old;
        old = SET_HICON( wnd->hwnd, wnd->icon );
        ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam );
        SET_HICON( wnd->hwnd, old );
        return( ret );
    }
#endif
    case WM_PAINT:
        if( _wpi_isiconic( hwnd ) ) {
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
        } else {
            GUIPaint( wnd, hwnd, FALSE );
        }
        break;
#ifndef __OS2_PM__
    case WM_ACTIVATEAPP :
        root = GUIGetRootWindow();
        ActivateNC( root, wparam );
        if( GUICurrWnd != NULL ) {
            ActivateNC( GUICurrWnd, wparam );
        }
        use_defproc = (bool)wparam; // I'm cheating and using 'use_defproc'
                                    // outside of its self-documented purpose
        if( root ) GUIEVENTWND( root, GUI_ACTIVATEAPP, &use_defproc );
        use_defproc = TRUE;
        break;
#if 0
    // this repaints the nc client area when the window loses focus to
    // a window that is not a descendant of a GUI window
    case WM_KILLFOCUS :
        if( !GUIIsGUIChild( (HWND)wparam ) ) {
            ActivateNC( wnd, FALSE );
        }
        break;
#endif
    case WM_SETFOCUS :
        if( !_wpi_ismsgsetfocus( msg, lparam ) ) {
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
        }
        if( !EditControlHasFocus ) {
            if( SetFocusToParent() ) {
                return( 0L );
            }
        }
        break;
#endif
    case WM_VSCROLL :
    case WM_HSCROLL :
        GUIProcessScrollMsg( wnd, msg, wparam, lparam );
        return( 0L );
#ifdef __NT__
    case WM_MOUSEWHEEL :
        {
        // Try to handle mousewheel messages...
        // Fake them into GUIProcessScrollMsg()
        // as "normal" vertical scroll messages.
        short gcWheelDelta; //wheel delta from roll
        WORD  wKey;

        // The wnd I get is not the same as WM_VSCROLL : above gets...
        // Note to self: Fix it...
        // Seems like the main app window gets the message, rather than
        // the MDI clients...

        gcWheelDelta = HIWORD(wparam);
        wKey = LOWORD(wparam);
        // Scroll wheel upwards  gives  120
        //    "     "   downward   "   -120
        if( wnd != GUICurrWnd ) // Send to child window with focus
            wnd = GUICurrWnd;
        if( gcWheelDelta > 0 ) {
            // positive - scroll up
            if( wKey == MK_CONTROL || wKey == MK_SHIFT )
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_PAGEUP, 0L );
            else
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_LINEUP, 0L );
        } else {
            // negative - scroll down
            if( wKey == MK_CONTROL || wKey == MK_SHIFT )
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_PAGEDOWN, 0L );
            else
               GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_LINEDOWN, 0L );
        }
        // Inform GUI system we are done with scrolling for now.
        GUIProcessScrollMsg( wnd, WM_VSCROLL, SB_ENDSCROLL, 0 );
        }
        return( 0L );
#endif
    case WM_MOVE :
        use_defproc = TRUE;
        if( wnd->flags & DOING_CLOSE ) {
            break;
        }
        if( !GUIParentHasFlags( wnd, IS_MINIMIZED ) ) {
            GUIEVENTWND( wnd, GUI_MOVE, NULL );
        }
        use_defproc = TRUE;
        break;
    case WM_SIZE:
        use_defproc = TRUE;
        if( wnd->flags & DOING_CLOSE ) {
            break;
        }
        if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) {
            wnd->flags |= IS_MINIMIZED;
            if( wnd->style & GUI_CHANGEABLE_FONT ) {
                GUIEnableSysMenuItem( wnd, GUI_CHANGE_FONT, FALSE );
            }
            GUIEVENTWND( wnd, GUI_ICONIFIED, NULL );
            if( GUIMDI ) {
                GUIBringNewToFront( wnd );
            }
        } else {
            wnd->flags &= ~IS_MINIMIZED;
            size.x = _wpi_getwmsizex( wparam, lparam );
            size.y = _wpi_getwmsizey( wparam, lparam );
            GUIDoResize( wnd, hwnd, &size );
            if( wnd->flags & IS_ROOT ) {
                win = GUIGetParentFrameHWND( wnd );
                if( !_wpi_isiconic( win ) ) {
                    GUIMaximizeZoomedChildren( wnd );
                }
            }
        }
        //Call back to tell about resizing so system tray can be used
        WndSizeChange( hwnd, wparam, lparam );
        break;
    case WM_MOUSEMOVE:
        currentpoint.x = GET_WM_MOUSEMOVE_POSX( wparam, lparam );
        currentpoint.y = GET_WM_MOUSEMOVE_POSY( wparam, lparam );
        point.x = currentpoint.x;
        point.y = currentpoint.y;
        GUIScreenToScaleR( &point );
        if( ( currentpoint.x != prevpoint.x ) ||
            ( currentpoint.y != prevpoint.y ) ) {
            prevpoint.x = currentpoint.x;
            prevpoint.y = currentpoint.y;
            SendPointEvent( wparam, lparam, wnd, GUI_MOUSEMOVE, TRUE );
        }
        break;
#ifndef __OS2_PM__
    case WM_NCLBUTTONDOWN :
    case WM_NCMBUTTONDOWN :
    case WM_NCRBUTTONDOWN :
        CheckDoFront( wnd );
        use_defproc = TRUE;
        break;
    case WM_RBUTTONDOWN:
        _wpi_setcapture( hwnd );
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDOWN, TRUE );
        break;
#else
    case WM_RBUTTONDOWN :
        WPI_MAKEPOINT( wparam, lparam, currentpoint );
        win = PM1632WinWindowFromPoint( hwnd, &currentpoint, FALSE );
        if( ( win != (HWND)NULL) && ( win != hwnd ) ) {
            control_id = _wpi_getdlgctrlid( win );
            if( control_id != 0 ) {
                GUIEVENTWND( wnd, GUI_CONTROL_RCLICKED, &control_id );
            }
        } else {
            _wpi_setcapture( hwnd );
            CheckDoFront( wnd );
            SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDOWN, TRUE );
        }
        break;
#endif
    case WM_LBUTTONDOWN:
        _wpi_setcapture( hwnd );
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONDOWN, TRUE );
        use_defproc = TRUE;
        break;
    case WM_LBUTTONUP:
        _wpi_releasecapture();
        SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONUP, TRUE );
        use_defproc = TRUE;
        break;
    case WM_RBUTTONUP:
        _wpi_releasecapture();
        SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONUP, TRUE );
        break;
    case WM_LBUTTONDBLCLK:
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_LBUTTONDBLCLK, TRUE );
        break;
    case WM_RBUTTONDBLCLK:
        CheckDoFront( wnd );
        SendPointEvent( wparam, lparam, wnd, GUI_RBUTTONDBLCLK, TRUE );
        break;
    case WM_SYSCOMMAND:
        param = _wpi_getid( wparam );
        switch( param ) {
            case SC_NEXTWINDOW :
                if( GUIMDI ) {
                    NextWndToFront( hwnd );
                    return( 0L );
                }
            default :
                if( ( param & 0xf000 ) == ( SC_NEXTWINDOW & 0xf000 ) ) {
                    /* top value same for all SC_* values */
                    return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
                } else {
                    ProcessMenu( wnd, param );
                }
                break;
        }
        break;
#ifdef __OS2_PM__
    case WM_CONTROL :
        GUIProcessControlNotification( SHORT1FROMMP(wparam),
                                       SHORT2FROMMP(wparam), wnd );
        break;
#else
    case WM_PARENTNOTIFY:
        if( ( LOWORD(wparam) == WM_RBUTTONDOWN ) ||
            ( LOWORD(wparam) == WM_LBUTTONDOWN ) ||
            ( LOWORD(wparam) == WM_MBUTTONDOWN ) ) {
            if( wnd->root == NULLHANDLE ) {
                CheckDoFront( wnd );
            }
        }

        if( LOWORD(wparam) == WM_RBUTTONDOWN ) {
            WPI_MAKEPOINT( wparam, lparam, currentpoint );
            MapWindowPoints( hwnd, (HWND)NULL, &currentpoint, 1 );
            win = _wpi_windowfrompoint( currentpoint );
            control_id = _wpi_getdlgctrlid( win );
            if( control_id != 0 ) {
                if( _wpi_getparent(win) == hwnd ) {
                    GUIEVENTWND( wnd, GUI_CONTROL_RCLICKED, &control_id );
                }
            }
        }
        break;
    case WM_ENDSESSION : {
        gui_end_session     es;

        es.endsession = (bool)wparam;
        es.logoff = (bool)( lparam == 0x80000000L );
        GUIEVENTWND( wnd, GUI_ENDSESSION, &es );
        return( 0L );
    }
    case WM_QUERYENDSESSION : {
        gui_end_session     es;

        es.endsession = (bool)wparam;
        es.logoff = (bool)( lparam == 0x80000000L ); // ENDSESSION_LOGOFF
        if( !GUIEVENTWND( wnd, GUI_QUERYENDSESSION, &es ) ) {
            return( TRUE );
        }
        return( 0L );
    }
#endif
    case WM_COMMAND:
        if( _wpi_ismenucommand( wparam, lparam ) ||
            IsToolBarCommand( wnd, wparam, lparam ) ) { /* from menu or toolbar */
            ProcessMenu( wnd, _wpi_getid( wparam ) );
            //SetFocusToParent();
        } else {
            GUIProcessControlMsg( wparam, lparam, wnd, NULL );
        }
        use_defproc = TRUE;
        break;
#ifndef __OS2_PM__
    case WM_VKEYTOITEM :
        use_defproc = FALSE;
        ret = -1;
        GUIGetKeyState( &key_state.state );
        if( ( GUIWindowsMapKey( wparam, lparam, &key_state.key ) ) ) {
            ret = GUIEVENTWND( wnd, GUI_KEYTOITEM, &key_state );
        }
        break;
#endif
#ifdef __OS2_PM__
    case WM_CHAR :
    case WM_TRANSLATEACCEL :
#else
    case WM_MENUCHAR :
    case WM_SYSKEYDOWN :
    case WM_SYSKEYUP :
    case WM_KEYUP :
    case WM_KEYDOWN :
#endif
        return( GUIProcesskey( hwnd, msg, wparam, lparam ) );
    case WM_CLOSE :
        if( wnd->flags & DOING_CLOSE ) {
            return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
        } else if( wnd->style & GUI_CLOSEABLE ) {
            if( GUIEVENTWND( wnd, GUI_CLOSE, NULL ) ) {
                wnd->flags |= DOING_CLOSE;
                if( wnd->flags & IS_ROOT ) {
                    return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
                } else {
                    _wpi_destroywindow( wnd->hwnd_frame );
                }
            }
        }
        return( 0L );

    // Message to deal with tray icons (Win 95 and NT 4.0 ).
    case WM_TRAYCALLBACK :
        TrayCallBack( hwnd, wparam, lparam );
        return( 0L );

    case WM_DESTROY :
        wnd->flags |= DOING_DESTROY;
        NumWindows--;
        GUIEVENTWND( wnd, GUI_DESTROY, NULL );
        //ret = _wpi_defwindowproc( hwnd, msg, wparam, lparam );
        GUIDestroyAllChildren( wnd );
        if( wnd->flags & IS_ROOT ) {
            GUIDestroyAllPopupsWithNoParent();
        }
        GUIFreeWindowMemory( wnd, FALSE, FALSE );
        if( NumWindows == 0 ) {
            _wpi_postquitmessage( 0 );
            Posted = TRUE;
        }
        return( 0L );
    default:
        use_defproc = TRUE;
    }

    if( use_defproc ) {
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    } else {
        return( ret );
    }
}
コード例 #13
0
WPI_MRESULT CALLBACK GUIFrameProc( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam,
                                   WPI_PARAM2 lparam )
{
    HWND        client;
    bool        call_def;
    WPI_MRESULT ret;
    gui_window  *wnd;

    call_def = TRUE;
    ret      = 0L;

    client = WinWindowFromID( hwnd, FID_CLIENT );
    wnd = GUIGetWindow( client );

    if( wnd != NULL ) {
        switch( msg ) {

        case WM_SAVEAPPLICATION:
            call_def = TRUE; // I'm cheating and using 'call_def'
                             // outside of its self-documented purpose
            GUIEVENTWND( wnd, GUI_ENDSESSION, &call_def );
            return( 0L );

        case WM_TRANSLATEACCEL:  {
                // Don't let OS/2 process F10 as an accelerator
                // Note: similar code exists in guimapky.c but we need to
                // take different default action
                PQMSG   pqmsg = wparam;
                USHORT  flags = SHORT1FROMMP(pqmsg->mp1);
                USHORT  vkey  = SHORT2FROMMP(pqmsg->mp2);

                if( (flags & KC_VIRTUALKEY) && (vkey == VK_F10) )
                    return( (WPI_MRESULT)FALSE );
            }
            break;

        case WM_CHAR:
            return( GUIProcesskey( hwnd, msg, wparam, lparam ) );
            break;
        case WM_INITMENUPOPUP :
            ret = GUIProcessInitMenuPopup( wnd, hwnd, msg, wparam, lparam );
            return( ret );
        case WM_MENUSELECT:
            return( GUIProcessMenuSelect( wnd, hwnd, msg, wparam, lparam ) );
        case WM_SETFOCUS:
            if( !lparam ) {
                ActivateNC( wnd, FALSE );
            }
            break;
        case WM_ACTIVATE:
            if( wparam ) {
                CheckDoFront( wnd );
            }
            break;
        case WM_LBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_RBUTTONDOWN:
            CheckDoFront( wnd );
            break;
        case WM_VSCROLL :
        case WM_HSCROLL :
            GUIProcessScrollMsg( wnd, msg, wparam, lparam );
            call_def = FALSE;
            break;
        }
    }

    if( call_def ) {
        return( _wpi_callwindowproc( oldFrameProc, hwnd, msg, wparam, lparam ) );
    }

    return( ret );
}
コード例 #14
0
/*-------------------------------------------------------------------------
                              ActMsgCommand
--------------------------------------------------------------------------*/
MRESULT ActMsgCommand( WNDATTR *wndattr, MPARAM mp1, MPARAM mp2 )
{
 USHORT cmd;
 int    offset;

   cmd = SHORT1FROMMP( mp1 );

   switch (cmd) {
      case CMD_APPEND:
         CmdAppendFile( wndattr );
         break;
      case CMD_SAVE:
         CmdSaveAs( wndattr );
         break;
      case CMD_COPY:
         CmdCopy( wndattr );
         break;
      case CMD_PASTE:
         CmdPaste( wndattr );
         break;
      case CMD_UNMARK:
         CmdUnmark( wndattr );
         break;
      case CMD_REARRANGE:
         CmdRearrange( wndattr );
         break;
      case CMD_ABOUT:
         CmdAbout( wndattr );
         break;
      case CMD_ACCUM:
         CmdAccum( wndattr );
         break;
      case CMD_FIND:
         CmdFind( wndattr );
         break;
      case CMD_MARKFIND:
         CmdMarkFind( wndattr );
         break;
      case CMD_FINDNEXT:
         offset = FindIt( wndattr->list, wndattr->current, FNEXT );
         CorrectScroll( wndattr, offset );
         break;
      case CMD_FINDPREV:
         offset = FindIt( wndattr->list, wndattr->current, FPREV );
         CorrectScroll( wndattr, offset );
         break;
      case CMD_NEXTMARK:
         MoveToMark( wndattr, FNEXT );
         break;
      case CMD_PREVMARK:
         MoveToMark( wndattr, FPREV );
         break;
      case CMD_MATE:
         CmdMate( wndattr );
         break;
      case CMD_SPAWN:
         CmdSpawn( wndattr );
         break;
      case CMD_QUIT:
         CmdQuit( wndattr );
         break;
      default:
         return MRFROMSHORT( TRUE );
         break;
   }

   return MRFROMSHORT( FALSE );
}
コード例 #15
0
/*--------------------------------------------------
  This function backs the File/Print... dialog box.

  We must determine if the user wants to print to the PM Printer
  or direct to an HP PaintJet.
  If the user clicks OK, we return TRUE and the main line will
  schedule the print; else return FALSE on CANCEL.

  The Help button sends an appropriate message using the
  SMPLHELP system.
 --------------------------------------------------*/
MRESULT EXPENTRY PrintOptionsDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {

     char szPortName[9];
     DLF dlf;    /* OpenDlg parm */
     HFILE hfDummy;
     int rc;

     switch (msg)
          {
          case WM_INITDLG:

               CenterDialogBox(hwnd);

               /* set up the dialog box indicating the PM Printer
                  is the suggested output.  */
               WinSendDlgItemMsg(hwnd, IDD_PRINT_PM, BM_SETCHECK,
                    MPFROMSHORT(1), NULL);
               WinSendDlgItemMsg(hwnd, IDD_PRINT_PORT, BM_SETCHECK,
                    MPFROMSHORT(1), NULL);

               /* and go back */
               return 0;

          case WM_CONTROL:
               {
               SHORT sWho = SHORT1FROMMP(mp1);
               SHORT sWhat = SHORT2FROMMP(mp1);

               switch (sWho)
                    {
                    case IDD_PRINT_PM:
                         switch (sWhat)
                              {
                              case BN_CLICKED:
                                   /* if you want PM, then disable
                                      the PJ entry fields */
                                   WinEnableWindow (
                                       WinWindowFromID(hwnd, IDD_PRINT_FILE),
                                             FALSE);
                                   WinEnableWindow (
                                       WinWindowFromID(hwnd, IDD_PRINT_PORT),
                                             FALSE);
                                   WinEnableWindow (
                                       WinWindowFromID(hwnd, IDD_PRINT_PORTNAME),
                                             FALSE);
                              return 0;

                              }
                    case IDD_PRINT_PJ:
                         switch (sWhat)
                              {
                              case BN_CLICKED:
                                   /* if you want PJ, then enable
                                      the PJ entry fields */
                                   WinEnableWindow (
                                       WinWindowFromID(hwnd, IDD_PRINT_FILE),
                                             TRUE);
                                   WinEnableWindow (
                                       WinWindowFromID(hwnd, IDD_PRINT_PORT),
                                             TRUE);
                                   WinEnableWindow (
                                       WinWindowFromID(hwnd, IDD_PRINT_PORTNAME),
                                             TRUE);
                              return 0;

                              }
                    }
               break;
               }

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case DID_OK:
                         /* on OK, we need to find out what was set
                            and save it in CALCPARM. */
                         if (1 == (USHORT) WinSendDlgItemMsg(hwnd, IDD_PRINT_PM,
                                             BM_QUERYCHECK, NULL, NULL) )
                            {
                            /* we are going to PM */
                            cp.sSubFunction = SUB_PRINT_PM;
                            }
                         else
                            {
                            /* we are going to PaintJet, but File or Port? */
                            if (1 == (USHORT) WinSendDlgItemMsg(hwnd, IDD_PRINT_FILE,
                                               BM_QUERYCHECK, NULL, NULL) )
                               {
                               /* going to File */
                               SetupDLF(&dlf, DLG_SAVEDLG, &hfDummy,
                                        "\\*.prn", szTitleBar,
                                        szPrintAction, szPrintHelp);
                               _fstrcpy(dlf.szOpenFile, cp.szPrintName);
                               rc = DlgFile(hwnd, &dlf);
                               if (rc == TDF_NOSAVE)
                                  {
                                  /* user hit cancel */
                                  WinDismissDlg (hwnd, FALSE);
                                  return 0;
                                  }
                               DosClose(hfDummy);   /* close testing handle */
                               _fstrcpy(cp.szPrintName, dlf.szOpenFile);
                               cp.sSubFunction = SUB_PRINT_PJ;
                               }
                            else
                               {
                               /* we are going to PORT LPTn */
                               cp.sSubFunction = SUB_PRINT_PJ;
                               WinQueryDlgItemText(hwnd, IDD_PRINT_PORTNAME,
                                       sizeof(szPortName), szPortName);
                               _fstrcpy(cp.szPrintName, szPortName);
                               }
                            }

                         /* Indicate good return to caller */
                         WinDismissDlg (hwnd, TRUE) ;
                         return 0 ;

                    case DID_CANCEL:
                         /* just bag it on CANCEL */
                         WinDismissDlg (hwnd, FALSE) ;
                         return 0 ;
                    }
               break ;

          case WM_HELP:
               SimpleHelp(hab, hwnd, szTitleBar,
                       (HMODULE) 0, IDT_TEXT, IDT_HELP_TYPES);

               return 0;

               break;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #16
0
ファイル: kva.c プロジェクト: IAPark/vlc
static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    vout_display_t * vd = WinQueryWindowPtr( hwnd, 0 );
    MRESULT result = ( MRESULT )TRUE;

    if ( !vd )
        return WinDefWindowProc( hwnd, msg, mp1, mp2 );

    vout_display_sys_t * sys = vd->sys;
    RECTL rcl;
    SWP   swp;

    if ( sys->is_mouse_hidden &&
         ((msg >= WM_MOUSEFIRST    && msg <= WM_MOUSELAST) ||
          (msg >= WM_EXTMOUSEFIRST && msg <= WM_EXTMOUSELAST) ||
           msg == WM_MOUSELEAVE))
    {
        WinShowPointer(HWND_DESKTOP, TRUE);
        sys->is_mouse_hidden = false;
    }

    switch( msg )
    {
        /* the user wants to close the window */
        case WM_CLOSE:
            vout_display_SendEventClose(vd);
            result = 0;
            break;

        case WM_MOUSEMOVE :
        {
            SHORT i_mouse_x = SHORT1FROMMP( mp1 );
            SHORT i_mouse_y = SHORT2FROMMP( mp1 );
            RECTL movie_rect;
            int   i_movie_width, i_movie_height;
            int   i_src_width, i_src_height;

            /* Get a current movie area */
            kvaAdjustDstRect( &sys->kvas.rclSrcRect, &movie_rect );
            i_movie_width = movie_rect.xRight - movie_rect.xLeft;
            i_movie_height = movie_rect.yTop - movie_rect.yBottom;

            i_src_width =  sys->kvas.rclSrcRect.xRight -
                           sys->kvas.rclSrcRect.xLeft;
            i_src_height = sys->kvas.rclSrcRect.yBottom -
                           sys->kvas.rclSrcRect.yTop;

            int x = ( i_mouse_x - movie_rect.xLeft ) *
                    i_src_width / i_movie_width +
                    sys->kvas.rclSrcRect.xLeft;
            int y = ( i_mouse_y - movie_rect.yBottom ) *
                    i_src_height / i_movie_height;

            /* Invert Y coordinate and add y offset */
            y = ( i_src_height - y ) + sys->kvas.rclSrcRect.yTop;;

            vout_display_SendEventMouseMoved(vd, x, y);

            result = WinDefWindowProc( hwnd, msg, mp1,mp2 );
            break;
        }

        case WM_BUTTON1DOWN :
            MousePressed( vd, hwnd, MOUSE_BUTTON_LEFT );
            break;

        case WM_BUTTON2DOWN :
            MousePressed( vd, hwnd, MOUSE_BUTTON_RIGHT );
            break;

        case WM_BUTTON3DOWN :
            MousePressed( vd, hwnd, MOUSE_BUTTON_CENTER );
            break;

        case WM_BUTTON1UP :
            MouseReleased( vd, MOUSE_BUTTON_LEFT );
            break;

        case WM_BUTTON2UP :
            MouseReleased( vd, MOUSE_BUTTON_RIGHT );
            break;

        case WM_BUTTON3UP :
            MouseReleased( vd, MOUSE_BUTTON_CENTER );
            break;

        case WM_BUTTON1DBLCLK :
            vout_display_SendEventMouseDoubleClick(vd);
            break;

        case WM_TRANSLATEACCEL :
            /* We have no accelerator table at all */
            result = ( MRESULT )FALSE;
            break;

        case WM_CHAR :
        {
            USHORT i_flags = SHORT1FROMMP( mp1 );
            USHORT i_ch    = SHORT1FROMMP( mp2 );
            USHORT i_vk    = SHORT2FROMMP( mp2 );
            int    i_key   = 0;

            /* If embedded window, let the parent process keys */
            if( sys->parent_window )
            {
                WinPostMsg( sys->parent, msg, mp1, mp2 );
                break;
            }

            if( !( i_flags & KC_KEYUP ))
            {
                if( i_flags & KC_VIRTUALKEY )
                    /* convert the key if possible */
                    i_key = ConvertKey( i_vk );
                else if(( i_flags & KC_CHAR ) && !HIBYTE( i_ch ))
                    i_key = tolower( i_ch );

                if( i_key )
                {
                    if( i_flags & KC_SHIFT )
                       i_key |= KEY_MODIFIER_SHIFT;

                    if( i_flags & KC_CTRL )
                        i_key |= KEY_MODIFIER_CTRL;

                    if( i_flags & KC_ALT )
                        i_key |= KEY_MODIFIER_ALT;

                    vout_display_SendEventKey(vd, i_key);
                }
            }
            break;
        }

        /* Process Manage() call */
        case WM_VLC_MANAGE :
            break;

        /* Fullscreen change */
        case WM_VLC_FULLSCREEN_CHANGE :
            if( LONGFROMMP( mp1 ))
            {
                WinQueryWindowPos( sys->frame, &swp );
                sys->client_rect.xLeft   = swp.x;
                sys->client_rect.yBottom = swp.y;
                sys->client_rect.xRight  = sys->client_rect.xLeft   + swp.cx;
                sys->client_rect.yTop    = sys->client_rect.yBottom + swp.cy;
                WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE );

                rcl.xLeft   = 0;
                rcl.yBottom = 0;
                rcl.xRight  = sys->i_screen_width;
                rcl.yTop    = sys->i_screen_height;
            }
            else
                rcl = sys->client_rect;

            WinCalcFrameRect( sys->frame, &rcl, FALSE );

            WinSetWindowPos( sys->frame, HWND_TOP,
                             rcl.xLeft, rcl.yBottom,
                             rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                             SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW |
                             SWP_ACTIVATE );
            break;

        /* Size change */
        case WM_VLC_SIZE_CHANGE :
            rcl.xLeft   = 0;
            rcl.yBottom = 0;
            rcl.xRight  = LONGFROMMP( mp1 );
            rcl.yTop    = LONGFROMMP( mp2 );
            WinCalcFrameRect( sys->frame, &rcl, FALSE );

            WinSetWindowPos( sys->frame, NULLHANDLE,
                             0, 0,
                             rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                             SWP_SIZE );

            WinQueryWindowPos( sys->frame, &swp );
            sys->client_rect.xLeft   = swp.x;
            sys->client_rect.yBottom = swp.y;
            sys->client_rect.xRight  = sys->client_rect.xLeft   + swp.cx;
            sys->client_rect.yTop    = sys->client_rect.yBottom + swp.cy;
            WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE );
            break;

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

    /* If embedded window, we need to change our window size according to a
     * parent window size */
    if( sys->parent_window )
    {
        WinQueryWindowRect( sys->parent, &rcl );

        if( rcl.xLeft   != sys->parent_rect.xLeft   ||
            rcl.yBottom != sys->parent_rect.yBottom ||
            rcl.xRight  != sys->parent_rect.xRight  ||
            rcl.yTop    != sys->parent_rect.yTop)
        {
            sys->parent_rect = rcl;

            WinCalcFrameRect( sys->frame, &rcl, FALSE );

            WinSetWindowPos( sys->frame, NULLHANDLE,
                             rcl.xLeft, rcl.yBottom,
                             rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom,
                             SWP_SIZE | SWP_MOVE );
        }
    }

    return result;
}
コード例 #17
0
/*--------------------------------------------------
  This function backs the General Selection dialog box.
  It is called during processing of File/New to
  get the L-System or Formula name after a list has
  been generated from the file selected by the user.

  The user may select from the list box.
  The result is returned on OK or double-click in the list box.

  Help sends an appropriate message using the
  SMPLHELP system.
 --------------------------------------------------*/
MRESULT EXPENTRY SelWhatDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {
     SHORT i, isSelected;

     switch (msg)
          {
          case WM_INITDLG:

               CenterDialogBox(hwnd);

               /* Begin by setting the Title */
               WinSetDlgItemText(hwnd, IDD_SEL_LIST_WHAT, gs.pszTitle);

               /* Load the list box from the list of names */
               WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_DELETEALL, MPFROMP(NULL), MPFROMP(NULL) );
               isSelected = 0;   /* default if old not found in current list */
               for (i = 0; i < gs.sCountNames; i++)
                   {
                   WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_INSERTITEM, MPFROM2SHORT(LIT_END, 0),
                          MPFROMP(gs.szNames[i]) );
                   if (0 == _fstrcmp(gs.szNames[i], gs.szSelected) )
                        isSelected = i;
                   }

               /* Flag the current Selection in the list box */
               WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_SELECTITEM, MPFROMSHORT (isSelected),
                                 MPFROMSHORT(TRUE) ) ;
               /* and put it near the middle */
               WinSendDlgItemMsg (hwnd, IDD_SEL_LIST_LB,
                          LM_SETTOPINDEX,
                          MPFROMSHORT(max(isSelected-4, 0) ),
                          MPFROMP(NULL) ) ;

               return 0;

          case WM_CONTROL:
               {
               SHORT sWho = SHORT1FROMMP(mp1);
               SHORT sWhat = SHORT2FROMMP(mp1);

               switch (sWho)
                    {
                    case IDD_SEL_LIST_LB:
                         switch (sWhat)
                              {
                              case LN_ENTER:
                                   /* fake the OK button on double click */
                                   WinSendMsg(hwnd, WM_COMMAND,
                                   MPFROMSHORT(DID_OK),
                                   MPFROM2SHORT(CMDSRC_PUSHBUTTON, FALSE) ) ;
                              return 0;

                              }
                    }
               break;
               }

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case DID_OK:
                         isSelected = (SHORT) WinSendDlgItemMsg(hwnd,
                             IDD_SEL_LIST_LB, LM_QUERYSELECTION,
                             MPFROMSHORT(0), MPFROMP(NULL) );

                         _fstrcpy(gs.szSelected, gs.szNames[isSelected]);

                         npTempParms.fNewParms = TRUE;
                         WinDismissDlg (hwnd, TRUE) ;
                         return 0 ;

                    case DID_CANCEL:
                         npTempParms.fNewParms = FALSE;
                         WinDismissDlg (hwnd, FALSE) ;
                         return 0 ;
                    }
               break ;

          case WM_HELP:
               SimpleHelp(hab, hwnd, szTitleBar,
                       (HMODULE) 0, IDT_TEXT, IDT_HELP_TYPES);

               return 0;

               break;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #18
0
MRESULT os2FrameWindow::ProcessFrameMessage(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  MRESULT mresult = 0;
  bool    isDone = false;

  switch (msg) {
    case WM_WINDOWPOSCHANGED: {
      PSWP pSwp = (PSWP)mp1;

      // Don't save the new position or size of a minimized
      // window, or else it won't be restored correctly.
      if (pSwp->fl & SWP_MOVE && !(pSwp->fl & SWP_MINIMIZE)) {
        POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy };
        ptl.y = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN) - ptl.y;
        mFrameBounds.x = ptl.x;
        mFrameBounds.y = ptl.y;
        mOwner->DispatchMoveEvent(ptl.x, ptl.y);
      }

      // Save the frame's bounds, then call the default wndproc
      // so the client can handle its WM_WINDOWPOSCHANGED msg now.
      if (pSwp->fl & SWP_SIZE && !(pSwp->fl & SWP_MINIMIZE)) {
        mFrameBounds.width = pSwp->cx;
        mFrameBounds.height = pSwp->cy;
        mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2);
        isDone = true;
      }

      if (pSwp->fl & (SWP_MAXIMIZE | SWP_MINIMIZE | SWP_RESTORE)) {
        nsSizeModeEvent event(true, NS_SIZEMODE, mOwner);
        if (pSwp->fl & SWP_MAXIMIZE) {
          event.mSizeMode = nsSizeMode_Maximized;
        } else if (pSwp->fl & SWP_MINIMIZE) {
          event.mSizeMode = nsSizeMode_Minimized;
        } else {
          event.mSizeMode = nsSizeMode_Normal;
        }
        mOwner->InitEvent(event);
        mOwner->DispatchWindowEvent(&event);
      }
      break;
    }

     // A frame window in kiosk/fullscreen mode must have its frame
     // controls reattached before it's minimized & detached after it's
     // restored.  If this doesn't happen at the correct times, clicking
     // on the icon won't restore it, the sysmenu will have the wrong
     // items, and/or the minmax button will have the wrong buttons.

    case WM_ADJUSTWINDOWPOS:
      if (mChromeHidden && ((PSWP)mp1)->fl & SWP_MINIMIZE) {
        WinSetParent(mTitleBar, mFrameWnd, TRUE);
        WinSetParent(mSysMenu, mFrameWnd, TRUE);
        WinSetParent(mMinMax, mFrameWnd, TRUE);
      }
      break;

    case WM_ADJUSTFRAMEPOS:
      if (mChromeHidden && ((PSWP)mp1)->fl & SWP_RESTORE) {
        WinSetParent(mTitleBar, HWND_OBJECT, TRUE);
        WinSetParent(mSysMenu, HWND_OBJECT, TRUE);
        WinSetParent(mMinMax, HWND_OBJECT, TRUE);
      }
      break;

    case WM_DESTROY:
      DEBUGFOCUS(frame WM_DESTROY);
      WinSubclassWindow(mFrameWnd, mPrevFrameProc);
      WinSetWindowPtr(mFrameWnd, QWL_USER, 0);
      break;

    case WM_INITMENU:
      // If we are in fullscreen/kiosk mode, disable maximize menu item.
      if (mChromeHidden &&
          SHORT1FROMMP(mp1) == SC_SYSMENU &&
          WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) {
        MENUITEM menuitem;
        WinSendMsg(WinWindowFromID(mFrameWnd, FID_SYSMENU), MM_QUERYITEM,
                   MPFROM2SHORT(SC_SYSMENU, FALSE), MPARAM(&menuitem));
        mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2);
        WinEnableMenuItem(menuitem.hwndSubMenu, SC_MAXIMIZE, FALSE);
        isDone = true;
      }
      break;

    case WM_SYSCOMMAND:
      // If we are in fullscreen/kiosk mode, don't honor maximize requests.
      if (mChromeHidden &&
          SHORT1FROMMP(mp1) == SC_MAXIMIZE &&
          WinQueryWindowULong(mFrameWnd, QWL_STYLE) & WS_MINIMIZED) {
        isDone = true;
      }
      break;

    // When the frame is activated, set a flag to be acted on after
    // PM has finished changing focus.  When deactivated, dispatch
    // the event immediately because it doesn't affect the focus.
    case WM_ACTIVATE:
      DEBUGFOCUS(WM_ACTIVATE);
      if (mp1) {
        mNeedActivation = true;
      } else {
        mNeedActivation = false;
        DEBUGFOCUS(NS_DEACTIVATE);
        mOwner->DispatchActivationEvent(NS_DEACTIVATE);
        // Prevent the frame from automatically focusing any window
        // when it's reactivated.  Let moz set the focus to avoid
        // having non-widget children of plugins focused in error.
        WinSetWindowULong(mFrameWnd, QWL_HWNDFOCUSSAVE, 0);
      }
      break;
  }

  if (!isDone) {
    mresult = (*mPrevFrameProc)(mFrameWnd, msg, mp1, mp2);
  }

  return mresult;
}
コード例 #19
0
/*--------------------------------------------------
  This function backs the Load/Save Format dialog box.
  It is called during processing of File/Open or File/Save as
  to define the format before proceeding to select a file name.
  Besides setting the format for the Load or Save operation,
  it eventually serves to set the default expected extension.

  The user may select from radio buttons presented.
  The result is returned on OK.

  Help sends an appropriate message using the
  SMPLHELP system.
 --------------------------------------------------*/
MRESULT EXPENTRY LoadSaveFmtDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {
     USHORT i;

     switch (msg)
          {
          case WM_INITDLG:

               CenterDialogBox(hwnd);

               /* Begin by setting the Title */
               WinSetDlgItemText(hwnd, IDD_LST_WHAT,
                          (PSZ) PVOIDFROMMP(mp2) );

               /* suggest the last format we used */
               switch (cp.sLastLoadSaveType)
                  {
                  case SUB_LOADSAVE_GIF: i = IDD_LST_GIF; break;
                  case SUB_LOADSAVE_BMP: i = IDD_LST_BMP; break;
                  case SUB_LOADSAVE_MET: i = IDD_LST_MET; break;
                  case SUB_LOADSAVE_WIN3BMP: i = IDD_LST_WIN3BMP; break;
                  case SUB_LOADSAVE_PCX: i = IDD_LST_PCX; break;
                  default: i = IDD_LST_GIF;
                           cp.sLastLoadSaveType = SUB_LOADSAVE_GIF;
                           break;
                  }

               WinSendDlgItemMsg (hwnd, i, BM_SETCHECK,
                    MPFROMSHORT((USHORT) 1), NULL);

               return 0;

          case WM_CONTROL:
               {
               SHORT sWho = SHORT1FROMMP(mp1);
               SHORT sWhat = SHORT2FROMMP(mp1);

               switch (sWhat)
                    {
                    case BN_CLICKED:
                         switch (sWho)
                              {
                              case IDD_LST_GIF:
                                   cp.sLastLoadSaveType = SUB_LOADSAVE_GIF;
                                   return 0;
                              case IDD_LST_BMP:
                                   cp.sLastLoadSaveType = SUB_LOADSAVE_BMP;
                                   return 0;
                              case IDD_LST_MET:
                                   cp.sLastLoadSaveType = SUB_LOADSAVE_MET;
                                   return 0;
                              case IDD_LST_WIN3BMP:
                                   cp.sLastLoadSaveType = SUB_LOADSAVE_WIN3BMP;
                                   return 0;
                              case IDD_LST_PCX:
                                   cp.sLastLoadSaveType = SUB_LOADSAVE_PCX;
                                   return 0;
                              }
                    }
               break;
               }

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case DID_OK:
                         WinDismissDlg (hwnd, TRUE) ;
                         return 0 ;

                    case DID_CANCEL:
                         WinDismissDlg (hwnd, FALSE) ;
                         return 0 ;
                    }
               break ;

          case WM_HELP:
               SimpleHelp(hab, hwnd, szTitleBar,
                       (HMODULE) 0, IDT_TEXT, IDT_HELP_OPERATE);

               return 0;

               break;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #20
0
ファイル: dlg-joystick.c プロジェクト: martinpiper/VICE
static MRESULT EXPENTRY pm_keyset(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    static int set1 = TRUE;

    static int id = 0;

    switch (msg)
    {
    case WM_INITDLG:
        {
            int j1, j2;

            resources_get_int("JoyDevice1", &j1);
            resources_get_int("JoyDevice2", &j2);
            WinSendMsg(hwnd, WM_KPROCESS,
                       (void*)!!((j1|j2)&JOYDEV_KEYSET1),
                       (void*)!!((j1|j2)&JOYDEV_KEYSET2));
        }
        break;

    case WM_CONTROL:
        {
            int ctrl = SHORT1FROMMP(mp1);
            switch (ctrl)
            {
            case RB_SET1:
            case RB_SET2:
                if (!(ctrl==RB_SET1 && set1) && !(ctrl==RB_SET2 && !set1))
                {
                    set1 = !set1;
                    WinSendMsg(hwnd, WM_KENABLECTRL, 0, 0);
                    WinSendMsg(hwnd, WM_KFILLSPB, 0, 0);
                }
                break;
            case SPB_N:
            case SPB_NE:
            case SPB_E:
            case SPB_SE:
            case SPB_S:
            case SPB_SW:
            case SPB_W:
            case SPB_NW:
            case SPB_FIRE:
                if (SHORT2FROMMP(mp1)==SPBN_SETFOCUS)
                    id = ctrl;
                break;
            }
            break;
        }
    case WM_KPROCESS:
        if (((int)mp1^(int)mp2)&1)
            set1 = (int)mp1;

        WinCheckButton(hwnd, set1?RB_SET1:RB_SET2, 1);
        WinEnableControl(hwnd, RB_SET1, (ULONG)mp1);
        WinEnableControl(hwnd, RB_SET2, (ULONG)mp2);

        WinSendMsg(hwnd, WM_KENABLECTRL, (void*)(!mp1 && !mp2), NULL);
        WinSendMsg(hwnd, WM_KFILLSPB, 0, 0);
        break;

    case WM_TRANSLATEACCEL:
        if (id>=SPB_N && id<= SPB_FIRE)
        {
            //
            // Returning FALSE and using WM_CHAR doesn't work
            // for all keys - I don't know why
            //
            SetKeyVal(hwnd, id, set1, CHAR4FROMMP(((QMSG*)mp1)->mp1));
            return FALSE;
        }
        break;

    case WM_SETKEY:
        {
            ULONG state1 = mp1?1:0;
            ULONG state2 = mp2?1:0;

            WinEnableControl(hwnd, RB_SET1, state1);
            WinEnableControl(hwnd, RB_SET2, state2);
            WinSendMsg(hwnd, WM_KPROCESS, (void*)state1, (void*)state2);
        }
        break;

    case WM_KENABLECTRL:
        WinEnableControl(hwnd, SPB_N,    mp1?0:1);
        WinEnableControl(hwnd, SPB_E,    mp1?0:1);
        WinEnableControl(hwnd, SPB_S,    mp1?0:1);
        WinEnableControl(hwnd, SPB_W,    mp1?0:1);
        WinEnableControl(hwnd, SPB_NE,   mp1?0:1);
        WinEnableControl(hwnd, SPB_SE,   mp1?0:1);
        WinEnableControl(hwnd, SPB_SW,   mp1?0:1);
        WinEnableControl(hwnd, SPB_NW,   mp1?0:1);
        WinEnableControl(hwnd, SPB_FIRE, mp1?0:1);
        return FALSE;

    case WM_KFILLSPB:
        UpdateKeyVal(hwnd, SPB_N,    set1);
        UpdateKeyVal(hwnd, SPB_E,    set1);
        UpdateKeyVal(hwnd, SPB_S,    set1);
        UpdateKeyVal(hwnd, SPB_W,    set1);
        UpdateKeyVal(hwnd, SPB_NE,   set1);
        UpdateKeyVal(hwnd, SPB_SE,   set1);
        UpdateKeyVal(hwnd, SPB_SW,   set1);
        UpdateKeyVal(hwnd, SPB_NW,   set1);
        UpdateKeyVal(hwnd, SPB_FIRE, set1);
        return FALSE;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
コード例 #21
0
ファイル: ddbufdlg.c プロジェクト: OS2World/APP-COMM-ComScope
MRESULT EXPENTRY fnwpCOMscopeBuffDlgProc(HWND hwndDlg,USHORT msg,MPARAM mp1,MPARAM mp2)
  {
  ULONG ulTemp;
  char acBuffer[15];
  static ULONG ulOrgBuffLen;
  static ULONG ulBuffLen;
  USHORT *pusLen;
  static NBKPAGECTL *pstPage;
  static int iResDevider = 1;
  static BOOL bNotFirst;

  switch (msg)
    {
    case WM_INITDLG:
      if (lYScr < 768)
        iResDevider = 2;
      if (!bInsertNewDevice)
        WinSetDlgItemText(hwndDlg,DID_INSERT,"S~ave");
//        ControlEnable(hwndDlg,DID_INSERT,FALSE);
//      CenterDlgBox(hwndDlg);
//      WinSetFocus(HWND_DESKTOP,hwndDlg);
      pstPage = PVOIDFROMMP(mp2);
//      pstPage->bDirtyBit = FALSE;
      bNotFirst = FALSE;
      ulBuffLen = *(USHORT *)pstPage->pVoidPtrOne;
      if (ulBuffLen == 0)
        ulBuffLen = DEF_COMscope_BUFF_LEN;
      ulOrgBuffLen = ulBuffLen;
//      WinSetDlgItemText(hwndDlg,PCFG_BUFF_NAME,"~COMscope buffer");
      WinSetDlgItemText(hwndDlg,PCFG_BUFF_NAME,"COMscope buffer");
      WinSetDlgItemText(hwndDlg,ST_TITLE,"COMscope Capture Buffer Length Configuration");
      WinSetDlgItemText(hwndDlg,ST_DEVICEINTERFACECONFIGURATION,"element");
      InitCOMscopeBufferSize(hwndDlg,ulBuffLen,iResDevider);
      return (MRESULT) TRUE;
    case WM_COMMAND:
      switch (SHORT1FROMMP(mp1))
        {
        case DID_INSERT:
           WinPostMsg(hwndNoteBookDlg,UM_CLOSE,(MPARAM)0,(MPARAM)0);
           break;
        case DID_CANCEL:
          WinPostMsg(hwndNoteBookDlg,WM_COMMAND,MPFROMSHORT(DID_CANCEL),(MPARAM)0);
          return(FALSE);
        case DID_HELP:
           WinPostMsg(hwndNoteBookDlg,WM_COMMAND,MPFROMSHORT(DID_HELP),(MPARAM)0);
        case DID_UNDO:
          if (pstPage->bDirtyBit)
            {
            pstPage->bDirtyBit = FALSE;
            ulBuffLen = ulOrgBuffLen;
            WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,SLM_SETSLIDERINFO,
                              MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE),MPFROMSHORT((ulBuffLen / 128) - 8));
            WinSetDlgItemText(hwndDlg,PCFG_BUFF_DATA,
                             ltoa(ulBuffLen,acBuffer,10));
            }
          return(FALSE);
        }
      break;
    case UM_SET_FOCUS:
      WinSetFocus(HWND_DESKTOP,WinWindowFromID(hwndDlg,SHORT1FROMMP(mp1)));
      break;
    case WM_CONTROL:
      if (SHORT2FROMMP(mp1) & (SLN_SLIDERTRACK | SLN_CHANGE))
        {
        if (bNotFirst)
          pstPage->bDirtyBit = TRUE;
        else
          bNotFirst = TRUE;
        ulTemp = (ULONG)WinSendDlgItemMsg(hwndDlg,PCFG_BUFF_SLIDER,
                                          SLM_QUERYSLIDERINFO,
                                          MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
                                          NULL);
        ulBuffLen = ((ulTemp * 128 * iResDevider) + MIN_COMscope_BUFF_LEN);
        WinSetDlgItemText(hwndDlg,PCFG_BUFF_DATA,ltoa(ulBuffLen,acBuffer,10));
        }
      return((MRESULT)TRUE);
    case UM_SAVE_DATA:
      pusLen = pstPage->pVoidPtrOne;
      *pusLen = (USHORT)ulBuffLen;
      return (MRESULT) TRUE;
    }
  return(WinDefDlgProc(hwndDlg,msg,mp1,mp2));
  }