/****************************************************************************
   SysMenu Dialog Procedure
*****************************************************************************/
MRESULT EXPENTRY SysMenuProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    {
        BOOL    Handled = TRUE;
        MRESULT mReturn  = 0;
        RECTL   Rectl;
        POINTL  Pointl;
        ULONG   temp;
        HPS     hps;
        HBITMAP hbm;

        switch (msg)
            {
                case    WM_PAINT:
                    hps = WinBeginPaint(hWnd, 0, 0);
                    WinQueryWindowRect(hWnd,&Rectl);
                    WinFillRect(hps, &Rectl, CLR_BLACK);
                    hbm = PointerInfo.hbmMiniColor;
                    WinInflateRect(hab, &Rectl, -1L, -1L);
                    WinDrawBitmap(hps, hbm, NULL, (PPOINTL)&Rectl, 0L, 0L, DBM_NORMAL);
                    WinEndPaint(hps);
                    break;
                case WM_ERASEBACKGROUND:
                    WinFillRect((HPS)LONGFROMMP(mp1),PVOIDFROMMP(mp2),CLR_BLACK);
                    mReturn = MRFROMLONG(1L);
                    break;
                default:
                    Handled = FALSE;
                    break;
            }
        if (!Handled) mReturn =  (*SysMenuDefProc)(hWnd, msg, mp1, mp2);
        return (mReturn);
    }
示例#2
0
VOID SetSystemMenu(HWND hwnd)
  {
  HWND     hwndSysMenu;                 /* sys menu pull-down handle */
  MENUITEM miTemp;                      /* menu item template        */
  MRESULT  mresItemId;                  /* system menu item ID       */
  SHORT    sItemIndex;                  /* system menu item index    */

  /*******************************************************************/
  /* Get the handle of the system menu pull-down.                    */
  /*******************************************************************/
  if ((hwndSysMenu = WinWindowFromID(hwnd,FID_SYSMENU)) != 0)
    {
    if (WinSendMsg( hwndSysMenu,
                   MM_QUERYITEM,
                   MPFROM2SHORT( SC_SYSMENU, FALSE ),
                   MPFROMP( (PSZ)&miTemp )))
      {
      hwndSysMenu = miTemp.hwndSubMenu;

      /*******************************************************************/
      /* Remove all items from the system menu pull-down that are no     */
      /* longer wanted.                                                  */
      /*******************************************************************/
      for (sItemIndex = 0,mresItemId = 0L;LONGFROMMP(mresItemId) != (LONG)MIT_ERROR;sItemIndex++)
        {
        mresItemId = WinSendMsg(hwndSysMenu,
                                MM_ITEMIDFROMPOSITION,
                                MPFROMSHORT(sItemIndex),
                                NULL);
        if (LONGFROMMP(mresItemId) != (LONG)MIT_ERROR &&
            SHORT1FROMMP(mresItemId) != SC_MOVE   &&
            SHORT1FROMMP(mresItemId) != SC_CLOSE  &&
            SHORT1FROMMP(mresItemId) != SC_TASKMANAGER)
          {
          WinSendMsg(hwndSysMenu,
                     MM_DELETEITEM,
                     MPFROM2SHORT(SHORT1FROMMP(mresItemId),FALSE),
                     NULL);
          sItemIndex--;
          }
        }
      }
    }
  }
示例#3
0
文件: khserver.c 项目: komh/kime
MRESULT khs_umSetImStatus( HWND hwnd, MPARAM mp1, MPARAM mp2 )
{
    PKHSCD  pkhscd = WinQueryWindowPtr( hwnd, 0 );
    HWND    hwndInput = HWNDFROMMP( mp1 );
    BOOL    line = LONGFROMMP( mp2 );

    if(( BOOL )WinSendMsg( hwnd, KHSM_FINDWND, MPFROMHWND( hwndInput ), 0 ))
    {
        PHWNDLIST list;

        list = hwndlistSearch( pkhscd->list, hwndInput );
        list->line = line;
    }

    return 0;
}
示例#4
0
static MRESULT EXPENTRY _DirDlgSubclassProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
         PDIRDLG        pdd = WinQueryWindowPtr( hwnd, QWL_USER);

switch (msg)
   {
   case WM_COMMAND:
      switch (LONGFROMMP( mp1))
         {
         case DID_CANCEL:
            WinAlarm( HWND_DESKTOP, WA_ERROR);
            break;
         }
      break;
   }

return WtkDefDirDlgProc( hwnd, msg, mp1, mp2);
}
示例#5
0
static MRESULT EXPENTRY pm_joystick(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    switch (msg) {
        case WM_INITDLG:
            {
                int joy1, joy2;
                //
                // disable controls of non existing joysticks
                // remark: I think this cannot change while runtime
                //
                if (!(number_joysticks & JOYDEV_HW1)) {
                    WinEnableControl(hwnd, CB_JOY11, 0);
                    WinEnableControl(hwnd, CB_JOY12, 0);
                }
                if (!(number_joysticks&JOYDEV_HW2)) {
                    WinEnableControl(hwnd, CB_JOY21, 0);
                    WinEnableControl(hwnd, CB_JOY22, 0);
                }
                if (number_joysticks == 0) {
                    WinEnableControl(hwnd, ID_CALIBRATE, 0);
                }

                if (machine_class == VICE_MACHINE_VIC20) {
                    WinEnableControl(hwnd, CB_JOY12, 0);
                    WinEnableControl(hwnd, CB_JOY22, 0);
                    WinEnableControl(hwnd, CB_NUMJOY2, 0);
                    WinEnableControl(hwnd, CB_KS1JOY2, 0);
                    WinEnableControl(hwnd, CB_KS2JOY2, 0);
                    WinEnableControl(hwnd, ID_SWAP, 0);
                }

                resources_get_int("JoyDevice1", &joy1);
                resources_get_int("JoyDevice2", &joy2);
                WinSendMsg(hwnd, WM_SETCBS, (void*)joy1, (void*)joy2);
            }
            break;
        case WM_DESTROY:
        case WM_CLOSE:
            {
                if (WinIsWindowVisible(hwndCalibrate)) {
                    WinSendMsg(hwndCalibrate, WM_CLOSE, 0, 0);
                }

                if (WinIsWindowVisible(hwndKeyset)) {
                    WinSendMsg(hwndKeyset, WM_CLOSE, 0, 0);
                }
            }
            break;
        case WM_COMMAND:
            switch(LONGFROMMP(mp1)) {
                case DID_CLOSE:
                    {
                        if (WinIsWindowVisible(hwndCalibrate)) {
                            WinSendMsg(hwndCalibrate, WM_CLOSE, 0, 0);
                        }

                        if (WinIsWindowVisible(hwndKeyset)) {
                            WinSendMsg(hwndKeyset, WM_CLOSE, 0, 0);
                        }
                    }
                    break;
                case ID_SWAP:
                    {
                        int joy1, joy2;

                        resources_get_int("JoyDevice1", &joy1);
                        resources_get_int("JoyDevice2", &joy2);

                        resources_set_int("JoyDevice1", joy2);
                        resources_set_int("JoyDevice2", joy1);

                        WinSendMsg(hwnd, WM_SETCBS,  (void*)joy2, (void*)joy1);
                    }
                    return FALSE;
                case ID_CALIBRATE:
                    calibrate_dialog(hwnd);
                    return FALSE;
                case ID_KEYSET:
                    keyset_dialog(hwnd);
                    return FALSE;;
            }
            break;
        case WM_CONTROL:
            {
                int button =SHORT1FROMMP(mp1);
                int state = WinQueryButtonCheckstate(hwnd, button);
                int port = button & JOY_PORT1;
                int joya, joyb;

                resources_get_int(port ? "JoyDevice1" : "JoyDevice2", &joya);
                resources_get_int(port ? "JoyDevice2" : "JoyDevice1", &joyb);
                if (state) {
                    joya |= button & JOYDEV_ALL;
                } else {
                    joya &= ~(button & JOYDEV_ALL);
                }

                resources_set_int(port ? "JoyDevice1" : "JoyDevice2", joya);
                WinSendMsg(hwnd, WM_SETDLGS, (void*)(port ? joya : joyb), (void*)(port ? joyb : joya));

             }
             break;
        case WM_SETDLGS:
            {
                int joy1 = (int)mp1;
                int joy2 = (int)mp2;
                int joys = joy1 | joy2;

                if (WinIsWindowVisible(hwndCalibrate)) {
                    WinSendMsg(hwndCalibrate, WM_SETJOY, (MPARAM)(joys & JOYDEV_HW1), (MPARAM)(joys & JOYDEV_HW2));
                }

                if (WinIsWindowVisible(hwndKeyset)) {
                    WinSendMsg(hwndKeyset, WM_SETKEY, (MPARAM)(joys&JOYDEV_KEYSET1), (MPARAM)(joys&JOYDEV_KEYSET2));
                }
            }
            break;
        case WM_SETCBS:
            WinCheckButton(hwnd, CB_JOY11, (JOYDEV_HW1 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_JOY12, (JOYDEV_HW1 & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_JOY21, (JOYDEV_HW2 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_JOY22, (JOYDEV_HW2 & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_NUMJOY1, (JOYDEV_NUMPAD & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_NUMJOY2, (JOYDEV_NUMPAD & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS1JOY1, (JOYDEV_KEYSET1 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS1JOY2, (JOYDEV_KEYSET1 & (int)mp2) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS2JOY1, (JOYDEV_KEYSET2 & (int)mp1) ? 1 : 0);
            WinCheckButton(hwnd, CB_KS2JOY2, (JOYDEV_KEYSET2 & (int)mp2) ? 1 : 0);
            break;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
示例#6
0
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);
}
MRESULT EXPENTRY specialOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  CWDataFolder* thisPtr;
  ULONG ulFlags;
  LONG lSpinValue;
  static HWND hwndStatus;
  int a;
  char chrCD[4];
  char text[CCHMAXPATH];
  char title[CCHMAXPATH];
  char text2[40];

  ULONG rc;
  THISPTR thisPtrStruct;

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

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

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

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

        thisPtr->cwSetMkisofsFlags(ulFlags,MK_ALLFLAGS);
        thisPtr->wpSaveImmediate();
      }
      /* Setup is done */   
    
      return (MRESULT) FALSE;
    case WM_CONTROL:
      switch(SHORT1FROMMP(mp1))
        {
        case IDRB_SHADOWSINROOTONLY:
          enableArchiveCntrls(hwnd, FALSE);
          break;
        case IDRB_FOLLOWALLSHADOWS:
          enableArchiveCntrls(hwnd, TRUE);          
          break;
        default:
          break;
        }
      break;
    case WM_COMMAND:	
      //thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_SPECIALUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
      if(!somIsObj(thisPtr)) 
        return (MRESULT) TRUE;
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_SPECIALUNDO:
          /* User pressed the UNDO button */
          ulFlags=thisPtr->cwQueryMkisofsFlags();
          if(ulFlags & IDMK_SHADOWSINROOTONLY) 
            WinCheckButton(hwnd,IDRB_SHADOWSINROOTONLY,1);
          else
            WinCheckButton(hwnd, IDRB_FOLLOWALLSHADOWS,1);
          /* Use archive bit */
          if(ulFlags & IDMK_USEARCHIVEBIT) 
            WinCheckButton(hwnd, IDCB_USEARCHIVEBIT, 1);
          else
            WinCheckButton(hwnd, IDCB_USEARCHIVEBIT, 0);
          /* Reset archive bit */
          if(ulFlags & IDMK_RESETARCHIVEBIT) 
            WinCheckButton(hwnd, IDCB_RESETARCHIVEBIT,1);
          else
            WinCheckButton(hwnd, IDCB_RESETARCHIVEBIT, 0);          
          break;  
        case IDPB_SPECIALHELP:
          thisPtr->wpDisplayHelp(IDHLP_DATAFOLDERSPECIAL,AFHELPLIBRARY);
          break;
        case IDPB_RESETNOW:
          /* Text: ""
             Title: ""
             */
          rc=messageBox( text, IDSTRD_RESETARCHIVEBITCONFIRM , sizeof(text),
                      title, IDSTRD_RESETARCHIVEBITTITLE, sizeof(title),
                      hDataResource, HWND_DESKTOP, MB_YESNO | MB_ICONQUESTION | MB_MOVEABLE | MB_DEFBUTTON2);          
          if(rc==MBID_YES)
            DosBeep(5000,1000);
          break;
        default:
          break;
        }
      return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2); 
}
示例#8
0
MRESULT EXPENTRY scbProcedure(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   switch(msg)
   {
   case WM_CREATE:
      create(hwnd,PVOIDFROMMP(mp2));
      return WinDefWindowProc(hwnd, msg, mp1, mp2);

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

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

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

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

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

   case WM_PAINT:
      paint(hwnd);
      break;

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

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

   case WMSKN_QUERYPOS:
      return getpos(hwnd);

   case WMSKN_QUERYSIZE:
      return getsize(hwnd);

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

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

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

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

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

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

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

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

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

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

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

   }
   return 0;
}
示例#9
0
void Draw_Thread(ULONG ulThreadArg)
{
if(!(habDT=WinInitialize(0UL)))         /* Initialize client window */
    GEN_ERR(habDT,hwndFrame,hwndClient);
                                        /* Create a message queue */
if(!(hmqDT=WinCreateMsgQueue(habDT,0UL)))
    GEN_ERR(habDT,hwndFrame,hwndClient);
if(!(hpsDT=WinGetPS(hwndClient)))       /* Get a presentation space for client area */
    GEN_ERR(habDT,hwndFrame,hwndClient);
                                        /* Initialize message queue */
WinPostQueueMsg(hmqDT,DT_PAINT,0UL,0UL);
while(qmsqDT.msg!=DT_EXIT)
    {
    if(WinPeekMsg(habDT,                /* Get the message into message queue */
    &qmsqDT,                            /* Message structure */
    NULLHANDLE,                         /* Window filter (none) */
    0UL,                                /* First message ID */
    0UL,                                /* Last message ID */
    PM_REMOVE)==FALSE)                  /* Options (remove message) */
        qmsqDT.msg=DT_IDLE;             /* If no message available, assume idle */
    switch(qmsqDT.msg)
    {
    case DT_PAINT:                      /* Repaint client window */
        {
        RECTL   rclDT;
        int     x,y;
                                        /* Repaint client window aread */
        WinQueryWindowRect(hwndClient,&rclDT);
        WinFillRect(hpsDT,&rclDT,CLR_WHITE);
        for(x=1;x<RB_X;x++)             /* Draw the entries on playing ground */
            for(y=1;y<RB_Y;y++)
                if(RB_Array[x][y]!=RB_EMPTY)
                    Draw_Bitmap(RB_Array[x][y],ROP_SRCCOPY,(x-1)*RB_SIZE,(y-1)*RB_SIZE);
        break;
        }
    case DT_LBUTTON:
        {
        int     x,y;
                                        /* Left button was pressed, get the location,
                                           add \ to RB_Array, and draw \ bitmap, if
                                           field is emty */
        x=(LONGFROMMP(qmsqDT.mp1)/RB_SIZE)+1;
        y=(LONGFROMMP(qmsqDT.mp2)/RB_SIZE)+1;
        if(RB_Array[x][y]==RB_EMPTY)
            {
            RB_Array[x][y]=RB_LX;
            Draw_Bitmap(RB_LX,ROP_SRCCOPY,(x-1)*RB_SIZE,(y-1)*RB_SIZE);
            }
        break;
        }
    case DT_RBUTTON:
        {
        int     x,y;
                                        /* Right button was pressed, get the location,
                                           add / to RB_Array, and draw / bitmap, if
                                           field is emty */
        x=(LONGFROMMP(qmsqDT.mp1)/RB_SIZE)+1;
        y=(LONGFROMMP(qmsqDT.mp2)/RB_SIZE)+1;
        if(RB_Array[x][y]==RB_EMPTY)
            {
            RB_Array[x][y]=RB_RX;
            Draw_Bitmap(RB_RX,ROP_SRCCOPY,(x-1)*RB_SIZE,(y-1)*RB_SIZE);
            }
        break;
        }
     case DT_IDLE:
        {
        if(runRB==TRUE)
            {
            ULONG       x,y,Symbol;
                                        /* Under DOS we would query the time in milliseconds
                                           from the system timer, to adjust graphics. This
                                           is accurate, but in a multitasking in a multitasking
                                           system, we must assume being pre-empted. Therefore
                                           we can't have an exact time bases. Hope that
                                           the system timer counts more often than all 31
                                           milliseconds in future releases/machines */
                                        /* Draw bitmap */
            switch(RB_Dir)              /* Test that RollBall doesn't leave borders. A
                                           border reverses the direction and produces a
                                           beep */
            {
            case UP:
                RB_PosY++;
                if((RB_PosY+RB_SIZE)>=((RB_Y-2)*RB_SIZE))
                    {
                    RB_PosY=(RB_Y-3)*RB_SIZE;
                    RB_Dir=DOWN;
                    DosBeep(800,50);
                    }
                break;
            case DOWN:
                RB_PosY--;
                if(RB_PosY<0)
                    {
                    RB_PosY=0;
                    RB_Dir=UP;
                    DosBeep(800,50);
                    }
                break;
            case LEFT:
                RB_PosX--;
                if(RB_PosX<0)
                    {
                    RB_PosX=0;
                    RB_Dir=RIGHT;
                    DosBeep(800,50);
                    }
                break;
            case RIGHT:
                RB_PosX++;
                if((RB_PosX+RB_SIZE)>=((RB_X-2)*RB_SIZE))
                    {
                    RB_PosX=(RB_X-3)*RB_SIZE;
                    RB_Dir=LEFT;
                    DosBeep(800,50);
                    }
                break;
            }
                                        /* Draw RollBall at new position */
            Draw_Bitmap(RB_RB,ROP_SRCCOPY,RB_PosX,RB_PosY);
                                        /* Now, test if the middle of RollBall is over any
                                           symbol. If a symbol is found, add points, deflect
                                           or end game */
                                        /* RB_Array is 1 based, because 0 indices are the
                                           playing ground borders */
            x=((RB_PosX)/RB_SIZE)+1;
            y=((RB_PosY)/RB_SIZE)+1;
                                        /* A Symbol if RB_SIZE*RB_SIZE in size, that means
                                           RollBall is exactly over a symbol, if the lower
                                           left edges of both symbols match. Then, and only
                                           then, we count points, deflect or loose */
            if((RB_PosX==(x-1)*RB_SIZE) && (RB_PosY==(y-1)*RB_SIZE))
                Symbol=RB_Array[x][y];
            else Symbol=RB_EMPTY;
            switch(Symbol)
            {
            case RB_LX:                 /* We got a \ deflector */
                {
                switch(RB_Dir)          /* \ deflects direction of RollBall */
                {
                case RIGHT:
                    RB_Dir=DOWN; break;
                case UP:
                    RB_Dir=LEFT; break;
                case LEFT:
                    RB_Dir=UP; break;
                case DOWN:
                    RB_Dir=RIGHT; break;
                }                       /* Remove deflector */
                RB_Array[x][y]=RB_EMPTY;
                break;
                }
            case RB_RX:                 /* We got a / deflector */
                {
                switch(RB_Dir)          /* / deflects direction of RollBall */
                {
                case RIGHT:
                    RB_Dir=UP; break;
                case UP:
                    RB_Dir=RIGHT; break;
                case LEFT:
                    RB_Dir=DOWN; break;
                case DOWN:
                    RB_Dir=LEFT; break;
                }                       /* Remove deflector */
                RB_Array[x][y]=RB_EMPTY;
                DosBeep(600,20);
                break;
                }
            case RB_BP:                 /* We got a point */
            case RB_GP:
            case RB_MP:
            case RB_VP:
                {                       /* Add the points for each symbol */
                RB_Point[0]+=RB_Point[Symbol];
                                        /* Remove the point */
                RB_Array[x][y]=RB_EMPTY;
                if (ulDelay)
                    ulDelay--;
                DosBeep(700,20);
                break;
                }
            case RB_HOLE:               /* We got a hole, sorry but RollBall will be killed.
                                           We disable RollBall from rolling, and send a 
                                           ID_STOPTHREAD message to our window, which
                                           informs the user about the points with a message
                                           box */
                {
                int     freq;
                for(freq=5000;freq>100;freq-=100) DosBeep(freq,5);
                runRB=FALSE;            /* Prevent RollBall from further rolling */
                WinPostMsg(hwndClient,WM_COMMAND,(MPARAM)ID_STOPTHREAD,(MPARAM)0);
                break;
                }
            }
                                        /* Randomly add and remove symbols on playing ground */
            if((rand()%500)<2)
                {
                Put_Random_Field();
                Clear_Random_Field();
                }
            }
        }
    }
DosOpen("TIMER0$",
        &hfile,
        &ulAction,
        0,
        0,
        OPEN_ACTION_OPEN_IF_EXISTS,
        OPEN_FLAGS_FAIL_ON_ERROR | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
        NULL);   
ulDelay2=ulDelay/2;
DosDevIOCtl(hfile,
            HRT_IOCTL_CATEGORY,
            HRT_BLOCKUNTIL,
            &ulDelay2,
            ulSize2,
            &ulSize2,
            NULL,
            0,
            NULL);
DosClose(hfile);
}
WinReleasePS(hpsDT);                    /* Clean up */
WinDestroyMsgQueue(hmqDT);
WinTerminate(habDT);
DosExit(EXIT_THREAD,0UL);
}
示例#10
0
MRESULT LoadWizard::DlgProc(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  switch (msg)
  {case WM_INITDLG:
    { MRESULT ret = IntrospectBase::DlgProc(msg, mp1, mp2);
      SetTitle(Title);
      if (Configuration.SourceServer)
      { ComboBox(+GetCtrl(CB_SERVER)).Text(Configuration.SourceServer);
        PostMsg(UM_CONNECT, 0, 0);
      }
      if (Configuration.Source)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_SINKSRC, Configuration.Source));
      if (Configuration.SourcePort)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_PORT, Configuration.SourcePort));
      // Init rate spin button
      { SpinButton sb(GetCtrl(SB_RATE));
        sb.SetArray(SamplingRates, sizeof SamplingRates/sizeof *SamplingRates);
        size_t pos;
        if ( !binary_search<const char,const int>(Configuration.SourceRate, pos, &SamplingRates[0], sizeof SamplingRates/sizeof *SamplingRates, &SamplingRateCmp)
          && ( pos == sizeof SamplingRates/sizeof *SamplingRates
            || (pos && 2*Configuration.SourceRate < atoi(SamplingRates[pos]) + atoi(SamplingRates[pos-1])) ))
          --pos;
        sb.Value(pos);
      }
      WinCheckButton(GetHwnd(), Configuration.SourceChannels == 1 ? RB_MONO : RB_STEREO, TRUE);
      return ret;
    }

   case WM_COMMAND:
    DEBUGLOG(("LoadWizard::DlgProc:WM_COMMAND(%i,%i, %p)\n", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), mp2));
    switch (SHORT1FROMMP(mp1))
    {case DID_OK:
      { Configuration.SourceServer = WinQueryDlgItemXText(GetHwnd(), CB_SERVER);
        const xstring& source = WinQueryDlgItemXText(GetHwnd(), CB_SINKSRC);
        Configuration.Source = source.length() && !source.startsWithI("default") ? source : xstring();
        const xstring& port = WinQueryDlgItemXText(GetHwnd(), CB_PORT);
        Configuration.SourcePort = port.length() && !port.startsWithI("default") ? port : xstring();
        Configuration.SourceRate = atoi(SamplingRates[SpinButton(GetCtrl(SB_RATE)).Value()]);
        Configuration.SourceChannels = WinQueryButtonCheckstate(GetHwnd(), RB_MONO) ? 1 : 2;
      }
      break;
    }
    break;

   case UM_DISCOVER_SERVER:
    { DEBUGLOG(("LoadWizard::DlgProc:UM_DISCOVER_SERVER\n"));
      try
      { Context.GetServerInfo(ServerInfoOp);
        Sources.clear();
        Context.GetSourceInfo(SourceInfoOp);
      } catch (const PAException& ex)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, ex.GetMessage());
      }
      return 0;
    }

   case UM_UPDATE_SERVER:
    { int error = LONGFROMMP(mp1);
      DEBUGLOG(("LoadWizard::DlgProc:UM_UPDATE_SERVER %i\n", error));
      if (error)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, PAConnectException(Context.GetContext(), error).GetMessage());
        return 0;
      }
      WinSetDlgItemText(GetHwnd(), ST_STATUS, "Success");
      ComboBox cb(GetCtrl(CB_SINKSRC));
      // save old value
      const xstring& oldsink = cb.Text();
      // delete old list
      cb.DeleteAll();
      SelectedSource = -1;
      // insert new list and restore old value if reasonable.
      xstring def;
      def.sprintf("default (%s)", Server.default_sink_name.cdata());
      cb.InsertItem(def);
      if (Sources.size() != 0)
      { int defsink = -1;
        for (unsigned i = 0; i < Sources.size(); ++i)
        { PASourceInfo& source = *Sources[i];
          cb.InsertItem(source.name);
          if (SelectedSource < 0 && source.name.compareToI(oldsink) == 0)
            SelectedSource = i;
          if (defsink < 0 && source.name.compareToI(Server.default_sink_name) == 0)
            defsink = i;
        }
        cb.Select(SelectedSource+1);
        if (SelectedSource < 0)
          SelectedSource = defsink;
      }
    }
   case UM_UPDATE_PORT:
    { DEBUGLOG(("LoadWizard::DlgProc:UM_UPDATE_PORT %i\n", SelectedSource));
      ComboBox cb(GetCtrl(CB_PORT));
      // save old value
      const xstring& oldport = cb.Text();
      // delete old list
      cb.DeleteAll();
      // insert new list and restore old value if reasonable.
      xstring def;
      int selected = -1;
      if ((unsigned)SelectedSource < Sources.size())
      { PASourceInfo& source = *Sources[SelectedSource];
        if (source.active_port)
          def.sprintf("default (%s)", source.active_port->name.cdata());
        for (unsigned i = 0; i < source.ports.size(); ++i)
        { PAPortInfo& port = source.ports[i];
          cb.InsertItem(port.name);
          if (selected < 0 && port.name.compareToI(oldport) == 0)
            selected = i;
        }
      }
      cb.InsertItem(def ? def.cdata() : "default", 0);
      cb.Select(selected+1);
      return 0;
    }
  }
  return IntrospectBase::DlgProc(msg, mp1, mp2);
}
示例#11
0
static MRESULT EXPENTRY pm_datasette(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    switch (msg)
    {
    case WM_INITDLG:
        {
            int val;

            WinSendMsg(hwnd, WM_COUNTER,  (void*)ui_status.lastTapeCounter, 0);
            WinSendMsg(hwnd, WM_TAPESTAT,
                       (void*)ui_status.lastTapeCtrlStat,
                       (void*)ui_status.lastTapeStatus);
            WinShowDlg(hwnd, SS_SPIN,
                       ui_status.lastTapeMotor && ui_status.lastTapeStatus);

            resources_get_int("DatasetteResetWithCPU", &val);
            WinCheckButton(hwnd, CB_RESETWCPU, val);
            resources_get_int("DatasetteZeroGapDelay", &val);
            WinSetDlgSpinVal(hwnd, SPB_DELAY, (val/100));
            resources_get_int("DatasetteSpeedTuning", &val);
            WinSetDlgSpinVal(hwnd, SPB_GAP, val);
        }
        break;

    case WM_COUNTER:
        WinSetDlgSpinVal(hwnd, SPB_COUNT, (ULONG)mp1);
        return FALSE;

    case WM_TAPESTAT:
        WinEnableControl(hwnd, PB_RECORD,   mp2 && (int)mp1!=DATASETTE_CONTROL_RECORD);
        WinEnableControl(hwnd, PB_REWIND,   mp2 && (int)mp1!=DATASETTE_CONTROL_REWIND);
        WinEnableControl(hwnd, PB_STOP,     mp2 && (int)mp1!=DATASETTE_CONTROL_STOP);
        WinEnableControl(hwnd, PB_START,    mp2 && (int)mp1!=DATASETTE_CONTROL_START);
        WinEnableControl(hwnd, PB_FORWARD,  mp2 && (int)mp1!=DATASETTE_CONTROL_FORWARD);
        WinEnableControl(hwnd, PB_RESET,    mp2!=0);
        WinEnableControl(hwnd, PB_RESETCNT, mp2!=0);
        WinEnableControl(hwnd, SPB_COUNT,   mp2!=0);

        if (!mp2)
            WinShowDlg(hwnd, SS_SPIN, 0);

        return FALSE;

    case WM_SPINNING:
        WinShowDlg(hwnd, SS_SPIN, mp1 && mp2);
        return FALSE;
 
    case WM_COMMAND:
        switch (LONGFROMMP(mp1))
        {
        case PB_STOP:
        case PB_START:
        case PB_FORWARD:
        case PB_REWIND:
        case PB_RECORD:
        case PB_RESET:
        case PB_RESETCNT:
            datasette_control(LONGFROMMP(mp1)&0xf);
            return FALSE;

        case PB_TATTACH:
            ViceFileDialog(hwnd, 0x0201, FDS_OPEN_DIALOG);
            return FALSE;

        case PB_TDETACH:
            tape_image_detach(1);
            return FALSE;
        }
        break;
    case WM_CONTROL:
        switch (SHORT1FROMMP(mp1))
        {
        case CB_RESETWCPU:
            toggle("DatasetteResetWithCPU");
            break;
        case SPB_DELAY:
            if (SHORT2FROMMP(mp1)==SPBN_ENDSPIN)
            {
                const ULONG val = WinGetSpinVal((HWND)mp2);
                resources_set_int("DatasetteZeroGapDelay", val*100);
            }
            break;
        case SPB_GAP:
            if (SHORT2FROMMP(mp1)==SPBN_ENDSPIN)
            {
                const ULONG val = WinGetSpinVal((HWND)mp2);
                resources_set_int("DatasetteSpeedTuning", val);
            }
            break;
        }
        break;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
示例#12
0
MRESULT EXPENTRY MainWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   BOOL    fHandled = TRUE;
   MRESULT mReturn = 0;

   switch(msg)
   {
      case WM_CREATE:
         return (MRESULT)mwpCreate(hWnd, mp1);

      case WM_PAINT:
         mwpPaint(hWnd);
         break;

      case WM_SIZE:
         mwpSize(hWnd);
         break;

      case WM_CONTROL:
         switch(SHORT1FROMMP(mp1))
         {
            case SLRD_VOLUME:
               if((SHORT2FROMMP(mp1) == SLN_CHANGE) || (SHORT2FROMMP(mp1) == SLN_SLIDERTRACK))
               {
                  USHORT   usDeviceID = WinQueryWindowUShort(hWnd, QWS_DEVICEID);
                  ULONG    ulLevel = (ULONG)WinSendMsg(WinWindowFromID(hWnd, SLRD_VOLUME), SLM_QUERYSLIDERINFO, MPFROMLONG(MAKELONG(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE)), NULL);

                  ULONG          ulError = 0;
                  MCI_SET_PARMS  msp;
                  const ULONG    flParam1 = MCI_WAIT | MCI_SET_AUDIO | MCI_SET_VOLUME;

                  msp.ulLevel = ulLevel;
                  msp.ulAudio = MCI_SET_AUDIO_ALL;

                  mciSendCommand(usDeviceID, MCI_SET, flParam1, (PVOID)&msp, 0);
               }
               break;

            default:
               fHandled = FALSE;
               break;
         }
         break;

      case WM_CLOSE:
         _beginthread(ShutdownThread, NULL, 16384, (void*)hWnd);
         break;

      case MM_MCIPOSITIONCHANGE:
         WinSetPBValue(WinWindowFromID(hWnd, PB_PROGRESS), LONGFROMMP(mp2));
         break;

      case MM_MCINOTIFY:
         mmMCINotify(hWnd, mp1, mp2);
         break;

      case WMU_LOAD:
         mReturn = (MRESULT)mwpLoad(hWnd);
         break;

      case WMU_PLAY:
         mwpPlay(hWnd);
         break;

      default:
         fHandled = FALSE;
   }
   if(!fHandled)
      mReturn = WinDefWindowProc(hWnd, msg, mp1, mp2);

   return mReturn;
}
示例#13
0
文件: dlg-vsid.c 项目: AreaScout/vice
static MRESULT EXPENTRY pm_vsid(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    extern int trigger_shutdown;

    switch (msg) {
        case WM_INITDLG:
            {
                HWND hmenu;
                HPOINTER hicon = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, DLG_VSID);

                if (hicon) {
                    WinSendMsg(hwnd, WM_SETICON, MPFROMLONG(hicon), MPVOID);
                }

                //
                // Try to attach the menu and make it visible
                //
                hmenu = WinLoadMenu(hwnd, NULLHANDLE, IDM_VICE2);
                if (hmenu) {
                    SWP swp;
                    WinQueryWindowPos(hwnd, &swp);

                    WinDelMenuItem(hmenu, IDM_FILE);
                    WinDelMenuItem(hmenu, IDM_VIEW);
                    WinDelMenuItem(hmenu, IDM_SETUP);
                    WinDelMenuItem(hmenu, IDM_MONITOR);

                    swp.cy += WinQuerySysValue(HWND_DESKTOP, SV_CYMENU) + 1;
                    WinSetWindowPos(hwnd, 0, 0, 0, swp.cx, swp.cy, SWP_SIZE);

                    WinSendMsg(hwnd, WM_UPDATEFRAME, MPFROMLONG(FID_MENU), MPVOID);
                }

                WinSubclassDlg(hwnd, ID_TBOX, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TNAME, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TAUTHOR, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TCOPYRIGHT, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TSYNC, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TIRQ, pm_vsid_dragndrop);
                WinSubclassDlg(hwnd, ID_TSID, pm_vsid_dragndrop);
            }
            return FALSE;
        case WM_MENUSELECT:
            menu_select(HWNDFROMMP(mp2), SHORT1FROMMP(mp1));
            break;
        case WM_DESTROY:
            trigger_shutdown = 1;
            break;
        case WM_COMMAND:
            switch (LONGFROMMP(mp1)) {
                case DID_CLOSE:
                    trigger_shutdown = 1;
                    break;
                default:
                    menu_action(hwnd, SHORT1FROMMP(mp1));
                    return FALSE;
            }
            break;
        case WM_CONTROL:
            if (mp1 == MPFROM2SHORT(SPB_SETTUNE, SPBN_ENDSPIN)) {
                const ULONG val = WinGetSpinVal((HWND)mp2);

                resources_set_int("PSIDTune", (int)val);
            }
            break;
        case WM_DISPLAY:
            {
                char *txt = lib_msprintf("Vice/2 SID Player - %d%%", mp1);

                WinSetDlgItemText(hwnd, FID_TITLEBAR, txt);
                lib_free(txt);
            }
            return FALSE;
    }
    return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
static MRESULT APIENTRY PresParamChanged ( HWND Window, MESG msg, MPARAM1 mp1, MPARAM2 mp2 ) {

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

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * Get the presentation parameter that changed.                           *
   **************************************************************************/

   switch ( LONGFROMMP(mp1) ) {

     /***********************************************************************
      * If font, note the fact that we now have a font to be saved as       *
      *   part of the configuration.  Apply the font to the Main window.    *
      ***********************************************************************/

      case PP_FONTNAMESIZE: {
         if ( Data->SettingFont )
            break ;
         Data->SettingFont = TRUE ;
         ULONG ppid ;
         char Font [80] ;
         if ( WinQueryPresParam ( Window, PP_FONTNAMESIZE, 0, &ppid, sizeof(Font), PSZ(Font), 0 ) ) {
            if ( strcmpi ( Font, PCHAR(Data->IniData->RulerFont) ) ) {
               WinSetPresParam ( Data->MainWindow, PP_FONTNAMESIZE, strlen(Font)+1, PSZ(Font) ) ;
            } /* endif */
         } /* endif */
         Data->SettingFont = FALSE ;
         break ; }

     /***********************************************************************
      * If background color, note the fact and repaint the window.          *
      ***********************************************************************/

      case PP_BACKGROUNDCOLOR: {
         ULONG ppid ;
         if ( WinQueryPresParam ( Window, PP_BACKGROUNDCOLOR, 0, &ppid,
            sizeof(Data->IniData->RulerColors[0]), &Data->IniData->RulerColors[0], 0 ) ) {
            Data->IniData->fRulerColors[0] = TRUE ;
         } else {
            Data->IniData->RulerColors[0] = RGB_WHITE ;
            Data->IniData->fRulerColors[0] = FALSE ;
         } /* endif */
         Sys_InvalidateWindow ( Data->MainWindow ) ;
         break ; }

     /***********************************************************************
      * If foreground color, note the fact and repaint the window.          *
      ***********************************************************************/

      case PP_FOREGROUNDCOLOR: {
         ULONG ppid ;
         if ( WinQueryPresParam ( Window, PP_FOREGROUNDCOLOR, 0, &ppid,
            sizeof(Data->IniData->RulerColors[1]), &Data->IniData->RulerColors[1], 0 ) ) {
            Data->IniData->fRulerColors[1] = TRUE ;
         } else {
            Data->IniData->RulerColors[1] = RGB_BLUE ;
            Data->IniData->fRulerColors[1] = FALSE ;
         } /* endif */
         Sys_InvalidateWindow ( Data->MainWindow ) ;
         break ; }

   } /* endswitch */

  /**************************************************************************
   * Return through the default processor, letting window activation        *
   *   and other system functions occur.                                    *
   **************************************************************************/

   return ( Sys_DefWindowProc ( Window, msg, mp1, mp2 ) ) ;
}
static MRESULT APIENTRY SetTick ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

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

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * Get the new tick-mark position from the message.                       *
   **************************************************************************/

   LONG Tick = LONGFROMMP ( mp1 ) ;

  /**************************************************************************
   * If only the tick-mark has changed, move it.                            *
   **************************************************************************/

   if ( Data->Tick != Tick ) {

     /***********************************************************************
      * Get the presentation space.                                         *
      ***********************************************************************/

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

     /***********************************************************************
      * Find out some background information.                               *
      ***********************************************************************/

      RECTL Rectangle ;
      WinQueryWindowRect ( Window, &Rectangle ) ;
      PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

     /***********************************************************************
      * Erase the previous hairline.                                        *
      ***********************************************************************/

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

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

      Data->Tick = Tick ;

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

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

   } /* endif */
 
  /**************************************************************************
   * We're done.                                                            *
   **************************************************************************/

   return ( MRFROMSHORT ( 0 ) ) ;
}
示例#16
0
/****************************************************************************
 * ClientWndProc                                                            *
 *  - Typical PM client window procedure.  (see below)                      *
 *  - Standard client window I/O                                            *
 ****************************************************************************/
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
	   RECTL  rcl;
	   SWP	  swp;
	   HPS	  hpsPaint;

    static HPS	  hps;                      /* Permanent HPS                */
    static INT    cx, cy;		    /* Client window dimensions     */
    static BOOL   bSlowUpdateNow = FALSE;   /* Update toggle for asteroids  *
                                             *   and enemy which are slow.  */
    static POINTL ptlCenter;		    /* Center of client window      */

    switch (msg) {
      /* Recieved from WinCreateStdWindow */
      case WM_CREATE:
	/* Get permanent PS for entire window */
	hps = WinGetPS(hwnd);

	/* Load private Asteroid fonts from ASTEROID.DLL */
	if (GpiLoadFonts(hab, "ASTEROID") != GPI_OK) {
            WinReleasePS(hps);
	    WinAlarm(HWND_DESKTOP, WA_WARNING);
	    WinMessageBox(HWND_DESKTOP,NULLHANDLE,
		"Please put ASTEROID.DLL in a directory in your LIBPATH.",
		"Error reading ASTEROID.DLL",
		0,MB_ICONHAND|MB_OK|MB_APPLMODAL);
	    WinPostMsg(hwnd,WM_QUIT,(MPARAM) 0L,(MPARAM) 0L);
	    return (MRESULT) TRUE;
	    }

        /* Register/create logical fonts for use */
	InitFonts(hps);

	/* Display About dialoge box */
	WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)AboutDlgProc, NULLHANDLE,
		  IDD_ABOUT, NULL);

	return 0;

      /* Recieved during attract mode when user starts game */
      case WM_STARTGAME:
        /* Determine the number of players */
	cPlayers = (INT)LONGFROMMP(mp1);

        /* Initialize each player */
	for (Player=0;Player<cPlayers;Player++) {
	    Level[Player] = 1;
	    Ships[Player] = prfProfile.iSHIPS;
	    DeletePhotons();
	    InitAsteroids();
	    InitEnemy();
	    }

        /* Start with player 1 */
	Player = 0;
	iGameMode = GAME_MODE_NEXT;
	iGameModeCnt = GAME_PAUSE_TIME-1;

	/* Hide the pointer if mouse controls are enabled */
	ShowMouse(FALSE);
        
        /* Paint everything */
	WinSendMsg(hwnd, WM_PAINT, MPVOID, MPVOID);

	return 0;

      /* Recieved at startup and at the completion of a game */
      case WM_INITGAME:
        /* Make mouse visible if we hid it before */
        ShowMouse(TRUE);
        
	/* Fix menu to reflect attract mode */
	EnableMenuItem(hwndMenu, IDM_START, TRUE);
	EnableMenuItem(hwndMenu, IDM_STOP, FALSE);

	/* Initialize player and enemy data structures */
	cPlayers = 0;
	Level[0] = 1;
	for (Player=0;Player<2;Player++) {
	    Score[Player] = 0L;
	    Ships[Player] = 0;
	    DeletePhotons();
	    }
	Player = 0;

	/* Initialize asteroids (and enemy) for attract mode */
	InitAsteroids();
	InitEnemy();

        /* Depending on whether ASTEROID was just started or a game just  *
         *   completed display the "High Score" or "Press 1 or 2" screen. */
	if (SHORT1FROMMP(mp1) == 0) {
	    iGameMode = GAME_MODE_INIT1;
	    iGameModeCnt = GAME_INIT_TIME;
	    }
	else {
	    iGameMode = GAME_MODE_INIT2;
	    iGameModeCnt = GAME_INIT_TIME;
	    }

        /* Paint everything */
	WinSendMsg(hwnd, WM_PAINT, MPVOID, MPVOID);
	return 0;

      /* Usually recieved from the system, sometime forced by the program to *
       *   ensure the screen is not corrupt.                                 */
      case WM_PAINT:
	/* Clear entire window to insure no "droppings" */
	WinQueryWindowRect(hwnd,&rcl);
        WinFillRect(hps, &rcl, CLR_BLACK);
	WinInvalidateRect(hwnd, &rcl, FALSE);

	/* Get the update region and paint it black */
	hpsPaint = WinBeginPaint(hwnd, (HPS)NULL, &rcl);
	WinFillRect(hpsPaint, &rcl, CLR_BLACK);
	WinEndPaint(hpsPaint);

        /* Only in normal play mode should we draw the ship */
	if ((iGameMode == GAME_MODE_PLAY) &&
	    (iShipMode[Player] != EXPLOSION) &&
	    (iShipMode[Player] != HYPERSPACE))
	    DrawShip(hps, cx, cy, DRAW_INIT);
	else if ((iGameMode == GAME_MODE_PLAY) &&
		 (iShipMode[Player] == EXPLOSION))
	    ExplodeShip(hps, cx, cy);

        /* Draw the enemy if it is on the screen */
	if (iEnemyMode[Player] != NONE)
	    if (iEnemyMode[Player] != EXPLOSION)
		DrawEnemy(hps, cx, cy,DRAW_INIT);
	    else
		ExplodeEnemy(hps, cx, cy);

        /* Draw photons and asteroids in all modes but the "Enter your *
         *   initials" mode, otherwise draw that screen.               */
	if (iGameMode != GAME_MODE_HIGH) {
	    DrawPhotons(hps, cx, cy, DRAW_INIT);
	    DrawAsteroids(hps, cx, cy, DRAW_INIT);
	    }
	else
	    DrawHighScore(hps, cx, cy, DRAW_INIT);

        /* Always draw the score */
	DrawScore(hps, cx, cy, DRAW_INIT);

	return 0;

      /* Left mouse button down.  This simulates the move/track function *
       *   in the system menu.                                           */
      case WM_BUTTON1DOWN:
        if (prfProfile.bMOUSECONTROL &&
            iGameMode != GAME_MODE_INIT1 &&
            iGameMode != GAME_MODE_INIT2 &&
            !TogglePause(CHECK)) {
	    UPDATE_FIRE(iShipMode[Player], TRUE);
            return (MRESULT)TRUE;
        }
	return WinSendMsg(hwndFrame, WM_TRACKFRAME,
			 (MPARAM) (SHORT1FROMMP(mp2) | TF_MOVE), MPVOID);

      case WM_BUTTON1UP:
        if (prfProfile.bMOUSECONTROL) {
	    UPDATE_FIRE(iShipMode[Player], FALSE);
            return (MRESULT)TRUE;
        }
        return 0;
        
      /* Left mouse button double clicked.  Toggle frame control display. */
      case WM_BUTTON1DBLCLK:
        if (!prfProfile.bMOUSECONTROL ||
            iGameMode == GAME_MODE_INIT1 ||
            iGameMode == GAME_MODE_INIT2 ||
            TogglePause(CHECK)) {
            if (prfProfile.bCONTROLS = !prfProfile.bCONTROLS)
	    	ShowFrameControls();
            else
	    	HideFrameControls();
        }
	return 0;

      case WM_BUTTON2DOWN:
        if (prfProfile.bMOUSECONTROL) {
	    UPDATE_SHIELD(iShipMode[Player], iShipShieldCnt[Player]);
            return (MRESULT)TRUE;
        }
        return 0;
        
      case WM_BUTTON2CLICK:
        if (prfProfile.bMOUSECONTROL) {
            UPDATE_HYPERSPACE(iShipMode[Player], iShipModeCnt[Player]);
            return (MRESULT)TRUE;
        }
        return 0;
        
      /* Right mouse button double clicked.  Display the about dialog box. */
      case WM_BUTTON2DBLCLK:
        if (!prfProfile.bMOUSECONTROL ||
            iGameMode == GAME_MODE_INIT1 ||
            iGameMode == GAME_MODE_INIT2 ||
            TogglePause(CHECK)) {
            WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)AboutDlgProc,
            	      NULLHANDLE, IDD_ABOUT, NULL);
        }
	return 0;

      /* User typed a key.  Most of this is self explanatory. */
      case WM_CHAR:
	ProcessChar((CHAR) (CHARMSG(&msg)->vkey-1),
		    CHARMSG(&msg)->fs & KC_VIRTUALKEY,
		    (CHAR) (CHARMSG(&msg)->chr),
		    (BOOL) !(CHARMSG(&msg)->fs & KC_KEYUP));
	return 0;

      /* User entered a command via the menu bar. */
      case WM_COMMAND:
	DoCommand(hwnd, msg, mp1, mp2);
	return 0;

      /* Suspend/un-suspend game depending on focus */
      case WM_SETFOCUS:
	if ((BOOL) SHORT1FROMMP(mp2))
	    TogglePause(SUSPEND_OFF);
	else if (!prfProfile.bBACKGRND)
	    TogglePause(SUSPEND_ON);
	return 0;

      /* Keep track of the client window size.  Profile information is not *
       *   updated here because there are better places (i.e. at exit)     */
      case WM_SIZE:
	cx = (INT)SHORT1FROMMP(mp2);
	cy = (INT)SHORT2FROMMP(mp2);

      /* Keep track of client window position.  Also updates profile info. */
      case WM_MOVE:
	WinQueryWindowPos(hwndFrame,&swp);
	if (!(swp.fl & SWP_MAXIMIZE) && !(swp.fl & SWP_MINIMIZE)) {
	    prfProfile.x  = swp.x;prfProfile.y   = swp.y;
	    prfProfile.cx = swp.cx;prfProfile.cy = swp.cy;
	    }

	if (swp.fl & SWP_MINIMIZE)
	    if (!prfProfile.bBACKGRND) {
		/* Set icon */
		WinSendMsg(hwndFrame, WM_SETICON,
		    (MPARAM) WinLoadPointer(HWND_DESKTOP, NULLHANDLE,
					    ID_RESOURCE), MPVOID);

		TogglePause(SUSPEND_ON);
		}
	    else
		WinSendMsg(hwndFrame, WM_SETICON, MPVOID, MPVOID);
	else
	    TogglePause(SUSPEND_OFF);

	ptlCenter.x = swp.cx / 2;
        ptlCenter.y = swp.cy / 2;
        WinMapWindowPoints(hwndClient, HWND_DESKTOP, &ptlCenter, 1L);

	return 0;

      /* Recieved approximately 31 times a second.  This is the longest and *
       *   ugliest of the messages, partly because there are so many cases  *
       *   to keep track of, partly because it must be highly optimized.    */
      case WM_TIMER:
        if (prfProfile.bMOUSECONTROL &&
            iGameMode != GAME_MODE_INIT1 &&
            iGameMode != GAME_MODE_INIT2) {                   POINTL ptl;
            static BOOL   bUp, bLeft, bRight;

            WinQueryPointerPos(HWND_DESKTOP, &ptl);
            if (bUp || (ptl.y - ptlCenter.y > 0))
	       	UPDATE_THRUST(iShipMode[Player],
            		      bUp = (ptl.y - ptlCenter.y > 0));
            if (bLeft || (ptlCenter.x - ptl.x > 0))
                UPDATE_LEFT(iShipMode[Player],
                	    bLeft = (ptlCenter.x - ptl.x > 0));
            if (bRight || (ptlCenter.x - ptl.x < 0))
                UPDATE_RIGHT(iShipMode[Player],
                 	     bRight = (ptlCenter.x - ptl.x < 0));
            WinSetPointerPos(HWND_DESKTOP, ptlCenter.x, ptlCenter.y);
        }
        
        /* Determine the current game mode */
	switch (iGameMode) {

          /* Either initialization/attract mode screen. */
	  case GAME_MODE_INIT1: case GAME_MODE_INIT2:
            /* Switch screens when count expires */
	    if (--iGameModeCnt == 0) {
		if (iGameMode == GAME_MODE_INIT1)
		    iGameMode = GAME_MODE_INIT2;
		else
		    iGameMode = GAME_MODE_INIT1;
		iGameModeCnt = GAME_INIT_TIME;

                /* Score must be redrawn because the attract mode screens *
                 *   draw the score differently.                          */
		DrawScore(hps, cx, cy, DRAW_REINIT);
		}

            /* Update photons, asteroids, enemy, and score */
	    UpdatePhotons(hps, cx, cy);
	    if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) {
		UpdateAsteroids(hps, cx, cy);
		UpdateEnemy(hps, cx, cy);
		DrawScore(hps, cx, cy, DRAW_REFRESH);
		}
	    break;

          /* Completion of one player's turn or new game */
	  case GAME_MODE_NEXT:
            /* Initially, erase and redraw everything for new player */
	    if (iGameModeCnt-- == GAME_PAUSE_TIME) {
		if ((cPlayers == MAXPLAYERS) &&
                    (Ships[(Player+1) % MAXPLAYERS])) {
		    DrawAsteroids(hps, cx, cy, DRAW_ERASE);
		    DrawPhotons(hps, cx, cy, DRAW_ERASE);
		    Player = (Player+1) % MAXPLAYERS;
		    }
		DrawScore(hps, cx, cy, DRAW_REINIT);
		DrawAsteroids(hps, cx, cy, DRAW_INIT);
		}
            /* During countdown update score and asteroids */
	    else if (iGameModeCnt > 0) {
		if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) {
		    DrawScore(hps, cx, cy, DRAW_REFRESH);
		    UpdateAsteroids(hps, cx, cy);
		    }
		}
            /* At end of countdown start the player */
	    else {
		InitShip();
		InitEnemy();
		iGameMode = GAME_MODE_PLAY;
		DrawScore(hps, cx, cy, DRAW_REINIT);
		}
	    break;

          /* Normal play mode */
	  case GAME_MODE_PLAY:
            /* Update ship, photons, asteroids, enemy, and score */
	    UpdateShip(hps, cx, cy);
	    UpdatePhotons(hps, cx, cy);
	    if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) {
		UpdateAsteroids(hps, cx, cy);
		UpdateEnemy(hps, cx, cy);
                /* Erase old and draw new scores if there is a change*/
		if (bChangeScore) {
		    bChangeScore = FALSE;
		    DrawScore(hps, cx, cy, DRAW_REINIT);
		    }
                /* Else just refresh the score */
		else
		    DrawScore(hps, cx, cy, DRAW_REFRESH);
		}
	    break;

          /* Game over mode.  This is the longest and ugliest case because  *
           *   conditions are highly dependent on the number of players,    *
           *   multiplayer game status, and the number and order of high    *
           *   scores.                                                      */
	  case GAME_MODE_OVER:
            /* Initially, just update the score and number of ships */
	    if (iGameModeCnt-- == GAME_PAUSE_TIME)
		DrawScore(hps, cx, cy, DRAW_REINIT);

            /* During countdown refresh the score and update the asteroids */
	    else if (iGameModeCnt > 0) {
		if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) {
		    DrawScore(hps, cx, cy, DRAW_REFRESH);
		    UpdateAsteroids(hps, cx, cy);
		    }
		}

            /* At the end of the countdown, if there are any other players, *
             *   continue with them.                                        */
	    else {
                /* Countinue on with any remaining players. */
		if ((cPlayers == MAXPLAYERS) &&
                    (Ships[(Player+1) % MAXPLAYERS])) {
                    /* Erase all of the old asteroids. */
		    DrawAsteroids(hps, cx, cy, DRAW_ERASE);

                    /* Setup everything for the next player */
		    Player = (Player+1) % MAXPLAYERS;
		    InitShip();
		    InitEnemy();
		    iGameMode = GAME_MODE_PLAY;
		    DrawAsteroids(hps, cx, cy, DRAW_INIT);
		    DrawScore(hps, cx, cy, DRAW_REINIT);
		    }

                /* Check for new high scores and update table as necessary. */
		else {
                    /* Erase all of the old asteroids. */
		    DrawAsteroids(hps, cx, cy, DRAW_ERASE);


                /* The following if/else block is admittedly a kludge, it is *
                 *   simple and it does work, however.  Ideally it should    *
                 *   sort the high scores and update the high score table in *
                 *   descending order.                                       */

                    /* If player 1 scored higher than player 2 then check *
                     *   player 1 first for a high score.                 */
       		    if (Score[0] > Score[1])
			for (Player=0;Player<cPlayers;Player++)
                            /* If the player's score is > than the lowest, *
                             *   update the high score table.              */
			    if (Score[Player] > prfProfile.lSCORES[9]) {
				UpdateHighScores();
				iGameMode = GAME_MODE_HIGH;
				}
                            /* Otherwise, make sure he is not asked for his *
                             *   initials.                                  */
			    else
				Score[Player] = 0;

                    /* Otherwise, check player 2 first */
		    else
			for (Player=cPlayers;Player>=0;Player--)
                            /* If the player's score is > than the lowest, *
                             *   update the high score table.              */
			    if (Score[Player] > prfProfile.lSCORES[9]) {
				UpdateHighScores();
				iGameMode = GAME_MODE_HIGH;
				}
                            /* Otherwise, make sure he is not asked for his *
                             *   initials.                                  */
			    else
				Score[Player] = 0L;

                    /* If there was no high score, go into attract mode */
		    if (iGameMode != GAME_MODE_HIGH)
			WinSendMsg(hwnd,WM_INITGAME,MPFROMSHORT(1),(MPARAM) 0L);
                    /* Else, check for player 1's initials first then 2's   *
                     * This is not faithful, in the arcade game the player  *
                     *   with the higher score always goes first.           */
		    else {
			if (Score[0] > 0L)
			    Player = 0;
			else
			    Player = 1;
			DrawScore(hps, cx, cy, DRAW_REINIT);
			DrawHighScore(hps, cx, cy, DRAW_INIT);
			}
		    }
		}
	    break;

          /* Mode which prompts players to enter their initials */
	  case GAME_MODE_HIGH:
            /* If the player's position is > 0 then refresh the screen */
	    if (Score[Player] > 0L)
		DrawHighScore(hps, cx, cy, DRAW_REFRESH);
            /* Else, the current player is done go to the next */
	    else if ((cPlayers == MAXPLAYERS) && (Player == 0) &&
		     (Score[1] > 0L)) {
		Player++;
		DrawHighScore(hps, cx, cy, DRAW_REINIT);
		}
            /* If there are no more high scores then go into attract mode */
	    else
		WinSendMsg(hwnd, WM_INITGAME, MPFROMSHORT(1), MPVOID);
	    break;
	  }
	return 0;

      /* Used by help manager */
      case HM_QUERY_KEYS_HELP:
	 return((MRESULT)IDH_CLIENTKEYS);

      /* Recieved always from the system or in the case of an initialization*
       *   error.  Both messages will normally save the profile information.*
       * Ideally the profile section should be moved to a subroutine and the*
       *   the following should be broken into two distinct cases.	    */
      case WM_SAVEAPPLICATION:
      case WM_DESTROY:
	/* If the fonts were not found bApplicationOk will be false, in     *
	 *   that case the window profile information should not be updated.*/
	if (TRUE) {
	    /* Copy window position and size info into profile structure */
	    WinQueryWindowPos(hwndFrame, &swp);
	    if (swp.fl & SWP_MAXIMIZE)
		prfProfile.ulMINMAX = SWP_MAXIMIZE;
	    else if (swp.fl & SWP_MINIMIZE)
		prfProfile.ulMINMAX = SWP_MINIMIZE;
	    else {
		prfProfile.ulMINMAX = 0;
		prfProfile.x  = swp.x;prfProfile.y   = swp.y;
		prfProfile.cx = swp.cx;prfProfile.cy = swp.cy;
		}

	    /* Write profile information */
	    PrfWriteProfileData(HINI_USERPROFILE, szClientClass, "Data",
		&prfProfile, sizeof(PROFILEREC));
	    }

        /* If the application is terminating release the fonts and the hps. */
        if (msg == WM_DESTROY) {
	    /* Make sure mouse is visible if we hid it before */
            ShowMouse(TRUE);
            
	    /* Release font identifiers and DLL resource module */
	    GpiSetCharSet(hps, LCID_DEFAULT);
	    GpiDeleteSetId(hps, LCID_LARGE);
	    GpiDeleteSetId(hps, LCID_SMALL);
	    GpiUnloadFonts(hab, "ASTEROID");

	    /* Release the "permanent" presentation space */
	    WinReleasePS(hps);
            }
	return 0;

      }
    return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
示例#17
0
MRESULT EXPENTRY fnwpClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2)
{
    RECTL   rcl;
    USHORT   Command;
    ULONG *pulPtr;

    switch(msg)
    {
    case WM_CREATE:
        stCell.cy = 12;
        stCell.cx = 8;
        hdcPs = WinOpenWindowDC(hwnd);

        /****************************************************************/
        /* Set the size and position of the frame window by making the  */
        /* client area width and height integral numbers of AVIO cell   */
        /* units.  Calculate the frame window values necessary to       */
        /* achieve this.                                                */
        /****************************************************************/

        rcl.yBottom = 0L;
        rcl.xLeft   = 0L;
        rcl.yTop    = 20 * stCell.cy;
        rcl.xRight  = 40 * stCell.cx;

        WinCalcFrameRect(WinQueryWindow(hwnd,QW_PARENT),&rcl,FALSE);

        WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT),
                        0,
                        7 * stCell.cx,
                        2 * stCell.cy,
                        (SHORT)(rcl.xRight - rcl.xLeft),
                        (SHORT)(rcl.yTop - rcl.yBottom),
                        SWP_MOVE | SWP_SIZE);

        WinPostMsg(hwnd,UM_INIT,0L,0L);
        break;
    case WM_ACTIVATE:
        if(LOUSHORT(LONGFROMMP(mp1)))
            WinSetFocus(HWND_DESKTOP,hwnd);
        break;
    case UM_INIT:
        if (szPortName[0] != 0)
            WinSetWindowText(hwndFrame,szPortName);
        else
            MenuItemEnable(hwndFrame,IDM_PROCESS,FALSE);
        WinShowWindow(hwndFrame,TRUE);
        WinQueryWindowRect(hwndClient,&rcl);
        ulWindowWidth = rcl.xRight;
        ulWindowHeight = rcl.yTop;
        ClearScreen();
        break;
    case WM_PAINT:
        Paint();
        break;
    case WM_SIZE:
        WndSize(hwnd,mp2);
        ClearScreen();
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
    case WM_COMMAND:
        switch (SHORT1FROMMP(mp1))
        {
        case IDM_SELECT:
            if (WinDlgBox(HWND_DESKTOP,
                          hwnd,
                          (PFNWP)fnwpSelectPortDlg,
                          (USHORT)NULL,
                          PS_DLG,
                          NULL))
                WinSetWindowText(hwndFrame,szPortDesc);
            break;
        case IDM_RECOVER_USER_INI:
            RecoverProfile(HINI_USERPROFILE);
            break;
        case IDM_RECOVER_SYS_INI:
            RecoverProfile(HINI_SYSTEMPROFILE);
            break;
        case IDM_EXIT:
            WinPostMsg(hwnd,WM_QUIT,0L,0L);
            break;
        case IDM_SETUP:
            SetupPort();
            break;
        case IDM_REMOVE:
            RemovePort();
            break;
        case IDM_INSTALL:
            InstallPort();
            break;
        case IDM_INIT:
            InitializePort();
            break;
        case IDM_TERM:
            TerminatePort();
//          TerminatePort(szPortName);
            break;
        case IDM_QUERY:
            ulItemCount = QueryPort(achBuffer,4096);
            break;
        default:
            return WinDefWindowProc(hwnd,msg,mp1,mp2);
        }
        break;
    case WM_CLOSE:
        WinPostMsg(hwnd,WM_QUIT,0L,0L);  /* Cause termination     */
        break;
    default:
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
    return(FALSE);
}
示例#18
0
文件: kva.c 项目: fabsther/vlc-mort
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;
}
/* This Proc handles the on-the-fly data CD writing */
MRESULT EXPENTRY onTheFlyStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH*2+10];
  char title[CCHMAXPATH];
  char *textPtr;
  char *textPtr2; 
  static LONG lCDSize;
  static LONG lImageSize;
  SWCNTRL swctl;
  PID pid;

  switch (msg)
    {      
    case WM_PAINT:
      {
        if(HlpPaintFrame(hwnd, TRUE))
          return (MRESULT)0;
        break;
      }
    case WM_INITDLG:   

      WinShowWindow(WinWindowFromID(hwnd,IDPB_STATUSOK),FALSE);
      WinShowWindow(WinWindowFromID(hwnd,IDPB_SHOWLOG),FALSE);      
      WinShowWindow(WinWindowFromID(hwnd,IDPB_ABORTWRITE), TRUE);
      /* Hide percent bar which shows the write progress */
      WinShowWindow(WinWindowFromID(hwnd,IDSR_PERCENT), FALSE);

      /* Add switch entry */
      memset(&swctl,0,sizeof(swctl));
      WinQueryWindowProcess(hwnd,&pid,NULL);
      swctl.hwnd=hwnd;
      swctl.uchVisibility=SWL_VISIBLE;
      swctl.idProcess=pid;
      swctl.bProgType=PROG_DEFAULT;
      swctl.fbJump=SWL_JUMPABLE;
      WinAddSwitchEntry(&swctl);

      /* Set percent bar to 0. */
      WinSetWindowText(WinWindowFromID(hwnd,IDSR_PERCENT),"0#0%");

      /* Set dialog font to WarpSans for Warp 4 and above */
      if(cwQueryOSRelease()>=40) {
        WinSetPresParam(hwnd,
                        PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
                        DEFAULT_DIALOG_FONT );
      }

      /* Custom painting */
      setupGroupBoxControl(hwnd, IDGB_CHECKSTATUS);
      setupStaticTextControl(hwnd, IDST_ACTIONTEXT);

      /* Show dialog */
      if(!bHaveWindowPos)
        WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ZORDER|SWP_ACTIVATE);
      else
        WinSetWindowPos(hwnd,HWND_TOP,swpWindow.x, swpWindow.y, 0, 0, SWP_MOVE|SWP_ZORDER|SWP_ACTIVATE|SWP_SHOW);

      /* Get writer device from parameter memory */
      if((textPtr=strstr(ptrLocalMem, "--device"))!=NULL) 
        if((textPtr2=strchr(textPtr, ' '))!=NULL)
          if((textPtr2=strchr(++textPtr2, ' '))!=NULL)
            *textPtr2=0;
      sprintf(text, "\"%s\"", textPtr);
      /* First query free CD space */
      if(queryFreeDVDSpace(hwnd, text)) {
        WinPostMsg(hwnd,WM_CLOSE,0,0);
        return (MRESULT) TRUE;
      };
      if(textPtr2)
        *textPtr2=' ';
      
      return (MRESULT) TRUE;
    case WM_CLOSE:
      WinShowWindow(WinWindowFromID(hwnd,IDPB_ABORTWRITE),FALSE);
      WinShowWindow(WinWindowFromID(hwnd,IDPB_STATUSOK),TRUE);
      WinShowWindow(WinWindowFromID(hwnd,IDPB_SHOWLOG),TRUE);      
      return FALSE;
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_ABORTWRITE:
          /* User pressed the ABORT button */
          DosBeep(1000,200);
          bAbort=TRUE;
          writeLog("User pressed ABORT.\n");
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          break;
        case IDPB_STATUSOK:
          WinQueryWindowPos(hwnd,&swpWindow);
          WinDismissDlg(hwnd,0);
          break;
        case IDPB_SHOWLOG:
          showLogFile();
          break;
        default:
          break;
        }
    case WM_APPTERMINATENOTIFY:
      if(1) {
        switch(LONGFROMMP(mp1)) {
        case ACKEY_ONTHEFLY:
          /* Writing done. */
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_DELETEITEM,MPFROMSHORT(2),0);
          if(!(LONGFROMMP(mp2))) {
            /* Tell the folder that we successfully wrote the CD  */
            /* This message will cause the folder to reset the archive bit if selected */
            sendCommand("ONTHEFLYDONE=1");
            /* Text: "CD-ROM successfully created." */
            getMessage(text, IDSTRLB_CDROMCREATIONSUCCESS, sizeof(text), RESSOURCEHANDLE, hwnd);
            DosBeep(1000,100);
            DosBeep(2000,100);
            DosBeep(3000,100);
          }
          else {
            /* There was an error while writing */
            sendCommand("ONTHEFLYDONE=0");
            DosBeep(100,200);
            /* Text: "Error while writing on the fly!" */
            getMessage(text, IDSTRLB_ONTHEFLYDVDERROR, sizeof(text), RESSOURCEHANDLE, hwnd);
          }
          writeLog(text);
          writeLog("\n");
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_INSERTITEM,MPFROMSHORT(2),text);
          WinShowWindow(WinWindowFromID(hwnd,IDSR_PERCENT),FALSE);
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ZORDER|SWP_ACTIVATE);
          break;
        case ACKEY_FIXATING:
          /* This msg. is sent by the helper process when cdrecord begins with fixating the disk */
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_DELETEITEM,MPFROMSHORT(2),0);
          if(LONGFROMMP(mp2)==0) {
            /* Text: "Fixating... (may need some minutes)" */
            getMessage(text, IDSTRLB_FIXATING, sizeof(text), RESSOURCEHANDLE, hwnd);
          }
          else {
            /* Text: "Writing buffers to CD..." */
            getMessage(text, IDSTRLB_WRITINGBUFFERS, sizeof(text), RESSOURCEHANDLE, hwnd);
          }
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_INSERTITEM,MPFROMSHORT(2),text);
          break;
        case ACKEY_MBWRITTEN:
          {
            int iPercent;

            iPercent=LONGFROMMP(mp2);

            if(lImageSize<100)/* Catch division by zero trap */
              iPercent=0;
            else
              iPercent/=(lImageSize/100);

            if(iPercent>100)
              iPercent=100;
            if(iPercent<0)
              iPercent=0;
            
            /* Update percent bar value. The helper prog sends us the actual written Mbytes. */
            sprintf(text,"%d#%d%%", iPercent, iPercent);
            WinSetWindowText(WinWindowFromID(hwnd,IDSR_PERCENT), text);  
            break;
          }
        case ACKEY_PRINTSIZE:
          {
            FILE * file;

          /* The PM wrapper requested the imagesize by invoking mkisofs with the -print-size option.
             The helper prog sends us the # of extents (each 2048bytes) with this msg */

          /* Delete previous message in listbox */
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_DELETEITEM,MPFROMSHORT(1),0);
          if(LONGFROMMP(mp2)<=2097152) {
            /* Put new msg with imagesize into listbox */
            /* title: "Imagesize is %d.%0.3d.%0.3d bytes" */
            getMessage(title, IDSTRD_IMAGESIZE, sizeof(title), RESSOURCEHANDLE, hwnd);
            sprintf(text,title,
                    LONGFROMMP(mp2)*2048/1000000,(LONGFROMMP(mp2)*2048%1000000)/1000,LONGFROMMP(mp2)*2048%1000);
          }
          else {
            /* title: "Estimated imagesize is %d Mb" */
            getMessage( title, IDSTRD_IMAGESIZESTATUSLINETEXT2, sizeof(title), RESSOURCEHANDLE, hwnd);
            sprintf(text, title, LONGFROMMP(mp2)*2/1024);
          }
          writeLog(text);
          writeLog("\n");
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_INSERTITEM,MPFROMSHORT(1),text);
          /* Save imagesize. We need it for the percent bar */
          lImageSize=LONGFROMMP(mp2);

          /* mkisofs can't create the image for some reason... */
          if(lImageSize==0) {
            messageBox( text, IDSTRD_CHECKSIZEERRORMULTI, sizeof(text),
                        title, IDSTRD_ONTHEFLYTITLE, sizeof(title),
                        RESSOURCEHANDLE, hwnd, MB_OK | MB_ERROR | MB_MOVEABLE);
            WinPostMsg(hwnd,WM_CLOSE,0,0);
            break;
          }
          if(LONGFROMMP(mp2) >lCDSize && lCDSize!=0) {
            /* Text: "Image is bigger than free CD space! [...]. Do you want to proceed?"
               Title: "On the fly writing"
               */
            if(MBID_NO==messageBox( text, IDSTRPM_IMAGETOBIG , sizeof(text),
                                     title, IDSTRD_ONTHEFLYTITLE, sizeof(title),
                                     RESSOURCEHANDLE, hwnd, MB_YESNO | MB_WARNING|MB_MOVEABLE)) {            
              WinPostMsg(hwnd,WM_CLOSE,0,0);
              break;
            }
          }
          /**************************************************************************************************************************************************************/

          /* Check if user pressed Abort in the meantime */
          if(bAbort)
            return FALSE;

          /* Now starting the write process */
          if(pipePtr) {
            *pipePtr='|';
            pipePtr++;
            *pipePtr=' ';
          }

          /* Copy updated command line to parameter file */
          if((file=fopen(params[4],"wb"))!=NULL) {
            fwrite(ptrLocalMem, sizeof(char), SHAREDMEM_SIZE, file);
            fclose(file); 
          }
          /* Put a message in the listbox  */
          /* Text: "Writing on the fly..." */
          getMessage(text, IDSTR_ONTHEFLYWRITING, sizeof(text), RESSOURCEHANDLE, hwnd);
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_INSERTITEM,MPFROMSHORT(2),text);

          /* Hide ABORT Button in the status dialog. We do not let the user interrupt a write because this
             will damage the CD. */
          WinShowWindow(WinWindowFromID(hwnd,IDPB_ABORTWRITE),FALSE);
          /* Set percent bar value */
          WinPostMsg(WinWindowFromID(hwnd,IDSR_PERCENT),WM_UPDATEPROGRESSBAR,MPFROMLONG(0),MPFROMLONG(lImageSize));
          /* Show percent bar which shows the write progress */
          WinShowWindow(WinWindowFromID(hwnd,IDSR_PERCENT),TRUE);

          /* logfilename as a parameter */
          buildLogName(title, logName,  sizeof(title));
          //          snprintf(text, sizeof(text), "\"%s\"" ,title);
          snprintf(text, sizeof(text), "\"%s\" \"%s\"" ,params[4], title);
          /* Launch the helper program */
          /* Title: "On the fly VIO helper" */
          getMessage(title, IDSTRVIO_ONTHEFLY, sizeof(title), RESSOURCEHANDLE, hwnd);
          launchWrapper( text, chrInstallDir, hwnd, "dvdthefly.exe", title);          
          break;
          }
        case ACKEY_CDSIZE:
          {
            FILE * file;

          /* This msg is sent by the helper prog after getting the actual free space of the inserted
             CD */
      
          /* Save CD-Size */
          lCDSize=LONGFROMMP(mp2);
          /* Delete previous Message in the listbox */
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_DELETEITEM,MPFROMSHORT(0),0);

          if(lCDSize==0) {
            /* There was an error. */
            /* Title: "Writing CD"
               Text: "Can't query free CD space! On some systems detection of free CD space fails 
               so you may override this message if you know what you're doing! Do you want to proceed with writing? "
               */
            writeLog("Can't query CD-size. Returned value is 0.\n");
            writeLog("\n");

            if(MBID_NO==queryFreeCDSpaceError(hwnd)) {
              WinPostMsg(hwnd, WM_CLOSE,0,0);
              return FALSE;
            }
          }
          /* Delete check size error message in listbox */
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_DELETEITEM,MPFROMSHORT(0),0);

          if(LONGFROMMP(mp2)<=2097152) {
            /* Insert the CD size into the listbox to inform the user */
            /* title: "Free CD space is %d.%0.3d.%0.3d bytes" */
            getMessage(title, IDSTRLB_FREECDSPACE, sizeof(title), RESSOURCEHANDLE, hwnd);
            sprintf(text,title,
                    LONGFROMMP(mp2)*2048/1000000,(LONGFROMMP(mp2)*2048%1000000)/1000,LONGFROMMP(mp2)*2048%1000);
          }
          else
            {
              getMessage( title, IDSTR_CDSIZESTATUSLINETEXT2, sizeof(title), RESSOURCEHANDLE, hwnd);
              sprintf(text, title, LONGFROMMP(mp2)*2/1024);
            }
          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_INSERTITEM,MPFROMSHORT(0),text);

          /* User pressed 'Abort' */
          if(bAbort)
            return FALSE;

           /* Query image size. This is the second check prior to writing */
          /* Put a message into the listbox */
          /* Text: "Calculating image size. Please wait..." */
          getMessage(text, IDSTRD_CALCULATINGIMAGESIZE, sizeof(text), RESSOURCEHANDLE, hwnd);
          writeLog(text);
          writeLog("\n");

          WinSendMsg(WinWindowFromID(hwnd,IDLB_CHECKSTATUS),LM_INSERTITEM,MPFROMSHORT(1),text);
          
          pipePtr=strchr(ptrLocalMem,'|');
          if(pipePtr) {
            *pipePtr=0;
            pipePtr++;
            *pipePtr=0;
            pipePtr--;

          }
          textPtr=strstr(ptrLocalMem,"-o-print-size");
          if(textPtr) {
            *textPtr=' ';
            textPtr++;
            *textPtr=' ';
          }
          /* Copy updated command line to parameter file */
          if((file=fopen(params[4],"wb"))!=NULL) {
            fwrite(ptrLocalMem, sizeof(char), SHAREDMEM_SIZE, file);
            fclose(file); 
          }
          /* logfilename as a parameter */
          buildLogName(title, logName,  sizeof(title));
          snprintf(text, sizeof(text), "\"%s\" \"%s\"" ,params[4], title);
          /* Launch the helper program */
          launchWrapper( text, chrInstallDir, hwnd,"prntsize.exe", "Query image size");          
          break;
          }
        default:
          break;
        }/* switch */
      }/* if(thisPtr) */           
      return WinDefWindowProc( hwnd, msg, mp1, mp2);
    default:
      break;
    }
    return WinDefDlgProc(hwnd, msg, mp1, mp2);    
}
SOM_Scope ODBoolean  SOMLINK ShapePartHandleMenuEvent( ShapePart *somSelf,
                                                       Environment *ev,
                                                       ODFrame* focusFrame,
                                                       ODEventData* event)
{
    ShapePartData *somThis = ShapePartGetData(somSelf);
    ShapePartMethodDebug("ShapePart","ShapePartHandleMenuEvent");

    ODBoolean handled = kODFalse;

#ifndef _PLATFORM_UNIX_
    try
    {

#ifdef _PLATFORM_WIN32_
       ODCommandID command = event->wParam;
#elif defined(_PLATFORM_OS2_)
       ODCommandID command = LONGFROMMP(event->mp1);
#endif


       switch (command)
       {
          case kShapePartBGColorMenuID:
             somSelf->HandleColorChange (ev, focusFrame);
             handled = kODTrue;
             break;

          case kSimplePartHelpMenu:
             {
                ODHelp *help = _fSession->GetHelp(ev);
                help->DisplayHelp(ev, SHAPE_HELP_FILE, SHAPE_HELP_PANEL);
                handled = kODTrue;
             }
             break;
          case kSimplePartInfoMenu:
             {
                somSelf->DisplayInfoDialog(ev,
                                           SHAPE_MSG_CATALOG,
                                           SHAPE_MSG_SET,
                                           SHAPEMSG_INFOTITLE,
                                           SHAPE_DEFMSG_INFOTITLE,
                                           SHAPEMSG_INFO,
                                           SHAPE_DEFMSG_INFO);
                handled = kODTrue;
             }
             break;
          default:
             handled = ShapePart_parent_SimplePart_HandleMenuEvent(somSelf, ev, focusFrame, event);
             break;
       }

    } // end try
    catch(...)
    {
    }

#endif // _PLATFORM_UNIX

    return handled;
}
/* This Proc handles the on-the-fly data CD writing */
MRESULT EXPENTRY waveinfoStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH*2 +10];
  char title[CCHMAXPATH];
  SWCNTRL swctl;
  PID pid;
  int a;
  int rate;
  int iBitRate;
  SHORT stereo;
  LONG lSec;

  switch (msg)
    {      
    case WM_INITDLG:

      /* Add switch entry */
      memset(&swctl,0,sizeof(swctl));
      WinQueryWindowProcess(hwnd,&pid,NULL);
      swctl.hwnd=hwnd;
      swctl.uchVisibility=SWL_VISIBLE;
      swctl.idProcess=pid;
      swctl.bProgType=PROG_DEFAULT;
      swctl.fbJump=SWL_JUMPABLE;
      WinAddSwitchEntry(&swctl);

      /*      sprintf(text,"1: %s, 2: %s, 3: %s",params[1],params[2],params[3]);
              WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text,
              params[3],
              0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
              */

      WinSendMsg(WinWindowFromID(hwnd,IDST_WAVENAME),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0);
      
      if(!iMp3 || (iMp3 && iMp3Decoder==IDKEY_USEMMIOMP3)) {
        /* Query a wave */          
        switch (mmAudioHeader.mmXWAVHeader.WAVEHeader.usFormatTag)
          {
          case DATATYPE_WAVEFORM:
            getMessage(text, IDSTR_PMWAVEINFOPCM, sizeof(text), RESSOURCEHANDLE, hwnd);
            break;
          case DATATYPE_ALAW:
            getMessage(text, IDSTR_PMWAVEINFOALAW, sizeof(text), RESSOURCEHANDLE, hwnd);
            break;
          case DATATYPE_MULAW:
            getMessage(text, IDSTR_PMWAVEINFOMULAW, sizeof(text), RESSOURCEHANDLE, hwnd);
            break;
          case DATATYPE_ADPCM_AVC:
            getMessage(text, IDSTR_PMWAVEINFOADPCM, sizeof(text), RESSOURCEHANDLE, hwnd);
            break;
          default:
            getMessage(text, IDSTR_PMWAVEINFOUNKNOWN, sizeof(text), RESSOURCEHANDLE, hwnd);	
            break;
          }
        
        /* Channels */
        getMessage(title, IDSTR_PMWAVEINFOCHANNELS, sizeof(title), RESSOURCEHANDLE, hwnd);	
        sprintf(text, title, mmAudioHeader.mmXWAVHeader.WAVEHeader.usChannels);
        WinSetWindowText(WinWindowFromID(hwnd,IDST_CHANNELS),text);
        
        /* Bit per sample */
        getMessage(title, IDSTR_PMWAVEINFOBITPERSAMPLE, sizeof(title), RESSOURCEHANDLE, hwnd);	
        sprintf(text, title,mmAudioHeader.mmXWAVHeader.WAVEHeader.usBitsPerSample);
        WinSetWindowText(WinWindowFromID(hwnd,IDST_BITPERSAMPLE),text);
        
        /* Samplerate */
        getMessage(title, IDSTR_PMWAVEINFOSAMPLERATE, sizeof(title), RESSOURCEHANDLE, hwnd);	
        sprintf(text, title, mmAudioHeader.mmXWAVHeader.WAVEHeader.ulSamplesPerSec);
        WinSetWindowText(WinWindowFromID(hwnd,IDST_SAMPLERATE),text);
        
        /* Filename */
        WinSetWindowText(WinWindowFromID(hwnd,IDST_WAVENAME),params[3]);
        
        /* Playtime */
        getMessage(title, IDSTR_PMWAVEINFOPLAYTIME, sizeof(title), RESSOURCEHANDLE, hwnd);	
        sprintf(text, title, mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes/
					 mmAudioHeader.mmXWAVHeader.WAVEHeader.ulAvgBytesPerSec/60,
					 mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes/
					 mmAudioHeader.mmXWAVHeader.WAVEHeader.ulAvgBytesPerSec%60);
        WinSetWindowText(WinWindowFromID(hwnd,IDST_PLAYTIME),text);

      }
      else
        {
          /* Query info for MP3 */
          getMessage(title, IDSTR_PMMP3INFODLGTITLE, sizeof(title), RESSOURCEHANDLE, hwnd);	
          WinSetWindowText(hwnd,title);

          WinSetWindowText(WinWindowFromID(hwnd,IDST_CDBITS), "");
        
          /* Filename */
          WinSetWindowText(WinWindowFromID(hwnd,IDST_WAVENAME),params[3]);

          audioHlpStartMp3Query(params[3], hwnd);
        }
      /* Set dialog font to WarpSans for Warp 4 and above */
      if(cwQueryOSRelease()>=40) {
        WinSetPresParam(hwnd,
                        PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
                        DEFAULT_DIALOG_FONT );
      }

      if(!bHaveWindowPos)
        WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ZORDER|SWP_ACTIVATE|SWP_SHOW);
      else
        WinSetWindowPos(hwnd,HWND_TOP,swpWindow.x, swpWindow.y, 0, 0, SWP_MOVE|SWP_ZORDER|SWP_ACTIVATE|SWP_SHOW);

      return (MRESULT) TRUE;
      /* WM_APPTERMINATENOTIFY messages are sent from the helper programs e.g. format checker. */
    case WM_APPTERMINATENOTIFY:
      switch(LONGFROMMP(mp1))
        {
        case ACKEY_MP3INFO:
          rate=SHORT2FROMMP(mp2);
          iBitRate=SHORT1FROMMP(mp2);
          iBitRate>>=2;
          stereo=SHORT1FROMMP(mp2) & 0x3;

          /* Channels */
          getMessage(title, IDSTR_PMWAVEINFOCHANNELS, sizeof(title), RESSOURCEHANDLE, hwnd);
          if(stereo)	
            sprintf(text, title, 2);
          else
            sprintf(text, title, 1);
          WinSetWindowText(WinWindowFromID(hwnd,IDST_CHANNELS),text);
          
          /* Bitrate */
          getMessage(title, IDSTR_PMMP3INFOBITRATE, sizeof(title), RESSOURCEHANDLE, hwnd);	
          sprintf(text, title, iBitRate);
          WinSetWindowText(WinWindowFromID(hwnd,IDST_BITPERSAMPLE),text);
          
          /* Samplerate */
          getMessage(title, IDSTR_PMWAVEINFOSAMPLERATE, sizeof(title), RESSOURCEHANDLE, hwnd);	
          sprintf(text, title, rate);
          WinSetWindowText(WinWindowFromID(hwnd,IDST_SAMPLERATE),text);


          break;
        case ACKEY_PLAYTIME:
          lSec=LONGFROMMP(mp2);
          lSec/=(44100*4);

          /* Playtime */
          getMessage(title, IDSTR_PMWAVEINFOPLAYTIME, sizeof(title), RESSOURCEHANDLE, hwnd);	
          sprintf(text, title, lSec/60, lSec%60);
          WinSetWindowText(WinWindowFromID(hwnd,IDST_PLAYTIME),text);

          break;
        default:
          break;
        }
      return FALSE;

    case WM_CLOSE:
      WinQueryWindowPos(hwnd,&swpWindow);
      WinDismissDlg(hwnd,0);
      return FALSE;
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_OK:
          /* User pressed the OK button */
          WinPostMsg(hwnd,WM_CLOSE,0,0);
          break;
        default:
          break;
        }
      return (MRESULT) FALSE;
    default:
      break;
    }/* switch */
  
  return WinDefDlgProc( hwnd, msg, mp1, mp2);
}
示例#22
0
 MRESULT EXPENTRY icqFrameWindow(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
    switch(msg)
    {
    case WM_DDE_INITIATEACK:
       return (MRESULT) icqDDEInitiateAck(hwnd, (HWND)mp1, (PDDEINIT)mp2);

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

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

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

    case WM_DESTROY:
       destroy(hwnd);
       break;

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

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

    case WM_PAINT:
       paint(hwnd);
       break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    case WM_ENDDRAG:
       return endDrag(hwnd);

    case WM_TIMER:
       timer(hwnd);
       break;

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

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

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

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

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

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

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

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

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

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

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

    case WMICQ_DRAWCONTENTS:
       break;

    case WMICQ_AUTOSIZE:
       autoSize(hwnd);
       break;

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

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

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

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

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

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

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

    default:
       return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
    return 0;
 }
示例#23
0
MRESULT ConfigDialog::DlgProc(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  switch (msg)
  {case WM_INITDLG:
    { MRESULT ret = IntrospectBase::DlgProc(msg, mp1, mp2);
      if (Configuration.Sink)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_SINKSRC, Configuration.Sink));
      if (Configuration.SinkPort)
        PMRASSERT(WinSetDlgItemText(GetHwnd(), CB_PORT, Configuration.SinkPort));
      // Set current value
      if (Configuration.SinkServer)
      { ComboBox(+GetCtrl(CB_SERVER)).Text(Configuration.SinkServer);
        PostMsg(UM_CONNECT, 0, 0);
      }
      SpinButton sb(GetCtrl(SB_MINLATENCY));
      sb.SetLimits(0, 5000, 4);
      sb.Value(Configuration.SinkMinLatency);
      sb = SpinButton(GetCtrl(SB_MAXLATENCY));
      sb.SetLimits(100, 10000, 4);
      sb.Value(Configuration.SinkMaxLatency);
      return ret;
    }

   case WM_COMMAND:
    DEBUGLOG(("ConfigDialog::DlgProc:WM_COMMAND(%i,%i, %p)\n", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), mp2));
    switch (SHORT1FROMMP(mp1))
    {case DID_OK:
      { Configuration.SinkServer = WinQueryDlgItemXText(GetHwnd(), CB_SERVER);
        const xstring& sink = WinQueryDlgItemXText(GetHwnd(), CB_SINKSRC);
        Configuration.Sink = sink.length() && !sink.startsWithI("default") ? sink : xstring();
        const xstring& port = WinQueryDlgItemXText(GetHwnd(), CB_PORT);
        Configuration.SinkPort = port.length() && !port.startsWithI("default") ? port : xstring();
        Configuration.SinkMinLatency = SpinButton(GetCtrl(SB_MINLATENCY)).Value();
        Configuration.SinkMaxLatency = SpinButton(GetCtrl(SB_MAXLATENCY)).Value();
      }
      break;
    }
    break;

   case UM_DISCOVER_SERVER:
    { DEBUGLOG(("ConfigDialog::DlgProc:UM_DISCOVER_SERVER\n"));
      try
      { Context.GetServerInfo(ServerInfoOp);
        Sinks.clear();
        Context.GetSinkInfo(SinkInfoOp);
      } catch (const PAException& ex)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, ex.GetMessage());
      }
      return 0;
    }

   case UM_UPDATE_SERVER:
    { int error = LONGFROMMP(mp1);
      DEBUGLOG(("ConfigDialog::DlgProc:UM_UPDATE_SERVER %i\n", error));
      if (error)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, PAConnectException(Context.GetContext(), error).GetMessage());
        return 0;
      }
      WinSetDlgItemText(GetHwnd(), ST_STATUS, "Success");
      ComboBox cb(GetCtrl(CB_SINKSRC));
      // save old value
      const xstring& oldsink = cb.Text();
      // delete old list
      cb.DeleteAll();
      SelectedSink = -1;
      // insert new list and restore old value if reasonable.
      xstring def;
      def.sprintf("default (%s)", Server.default_sink_name.cdata());
      cb.InsertItem(def);
      if (Sinks.size() != 0)
      { int defsink = -1;
        for (unsigned i = 0; i < Sinks.size(); ++i)
        { PASinkInfo& sink = *Sinks[i];
          cb.InsertItem(sink.name);
          if (SelectedSink < 0 && sink.name.compareToI(oldsink) == 0)
            SelectedSink = i;
          if (defsink < 0 && sink.name.compareToI(Server.default_sink_name) == 0)
            defsink = i;
        }
        cb.Select(SelectedSink+1);
        if (SelectedSink < 0)
          SelectedSink = defsink;
      }
    }
   case UM_UPDATE_PORT:
    { DEBUGLOG(("ConfigDialog::DlgProc:UM_UPDATE_PORT %i\n", SelectedSink));
      ComboBox cb(GetCtrl(CB_PORT));
      // save old value
      const xstring& oldport = cb.Text();
      // delete old list
      cb.DeleteAll();
      // insert new list and restore old value if reasonable.
      xstring def;
      int selected = -1;
      if ((unsigned)SelectedSink < Sinks.size())
      { PASinkInfo& sink = *Sinks[SelectedSink];
        if (sink.active_port)
          def.sprintf("default (%s)", sink.active_port->name.cdata());
        for (unsigned i = 0; i < sink.ports.size(); ++i)
        { PAPortInfo& port = sink.ports[i];
          cb.InsertItem(port.name);
          if (selected < 0 && port.name.compareToI(oldport) == 0)
            selected = i;
        }
      }
      cb.InsertItem(def ? def.cdata() : "default", 0);
      cb.Select(selected+1);
      return 0;
    }
  }
  return IntrospectBase::DlgProc(msg, mp1, mp2);
}
MRESULT EXPENTRY newProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          WinReleasePS(hps);

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

        WinQueryWindowRect(hwnd, &rcl);

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

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

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

        rcl3=rcl=rcl2;

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

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

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

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

  return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
示例#25
0
MRESULT IntrospectBase::DlgProc(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  switch (msg)
  {case WM_INITDLG:
    { MRESULT ret = DialogBase::DlgProc(msg, mp1, mp2);
      do_warpsans(GetHwnd());
      // Populate MRU list
      ComboBox cb(GetCtrl(CB_SERVER));
      if (Configuration.SinkServer)
        cb.InsertItem(Configuration.SinkServer);
      char key[] = "Server1";
      do
      { xstring url;
        ini_query(key, url);
        if (!url)
          break;
        cb.InsertItem(url);
      } while (++key[sizeof key -2] <= '9');
      return ret;
    }

   case WM_COMMAND:
    DEBUGLOG(("IntrospectBase::DlgProc:WM_COMMAND(%i,%i, %p)\n", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), mp2));
    switch (SHORT1FROMMP(mp1))
    {case PB_UPDATE:
      PostMsg(UM_CONNECT, 0,0);
      return 0;
     case DID_OK:
      { ComboBox cb(GetCtrl(CB_SERVER));
        const xstring& server = cb.Text();
        // update MRU list
        if (server.length())
        { char key[] = "Server1";
          int i = 0;
          int len = 0;
          xstring url;
          do
          { if (len >= 0)
            {skip:
              url.reset();
              len = (SHORT)SHORT1FROMMR(WinSendMsg(cb.Hwnd, LM_QUERYITEMTEXTLENGTH, MPFROMSHORT(i), 0));
              if (len >= 0)
              { WinSendMsg(cb.Hwnd, LM_QUERYITEMTEXT, MPFROM2SHORT(i, len+1), MPFROMP(url.allocate(len)));
                DEBUGLOG(("IntrospectBase::DlgProc: save MRU %i: (%i) %s\n", i, len, url.cdata()));
                ++i;
                if (url == server)
                  goto skip;
              }
            }
            ini_write(key, url);
          } while (++key[sizeof key -2] <= '9');
        }
        Configuration.Save();
      }
      break;
    }
    break;

   case WM_CONTROL:
    switch (SHORT1FROMMP(mp1))
    {case CB_SERVER:
      switch (SHORT2FROMMP(mp1))
      {case CBN_ENTER:
        PostMsg(UM_CONNECT, 0,0);
        break;
      }
      break;
     case CB_SINKSRC:
      switch (SHORT2FROMMP(mp1))
      {case CBN_ENTER:
        PostMsg(UM_UPDATE_PORT, 0,0);
        break;
      }
    }
    break;

   case UM_CONNECT:
    { DEBUGLOG(("IntrospectBase::DlgProc:UM_CONNECT\n"));
      // destroy any old connection
      Cleanup();
      const xstring& server = WinQueryDlgItemXText(GetHwnd(), CB_SERVER);
      if (!server.length())
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, "enter server name above");
        return 0;
      }
      // open new connection
      try
      { Context.Connect("PM123", server);
      } catch (const PAException& ex)
      { WinSetDlgItemText(GetHwnd(), ST_STATUS, ex.GetMessage());
      }
      return 0;
    }

   case UM_STATE_CHANGE:
    { pa_context_state_t state = (pa_context_state_t)LONGFROMMP(mp1);
      DEBUGLOG(("IntrospectBase::DlgProc:UM_STATE_CHANGE %u\n", state));
      const char* text = "";
      switch (state)
      {case PA_CONTEXT_CONNECTING:
        text = "Connecting ...";
        break;
       case PA_CONTEXT_AUTHORIZING:
        text = "Authorizing ...";
        break;
       case PA_CONTEXT_SETTING_NAME:
        text = "Set name ...";
        break;
       case PA_CONTEXT_READY:
        text = "Connected";
        PostMsg(UM_DISCOVER_SERVER, 0,0);
        break;
       case PA_CONTEXT_FAILED:
        WinSetDlgItemText(GetHwnd(), ST_STATUS, PAConnectException(Context.GetContext()).GetMessage());
        return 0;
       case PA_CONTEXT_TERMINATED:
        text = "Closed";
        break;
       case PA_CONTEXT_UNCONNECTED:;
      }
      WinSetDlgItemText(GetHwnd(), ST_STATUS, text);
      return 0;
    }
  }
  return DialogBase::DlgProc(msg, mp1, mp2);
}
示例#26
0
static MRESULT EXPENTRY pm_crt(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{

static const char *oddlines_offset_res = NULL;

    switch (msg) {
        case WM_INITDLG:
            {
                int val;

                SetSliderTxt(hwnd, ID_SCANLINE_SHADE, 0, "0");
                SetSliderTxt(hwnd, ID_SCANLINE_SHADE, 100, "0.5");
                SetSliderTxt(hwnd, ID_SCANLINE_SHADE, 200, "1.0");
                resources_get_int(scanline_shade_res, &val);
                SetSliderPos(hwnd, ID_SCANLINE_SHADE, val / 5);

                SetSliderTxt(hwnd, ID_BLUR, 0, "0");
                SetSliderTxt(hwnd, ID_BLUR, 100, "0.5");
                SetSliderTxt(hwnd, ID_BLUR, 200, "1.0");
                resources_get_int(blur_res, &val);
                SetSliderPos(hwnd, ID_BLUR, val / 5);

                SetSliderTxt(hwnd, ID_ODDLINES_PHASE, 0, "0");
                SetSliderTxt(hwnd, ID_ODDLINES_PHASE, 100, "1.0");
                SetSliderTxt(hwnd, ID_ODDLINES_PHASE, 200, "2.0");
                resources_get_int(oddlines_phase_res, &val);
                SetSliderPos(hwnd, ID_ODDLINES_PHASE, val / 10);

                SetSliderTxt(hwnd, ID_ODDLINES_OFFSET, 0, "0");
                SetSliderTxt(hwnd, ID_ODDLINES_OFFSET, 100, "1.0");
                SetSliderTxt(hwnd, ID_ODDLINES_OFFSET, 200, "2.0");
                resources_get_int(oddlines_offset_res, &val);
                SetSliderPos(hwnd, ID_ODDLINES_OFFSET, val / 10);
            }
            break;
        case WM_COMMAND:
            if (LONGFROMMP(mp1) != ID_DEFAULT) {
                break;
            }
            resources_set_int(scanline_shade_res, 667);
            resources_set_int(blur_res, 500);
            resources_set_int(oddlines_phase_res, 1250);
            resources_set_int(oddlines_offset_res, 750);
            SetSliderPos(hwnd, ID_SCANLINE_SHADE, (int)(667 / 5));
            SetSliderPos(hwnd, ID_BLUR, 100);
            SetSliderPos(hwnd, ID_ODDLINES_PHASE, 125);
            SetSliderPos(hwnd, ID_ODDLINES_OFFSET, 75);
            return FALSE;
        case WM_CONTROL:
            if (SHORT2FROMMP(mp1) != SLN_CHANGE && SHORT2FROMMP(mp1) != SLN_SLIDERTRACK) {
                break;
            }
            switch (SHORT1FROMMP(mp1)) {
#if 0
                case ID_SCANLINE_SHADE:
                    resources_set_int(scanline_shade_res, (int)mp2 * 5);
                    break;
                case ID_BLUR:
                    resources_set_int(blur_res, (int)mp2 * 5);
                    break;
                case ID_ODDLINES_PHASE:
                    resources_set_int(oddlines_phase_res, (int)mp2 * 10);
                    break;
                case ID_ODDLINES_OFFSET:
                    resources_set_int(oddlines_offset_res, (int)mp2 * 10);
                    break;
#endif
            }
            break;
    }
    return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
/*...sHlpWndProc:0:*/
MRESULT _System HlpWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
	{
	CHAR sz[256+1];

	switch ( (int) msg )
		{
/*...sHM_ERROR:16:*/
case HM_ERROR:
	switch( SHORT1FROMMP(mp1) )
		{
		case HMERR_HELPITEM_NOT_FOUND:
			sprintf(sz, "Item 0x%08lx not found", LONGFROMMP(mp2));
			HlpWarning(hwnd, sz);
			break;
		case HMERR_HELPSUBITEM_NOT_FOUND:
			sprintf(sz, "Sub-Item 0x%08lx not found", LONGFROMMP(mp2));
			HlpWarning(hwnd, sz);
			break;
		case HMERR_INDEX_NOT_FOUND:
			HlpWarning(hwnd, "No index in library file" );
			break;
		case HMERR_CONTENT_NOT_FOUND:
			HlpWarning(hwnd, "Library file does not have any contents");
			break;
		case HMERR_OPEN_LIB_FILE:
			HlpWarning(hwnd, "Cannot open library file");
			break;
		case HMERR_READ_LIB_FILE:
			HlpWarning(hwnd, "Cannot read library file");
			break;
		case HMERR_CLOSE_LIB_FILE:
			HlpWarning(hwnd, "Cannot close library file");
			break;
		case HMERR_INVALID_LIB_FILE:
			HlpWarning(hwnd, "Improper library file provided");
			break;
		case HMERR_NO_MEMORY:
			HlpWarning(hwnd, "Unable to allocate the requested amount of memory");
			break;
		case HMERR_ALLOCATE_SEGMENT:
			HlpWarning(hwnd, "Unable to allocate memory for IPF");
			break;
		case HMERR_FREE_MEMORY:
			HlpWarning(hwnd, "Unable to free allocated memory");
			break;
		case HMERR_PANEL_NOT_FOUND:
			HlpWarning(hwnd, "Unable to find help panel requested");
			break;
		case HMERR_DATABASE_NOT_OPEN:
			HlpWarning(hwnd, "Unable to read the unopened database");
			break;
		default:
			sprintf(sz, "Error mp1=0x%08lx mp2=0x%08lx",LONGFROMMP(mp1), LONGFROMMP(mp2));
			HlpWarning(hwnd, sz);
			break;
		}
	break;
/*...e*/
/*...sHM_INFORM:16:*/
case HM_INFORM:
	sprintf(sz, "Inform 0x%08lx 0x%08lx",
		LONGFROMMP(mp1), LONGFROMMP(mp2));
	HlpWarning(hwnd, sz);
	break;
/*...e*/
/*...sHM_QUERY_KEYS_HELP:16:*/
case HM_QUERY_KEYS_HELP:
	return ( (MRESULT) HID_HELPKEYS );	
/*...e*/
/*...sHM_EXT_HELP_UNDEFINED:16:*/
case HM_EXT_HELP_UNDEFINED:
	sprintf(sz, "Extended help undefined mp1=0x%08lx mp2=0x%l08x",
		LONGFROMMP(mp1), LONGFROMMP(mp2));
	HlpWarning(hwnd, sz);
	break;
/*...e*/
/*...sHM_HELPSUBITEM_NOT_FOUND:16:*/
case HM_HELPSUBITEM_NOT_FOUND:
	sprintf(sz, "Sub-Item 0x%08lx 0x%08lx not found",
		LONGFROMMP(mp1), LONGFROMMP(mp2));
	HlpWarning(hwnd, sz);
	break;
/*...e*/
		}
	return ( WinDefWindowProc(hwnd, msg, mp1, mp2) );
	}
示例#28
0
static MRESULT EXPENTRY pm_color(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    switch (msg) {
        case WM_INITDLG:
            {
                int val;

                SetSliderTxt(hwnd, ID_GAMMA, 0, "0");
                SetSliderTxt(hwnd, ID_GAMMA, 100, "2.0");
                SetSliderTxt(hwnd, ID_GAMMA, 200, "4.0");
                resources_get_int(gamma_res, &val);
                SetSliderPos(hwnd, ID_GAMMA, val / 20);

                SetSliderTxt(hwnd, ID_TINT, 0, "0");
                SetSliderTxt(hwnd, ID_TINT, 100, "1.0");
                SetSliderTxt(hwnd, ID_TINT, 200, "2.0");
                resources_get_int(tint_res, &val);
                SetSliderPos(hwnd, ID_TINT, val / 10);

                SetSliderTxt(hwnd, ID_SATURATION, 0, "0");
                SetSliderTxt(hwnd, ID_SATURATION, 100, "1.0");
                SetSliderTxt(hwnd, ID_SATURATION, 200, "2.0");
                resources_get_int(saturation_res, &val);
                SetSliderPos(hwnd, ID_SATURATION, val / 10);

                SetSliderTxt(hwnd, ID_CONTRAST, 0, "0");
                SetSliderTxt(hwnd, ID_CONTRAST, 100, "1.0");
                SetSliderTxt(hwnd, ID_CONTRAST, 200, "2.0");
                resources_get_int(contrast_res, &val);
                SetSliderPos(hwnd, ID_CONTRAST, val / 10);

                SetSliderTxt(hwnd, ID_BRIGHTNESS, 0, "0");
                SetSliderTxt(hwnd, ID_BRIGHTNESS, 100, "1.0");
                SetSliderTxt(hwnd, ID_BRIGHTNESS, 200, "2.0");
                resources_get_int(brightness_res, &val);
                SetSliderPos(hwnd, ID_BRIGHTNESS, val / 10);
            }
            break;
        case WM_COMMAND:
            if (LONGFROMMP(mp1) != ID_DEFAULT) {
                break;
            }
            resources_set_int(gamma_res, 2200);
            resources_set_int(tint_res, 1000);
            resources_set_int(saturation_res, 1000);
            resources_set_int(contrast_res, 1000);
            resources_set_int(brightness_res, 1000);
            SetSliderPos(hwnd, ID_GAMMA, 110);
            SetSliderPos(hwnd, ID_TINT, 100);
            SetSliderPos(hwnd, ID_SATURATION, 100);
            SetSliderPos(hwnd, ID_CONTRAST, 100);
            SetSliderPos(hwnd, ID_BRIGHTNESS, 100);
            return FALSE;
        case WM_CONTROL:
            if (SHORT2FROMMP(mp1) != SLN_CHANGE && SHORT2FROMMP(mp1) != SLN_SLIDERTRACK) {
                break;
            }
            switch (SHORT1FROMMP(mp1)) {
#if 0
                case ID_GAMMA:
                    resources_set_int(gamma_res, (int)mp2 * 20);
                    break;
                case ID_TINT:
                    resources_set_int(tint_res, (int)mp2 * 10);
                    break;
                case ID_SATURATION:
                    resources_set_int(saturation_res, (int)mp2 * 10);
                    break;
                case ID_CONTRAST:
                    resources_set_int(contrast_res, (int)mp2 * 10);
                    break;
                case ID_BRIGHTNESS:
                    resources_set_int(brightness_res, (int)mp2 * 10);
                    break;
#endif
            }
            break;
    }
    return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
示例#29
0
static MRESULT EXPENTRY pm_emulator(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    // FIXME: Speed=0 'No Limit' is missing
    static int first = TRUE;
    const char psz[11][6] = {
        " Auto",
        " 1/1",
        " 1/2",
        " 1/3",
        " 1/4",
        " 1/5",
        " 1/6",
        " 1/7",
        " 1/8",
        " 1/9",
        " 1/10"
    };

    switch (msg) {
        case WM_INITDLG:
            {
            int val=0;

                for (val = 0; val < 11; val++) {
                    WinDlgLboxInsertItem(hwnd, CBS_REFRATE, psz[val]);
                }
                resources_get_int("Speed", &val);
                WinSetDlgSpinVal(hwnd, SPB_SPEED, val);
                WinEnableControl(hwnd, PB_SPEED100, (val!=100));
                resources_get_int("RefreshRate", &val);
                WinDlgLboxSelectItem(hwnd, CBS_REFRATE, val);
            }
            break;
        case WM_COMMAND:
            switch (LONGFROMMP(mp1)) {
                case PB_SPEED100:
                WinSetDlgSpinVal(hwnd, SPB_SPEED, 100);
                vsync_suspend_speed_eval();
                resources_set_int("Speed", 100);
                WinEnableControl(hwnd, PB_SPEED100, FALSE);
                return FALSE;
            }
            break;
        case WM_DISPLAY:
            {
                char txt1[8] = "---%";
                char txt2[8] = "--fps";

                if ((int)mp1 < 100000) {
                    sprintf(txt1, "%5d%%", mp1);
                }
                if ((int)mp2 < 10000) {
                    sprintf(txt2, "%4dfps", mp2);
                }
                WinSetDlgItemText(hwnd, ID_SPEEDDISP, txt1);
                WinSetDlgItemText(hwnd, ID_REFRATEDISP, txt2);
            }
            return FALSE;
        case WM_CONTROL:
            {
                const int ctrl = SHORT1FROMMP(mp1);

                switch (ctrl) {
                    case SPB_SPEED:
                        if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN) {
                            const ULONG val = WinGetSpinVal((HWND)mp2);

                            vsync_suspend_speed_eval();
                            resources_set_int("Speed", val);
                            WinEnableControl(hwnd, PB_SPEED100, (val != 100));
                        }
                        break;
                    case CBS_REFRATE:
                        if (SHORT2FROMMP(mp1) == LN_SELECT) {
                            const int val = WinQueryLboxSelectedItem((HWND)mp2);

                            resources_set_int("RefreshRate", val);
                        }
                        break;
                }
                break;
            }
            break;
    }
    return WinDefDlgProc (hwnd, msg, mp1, mp2);
}
示例#30
0
文件: kimehook.c 项目: komh/kime
MRESULT EXPENTRY newKimeWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    if( msg == KIMEM_RELOAD )
    {
        WinSendMsg( hwndKHS, KHSM_RELOADEXCEPTFILE, 0, 0 );
        hwndCurrentInput = NULLHANDLE;
    }

    if( msg == KIMEM_CALLHANJAINPUT )
    {
        initKimeStatus( hwndCurrentInput, FALSE );

        WinSendMsg( hwndHIA, WM_CHAR, MPFROMSH2CH( KC_LONEKEY | KC_SCANCODE, 0, 0x5B ), 0 );

        WinSetFocus( HWND_DESKTOP, hwndCurrentInput );

        return 0;
    }

    if( msg == KIMEM_CHANGEHANHOOK )
    {
        WinSendMsg( hwndHIA, HIAM_CHANGEHANMODE, 0, 0 );

        if( kimeOpt.useOS2IME )
            toggleOS2IMEHanEng( hwndCurrentInput );

        return 0;
    }

    if( msg == WM_CONTROL )
    {
        switch (SHORT1FROMMP(mp1))
        {
            case ID_HIA:
                switch (SHORT2FROMMP(mp1))
                {
                    case HIAN_INSERTHCH:
                        if (!(SHORT1FROMMP(mp2) & 0x8000))
                        {
                            sendCharToWnd( SHORT1FROMMP( mp2 ));

                            setInputBoxHch( 0 );
                            showInputBox( FALSE );
                        }
                        break;

                    case HIAN_COMPO_BEGIN:
                    case HIAN_COMPO_STEP:
                    case HIAN_COMPO_STEPBACK:
                        hchComposing = SHORT2FROMMP(mp2);

                        setInputBoxHch( hchComposing );
                        showInputBox( TRUE );
                        break;

#if 0
                    case HIAN_COMPO_STEP:
                        hchComposing = SHORT2FROMMP(mp2);

                        setInputBoxHch( hchComposing );
                        break;

                    case HIAN_COMPO_STEPBACK:
                        hchComposing = SHORT2FROMMP(mp2);

                        setInputBoxHch( hchComposing );
                        break;
#endif

                    case HIAN_COMPO_CANCEL:
                        setInputBoxHch( 0 );
                        showInputBox( FALSE );
                        hchComposing = 0;
                        break;

                    case HIAN_COMPO_COMPLETE:
                        sendCharToWnd( SHORT1FROMMP( mp2 ));

                        setInputBoxHch( 0 );
                        showInputBox( FALSE );
                        hchComposing = 0;
                        break;

                    case HIAN_HANMODECHANGED:
                        WinSendMsg( hwndKHS, KHSM_SETHANSTATUS, MPFROMHWND( hwndCurrentInput ), MPFROMLONG( LONGFROMMP( mp2 ) == HCH_HAN ));
                        WinSendMsg( hwndKime, KIMEM_SETHAN, MPFROMLONG( LONGFROMMP( mp2 ) == HCH_HAN ), 0 );
                        break;

                    case HIAN_KBDTYPECHANGED:
                        kimeOpt.kbdLayout = LONGFROMMR( mp2 );
                        break;

                    case HIAN_INSERTMODECHANGED:
                        break;

                    case HIAN_HGHJCONVERT:
                        WinSendMsg( hwndHIA, WM_CHAR, 0, 0 ); // call special char input

                        WinSetFocus( HWND_DESKTOP, hwndCurrentInput);
                        break;

                } // note switch end
                break;
        } // control switch end

        return 0;
    }

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