BOOL OSpinBtn::jumptoEnd()
{
  while(WinSendMsg(hwnd,SPBM_SPINUP,MPFROMLONG(1),0)) {}
  return(TRUE);
}
Пример #2
0
MRESULT ProcessCommandMsg ( HWND hwndWnd, ULONG ulMsg, MPARAM mpParm1, MPARAM mpParm2 )
{
   switch ( SHORT1FROMMP( mpParm1 ) )
   {
      /*
       * First, the menu selections.
       */

      case IDM_FILE_OPEN:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            if ( FileOpenDialog( hwndWnd, NULL ) )
            {
               SetWindowTitle( hwndWnd );
               UpdateScreenLimits( hwndWnd, TRUE );
            }
         }
         break;

      case IDM_FILE_SAVE:
         FileSaveDialog( hwndWnd, szFileName );
         SetWindowTitle( hwndWnd );
         break;

      case IDM_FILE_SAVE_AS:
         FileSaveDialog( hwndWnd, NULL );
         SetWindowTitle( hwndWnd );
         break;

      case IDM_FILE_CLEAR:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            ClearFile( hwndWnd );
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_FILE_ALLOCATE:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            if ( FileAllocateDialog( hwndWnd ) )
            {
               SetWindowTitle( hwndWnd );
               UpdateScreenLimits( hwndWnd, TRUE );
            }
         }
         break;

      case IDM_FILE_RESIZE:
         if ( FileResizeDialog( hwndWnd ) )
         {
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_FILE_EXIT:
         if ( QueryAbandonChanges( hwndWnd ) )
         {
            ClearFile( hwndWnd );
            WinPostMsg(hwndWnd, WM_QUIT, 0L, 0L);
         }
         break;

      case IDM_EDIT_CUT:
         if ( EditCut( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_COPY:
         if ( EditCopy( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_PASTE:
         if ( EditPaste( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_DELETE:
         if ( EditDelete( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_EDIT_INSERT:
         if ( EditInsert( hwndWnd ) )
         {
            SetWindowTitle( hwndWnd );
            UpdateScreenLimits( hwndWnd, TRUE );
         }
         break;

      case IDM_SEARCH_FORWARD:
         SearchForward( hwndWnd );
         break;

      case IDM_SEARCH_BACKWARD:
         SearchBackward( hwndWnd );
         break;

      case IDM_SEARCH_AGAIN:
         SearchAgain( hwndWnd );
         break;

      case IDM_REPLACE_FORWARD:
         ReplaceForward( hwndWnd );
         break;

      case IDM_REPLACE_BACKWARD:
         ReplaceBackward( hwndWnd );
         break;

      case IDM_REPLACE_AGAIN:
         ReplaceAgain( hwndWnd );
         break;

      case IDM_GOTO_OFFSET:
         GotoOffset( hwndWnd );
         break;

      case IDM_OPTIONS_FONT:
         FontSelectDialog( hwndWnd );
         break;

      case IDM_OPTIONS_READONLY:
         bReadOnly ^= TRUE;
         WinSendMsg( hwndMenu, MM_SETITEMATTR,
                     MPFROM2SHORT( IDM_OPTIONS_READONLY, TRUE ),
                     MPFROM2SHORT( MIA_CHECKED, bReadOnly ? MIA_CHECKED : 0 ) );
         break;

      case IDM_OPTIONS_AUTORESIZE:
         bAutoResize ^= TRUE;
         WinSendMsg( hwndMenu, MM_SETITEMATTR,
                     MPFROM2SHORT( IDM_OPTIONS_AUTORESIZE, TRUE ),
                     MPFROM2SHORT( MIA_CHECKED, bAutoResize ? MIA_CHECKED : 0 ) );
         if ( bAutoResize )
            UpdateScreenLimits( hwndWnd, TRUE );
         break;

      case IDM_OPTIONS_REGISTER:
         DisplayRegistrationPanel( hwndWnd );
         break;

      case IDM_DISPLAY:
         DisplayModeDialog( hwndWnd );
         break;

      /*
       * Next, the DISPLAY dialog accelerator keys
       */

      case IDD_DISPLAY_OFFSET_OCTAL:
      case IDD_DISPLAY_OFFSET_DECIMAL:
      case IDD_DISPLAY_OFFSET_HEX:
      case IDD_DISPLAY_ENTITY_OCTAL:
      case IDD_DISPLAY_ENTITY_DECIMAL:
      case IDD_DISPLAY_ENTITY_HEX:
      case IDD_DISPLAY_1_BYTE:
      case IDD_DISPLAY_2_BYTE:
      case IDD_DISPLAY_4_BYTE:
         DisplayModeAccelKey( hwndWnd, SHORT1FROMMP( mpParm1 ) );
         break;

      /*
       * And the default
       */

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

   return MRFROMSHORT ( FALSE ) ;
}
Пример #3
0
MRESULT os2FrameWindow::ProcessFrameMessage(ULONG msg, MPARAM mp1, MPARAM mp2)
{
  MRESULT mresult = 0;
  bool    isDone = false;

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

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

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

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

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

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

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

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

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

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

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

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

  return mresult;
}
MRESULT EXPENTRY AirTrafficControlDlg (HWND hwnd, ULONG msg,
    MPARAM mp1, MPARAM mp2)
{
    PINST   pinst;

    pinst = (PINST) WinQueryWindowPtr(hwnd,QWL_USER);

    switch (msg)
    {
        case WM_INITDLG:
        {
            /*
             *  INITIALIZE APPLICATION
             */

            CNRINFO     ccinfo;         // Container info structure

            // Initialize instance data
            pinst = (PINST) calloc (1, sizeof *pinst);
            WinSetWindowPtr(hwnd,QWL_USER,pinst);
            pinst->hwndCnr = WinWindowFromID (hwnd, IDCNR_SAMPLE);
            pinst->hab     = WinQueryAnchorBlock (hwnd);
            pinst->hwndAircraftMenu =               // Load aircraft menu
                WinLoadMenu( HWND_OBJECT, 0, IDMENU_AIRCRAFT);
            pinst->hwndContainerMenu =              // Load container menu
                WinLoadMenu( HWND_OBJECT, 0, IDMENU_CONTAINER);
            pinst->CurrentView = IDMVIEW_RADAR;

            // Set container info to request owner background painting
            memset (&ccinfo, 0, sizeof ccinfo);
            ccinfo.cb = sizeof ccinfo;
            ccinfo.flWindowAttr = CA_OWNERPAINTBACKGROUND;
            WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo,
                MPFROMLONG(CMA_FLWINDOWATTR));

            // Subclass container window to provide background painting
            pfnwpCnr = WinSubclassWindow (pinst->hwndCnr,
                CnrSubclassWndProc);
            assert (pfnwpCnr);

            // Insert the columns into the container
            InsertContainerColumns (pinst);

            // Insert the initial records into the container
            InsertContainerRecords (pinst);

            // Start a timer to control aircraft
            WinStartTimer (pinst->hab, hwnd,
                IDTIMER_ADJUSTAIRCRAFT, AIRCRAFT_ADJUST_FREQUENCY);

            // The container is ready for viewing
            WinShowWindow (pinst->hwndCnr, TRUE);

            SetUpControllerHandoffValueSet (hwnd);

            return 0;
        }

        case WM_TIMER:

            /*
             *  DO TIME-RELATED AIRCRAFT HANDLING
             */

            if (SHORT1FROMMP (mp1) == IDTIMER_ADJUSTAIRCRAFT)
            {
                PAPPCNRREC      pacrTraverse;

                // Loop through all container records
                for (pacrTraverse = FIRST_CNR_ITEM (pinst->hwndCnr);
                    pacrTraverse;
                    pacrTraverse = NEXT_CNR_ITEM(pinst->hwndCnr,pacrTraverse))
                {
                    BOOL        fInvalid = FALSE;

                    if (pinst->CurrentView == IDMVIEW_RADAR)
                    {
                        /* Erase the record from previous location. */
                        WinSendMsg (pinst->hwndCnr, CM_ERASERECORD,
                            MPFROMP(pacrTraverse), NULL);
                    }

                    // Maneuver the aircraft
                    if (ManeuverAircraft (pacrTraverse))
                    {
                        // Update aircraft text if necessary
                        SetRecordText (pacrTraverse);
                        fInvalid = TRUE;
                    }

                    if (fInvalid || pinst->CurrentView == IDMVIEW_RADAR)
                        /* Paint the record in its new position */
                        WinSendMsg (pinst->hwndCnr, CM_INVALIDATERECORD,
                            MPFROMP(&pacrTraverse),
                            MPFROMSHORT(1));
                }
            }
            else
                if (SHORT1FROMMP (mp1) == IDTIMER_DISPLAYTIMEDMSG)
                {
                    WinStopTimer (pinst->hab, hwnd,
                        IDTIMER_DISPLAYTIMEDMSG);
                    WinSetDlgItemText (hwnd, IDST_STATUSMESSAGES, "");
                }


            return 0;


        case WM_CONTROL:
            if (SHORT1FROMMP (mp1) == IDCNR_SAMPLE)
                switch (SHORT2FROMMP (mp1))
                {
                    case CN_CONTEXTMENU:
                    {
                        /*
                         *  MENU HANDLING
                         */

                        POINTL  ptlMouse;
                        HWND    hwndMenu;

                        WinQueryMsgPos (pinst->hab, &ptlMouse);

                        // Save pointer to record mouse is over, if any
                        pinst->pacrSelected = (PAPPCNRREC) mp2;

                        hwndMenu = pinst->pacrSelected ?
                            pinst->hwndAircraftMenu :
                            pinst->hwndContainerMenu;

                        // Display menu
                        WinPopupMenu (HWND_DESKTOP, hwnd, hwndMenu,
                            ptlMouse.x, ptlMouse.y, 0,
                            PU_HCONSTRAIN | PU_VCONSTRAIN |
                            PU_KEYBOARD | PU_MOUSEBUTTON1 |
                            PU_MOUSEBUTTON2 |
                            PU_MOUSEBUTTON3);
                        return 0;
                    }

                    case CN_INITDRAG:
                        ProcessInitDrag (
                            WinWindowFromID (hwnd, SHORT1FROMMP (mp1)),
                            ((PCNRDRAGINIT) (PVOIDFROMMP(mp2))));
                        return 0;

                    case CN_SCROLL:
                        WinInvalidateRect (pinst->hwndCnr, 0, 0);
                        return 0;
                }
            else

/*
 *  HANDLE WM_CONTROL MESSAGES FROM VALUE SET CONTROL
 */

                if (SHORT1FROMMP (mp1) == IDVS_CONTROLLERS)
                    switch (SHORT2FROMMP (mp1))
                    {
                        case VN_SELECT:
                            DisplayTimedMsg (pinst->hab, hwnd,
                                "Drag an airplane to one "
                                "of the controller icons to hand off to "
                                "another controller.", 8);

                            return 0;

                        case VN_DROP:
                        {
                            PVSDRAGINFO pvsdinfo = (PVSDRAGINFO)
                               PVOIDFROMMP (mp2);
                            PDRAGINFO   pdinfo = pvsdinfo->pDragInfo;
                            PDRAGITEM   pditem;
                            INT         iItem;
                            INT         cHandedOffAircraft = 0;
                            CHAR        szHandedOffAircraft [100];

                            *szHandedOffAircraft = 0;

                            assert (DrgAccessDraginfo(pdinfo));

                            for (iItem = 0; iItem < pdinfo->cditem; ++iItem)
                            {
                                PAPPCNRREC      pacr;

                                pditem =  DrgQueryDragitemPtr (pdinfo, iItem);

                                pacr = (PAPPCNRREC) pditem->ulItemID;

                                if (pdinfo->usOperation == DO_MOVE)
                                {
                                    WinSendMsg (pdinfo->hwndSource,
                                        CM_REMOVERECORD,
                                        MPFROMP(&pacr),
                                        MPFROM2SHORT (1, CMA_INVALIDATE));

                                    if (cHandedOffAircraft++)
                                        strcat (szHandedOffAircraft, ", ");

                                    strcat (szHandedOffAircraft,
                                        pacr->pszCallsign);
                                }
                            }

                            if (cHandedOffAircraft)
                            {
                                CHAR    szMsg [200];

                                sprintf (szMsg,
                                    "Aircraft %s %s been handed off "
                                    "to %s Sector controller.",
                                    szHandedOffAircraft,
                                    cHandedOffAircraft > 1 ?
                                        "have" : "has",
                                    pvsdinfo->usColumn == 1 ?
                                        "West" : "East");

                                DisplayTimedMsg (pinst->hab, hwnd,
                                    szMsg, 8);
                            }

                            DrgFreeDraginfo (pdinfo);
                            WinAlarm (HWND_DESKTOP, WA_NOTE);
                            return 0;
                        }
                    }

            return 0;


        case WM_COMMAND:

            /*
             *  COMMAND HANDLING
             */

            switch (SHORT1FROMMP (mp1))
            {
                case IDMAIRCRAFT_CONTROLINSTRUCT:   // Issue instruction
                {
                    // Present "Control Aircraft" dialog
                    WinDlgBox (HWND_DESKTOP, hwnd,
                        ControlInstructionDlg, 0,
                        IDDLG_CONTROLAIRCRAFT, pinst);
                    return 0;
                }

                case IDMVIEW_RADAR:
                case IDMVIEW_NAME:
                case IDMVIEW_TREE:
                case IDMVIEW_DETAILS:
                case IDMVIEW_TEXT:
                {
                    static const ULONG  aViews [] =
                        { CV_ICON, CV_NAME, CV_TREE, CV_DETAIL, CV_TEXT };

                    CNRINFO ccinfo;
                    memset (&ccinfo, 0, sizeof ccinfo);
                    ccinfo.cb = sizeof ccinfo;
                    ccinfo.flWindowAttr = CA_DETAILSVIEWTITLES |
                        CA_TITLESEPARATOR | CA_TREELINE |
                        CA_OWNERPAINTBACKGROUND |
                        aViews [SHORT1FROMMP (mp1) - IDMVIEW_BASE];
                    WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo,
                        MPFROMLONG(CMA_FLWINDOWATTR));
                    pinst->CurrentView = SHORT1FROMMP (mp1);

                    WinInvalidateRect (pinst->hwndCnr, 0, 0);
                    return 0;
                }
            }

            return WinDefDlgProc (hwnd, msg, mp1, mp2);

        default:
            return WinDefDlgProc (hwnd, msg, mp1, mp2);
    }
}
static INT InsertContainerRecords (PINST pinst)
{
    PAPPCNRREC      pacrRoot;           // Ptr to root of list of records
    PAPPCNRREC      pacrTraverse;       // Ptr to traverse list of records
    RECORDINSERT    recins;             // Record insertion information
    HPOINTER        hptrIcon;           // Handle of jet icon
    RECTL           rclCnr;             // Container dimensions
    LONG            iRecord = 0;        // Record index
    static const PSZ apszCallSignPrefixes [] =
        { "AA", "DA", "UA", "TW" };
    static const INT cPrefixes = sizeof apszCallSignPrefixes /
        sizeof apszCallSignPrefixes[0];
    CHAR            szBuf [30];

    /*
     *  SET UP RECORD INSERT STRUCTURE
     */

    memset (&recins, 0, sizeof recins);
    recins.cb                = sizeof recins;
    recins.pRecordOrder      = (PRECORDCORE) CMA_END;
    recins.zOrder            = CMA_TOP;
    recins.cRecordsInsert    = 5;
    recins.fInvalidateRecord = TRUE;


    /*
     *  ALLOCATE CONTAINER ITEM LINKED LIST
     */

    pacrRoot = (PAPPCNRREC) WinSendMsg (
        pinst->hwndCnr, CM_ALLOCRECORD,
        MPFROMLONG(sizeof(APPCNRREC) - sizeof(MINIRECORDCORE)),
        MPFROMLONG(recins.cRecordsInsert));


    /*
     *  SET UP USER RECORD LINKED LIST
     */

    hptrIcon = WinLoadPointer (HWND_DESKTOP, 0, IDICON_JET);
    WinQueryWindowRect (pinst->hwndCnr, &rclCnr);
    srand (clock());


    for (iRecord = 0, pacrTraverse = pacrRoot;
        iRecord < recins.cRecordsInsert;
        ++iRecord, pacrTraverse = (PAPPCNRREC)
        pacrTraverse->recc.preccNextRecord)
    {
        pacrTraverse->cnrrtyp       = CNRRT_AIRCRAFT;
        pacrTraverse->iRecord       = iRecord;
        pacrTraverse->Altitude      =
        pacrTraverse->AssignedAltitude = rand() % 50 + 50;
        pacrTraverse->Heading       =
        pacrTraverse->AssignedHeading  = rand() % 360 + 1;
        pacrTraverse->Speed         =
        pacrTraverse->AssignedSpeed = rand() % 20 + 10;
        sprintf (szBuf, "%s%ld",
            apszCallSignPrefixes [rand() % cPrefixes], rand() % 1000);
        pacrTraverse->pszCallsign   = strdup (szBuf);

        SetRecordText (pacrTraverse);
        pacrTraverse->recc.hptrIcon = hptrIcon;
        pacrTraverse->recc.ptlIcon.x = rclCnr.xRight / 10 * (rand() % 9 + 1);
        pacrTraverse->recc.ptlIcon.y = rclCnr.yTop   / 10 * (rand() % 9 + 1);
    }


    /*
     *  INSERT ALL CONTAINER ITEMS
     */

    WinSendMsg (pinst->hwndCnr, CM_INSERTRECORD,
        MPFROMP(pacrRoot), MPFROMP(&recins));


    /*
     *  INSERT CHILD RECORDS FOR TREE VIEW
     */

    InsertCrewRecords (pinst->hwndCnr, pacrRoot);


    /*
     *  DESELECT FIRST AIRPLANE, WHICH BECOMES SELECTED AUTOMATICALLY
     */

    WinSendMsg (pinst->hwndCnr, CM_SETRECORDEMPHASIS,
        MPFROMP(pacrRoot), MPFROM2SHORT(FALSE, CRA_SELECTED));

    return 0;
}
Пример #6
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);
}
Пример #7
0
MRESULT EXPENTRY MyWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  SWP   swp;
  ULONG rc;
  HWND  hFrame, hwndMenu;

  switch (msg)
  {
  case WM_CREATE:
       hListBox = WinCreateWindow(hwnd,
                                  WC_LISTBOX,
                                  NULL,
                                  WS_VISIBLE     |
                                  LS_NOADJUSTPOS |
                                  LS_HORZSCROLL,
                                  0, 0, 0, 0,
                                  hwnd,
                                  HWND_TOP,
                                  ID_LISTBOX,
                                  0,
                                  0);

       pwpList = WinSubclassWindow(hListBox,
                    wpSubList);

       hFrame = WinQueryWindow(hwnd,
                               QW_PARENT);
       rc = WinSetWindowPos(hFrame,
                            HWND_TOP,
                            50, 250,
                            300, 200,
                            SWP_MOVE     |
                            SWP_SIZE     |
                            SWP_ACTIVATE |
                            SWP_SHOW);
       hptrDrag = WinLoadPointer( HWND_DESKTOP, NULLHANDLE, ID_DRAGPTR);
                            
       break;

  case WM_SIZE:
       WinQueryWindowPos(hwnd, &swp);
       hListBox=WinWindowFromID(hwnd,
                                ID_LISTBOX);
       WinSetWindowPos(hListBox,
                       HWND_TOP,
                       swp.x, swp.y,
                       swp.cx, swp.cy,
                       SWP_SIZE  |
                       SWP_SHOW);
       break;

  /* just record drag messages sent to client window 
  */
  case DM_DROP:
  case DM_DRAGOVER:
  case DM_DRAGLEAVE:
  case DM_DROPHELP:
  case DM_ENDCONVERSATION:
  case DM_PRINT:
  case DM_RENDER:
  case DM_RENDERCOMPLETE:
  case DM_RENDERPREPARE:
  case DM_DRAGFILECOMPLETE:
  case DM_EMPHASIZETARGET:
  case DM_DRAGERROR:
  case DM_FILERENDERED:
  case DM_RENDERFILE:
  case DM_DRAGOVERNOTIFY:
  case DM_PRINTOBJECT:
  case DM_DISCARDOBJECT:
    PutMsg( 0, msg, mp1, mp2 );
    return (MRESULT)FALSE;
    break;

  case WM_MENUSELECT:
    switch( SHORT1FROMMP(mp1) )
    {
    case ID_OPTIONS:
      WinCheckMenuItem(HWNDFROMMP(mp2), IDM_DRGDRAG, bDrgDrag);
      WinCheckMenuItem(HWNDFROMMP(mp2), IDM_DRGDRAGFILES, !bDrgDrag);
      return (MRESULT)FALSE;

    default:
      return(WinDefWindowProc(hwnd, msg, mp1, mp2));
    }
  case WM_COMMAND:
    if( SHORT1FROMMP(mp2) == CMDSRC_MENU )
    {
      hwndMenu = WinWindowFromID(hFrame, FID_MENU);
      switch( SHORT1FROMMP(mp1) )
      {
      case IDM_DRGDRAG:
        bDrgDrag = TRUE;
        WinCheckMenuItem(hwndMenu, IDM_DRGDRAG, bDrgDrag);
        WinCheckMenuItem(hwndMenu, IDM_DRGDRAGFILES, !bDrgDrag);
        return (MRESULT)FALSE;
  
      case IDM_DRGDRAGFILES:
        bDrgDrag = FALSE;
        WinCheckMenuItem(hwndMenu, IDM_DRGDRAG, bDrgDrag);
        WinCheckMenuItem(hwndMenu, IDM_DRGDRAGFILES, !bDrgDrag);
        return (MRESULT)FALSE;
  
      case IDM_CONFIGDLG:
        if( bDrgDrag == TRUE )
          WinDlgBox(HWND_DESKTOP, hwnd, wpConfDrgDrag, NULLHANDLE,
                    IDD_CONFIG1, NULL);
        else
          WinDlgBox(HWND_DESKTOP, hwnd, wpConfDrgDragFiles, NULLHANDLE,
                    IDD_CONFIG2, NULL);
        return (MRESULT)TRUE;
    
      case IDM_CLEARLIST:
        WinSendMsg( hListBox, LM_DELETEALL, (MPARAM)0, (MPARAM)0 );
        return((MRESULT)TRUE);
    
      case IDM_DOSOMETHING:
        if( WinMessageBox(HWND_DESKTOP, hwnd, "OK, so do something else!",
                       "Message", 0, MB_OKCANCEL ) == MBID_OK )
          WinPostMsg( hwnd, WM_QUIT, (MPARAM)0, (MPARAM)0 );
        return((MRESULT)TRUE);
      }
    }
    break;

  default:
       return(WinDefWindowProc(hwnd,
                               msg,
                               mp1,
                               mp2));
  }
  return((MRESULT)FALSE);
}
Пример #8
0
static MRESULT processControl(HWND hwnd,MPARAM mp1,MPARAM mp2)
{
	switch(SHORT2FROMMP(mp1))
	{
		case CN_CONTEXTMENU:
		{
			RECORDCORE *record = (RECORDCORE *) PVOIDFROMMP(mp2);

			processPopUp(hwnd, CT_TRACK, record,
				PUM_CDRECORD, PUM_CDCONTAINER, &sourceEmphasisInfo);

			WinSendMsg(sourceEmphasisInfo.PUMHwnd, MM_SETITEMATTR,
				MPFROM2SHORT(IDM_MINIICONS, FALSE),
				MPFROM2SHORT(MIA_CHECKED, miniIcons ? MIA_CHECKED : 0));

			return 0;
		}

		case CN_BEGINEDIT: break;

		case CN_REALLOCPSZ:
		{
			CNREDITDATA *data = (CNREDITDATA *) mp2;
			CDTRACKRECORD *posRecord = (CDTRACKRECORD *) data->pRecord;

			if(data->pFieldInfo->offStruct == FIELDOFFSET(RECORDCORE,pszIcon))
			{
				posRecord->record.pszIcon = posRecord->record.pszText =
				posRecord->record.pszName = posRecord->record.pszTree =
					(char*) realloc(posRecord->record.pszIcon,data->cbText);
				return (MRESULT) TRUE;
			}

			else if(data->pFieldInfo->offStruct == FIELDOFFSET(CDTRACKRECORD,titleptr))
				{if(data->cbText <= sizeof(posRecord->title)) return (MRESULT) TRUE;}
			else if(data->pFieldInfo->offStruct == FIELDOFFSET(CDTRACKRECORD,artistptr))
				{if(data->cbText <= sizeof(posRecord->artist)) return (MRESULT) TRUE;}
			else if(data->pFieldInfo->offStruct == FIELDOFFSET(CDTRACKRECORD,albumptr))
				{if(data->cbText <= sizeof(posRecord->album)) return (MRESULT) TRUE;}
			else if(data->pFieldInfo->offStruct == FIELDOFFSET(CDTRACKRECORD,yearptr))
				{if(data->cbText <= sizeof(posRecord->year)) return (MRESULT) TRUE;}
			else if(data->pFieldInfo->offStruct == FIELDOFFSET(CDTRACKRECORD,genreptr))
				{if(data->cbText <= sizeof(posRecord->genre)) return (MRESULT) TRUE;}
			else if(data->pFieldInfo->offStruct == FIELDOFFSET(CDTRACKRECORD,commentptr))
				{if(data->cbText <= sizeof(posRecord->comment)) return (MRESULT) TRUE;}

			return 0;
		}

		/* rebuilds the filename */
		case CN_ENDEDIT:
		{
			CNREDITDATA *data = (CNREDITDATA *) mp2;
			CDTRACKRECORD *posRecord = (CDTRACKRECORD *) data->pRecord;

         if(data->pFieldInfo->offStruct == FIELDOFFSET(RECORDCORE,pszIcon))
         {
            makeValidLFN(posRecord->record.pszIcon);
         }
         else
			{
				char buffer2[256];
				char buffer[256];

				getFilenameFormat(buffer2,sizeof(buffer2));
				formatFilename(buffer,sizeof(buffer),buffer2,posRecord,hwnd);

				posRecord->record.pszIcon = posRecord->record.pszText =
				posRecord->record.pszName = posRecord->record.pszTree =
					(char*) realloc(posRecord->record.pszIcon,strlen(buffer)+1);
            strcpy(posRecord->record.pszIcon,makeValidLFN(buffer));
			}
			return 0;
		}

	}

	return 0;
}
Пример #9
0
void dlgcd_refresh(void *mp1, void **mp2)
{
	int i;
	char drive[4];
	HWND hwnd = (HWND) mp1;

	cdDrive = new CD_drive;

	getText(WinWindowFromID(hwnd, CB_DRIVE), CBID_EDIT, drive, sizeof(drive));
	drive[1] = ':';
	drive[2] = 0;

	/* find info on CD tracks */
   if(!cdDrive->open(drive) ||
      !cdDrive->readCDInfo() ||
      !cdDrive->fillTrackInfo() ||
      !cdDrive->close()
     )
   {
      delete cdDrive;
      cdDrive = NULL;
      return;
   }

	if(getCheck(hwnd, CB_USECDDB))
	{
		char server[512];
		BOOL success = FALSE;
		ULONG serverType;
		SHORT index = LIT_FIRST;

		cddbSocket = new CDDB_socket;
		*mp2 = cddbSocket; /* to be able to cancel */

		do
		{
			serverType = getNextCDDBServer(server,sizeof(server),&index);
			if(serverType != NOSERVER)
			{
				if(serverType == CDDB)
				{
					updateStatus("Contacting: %s", server);

					char host[512]=""; int port=8880;
					sscanf(server,"%[^:\n\r]:%d",host,&port);
					if(host[0])
						cddbSocket->tcpip_socket::connect(host,port);
				}
				else
				{
               char host[512], path[512], proxy[512], *slash = NULL, *http = NULL;

               http = strstr(server,"http://");
               if(http)
                  slash = strchr(http+7,'/');
					if(slash)
					{
						strncpy(host,server,slash-server);
						strcpy(path,slash);
                  getProxy(proxy,sizeof(proxy));
                  if(*proxy)
                     updateStatus("Contacting: %s", proxy);
                  else
                     updateStatus("Contacting: %s", server);
                  cddbSocket->connect(host,proxy,path);
					}
               else
                  updateError("Invalid URL: %s", server);
            }

				if(!cddbSocket->isOnline())
				{
					if(cddbSocket->getSocketError() == SOCEINTR)
						goto end;
					else
						continue;
				}
				updateStatus("Looking at CDDB Server Banner at %s", server);
				if(!cddbSocket->banner_req())
				{
					if(cddbSocket->getSocketError() == SOCEINTR)
						goto end;
					else
						continue;
				}
				updateStatus("Handshaking with CDDB Server %s", server);
				char user[128]="",host[128]="";
				getUserHost(user,sizeof(user),host,sizeof(host));
				if(!cddbSocket->handshake_req(user,host))
				{
					if(cddbSocket->getSocketError() == SOCEINTR)
						goto end;
					else
						continue;
				}

				updateStatus("Looking for CD information on %s", server);
            int rc = cddbSocket->query_req(cdDrive, &queryData);
				if(!rc)
				{
					if(cddbSocket->getSocketError() == SOCEINTR)
						goto end;
					else
						continue;
				}
				else if(rc == -1)
					continue; /* no match for this server */
				else if(rc == COMMAND_MORE)
				{
					CDDBQUERY_DATA *matches = (CDDBQUERY_DATA *) malloc(sizeof(CDDBQUERY_DATA));
               int i = 0;

               while(cddbSocket->get_query_req(&matches[i]))
					{
						i++;
                  matches = (CDDBQUERY_DATA *) realloc(matches, (i+1)*sizeof(CDDBQUERY_DATA));
					}
               memset(&matches[i],0,sizeof(matches[i]));
					/* don't try to open a window in this thread */
               WinSendMsg(hwnd,CDDB_FUZZYMATCH,matches,&queryData);
					free(matches);
				}
				/* else there is only one match */

            if(queryData.discid)
            {
               updateStatus("Requesting CD information from %s", server);
               if(!cddbSocket->read_req(queryData.category, queryData.discid))
               {
                  if(cddbSocket->getSocketError() == SOCEINTR)
                     goto end;
                  else
                     continue;
               }
               else
                  success = TRUE;
            }
			}
		} while(serverType != NOSERVER && !success);

		end:

		if(!success)
		{
			delete cddbSocket;
			cddbSocket = NULL;
		}

		updateStatus("");
	}

	return;
}
MRESULT EXPENTRY Dlg_UserPage (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
     switch( msg )
     {
     case WM_INITDLG:
         {
             WinSendMsg(WinWindowFromID(hwnd,USER_LOOP),EM_SETTEXTLIMIT,MPFROM2SHORT(4,TRUE),MPFROM2SHORT(0,TRUE));
             WinSendMsg(WinWindowFromID(hwnd,USER_WAIT),EM_SETTEXTLIMIT,MPFROM2SHORT(4,TRUE),MPFROM2SHORT(0,TRUE));
             String number;
             number = p_config->getUserLoopTimes();
             WinSetWindowText(WinWindowFromID(hwnd,USER_LOOP),number.asCharStar());
             number = (int)p_config->getUserLoopDelay();
             WinSetWindowText(WinWindowFromID(hwnd,USER_WAIT),number.asCharStar());
             
             if (p_config->getUserAutoStart())
                 WinCheckButton(hwnd,USER_AUTO,(unsigned short)TRUE);
             else
                 WinCheckButton(hwnd,USER_AUTO,(unsigned short)FALSE);
             
             if (p_config->getUserShowAllFiles())
             {
                 WinCheckButton(hwnd,USER_SMALLTREE,(unsigned short)FALSE);
                 WinCheckButton(hwnd,USER_BIGTREE,(unsigned short)TRUE);
             }
             else
             {
                 WinCheckButton(hwnd,USER_SMALLTREE,(unsigned short)TRUE);
                 WinCheckButton(hwnd,USER_BIGTREE,(unsigned short)FALSE);
             }
             
             if (p_config->getUserSmallIcons())
                 WinCheckButton(hwnd,USER_ICONS,(unsigned short)TRUE);
             else
                 WinCheckButton(hwnd,USER_ICONS,(unsigned short)FALSE);
         }
         
         break;
     //----------------------------------
     case WM_CLOSE:
         {
             unsigned short previous = WinCheckButton(hwnd,USER_AUTO,(unsigned short)TRUE);
             p_config->setUserAutoStart(previous);
             previous = WinCheckButton(hwnd,USER_BIGTREE,(unsigned short)TRUE);
             p_config->setUserShowAllFiles(previous);
             previous = WinCheckButton(hwnd,USER_ICONS,(unsigned short)TRUE);
             p_config->setUserSmallIcons(previous);
             
             char *buffer = new char[1024];
             WinQueryWindowText(WinWindowFromID(hwnd,USER_LOOP),1023,buffer);
             p_config->setUserLoopTimes(atoi(buffer));
             WinQueryWindowText(WinWindowFromID(hwnd,USER_WAIT),1023,buffer);
             p_config->setUserLoopDelay(atoi(buffer));
             delete[] buffer;
         }

	 return 0;	// 06 Mar 01 SHL
         
     case WM_CONTROL:
         switch(SHORT2FROMMP(mp1))
         {
             case EN_CHANGE:
             {
                 char *number_str = new char[1024];
                 switch (SHORT1FROMMP(mp1))
                 {
                     case USER_LOOP:
                         WinQueryWindowText(WinWindowFromID(hwnd,USER_LOOP),1023,number_str);
                         if (makeDigitsOnly(number_str))
                             WinSetWindowText(WinWindowFromID(hwnd,USER_LOOP),number_str);
                         break;
                     case USER_WAIT:
                         WinQueryWindowText(WinWindowFromID(hwnd,USER_WAIT),1023,number_str);
                         if (makeDigitsOnly(number_str))
                             WinSetWindowText(WinWindowFromID(hwnd,USER_WAIT),number_str);
                         break;
                 }
                 
                 delete[] number_str;
             }
         }
                 
         
     //----------------------------------
     case WM_COMMAND:
          switch( SHORT1FROMMP( mp1 ) )
          {
               case PB_DEFAULT:
                    // The default pushbutton has been pressed
                   // The entries should be reset to their default values
                   {
                       WinCheckButton(hwnd,USER_AUTO,(unsigned short)FALSE);
                       WinCheckButton(hwnd,USER_SMALLTREE,(unsigned short)FALSE);
                       WinCheckButton(hwnd,USER_BIGTREE,(unsigned short)TRUE);
                       WinCheckButton(hwnd,USER_ICONS,(unsigned short)TRUE);
                       WinSetWindowText(WinWindowFromID(hwnd,USER_LOOP),"0");
                       WinSetWindowText(WinWindowFromID(hwnd,USER_WAIT),"0");
                   }
                    break;
                //----------------------------------
          }
          return 0;
     //----------------------------------
     case WM_VALIDATE:
         {
/*             // get status of check box
             WinEnableWindowUpdate(WinWindowFromID(hwnd,USER_AUTO),FALSE);
             unsigned short previous = WinCheckButton(hwnd,USER_AUTO,(unsigned short)TRUE);
             WinCheckButton(hwnd,USER_AUTO,previous);
             WinEnableWindowUpdate(WinWindowFromID(hwnd,USER_AUTO),TRUE);

             // check log filename is available & writeable if being used
             char *buffer=new char[1024];
             WinQueryWindowText(WinWindowFromID(hwnd,LOG_PATH),1023,buffer);
             lrSpaceTrim(buffer);
             delete[] buffer;
*/         }
         
          return (MPARAM) 1; // !WinQueryButtonCheckstate( hwnd, CKB_VALIDATIONERROR );
     }//switch( msg )

     return WinDefDlgProc( hwnd, msg, mp1, mp2 );

}// Dlg_NbkpPage Dialog Procedure
Пример #11
0
MRESULT EXPENTRY MimeDlgProc(HWND hwndDlg,ULONG msg,MPARAM mp1,MPARAM mp2)
{
    HPOINTER  hptrOrig, hptrWait;
    static int num_entries;
    static int entry;
    static FILE *in;
    static Container *list;
    static MimeSet *mimes;
    UserData *ud;
    char buffer[1024];
    int i;
    
    switch(msg)
    {
        
        case WM_INITDLG:
            hptrWait = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE );
            hptrOrig = WinQueryPointer( HWND_DESKTOP );
            WinSetPointer( HWND_DESKTOP, hptrWait );
            
            WinSendMsg(WinWindowFromID(hwndDlg,MIME_NAME),EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0));
            WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXT), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0));
            WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXE), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0));
            
            mimes = (MimeSet*)mp2;
            list = new Container();
            list->initialise(hwndDlg,MIME_CONT);
            
            num_entries = mimes->getSetNum();
            for (i=0; i<num_entries; i++)
            {
                sprintf(buffer,"%s: %s",mimes->getName(i),mimes->getExtensions(i));
//                message("%d/%d %s is %s",i,num_entries,mimes->getName(i),mimes->getExtensions(i));
                
                list->insert(buffer,(UserData*)NULL,8888L,8888L);
            }
            
            WinFocusChange(HWND_DESKTOP,WinWindowFromID(hwndDlg,MIME_CONT),0);
            
            WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(mimes->getSetNum()-1));
            WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(mimes->getSetNum()-1));
            WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(mimes->getSetNum()-1));
            list->setItemFocus(list->getLastInsert());
            
            WinSetPointer( HWND_DESKTOP, hptrOrig );
            
            entry = -1;
            break;
            
        case WM_HELP:
            showHelpWindow(HELP_MIMES);
            break;
            
            
        case WM_CLOSE:
            mimes->reload();
            delete list;
            return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
            
        case WM_USER:
            list->arrange();
            break;
            
        case WM_CONTROL:
            switch(SHORT2FROMMP(mp1))
            {
                
                case CN_HELP:
                    WinSendMsg(hwndDlg,WM_HELP,0,0);
                    break;
                    
                // sent every time emphasis of an object is changed, so if
                // change from A to B, get deselect on A, and select on B
                case CN_EMPHASIS:
                {
                    PNOTIFYRECORDEMPHASIS nre = (PNOTIFYRECORDEMPHASIS)mp2;
                    ud = (UserData*)nre->pRecord;
                    
                    if (ud != NULL)
                    {
                        char *buffer = new char[4096];
                        strcpy(buffer,ud->getName());
                        char *ptr = buffer+strlen(buffer)-1;
                        while (ptr>buffer && *ptr!='.') ptr--;
                        if (*ptr == '.')
                        {
                            int index = mimes->find(ptr);
                            
                            if (index > -1)
                            {
                                entry = index;
                                WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(index));
                                WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(index));
                                WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(index));
                            }
                        }
                        delete[] buffer;
                    }
                }
                break;
                    
                case EN_CHANGE:
                {
                    if (SHORT1FROMMP(mp1) == MIME_EXE)
                    {
                        ud = list->findSelectedRecord(NULL);
                        static int lastindex = 0;
                        if (ud && entry != -1)
                        {
                            if (lastindex == entry)
                            {
                                char *buffer = new char[4096];
                                WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer);
                                mimes->setCommand(entry,buffer);
                                delete[] buffer;
                            }
                            lastindex = entry;
                        }
                    }
                }
                break;
                    
            }
            break;
            
        case WM_COMMAND:
            switch( SHORT1FROMMP( mp1 ) )
            {
                case IDM_DELETE:
//                    message("delete");
                    break;
                    
                case DID_OK:
                    // all OK, close dialog, return
                    if (entry != -1)
                    {
                        WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer);
                        mimes->setCommand(entry,buffer);
                    }
                    mimes->save();
                    delete list;
                    WinDismissDlg( hwndDlg, TRUE);
                    return (MRESULT) TRUE;
                    
                case DID_CANCEL:
                    mimes->reload();
                    delete list;
                    WinDismissDlg( hwndDlg, TRUE);
                    return (MRESULT) FALSE;
            }
            break;
            
            
        default:
            return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
    }
    return (MRESULT) TRUE;
}
Пример #12
0
void wxMenuBar::Refresh()
{
    wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );

    WinSendMsg(GetWinHwnd(m_menuBarFrame), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
} // end of wxMenuBar::Refresh
BOOL OSpinBtn::setArray(PSZ array, ULONG num)
{
  return((BOOL)WinSendMsg (hwnd, SPBM_SETARRAY,
                     MPFROMP (array),
                     MPFROMLONG (num)));
}
BOOL OSpinBtn::jumptoStart()
{
  while(WinSendMsg(hwnd,SPBM_SPINDOWN,MPFROMLONG(1),0)) {}
  return(TRUE);
}
Пример #15
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static INT aiPuzzle[NUMROWS][NUMCOLS],
                iBlankRow, iBlankCol, cxSquare, cySquare ;
     CHAR       szNum[10] ;
     HPS        hps ;
     HWND       hwndFrame ;
     INT        iRow, iCol, iMouseRow, iMouseCol, i ;
     POINTL     ptl ;
     RECTL      rcl, rclInvalid, rclIntersect ;
     SIZEL      sizl ;

     switch (msg)
          {
          case WM_CREATE:
                              // Calculate square size in pixels

               hps = WinGetPS (hwnd) ;
               sizl.cx = sizl.cy = 0 ;
               GpiSetPS (hps, &sizl, PU_LOENGLISH) ;
               ptl.x = SQUARESIZE ;
               ptl.y = SQUARESIZE ;
               GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ;
               WinReleasePS (hps) ;

               cxSquare = ptl.x ;
               cySquare = ptl.y ;

                              // Calculate client window size and position

               rcl.xLeft   = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) -
                                           NUMCOLS * cxSquare) / 2 ;
               rcl.yBottom = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) -
                                           NUMROWS * cySquare) / 2 ;
               rcl.xRight  = rcl.xLeft   + NUMCOLS * cxSquare ;
               rcl.yTop    = rcl.yBottom + NUMROWS * cySquare ;

                              // Set frame window position and size

               hwndFrame = WinQueryWindow (hwnd, QW_PARENT) ;
               WinCalcFrameRect (hwndFrame, &rcl, FALSE) ;
               WinSetWindowPos  (hwndFrame, NULLHANDLE,
                                 rcl.xLeft, rcl.yBottom,
                                 rcl.xRight - rcl.xLeft,
                                 rcl.yTop - rcl.yBottom,
                                 SWP_MOVE | SWP_SIZE | SWP_ACTIVATE) ;

                              // Initialize the aiPuzzle array

               WinSendMsg (hwnd, WM_COMMAND, MPFROMSHORT (IDM_NORMAL), NULL) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, &rclInvalid) ;

                              // Draw the squares

               for (iRow = NUMROWS - 1 ; iRow >= 0 ; iRow--)
                    for (iCol = 0 ; iCol < NUMCOLS ; iCol++)
                         {
                         rcl.xLeft   = cxSquare * iCol ;
                         rcl.yBottom = cySquare * iRow ;
                         rcl.xRight  = rcl.xLeft   + cxSquare ;
                         rcl.yTop    = rcl.yBottom + cySquare ;

                         if (!WinIntersectRect (0, &rclIntersect,
                                                &rcl, &rclInvalid))
                              continue ;

                         if (iRow == iBlankRow && iCol == iBlankCol)
                              WinFillRect (hps, &rcl, CLR_BLACK) ;
                         else
                              {
                              WinDrawBorder (hps, &rcl, 5, 5,
                                             CLR_PALEGRAY, CLR_DARKGRAY,
                                             DB_STANDARD | DB_INTERIOR) ;

                              WinDrawBorder (hps, &rcl, 2, 2,
                                             CLR_BLACK, 0L, DB_STANDARD) ;

                              sprintf (szNum, "%d", aiPuzzle[iRow][iCol]) ;

                              WinDrawText (hps, -1, szNum,
                                           &rcl, CLR_WHITE, CLR_DARKGRAY,
                                           DT_CENTER | DT_VCENTER) ;
                              }
                         }
               WinEndPaint (hps) ;
               return 0 ;

          case WM_BUTTON1DOWN:
               iMouseCol = MOUSEMSG(&msg)->x / cxSquare ;
               iMouseRow = MOUSEMSG(&msg)->y / cySquare ;

                              // Check if mouse was in valid area

               if ( iMouseRow < 0          || iMouseCol < 0           ||
                    iMouseRow >= NUMROWS   || iMouseCol >= NUMCOLS    ||
                   (iMouseRow != iBlankRow && iMouseCol != iBlankCol) ||
                   (iMouseRow == iBlankRow && iMouseCol == iBlankCol))
                         break ;

                              // Move a row right or left

               if (iMouseRow == iBlankRow)
                    {
                    if (iMouseCol < iBlankCol)
                         for (iCol = iBlankCol ; iCol > iMouseCol ; iCol--)
                              aiPuzzle[iBlankRow][iCol] =
                                   aiPuzzle[iBlankRow][iCol - 1] ;
                    else
                         for (iCol = iBlankCol ; iCol < iMouseCol ; iCol++)
                              aiPuzzle[iBlankRow][iCol] =
                                   aiPuzzle[iBlankRow][iCol + 1] ;
                    }
                              // Move a column up or down
               else
                    {
                    if (iMouseRow < iBlankRow)
                         for (iRow = iBlankRow ; iRow > iMouseRow ; iRow--)
                              aiPuzzle[iRow][iBlankCol] =
                                   aiPuzzle[iRow - 1][iBlankCol] ;
                    else
                         for (iRow = iBlankRow ; iRow < iMouseRow ; iRow++)
                              aiPuzzle[iRow][iBlankCol] =
                                   aiPuzzle[iRow + 1][iBlankCol] ;
                    }
                              // Calculate invalid rectangle

               rcl.xLeft   = cxSquare *  min (iMouseCol, iBlankCol) ;
               rcl.yBottom = cySquare *  min (iMouseRow, iBlankRow) ;
               rcl.xRight  = cxSquare * (max (iMouseCol, iBlankCol) + 1) ;
               rcl.yTop    = cySquare * (max (iMouseRow, iBlankRow) + 1) ;

                              // Set new array and blank values

               iBlankRow = iMouseRow ;
               iBlankCol = iMouseCol ;
               aiPuzzle[iBlankRow][iBlankCol] = 0 ;

                              // Invalidate rectangle

               WinInvalidateRect (hwnd, &rcl, FALSE) ;
               break ;

          case WM_CHAR:
               if (!(CHARMSG(&msg)->fs & KC_VIRTUALKEY) ||
                     CHARMSG(&msg)->fs & KC_KEYUP)
                         return 0 ;

                              // Mimic a WM_BUTTON1DOWN message

               iMouseCol = iBlankCol ;
               iMouseRow = iBlankRow ;

               switch (CHARMSG(&msg)->vkey)
                    {
                    case VK_LEFT:   iMouseCol++ ;  break ;
                    case VK_RIGHT:  iMouseCol-- ;  break ;
                    case VK_UP:     iMouseRow-- ;  break ;
                    case VK_DOWN:   iMouseRow++ ;  break ;
                    default:        return 0 ;
                    }
               WinSendMsg (hwnd, WM_BUTTON1DOWN,
                           MPFROM2SHORT (iMouseCol * cxSquare,
                                         iMouseRow * cySquare), NULL) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                              // Initialize aiPuzzle array

                    case IDM_NORMAL:
                    case IDM_INVERT:
                         for (iRow = 0 ; iRow < NUMROWS ; iRow++)
                              for (iCol = 0 ; iCol < NUMCOLS ; iCol++)
                                   aiPuzzle[iRow][iCol] = iCol + 1 +
                                        NUMCOLS * (NUMROWS - iRow - 1) ;

                         if (COMMANDMSG(&msg)->cmd == IDM_INVERT)
                              {
                              aiPuzzle[0][NUMCOLS-2] = NUMCOLS * NUMROWS - 2 ;
                              aiPuzzle[0][NUMCOLS-3] = NUMCOLS * NUMROWS - 1 ;
                              }
                         aiPuzzle[iBlankRow = 0][iBlankCol = NUMCOLS - 1] = 0 ;
                         WinInvalidateRect (hwnd, NULL, FALSE) ;
                         return 0 ;

                              // Randomly scramble the squares

                    case IDM_SCRAMBLE:
                         WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (
                                        HWND_DESKTOP, SPTR_WAIT, FALSE)) ;

                         srand ((int) WinGetCurrentTime (0)) ;

                         for (i = 0 ; i < SCRAMBLEREP ; i++)
                              {
                              WinSendMsg (hwnd, WM_BUTTON1DOWN,
                                   MPFROM2SHORT (rand() % NUMCOLS * cxSquare,
                                        iBlankRow * cySquare), NULL) ;
                              WinUpdateWindow (hwnd) ;

                              WinSendMsg (hwnd, WM_BUTTON1DOWN,
                                   MPFROM2SHORT (iBlankCol * cxSquare,
                                        rand() % NUMROWS * cySquare), NULL) ;
                              WinUpdateWindow (hwnd) ;
                              }
                         WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (
                                        HWND_DESKTOP, SPTR_ARROW, FALSE));
                         return 0 ;
                    }
               break ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
/*
 *
 *  BrowseWndProc
 *
 *  DESCRIPTION:
 *
 *    Processes messages for the Browse-O-Matic client window.
 *
 */
MRESULT EXPENTRY BrowseWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   switch( msg){

      case WM_CREATE:
         {
            CHAR          pszTitle[ MAX_TITLE_LENGTH];
            PBROWSEDATA   pWindowData;

            pWindowData = (PBROWSEDATA)mp1;
            WinSetWindowPtr( hwnd, QWL_USER, pWindowData);

            /*******************/
            /* Load the object */
            /*******************/
            _LoadObject( pWindowData->somSelf,
                        pWindowData->pszObjectName, &pWindowData->ulFileLength,
                                   &pWindowData->pBuffer, &pWindowData->pLines,
                                             &pWindowData->usNumberOfTextLines,
                                          &pWindowData->usNumberOfTextColumns);

            _GetLinesAndColumns( pWindowData->somSelf, pWindowData->bDisplay,
                        &pWindowData->sTotalLines, &pWindowData->sTotalColumns,
                                             pWindowData->usNumberOfTextLines,
                                            pWindowData->usNumberOfTextColumns,
                                                    pWindowData->ulFileLength);

            /*********************************************/
            /* Get the window handle for the scroll bars */
            /*********************************************/
            pWindowData->hwndVscroll = WinWindowFromID( WinQueryWindow( hwnd,
                                                   QW_PARENT), FID_VERTSCROLL);
            pWindowData->hwndHscroll = WinWindowFromID( WinQueryWindow( hwnd,
                                                   QW_PARENT), FID_HORZSCROLL);

            /*************************/
            /* Save font information */
            /*************************/
            WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);

            /*****************/
            /* Get the focus */
            /*****************/
            WinSetFocus( HWND_DESKTOP, hwnd);

            /*****************************************************/
            /* Create the title for the Browse-O-Matic title bar */
            /*****************************************************/
            if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
               sprintf( pszTitle, "Object: %s    (%d Bytes)",
                        pWindowData->pszObjectName, pWindowData->ulFileLength);
            else
               sprintf( pszTitle, "Object: %s    (%hd Lines)",
                         pWindowData->pszObjectName, pWindowData->sTotalLines);

            /************************************************/
            /* Register the current open view of the object */
            /************************************************/
            _wpAddToObjUseList( pWindowData->somSelf, &(pWindowData->UseItem));
            _wpRegisterView( pWindowData->somSelf, WinQueryWindow( hwnd,
                                                         QW_PARENT), pszTitle);
         }
         break;

      case WM_CLOSE:
         {
            HWND        hwndFrame;
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);
            hwndFrame = WinQueryWindow( hwnd, QW_PARENT);

            /*****************************************************/
            /* Save the window info - size, location, and fonts. */
            /*****************************************************/
            WinStoreWindowPos( APPL_NAME, pWindowData->pszApplKey, hwndFrame);

            /**********************************************************/
            /* Free the window data and unload the file system object */
            /**********************************************************/
            if( pWindowData){
               if( pWindowData->pszObjectName)
                  _wpFreeMem( pWindowData->somSelf,
                                           ( PBYTE)pWindowData->pszObjectName);
               _wpFreeMem( pWindowData->somSelf, ( PBYTE)pWindowData);
            }

            _UnloadObject( pWindowData->somSelf, pWindowData->pBuffer,
                                                          pWindowData->pLines);

            _wpDeleteFromObjUseList( pWindowData->somSelf,
                                                        &pWindowData->UseItem);
            /*******************/
            /* Kill the window */
            /*******************/
            WinPostMsg( hwnd, WM_QUIT, 0, 0 );
            WinDestroyWindow( hwndFrame);
         }
         break;

      /*******************************************************************/
      /* The font characteristics have changed. This happens when a font */
      /* from the font palette is dropped on the client window.          */
      /*******************************************************************/
      case WM_PRESPARAMCHANGED:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            if( (ULONG)mp1 == PP_FONTNAMESIZE){

               /***********************************************/
               /* Get the new font information and redraw the */
               /* window with the new font/font size.         */
               /***********************************************/
               WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);
               WinSendMsg( hwnd, WM_SIZE, 0, MPFROM2SHORT(
                       pWindowData->sClientWidth, pWindowData->sClientHeight));
            }
         }
         break;

      case WM_SIZE:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            /***************************************/
            /* Save client window size information */
            /***************************************/
            pWindowData->sClientWidth = SHORT1FROMMP( mp2);
            pWindowData->sClientHeight = SHORT2FROMMP( mp2);
            pWindowData->sPageHeight = pWindowData->sClientHeight/
                                                      pWindowData->sCharHeight;
            pWindowData->sPageWidth = pWindowData->sClientWidth  /
                                                       pWindowData->sCharWidth;

            /**************************************/
            /* Set the ranges for the scroll bars */
            /**************************************/
            WinPostMsg( pWindowData->hwndVscroll, SBM_SETSCROLLBAR,
                         (MPARAM)pWindowData->sCurrentLine, MPFROM2SHORT( 0,
                         pWindowData->sTotalLines - pWindowData->sPageHeight));
            WinPostMsg( pWindowData->hwndHscroll, SBM_SETSCROLLBAR,
                        (MPARAM)pWindowData->sCurrentColumn, MPFROM2SHORT( 0,
                        pWindowData->sTotalColumns - pWindowData->sPageWidth));

            /*************************************/
            /* Set scroll bar thumb control size */
            /*************************************/
            WinPostMsg( pWindowData->hwndVscroll, SBM_SETTHUMBSIZE,
                                        MPFROM2SHORT( pWindowData->sPageHeight,
                                        pWindowData->sTotalLines), (MPARAM) 0);
            WinPostMsg( pWindowData->hwndHscroll, SBM_SETTHUMBSIZE,
                                      MPFROM2SHORT( pWindowData->sPageWidth,
                                      pWindowData->sTotalColumns), (MPARAM) 0);

            /************************************************************/
            /* If the all the lines and/or columns can fit in the new   */
            /* sized window, set the sCurrentLine and/or sCurrentColumn */
            /* to the top/right side.                                   */
            /************************************************************/
            if( pWindowData->sPageHeight >= pWindowData->sTotalLines)
               pWindowData->sCurrentLine = 0;

            if( pWindowData->sPageWidth >= pWindowData->sTotalColumns)
               pWindowData->sCurrentColumn = 0;

            /********************************************/
            /* Repaint window with new size information */
            /********************************************/
            WinInvalidateRect( hwnd, NULL, FALSE);
         }
         return( 0);

      case WM_PAINT:
         {
            HPS         hps;
            CHAR        pszText[255];
            UINT        nLength = 0;
            RECTL       rect;
            POINTL      point;
            SHORT       sLine;
            SHORT       sTopLine;
            SHORT       sBottomLine;
            SHORT       sLinesFromTop;
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            hps = WinBeginPaint( hwnd, NULLHANDLE, &rect);

            /*******************************************/
            /* Clear the area that needs to be redrawn */
            /*******************************************/
            GpiErase( hps);

            /********************************/
            /* Determine first clipped line */
            /********************************/
            sLinesFromTop = ( pWindowData->sClientHeight - rect.yTop) /
                                                      pWindowData->sCharHeight;
            rect.yTop = pWindowData->sClientHeight -
                                   ( pWindowData->sCharHeight * sLinesFromTop);

            /***************************************************************/
            /* Determine the first position to write at. NOTE: PM handles  */
            /* clipping for point.x < 0. Any characters written before the */
            /* the first column or after the last column are clipped.      */
            /***************************************************************/
            point.y = rect.yTop - pWindowData->sCharHeight +
                                                   pWindowData->sCharDescender;
            point.x = pWindowData->sCurrentColumn*pWindowData->sCharWidth * -1;

            /***********************************************/
            /* Determine the top and bottom lines to write */
            /***********************************************/
            sTopLine    = rect.yTop    / pWindowData->sCharHeight;
            sBottomLine = rect.yBottom / pWindowData->sCharHeight;

            /*********************************************************/
            /* Make sure that we aren't trying to display more lines */
            /* then are available.                                   */
            /*********************************************************/
            if( pWindowData->sPageHeight - sBottomLine + 1 >
                          pWindowData->sTotalLines - pWindowData->sCurrentLine)
               sBottomLine=pWindowData->sPageHeight-(pWindowData->sTotalLines -
                                                pWindowData->sCurrentLine) + 1;

            /********************************/
            /* Redraw the invalid rectangle */
            /********************************/
            for( sLine = sTopLine; sLine >= sBottomLine; sLine--){

               /*******************************************/
               /* Get the line of text or hex information */
               /* that we are going to write.             */
               /*******************************************/
               if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
                  nLength = _GetHexLine( pWindowData->somSelf,
                     pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
                           +1, pWindowData->pBuffer, pWindowData->ulFileLength,
                                                                      pszText);
               else
                  nLength = _GetTextLine( pWindowData->somSelf,
                       pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
                                             +1, pWindowData->pLines, pszText);

               /******************/
               /* Write the text */
               /******************/
               if( nLength != 0)
                  GpiCharStringAt( hps, &point, nLength, pszText);

               point.y -= pWindowData->sCharHeight;
            }

            WinEndPaint( hps);
         }
         return( 0);

      /*******************************************/
      /* Keyboard support for scrolling and help */
      /*******************************************/
      case WM_CHAR:

         /****************************************/
         /* Show general help if user selects F1 */
         /****************************************/
         if( CHARMSG( &msg)->vkey == VK_F1){
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);
            _wpDisplayHelp( pWindowData->somSelf, PANEL_MAIN,
                            "browse.hlp");
            return 0;
         }

         if( (CHARMSG( &msg)->fs & KC_KEYUP))
            return 0;

         switch( CHARMSG( &msg)->vkey){

            case VK_UP:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEUP));
               return 0;

            case VK_DOWN:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEDOWN));
               return 0;

            case VK_RIGHT:
               /************************************************************/
               /* Ctrl-Right scrolls one page to the right. Right scrolls  */
               /* to the right.                                            */
               /************************************************************/
               if( (CHARMSG( &msg)->fs & KC_CTRL))
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT(0, SB_PAGERIGHT));
               else
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT(0, SB_LINERIGHT));
               return 0;

            case VK_LEFT:
               /*********************************************************/
               /* Ctrl-Left scrolls one page to the left. Left scrolls  */
               /* to the Left.                                          */
               /*********************************************************/
               if( (CHARMSG( &msg)->fs & KC_CTRL))
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT( 0, SB_PAGELEFT));
               else
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT( 0, SB_LINELEFT));
               return 0;

            case VK_PAGEUP:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEUP));
               return 0;

            case VK_PAGEDOWN:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEDOWN));
               return 0;

            case VK_HOME:
               {
                  PBROWSEDATA pWindowData;

                  pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

                  /*********************************************************/
                  /* Ctrl-Home positions at the first line, Home positions */
                  /* at the beginning of the current line.                 */
                  /*********************************************************/
                  if( (CHARMSG( &msg)->fs & KC_CTRL)){
                     WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0,
                                          MPFROM2SHORT( 0, SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                                           MPFROMSHORT( 0), 0);
                  }
                  else{
                     WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0,
                                          MPFROM2SHORT( 0, SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                                           MPFROMSHORT( 0), 0);
                  }
                  return 0;
               }

            case VK_END:
               {
                  PBROWSEDATA pWindowData;

                  pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

                  /*********************************************************/
                  /* Ctrl-End positions at the last line, End positions at */
                  /* the end of the current line.                          */
                  /*********************************************************/
                  if( (CHARMSG( &msg)->fs & KC_CTRL)){
                     WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0, MPFROM2SHORT(
                           pWindowData->sTotalLines - pWindowData->sPageHeight,
                                                           SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                      MPFROMSHORT( pWindowData->sTotalLines -
                                                 pWindowData->sPageHeight), 0);
                  }
                  else{
                     WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0, MPFROM2SHORT(
                          pWindowData->sTotalColumns - pWindowData->sPageWidth,
                                                           SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                      MPFROMSHORT( pWindowData->sTotalColumns -
                                                  pWindowData->sPageWidth), 0);
                  }
                  return 0;
               }
         }
         break;

      /******************/
      /* Scroll Up/Down */
      /******************/
      case WM_VSCROLL:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

            switch( SHORT2FROMMP( mp2)){

               case SB_LINEUP:
                  if( pWindowData->sCurrentLine > 0){
                     pWindowData->sCurrentLine--;

                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                         (MPARAM)pWindowData->sCurrentLine, 0);

                     WinScrollWindow( hwnd, 0, pWindowData->sCharHeight * -1,
                               NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_LINEDOWN:
                  if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
                                                     pWindowData->sPageHeight){
                     pWindowData->sCurrentLine++;

                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                         (MPARAM)pWindowData->sCurrentLine, 0);

                     WinScrollWindow( hwnd, 0, pWindowData->sCharHeight, NULL,
                                     NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_PAGEUP:
                  if( pWindowData->sCurrentLine > 0){
                     pWindowData->sCurrentLine = max( 0,
                         pWindowData->sCurrentLine - pWindowData->sPageHeight);
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                          (MPARAM)pWindowData->sCurrentLine,0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_PAGEDOWN:
                  if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
                                                     pWindowData->sPageHeight){
                     pWindowData->sCurrentLine= min( pWindowData->sTotalLines -
                          pWindowData->sPageHeight, pWindowData->sCurrentLine +
                                                     pWindowData->sPageHeight);
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                          (MPARAM)pWindowData->sCurrentLine,0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_SLIDERPOSITION:
                  /***********************************************************/
                  /* Can't change current line if all the text fits in the   */
                  /* window.                                                 */
                  /***********************************************************/
                  if( pWindowData->sTotalLines > pWindowData->sPageHeight){
                     pWindowData->sCurrentLine = SHORT1FROMMP( mp2);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);
            }
         }
         break;


      /*********************/
      /* Scroll Right/Left */
      /*********************/
      case WM_HSCROLL:
         {
            PBROWSEDATA pWindowData;

            pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);

            switch( SHORT2FROMMP( mp2)){

               case SB_LINELEFT:
                  if( pWindowData->sCurrentColumn > 0){
                     pWindowData->sCurrentColumn = max( 0,
                                              pWindowData->sCurrentColumn - 1);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                        (MPARAM)pWindowData->sCurrentColumn,0);
                     WinScrollWindow( hwnd, pWindowData->sCharWidth, 0, NULL,
                                     NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_LINERIGHT:
                  if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
                                                      pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns,
                                              pWindowData->sCurrentColumn + 1);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinScrollWindow( hwnd, pWindowData->sCharWidth * -1, 0,
                               NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_PAGELEFT:
                  if( pWindowData->sCurrentColumn > 0){
                     pWindowData->sCurrentColumn = max( 0,
                        pWindowData->sCurrentColumn - pWindowData->sPageWidth);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_PAGERIGHT:
                  if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
                                                      pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns
                       - pWindowData->sPageWidth, pWindowData->sCurrentColumn +
                                                      pWindowData->sPageWidth);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_SLIDERPOSITION:
                  /***********************************************************/
                  /* Can't change current column if all the text fits in the */
                  /* window.                                                 */
                  /***********************************************************/
                  if( pWindowData->sTotalColumns > pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn = SHORT1FROMMP( mp2);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);
            }
         }
         break;

      /*****************************/
      /* Get font size information */
      /*****************************/
      case IDL_SETFONTINFO:
         {
            HPS         hps;
            FONTMETRICS fm;
            PBROWSEDATA pWindowData;

            pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);

            hps = WinGetPS( hwnd);
            GpiQueryFontMetrics( hps, sizeof( fm), &fm);
            WinReleasePS( hps);

            /***********************************************************/
            /* The character width is average of the average uppercase */
            /* and average lower case widths.                          */
            /***********************************************************/
            pWindowData->sCharWidth     = (SHORT)fm.lMaxCharInc;
            pWindowData->sCharHeight    = (SHORT)fm.lMaxBaselineExt;
            pWindowData->sCharDescender = (SHORT)fm.lMaxDescender;
         }
         return( 0);

      /*********************************************/
      /* Display no help available message to user */
      /*********************************************/
      case HM_HELPSUBITEM_NOT_FOUND:
         return( ( MRESULT)FALSE);

      /**************************************/
      /* Return name of help for keys panel */
      /**************************************/
      case HM_QUERY_KEYS_HELP:
         return( ( MRESULT)PANEL_HELPKEYS);
   }

   /********************************************************/
   /* Let the default window procedure process the message */
   /********************************************************/
   return( WinDefWindowProc( hwnd, msg, mp1, mp2));
}
Пример #17
0
//=============================================================================
// Dialog procedure
//=============================================================================
MRESULT EXPENTRY DlgMenu (HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  {
  unsigned int i, j, k, num, slider, masklen, subnetbit, hostbit;
  unsigned int numsubnet, numhost, numtotal;
  unsigned char InField[4], OutScale[3], class[2] = "\0", OutMsg[48];
  unsigned char currnet[4], netstart[4], netstop[4], broadcast[4];
  static char ErrAddr[] = "Wrong IP address";
  static char ErrMask[] = "Wrong network mask";

  switch (msg)
    {
//-----------------------------------------------------------------------------
// Handle the initialization of the dialog
//-----------------------------------------------------------------------------
    case WM_INITDLG:
      {
//-----------------------------------------------------------------------------
// Set icon
//-----------------------------------------------------------------------------
      HPOINTER hptr = (HPOINTER)WinLoadPointer(HWND_DESKTOP, NULLHANDLE, 1);
      WinSendMsg(hwndDlg, WM_SETICON, (MPARAM) hptr, 0l);
      for ( i=0; i<4; i++ )
        WinSendDlgItemMsg(hwndDlg, EF_A1+i, EM_SETTEXTLIMIT, (MPARAM)3, 0);

      WinSendDlgItemMsg(hwndDlg,
                        SBH,
                        SLM_SETTICKSIZE,
                        MPFROM2SHORT(SMA_SETALLTICKS, 3),
                        NULL);
      for ( i=0; i<=32; i+=8 )
        {
        itoa(i, OutScale, 10);
        WinSendDlgItemMsg(hwndDlg,
                          SBH,
                          SLM_SETSCALETEXT,
                          MPFROMLONG(i),
                          MPFROMP(OutScale));
        }
      break;
      }
//-----------------------------------------------------------------------------
// Handle WM_COMMAND
//-----------------------------------------------------------------------------
    case WM_COMMAND:
      {
      switch(SHORT1FROMMP(mp1))
        {
//-----------------------------------------------------------------------------
// Close the dialog
//-----------------------------------------------------------------------------
        case PB_EXIT:
          {
          WinSendMsg(hwndDlg, WM_CLOSE, 0L, 0L);
          break;
          }
//-----------------------------------------------------------------------------
// Calculate
//-----------------------------------------------------------------------------
        case PB_CALCULATE:
          {
          WinSetDlgItemText(hwndDlg, LT_NET,  "");
          WinSetDlgItemText(hwndDlg, TXT_MB,  "");
          WinSetDlgItemText(hwndDlg, TXT_M,   "");
          WinSetDlgItemText(hwndDlg, TXT_SB,  "");
          WinSetDlgItemText(hwndDlg, TXT_HB,  "");
          WinSetDlgItemText(hwndDlg, TXT_NS,  "");
          WinSetDlgItemText(hwndDlg, TXT_NH,  "");
          WinSetDlgItemText(hwndDlg, TXT_T,   "");
          WinSetDlgItemText(hwndDlg, TXT_CN,  "");
          WinSetDlgItemText(hwndDlg, TXT_CB,  "");
          WinSetDlgItemText(hwndDlg, TXT_CHR, "");

          for ( i=0; i<4; i++ )
            {
//-----------------------------------------------------------------------------
// Разберем поля IP-адреса
//-----------------------------------------------------------------------------
            if ( (num=WinQueryDlgItemTextLength(hwndDlg, EF_A1+i)) == 0 )
              {
              SendErrMsg(hwndDlg, ErrAddr);
              return (0);
              }

            WinQueryDlgItemText(hwndDlg, EF_A1+i, sizeof(InField), InField);
            for ( j=0; j<num; j++)
              if ( isdigit(InField[j]) == 0 )
                {
                SendErrMsg(hwndDlg, ErrAddr);
                return (0);
                }

            if ( (num=atoi(InField)) > 255 )
              {
              SendErrMsg(hwndDlg, ErrAddr);
              return (0);
              }

            addr[i] = num;
            }
//-----------------------------------------------------------------------------
// Разберем адрес IP
//-----------------------------------------------------------------------------
          memset(network, 0, sizeof(network));
          if ( (addr[0] & '\x80') == '\x00' )
            {
            class[0] = 'A';
            i = 1;
            }
          else
            if ( (addr[0] & '\xc0') == '\x80' )
              {
              class[0] = 'B';
              i = 2;
              }
            else
              if ( (addr[0] & '\xe0') == '\xc0' )
                {
                class[0] = 'C';
                i = 3;
                }
              else
                {
                SendErrMsg(hwndDlg, ErrAddr);
                return (0);
                }
          masklen = 8 * i;

          for ( j=0; j<i; j++ ) network[j] = addr[j];
          sprintf(OutMsg, "Class %s network %d.%d.%d.%d", class,
                  network[0], network[1], network[2], network[3]);
          WinSetDlgItemText(hwndDlg, LT_NET, OutMsg);
//-----------------------------------------------------------------------------
// Разберем поля маски
//-----------------------------------------------------------------------------
          slider =
              (ULONG)WinSendDlgItemMsg(hwndDlg,
                                       SBH,
                                       SLM_QUERYSLIDERINFO,
                                       MPFROM2SHORT(SMA_SLIDERARMPOSITION,
                                                    SMA_INCREMENTVALUE),
                                       NULL);

          if ( (slider<masklen) || (slider==(masklen+1)) || (slider>=31) )
            {
            SendErrMsg(hwndDlg, ErrMask);
            return (0);
            }

          sprintf(OutMsg, "%d", slider);
          WinSetDlgItemText(hwndDlg, TXT_MB, OutMsg);

          memset(mask, 0, sizeof(mask));
          for ( i=0, k=0; i<4; i++)
            for ( j=0; (j<8)&&(k<slider); j++, k++ ) mask[i] |= ('\x80'>>j);

          sprintf(OutMsg, "%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3]);
          WinSetDlgItemText(hwndDlg, TXT_M, OutMsg);

          subnetbit = slider-masklen;
          sprintf(OutMsg, "%d", subnetbit);
          WinSetDlgItemText(hwndDlg, TXT_SB, OutMsg);
          hostbit = 32-masklen-subnetbit;
          sprintf(OutMsg, "%d", hostbit);
          WinSetDlgItemText(hwndDlg, TXT_HB, OutMsg);

          if ( subnetbit != 0 ) numsubnet = (1L<<subnetbit)-2;
          else numsubnet = 0;
          sprintf(OutMsg, "%d", numsubnet);
          WinSetDlgItemText(hwndDlg, TXT_NS, OutMsg);
          numhost = (1L<<hostbit)-2;
          sprintf(OutMsg, "%d", numhost);
          WinSetDlgItemText(hwndDlg, TXT_NH, OutMsg);
          if ( subnetbit != 0 ) numtotal = numsubnet*numhost;
          else numtotal = numhost;
          sprintf(OutMsg, "%d", numtotal);
          WinSetDlgItemText(hwndDlg, TXT_T, OutMsg);

          for (i=0; i<4; i++) currnet[i] = addr[i] & mask[i];
          sprintf(OutMsg, "%d.%d.%d.%d",
                  currnet[0], currnet[1], currnet[2], currnet[3]);
          WinSetDlgItemText(hwndDlg, TXT_CN, OutMsg);

          for (i=0; i<4; i++) broadcast[i] = currnet[i] | (~mask[i]);
          sprintf(OutMsg, "%d.%d.%d.%d",
                  broadcast[0], broadcast[1], broadcast[2], broadcast[3]);
          WinSetDlgItemText(hwndDlg, TXT_CB, OutMsg);

          for (i=0; i<4; i++)
            {
            netstart[i] = currnet[i];
            netstop[i] = broadcast[i];
            }
          netstart[3]++;
          netstop[3]-=1;
          sprintf(OutMsg, "%d.%d.%d.%d-%d.%d.%d.%d",
                  netstart[0], netstart[1], netstart[2], netstart[3],
                  netstop[0],  netstop[1],  netstop[2],  netstop[3]);
          WinSetDlgItemText(hwndDlg, TXT_CHR, OutMsg);

          return (0);
          }
//-----------------------------------------------------------------------------
// Расскажем о себе
//-----------------------------------------------------------------------------
        case PB_ABOUT:
          {
          WinDlgBox( HWND_DESKTOP,
                     hwndDlg,
                     WinDefDlgProc,
                     NULLHANDLE,
                     200,
                     0 );
          return (0);
          }
        }
Пример #18
0
MRESULT	EXPENTRY DriverWndProc(HWND hWnd, ULONG	msg, MPARAM mp1, MPARAM	mp2)

{
CHAR	     szFile[CCHMAXPATH];   /* File HOlder			*/
FILEFINDBUF3 findbuf;		   /* File Find	Buffer			*/
FONTMETRICS  fm;		   /* Font Metrics Structure		*/
HDIR	     hDir = (HDIR)HDIR_CREATE; /* Directory Handle		*/
HPS	     hPS;		   /* Presentation Space Handle		*/
HWND	     hwndListBox;	   /* List Box Window Handle		*/
LISTBOXCDATA lbwcd;		   /* List Box Window Control Data	*/
POWNERITEM   poi;		   /* Owner Item			*/
RECTL	     rcl;		   /* Client Window Rectangle		*/
ULONG	     ulFileCnt = 1UL;	   /* File Counter Holder		*/
register INT i,	k, n;		   /* Loop Counter			*/

switch ( msg )
   {
		       /* Perform window initialization			*/
   case	WM_CREATE :
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);
       WinSetPointer(HWND_DESKTOP, hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
       memset(&lbwcd, 0, sizeof(LISTBOXCDATA));
       lbwcd.cb	= sizeof(LISTBOXCDATA);
       lbwcd.ulVersion = LBV_110;
       lbwcd.vdata.lbcd1_1.flExtStyles = LSXS_CHECKBOX | LSXS_EDITABLE;

       hwndList1 = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   10L,	10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndListx = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   125L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndList2 = WinCreateWindow(hWnd, "ListBoxWindow", "", WS_VISIBLE, 10L, 190L, 250L, 200L, hWnd,
				   HWND_TOP, 1025UL, (PVOID)&lbwcd, (PVOID)NULL);

       WinSendMsg(hwndList1, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_SINGLECLICK),
		  MPFROMP("ahooga.wav"));
       WinSendMsg(hwndListx, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_DOUBLECLICK),
		  MPFROMP("flush.wav"));

       hwndListA = WinCreateWindow(hWnd, WC_LISTBOX, "", LS_OWNERDRAW |	LS_HORZSCROLL |	LS_MULTIPLESEL | WS_VISIBLE,
				   275L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1026UL, (PVOID)NULL, (PVOID)NULL);

		       /* Sub-class the	default	window procedure with	*/
		       /* new one which	will handle specific messages	*/
		       /* allowing better control over the sizing frame	*/

       hwndListB = WinCreateWindow(hWnd, WC_LISTBOX, "", WS_VISIBLE | LS_EXTENDEDSEL, 275L, 190L, 250L,	200L, hWnd,
				   HWND_TOP, 1027UL, (PVOID)NULL, (PVOID)NULL);

       for ( i = 0; i <	10; i++	)
	   {
	   sprintf(szFile, "Item %04d Item %04d Item %04d", i, i, i);
	       WinSendMsg(hwndListx, LM_INSERTITEM,
			  MPFROMLONG(LIT_END),
			  MPFROMP(szFile));
	   }

       n = (INT)WinSendMsg(hwndList2, LMX_CALCLINECOUNT, MPFROMLONG(175L), 0L);

       k = 0;

       WinSendMsg(hwndList2, LM_SETITEMHEIGHT, MPFROMLONG(36L),	0L);

       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndList2, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       if ( ++k	> n )
		   WinSendMsg(hwndList2, LM_SETTOPINDEX, MPFROMLONG(k -	n), 0L);
	       WinSendMsg(hwndListB, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       break;

   case	WM_BUTTON1DOWN :
       WinEnableWindowUpdate(hwndListA,	FALSE);
       WinEnableWindowUpdate(hwndList1,	FALSE);

       WinSendMsg(hwndListA, LM_DELETEALL, 0L, 0L);
       WinSendMsg(hwndList1, LM_DELETEALL, 0L, 0L);
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       WinShowWindow(hwndListA,	TRUE);
       WinShowWindow(hwndList1,	TRUE);

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       }
	   --i;
	   }
       break;

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
		       /* Process double click on a List Box		*/

	   case	LN_SELECT :
	       switch (	SHORT1FROMMP(mp1) )
		   {
		   case	1024UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_NOTE);	  */
		       break;

		   case	1027UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_ERROR);  */
		       break;
		   }
	       break;
	   }
       break;


   case	WM_MEASUREITEM :
       GpiQueryFontMetrics(hPS = WinGetPS(hWnd), sizeof(FONTMETRICS), &fm);
       WinReleasePS(hPS);
       return(MRFROMLONG(fm.lMaxBaselineExt));

		       /* Draw a list box item				*/
   case	WM_DRAWITEM :

       if ( SHORT1FROMMP(mp1) == 1024 )
	   hwndListBox = hwndList1;
       else
	   if (	SHORT1FROMMP(mp1) == 1026 )
	       hwndListBox = hwndListA;

		       /* Point	to Owner Item information		*/

       poi = (POWNERITEM)mp2;
       GpiCreateLogColorTable(poi->hps,	0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXTLENGTH,
				      MPFROMLONG(poi->idItem), 0L));

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXT,
				      MPFROM2SHORT(poi->idItem,	CCHMAXPATH),
				      MPFROMP(szFile)));

		       /* Check	to see if item to be drawn or		*/
		       /* highlighted					*/

       if ( poi->fsState != poi->fsStateOld )
	   {
	   WinFillRect(poi->hps, &poi->rclItem,	RGBCLR_DIALOGBACKGROUND);

	   if (	poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);

		       /* Set item highlighting	by inverting the items	*/
		       /* rectangle colour				*/

	   WinInvertRect(poi->hps, &poi->rclItem);

	   if (	!poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);
	   poi->fsState	= poi->fsStateOld = 0;
	   }
       else
	   {
		       /* Item needs to	be drawn, get item rectangle	*/
		       /* item position					*/

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

	   WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
		       RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER	|
		       DT_ERASERECT);
	   }
       return(MRFROMLONG(TRUE));

   case	WM_BUTTON1DBLCLK :
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       }
	   --i;
	   }
       break;

   case	WM_BUTTON2DOWN :

       for ( i = 0; i <	5; i++ )
	   WinSendMsg(hwndListx, LM_DELETEITEM,	MPFROMSHORT(2),	0L);

#if 0
       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(LIT_NONE), MPFROMLONG(TRUE));

       i = LIT_FIRST;
       while ( (i = (INT)LONGFROMMR(WinSendMsg(hwndList1, LM_QUERYSELECTION, MPFROMLONG(i), 0L))) != LIT_NONE )
	   WinSendMsg(hwndList1, LM_SELECTITEM,	MPFROMLONG(i), MPFROMLONG(FALSE));
#endif
       break;
		       /* Erase	background				*/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)mp1, &rcl, SYSCLR_DIALOGBACKGROUND);
       break;
		       /* Paint	the main client	window			*/
   case	WM_PAINT :
       WinSetPointer(HWND_DESKTOP, hptrWait);

       WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL,	&rcl), &rcl, SYSCLR_DIALOGBACKGROUND);

       WinEndPaint(hPS);
       WinSetPointer(HWND_DESKTOP, hptrArrow);
       break;
		       /* Close	Down					*/
   case	WM_CLOSE :

       WinPostMsg(hWnd,	WM_QUIT, 0L, 0L);
       break;

   case	WM_DESTROY :
       WinDestroyPointer(hptrArrow);
       WinDestroyPointer(hptrWait);
       break;
		       /* Default message processing			*/
   default:
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
Пример #19
0
void PutMsg( USHORT unSrc, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char buf[100];                 /* Message buffer */

  switch( unSrc )
  {
  case 0:
    strcpy( buf, "message to client window: " );
    break;
  case 1:
    strcpy( buf, "message to listbox: " );
    break;
  default:
    strcpy( buf, "general: " );
    strcat( buf, (char *)msg );
  }

  switch( msg )
  {
  case DM_DROP:
    strcat( buf, "DM_DROP" );
    break;
  case DM_DRAGOVER:
    strcat( buf, "DM_DRAGOVER" );
    break;
  case DM_DRAGLEAVE:
    strcat( buf, "DM_DRAGLEAVE" );
    break;
  case DM_DROPHELP:
    strcat( buf, "DM_DROPHELP" );
    break;
  case DM_ENDCONVERSATION:
    strcat( buf, "DM_ENDCONVERSATION" );
    break;
  case DM_PRINT:
    strcat( buf, "DM_PRINT" );
    break;
  case DM_RENDER:
    strcat( buf, "DM_RENDER" );
    break;
  case DM_RENDERCOMPLETE:
    strcat( buf, "DM_RENDERCOMPLETE" );
    break;
  case DM_RENDERPREPARE:
    strcat( buf, "DM_RENDERPREPARE" );
    break;
  case DM_DRAGFILECOMPLETE:
    strcat( buf, "DM_DRAGFILECOMPLETE" );
    break;
  case DM_EMPHASIZETARGET:
    strcat( buf, "DM_EMPHASIZETARGET" );
    break;
  case DM_DRAGERROR:
    strcat( buf, "DM_DRAGERROR" );
    break;
  case DM_FILERENDERED:
    strcat( buf, "DM_FILERENDERED" );
    break;
  case DM_RENDERFILE:
    strcat( buf, "DM_RENDERFILE" );
    break;
  case DM_DRAGOVERNOTIFY:
    strcat( buf, "DM_DRAGOVERNOTIFY" );
    break;
  case DM_PRINTOBJECT:
    strcat( buf, "DM_PRINTOBJECT" );
    break;
  case DM_DISCARDOBJECT:
    strcat( buf, "DM_DISCARDOBJECT" );
    break;
  }
  WinSendMsg( hListBox, LM_INSERTITEM, (MPARAM)LIT_END, MPFROMP(buf));

  return;
}
MRESULT EXPENTRY cdTypeOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  CWDataFolder* thisPtr;
  ULONG ulFlags;
  LONG lSpinValue;
  static HWND hwndStatus;
  int a;
  char chrCD[4];
  char text[CCHMAXPATH];
  char title[CCHMAXPATH];
  char text2[40];

  ULONG rc;
  THISPTR thisPtrStruct;

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

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

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

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

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

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

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

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

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

          thisPtrStruct.usSize=sizeof(thisPtrStruct);
          thisPtrStruct.thisPtr=thisPtr;
          if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, _bootCDOptionsDialogProc, hDataResource, 
                         IDDLG_BOOTCDOPTIONS, &thisPtrStruct) == DID_OK )
            {
              getMessage(title,IDSTRD_BOOTIMAGE,sizeof(title), hDataResource,hwnd);
              sprintf(text,title,thisPtr->chrBootImage);
              WinSetWindowText( WinWindowFromID(hwnd,IDST_BOOTIMAGE), text );
              
              getMessage(title,IDSTRD_BOOTCATALOG,sizeof(title), hDataResource,hwnd);
              sprintf(text,title,thisPtr->chrBootCatalog);
              WinSetWindowText( WinWindowFromID(hwnd,IDST_BOOTCATALOG), text );
            }
          break;
        case IDPB_CDTYPEUNDO:
          // thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_CDTYPEUNDO),QWL_USER);
          thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
          /* User pressed the UNDO button */
          if(somIsObj(thisPtr)) {
            //ulFlags=thisPtr->cwQueryCDTypeFlags();
            /* Enable all multisesson controls */
            //  thisPtr->cwEnableMultiSessionCntrls(hwnd,TRUE);
            //            enableCDTypeCntrls(hwnd,thisPtr);
            enableCDTypeCntrls(hwnd, thisPtr->cwQueryCDTypeFlags());
            /*            if(ulFlags&IDCDT_FIXDISK) 
                          WinCheckButton(hwnd,IDCB_FIXDISK,1);
                          else
                          WinCheckButton(hwnd,IDCB_FIXDISK,0);*/
          }
          break;  
        default:
          break;
        }
      return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2); 
}
MRESULT EXPENTRY miscMainWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
static HPS hpsMain;
static ULONG lCodePage;
static LONG lFontHeight, lAveWidth;
static LONG desk_cx, desk_cy;
    RECTL rectl;
    HWND hwndEditorWin, hwndEditorClient;
    ULONG flCreate;
    FONTDLG fontDlg;
    char szFamilyname[FACESIZE];
    char szExmpl[128];
    ULONG stringID[NUM_MAINTEXT] = {IDS_MAINTEXT1, IDS_MAINTEXT2,
                                    IDS_MAINTEXT3 };
    static char* sText=NULL;
    static char* sTextEnjoy;
    void setFont( HWND hwnd, HPS hps, PFATTRS pAttrs );

    switch(msg)
    {
        case WM_CREATE:
        {
        int i;
        SIZEL sizl;
        HDC hdc;
        HWND hwndFrame;
        ULONG dataLength;
        char buf[BUFSIZ];
        LONG x,y,cx,cy;

            /* Read message text */
            for (i = 0; i < NUM_MAINTEXT; i++)
            {
              WinLoadString( hab, NULLHANDLE,
                             stringID[i], sizeof(buf), buf );
              if( sText == NULL )
              {
                 sText = malloc(strlen(buf)+1);
                 *sText = '\0';
              }
              else
                 sText = realloc( sText, strlen(sText)+strlen(buf)+1 );

              strcat( sText, buf );
            }

            WinLoadString( hab, NULLHANDLE,
                           IDS_TEXTENJOY, sizeof(buf), buf );

            sTextEnjoy = malloc( strlen(buf)+1 );
            strcpy( sTextEnjoy, buf );

            sizl.cx = 0L;
            sizl.cy = 0L;

            hdc = WinOpenWindowDC( hwnd );
            hpsMain = GpiCreatePS( hab,
                                   hdc,
                                   (PSIZEL)&sizl,
                                   (ULONG)PU_PELS | GPIT_MICRO | GPIA_ASSOC
                                  );
            /* Query the environment */
            DosQueryCp( sizeof(lCodePage), &lCodePage, &dataLength );

            GetFontSize( hpsMain, &lAveWidth, &lFontHeight );

            hwndFrame = WinQueryWindow(hwnd, QW_PARENT);

            desk_cx = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
            desk_cy = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );

            /* set window width to show maximum 40 SBCS characters */
            cx = (lAveWidth*MAIN_WIN_WIDTH>desk_cx) ? desk_cx : lAveWidth*MAIN_WIN_WIDTH;
            /* set window height large enough to show a string pointed to by sText.*/
            cy = (((strlen(sText)/MAIN_WIN_WIDTH)+10)*lFontHeight>desk_cy) ?
                  desk_cy : ((strlen(sText)/40) + 10)*lFontHeight;

            x = (cx<desk_cx) ? (desk_cx-cx)/2 : 0;
            y = (cy<desk_cy) ? (desk_cy-cy)/2 : 0;
            WinSetWindowPos(hwndFrame,
                            HWND_BOTTOM,
                            x, y, cx, cy,
                            SWP_MOVE | SWP_SIZE | SWP_ACTIVATE);

            return(MRESULT)(FALSE);
        }

        case WM_COMMAND:
            switch (SHORT1FROMMP(mp1))
            {
                case MID_CONV:    /* CPCONV */
                {
                  WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP) cpConvDlgProc,
                            NULLHANDLE, DID_CONV, &lCodePage);
                  break;
                }

                case MID_EDITOR:  /* Simple Editor */
                  flCreate= FCF_SIZEBORDER | FCF_MENU | FCF_MAXBUTTON | FCF_MINBUTTON
                          | FCF_SYSMENU | FCF_TITLEBAR | FCF_DBE_APPSTAT;
                  hwndEditorWin = WinCreateStdWindow(HWND_DESKTOP,
                                                    WS_VISIBLE,
                                                    &flCreate,
                                                    "editorWindow",
                                                    "Simple Editor",
                                                    0L,
                                                    NULLHANDLE,
                                                    WID_EDITOR,
                                                    (PHWND) & hwndEditorClient);

                  WinSetWindowPos(hwndEditorWin,
                                  HWND_BOTTOM,
                                  190, 130, 500, 300,
                                  SWP_MOVE | SWP_SIZE | SWP_ACTIVATE);
                  break;

                case MID_WORD:    /* Word Break */
                {
                  WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP) wordDlgProc,
                            NULLHANDLE, DID_WORD, &lCodePage);
                  break;
                }

                case MID_EXIT:    /* Exit */
                  WinSendMsg (hwnd, WM_CLOSE,mp1,mp2);
                  break;
            }
            break;

        case WM_PAINT:
        {
         int i;
         LONG lTotLen, lWrittenLen, lDrawn;
         SWP swp;

            WinBeginPaint( hwnd, hpsMain, (PRECTL)&rectl );
            /* Always update whole window - CS_SIZEREDRAW? */
            WinQueryWindowPos( hwnd, &swp );
            rectl.xLeft = rectl.yBottom = 0;
            rectl.xRight = swp.cx;
            rectl.yTop = swp.cy;

            WinFillRect( hpsMain, (PRECTL) &rectl, CLR_BACKGROUND );

            lTotLen = (LONG)strlen(sText);

            /* make some space between the text and the frame window */
            rectl.xLeft+=lAveWidth;
            rectl.xRight-=lAveWidth;
            rectl.yTop-=lFontHeight;

            for (lWrittenLen = 0; lWrittenLen != lTotLen; rectl.yTop -= lFontHeight)
            {
              lDrawn = WinDrawText( hpsMain, lTotLen - lWrittenLen,
                                    sText+lWrittenLen, &rectl, 0L, 0L,
                                    DT_WORDBREAK | DT_TOP | DT_LEFT | DT_TEXTATTRS);

              if( lDrawn != 0 )
                lWrittenLen  += lDrawn;
              else
                break;
            }

            rectl.yTop -= lFontHeight;
            WinDrawText( hpsMain, strlen(sTextEnjoy), sTextEnjoy, &rectl,
                         CLR_RED, CLR_BACKGROUND,
                         DT_TOP | DT_CENTER );
            WinEndPaint( hpsMain );
            break;
        }

        case WM_DESTROY:
            GpiDestroyPS( hpsMain );
            break;

        default:
            return(WinDefWindowProc(hwnd,msg,mp1,mp2));
    }
  return(MRFROMLONG(NULL));
}
/* This procedure handles the filename options page */ 
MRESULT EXPENTRY fileNameOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  CWDataFolder* thisPtr;
  ULONG ulFlags;

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

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

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

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

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

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

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

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


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

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

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

          if(ulFlags&IDMK_JOLIET)
            WinCheckButton(hwnd,IDCB_JOLIET,1);
          else
            WinCheckButton(hwnd,IDCB_JOLIET,0);
        }
        break;
      default:
        break;
      }
    return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
static INT InsertContainerColumns (PINST pinst)
{
#define NEWFIELDOFFSET(s,m) (&(((s *)0)->m))

    PFIELDINFO      pfldinfo;
    PFIELDINFO      pfldinfoFirst;
    FIELDINFOINSERT fiins;
    LONG            iField = 0;
    static const FIELDINFO afldinfo[] =
    {
        {0, CFA_STRING | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT,
         CFA_LEFT | CFA_FITITLEREADONLY, "Call sign",
         (ULONG)(NEWFIELDOFFSET(APPCNRREC,pszCallsign)), 0, 0, 0},
        {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT,
         CFA_LEFT | CFA_FITITLEREADONLY, "Heading",
         (ULONG)(NEWFIELDOFFSET(APPCNRREC,Heading)), 0, 0, 0},
        {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT,
         CFA_LEFT | CFA_FITITLEREADONLY, "Assigned\nHeading",
         (ULONG)(NEWFIELDOFFSET(APPCNRREC,AssignedHeading)), 0, 0, 0},
        {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT,
         CFA_LEFT | CFA_FITITLEREADONLY, "Altitude\n(Hundreds\nof Feet)",
         (ULONG)(NEWFIELDOFFSET(APPCNRREC,Altitude)), 0, 0, 0},
        {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT,
         CFA_LEFT | CFA_FITITLEREADONLY,
         "Assigned\nAltitude\n(Hundreds\nof Feet)",
         (ULONG)(NEWFIELDOFFSET(APPCNRREC,AssignedAltitude)), 0, 0, 0},
        {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT,
         CFA_LEFT | CFA_FITITLEREADONLY, "Speed\n(Tens of\nknots)",
         (ULONG)(NEWFIELDOFFSET(APPCNRREC,Speed)), 0, 0, 0},
        {0, CFA_ULONG | CFA_FIREADONLY | CFA_HORZSEPARATOR | CFA_LEFT,
         CFA_LEFT | CFA_FITITLEREADONLY, "Assigned\nSpeed\n(Tens of\nknots",
         (ULONG)(NEWFIELDOFFSET(APPCNRREC,AssignedSpeed)), 0, 0, 0}
    };
    static const INT cFields = sizeof afldinfo / sizeof afldinfo[0];

    pfldinfo = pfldinfoFirst = (PFIELDINFO) WinSendMsg (pinst->hwndCnr,
        CM_ALLOCDETAILFIELDINFO, MPFROMLONG(cFields), NULL);

    for (iField = 0; iField < cFields; ++iField)
    {
        pfldinfo->cb         = sizeof(FIELDINFO);
        pfldinfo->flData     = afldinfo [iField].flData;
        pfldinfo->flTitle    = afldinfo [iField].flTitle;
        pfldinfo->pTitleData = afldinfo [iField].pTitleData;
        pfldinfo->offStruct  = afldinfo [iField].offStruct;
        pfldinfo = pfldinfo->pNextFieldInfo;
    }

    fiins.cb = sizeof fiins;
    fiins.pFieldInfoOrder = (PFIELDINFO)CMA_FIRST;
    fiins.cFieldInfoInsert = cFields;
    fiins.fInvalidateFieldInfo = TRUE;

    /*
     *  INSERT DETAIL VIEW INFORMATION
     */

    WinSendMsg (pinst->hwndCnr, CM_INSERTDETAILFIELDINFO,
        MPFROMP(pfldinfoFirst), MPFROMP(&fiins));


    return 0;
}
/* This procedure handles the author settings page */ 
MRESULT EXPENTRY authorOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 
{
  CWDataFolder* thisPtr;

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

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

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

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

      /* Let the WPS save the new instance data */
      //      thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_AUTHORUNDO),QWL_USER);
      thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
      if(somIsObj(thisPtr)) {
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_APPLICATION),sizeof(thisPtr->chrApplication),thisPtr->chrApplication);
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_PUBLISHER),sizeof(thisPtr->chrPublisher),thisPtr->chrPublisher);
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_PREPARER),sizeof(thisPtr->chrPreparer),thisPtr->chrPreparer);
        WinQueryWindowText( WinWindowFromID(hwnd,IDEF_VOLUMENAME),sizeof(thisPtr->chrVolumeName),thisPtr->chrVolumeName);
        thisPtr->wpSaveDeferred();
      }
      /* Setup is done */
      return (MRESULT) TRUE;
    case WM_COMMAND:	
    switch(SHORT1FROMMP(mp1))
      {
      case IDPB_AUTHORUNDO:
        /* User pressed the UNDO button */
        //   thisPtr=(CWDataFolder*) WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_AUTHORUNDO),QWL_USER);
        thisPtr=(CWDataFolder*) WinQueryWindowULong(hwnd,QWL_USER);
        if(somIsObj(thisPtr)) {
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_APPLICATION),thisPtr->chrApplication);
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_PUBLISHER),thisPtr->chrPublisher);
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_PREPARER),thisPtr->chrPreparer);
          WinSetWindowText(WinWindowFromID(hwnd,IDEF_VOLUMENAME),thisPtr->chrVolumeName);
        }
        break;
      default:
        break;
      }
    return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
static INT InsertCrewRecords
(
    HWND        hwndCnr,
    PAPPCNRREC  pacrRoot            // Ptr to root of list of records
)
{
    PAPPCNRREC      pacrTraverse;       // Ptr to traverse list of records
    PAPPCNRREC      pacrCrew;           // Ptr to child crew record
    RECORDINSERT    recins;             // Record insertion information
    HPOINTER        hptrIconCrew;       // Crew icon
    INT             iCrewRecord;

    /*
     *  LOAD ICONS
     */

    hptrIconCrew = WinLoadPointer (HWND_DESKTOP, 0, IDICON_CREW);


    /*
     *  SET UP RECORD INSERT STRUCTURE
     */

    memset (&recins, 0, sizeof recins);
    recins.cb                = sizeof recins;
    recins.pRecordOrder      = (PRECORDCORE) CMA_END;
    recins.zOrder            = CMA_TOP;
    recins.cRecordsInsert    = 3;
    recins.fInvalidateRecord = TRUE;


    /*
     *  LOOP THROUGH ALL MAIN RECORDS
     */

    for (pacrTraverse = pacrRoot; pacrTraverse;
        pacrTraverse = (PAPPCNRREC) pacrTraverse->recc.preccNextRecord)
    {
        PAPPCNRREC      pacrCrewTraverse;   // Ptr to traverse crew records


        /*
         *  ALLOCATE CREW CHILD RECORDS
         */

        pacrCrew = (PAPPCNRREC) WinSendMsg (
            hwndCnr, CM_ALLOCRECORD,
            MPFROMLONG(sizeof(APPCNRREC) - sizeof(MINIRECORDCORE)),
            MPFROMLONG(recins.cRecordsInsert));


        /*
         *  SET PARENT RECORD IN RECORDINSERT STRUCTURE
         */

        recins.pRecordParent = (PRECORDCORE) pacrTraverse;


        /*
         *  LOOP THROUGH ALL CREW CHILD RECORDS
         */

        for (iCrewRecord = 0, pacrCrewTraverse = pacrCrew;
            pacrCrewTraverse;
            iCrewRecord++, pacrCrewTraverse =
            (PAPPCNRREC) pacrCrewTraverse->recc.preccNextRecord)
        {
            static  const   PSZ apszCrewPositions [] =
                { "Captain", "First Officer", "Head Flight Attendant" };
            CHAR    szTitle [100];
            PSZ     pszMadeUpName;


            /*
             *  SET ICON AND TEXT OF CREW RECORD
             */

            pacrCrewTraverse->cnrrtyp       = CNRRT_CREWMEMBER;
            pacrCrewTraverse->recc.hptrIcon = hptrIconCrew;
            pszMadeUpName = MakeUpPersonName ();
            sprintf (szTitle, "%s\n%s", pszMadeUpName,
                apszCrewPositions [iCrewRecord]);
            free (pszMadeUpName);
            pacrCrewTraverse->recc.pszIcon = strdup (szTitle);
        }


        /*
         *  INSERT ALL CREW RECORDS FOR THIS MAIN RECORD
         */

        WinSendMsg (hwndCnr, CM_INSERTRECORD,
            MPFROMP(pacrCrew), MPFROMP(&recins));
    }

    return 0;
}
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); 
}
Пример #27
0
void refreshClient( HWND hwnd )
{
    PHCHLB hchlb = WinQueryWindowPtr( hwnd, 0 );

    WinSendMsg( hchlb->hwndClient, HCHLMC_REFRESH, 0, 0 );
}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Mouse_VIO_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Mouse_VIO;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( Clipper.Settings.Mouse_in_VIO ) Value = 1;
     WinSendDlgItemMsg( Window, Mouse_VIO.Settings.Mouse_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     WinEnableControl( Window, Mouse_VIO.Settings.Mouse_Shift_button_ID, Value );
     WinEnableControl( Window, Mouse_VIO.Settings.Mouse_Remember_button_ID, Value );

     Value = 0; if( Clipper.Settings.Mouse_in_VIO_requires_Shift ) Value = 1;
     WinSendDlgItemMsg( Window, Mouse_VIO.Settings.Mouse_Shift_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Clipper.Settings.Mouse_in_VIO_sends_Copy ) Value = 1;
     WinSendDlgItemMsg( Window, Mouse_VIO.Settings.Mouse_Remember_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

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

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

           if( Button_is_checked ) Clipper.Settings.Mouse_in_VIO = 0;
           else Clipper.Settings.Mouse_in_VIO = 1;

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

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

           if( Button_is_checked ) Clipper.Settings.Mouse_in_VIO_requires_Shift = 0;
           else Clipper.Settings.Mouse_in_VIO_requires_Shift = 1;

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

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

           if( Button_is_checked ) Clipper.Settings.Mouse_in_VIO_sends_Copy = 0;
           else Clipper.Settings.Mouse_in_VIO_sends_Copy = 1;

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

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

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

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Mouse in VIO", &Clipper.Settings.Mouse_in_VIO, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Mouse in VIO requires Shift", &Clipper.Settings.Mouse_in_VIO_requires_Shift, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Mouse in VIO sends Copy", &Clipper.Settings.Mouse_in_VIO_sends_Copy, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

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

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

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

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
Пример #29
0
PPGDAT APIENTRY WnbkInsertPg(PNBK pnbk, PBOOKPAGEINFO pbpi, PNBINSPG pnbi,
                             PPGDAT pprev, ULONG flins) {
   MPARAM prevpg = (MPARAM)(pprev? (pprev == NBINS_ISFIRST? 0: pprev->pgid): 0);
   MPARAM bkfl;
   PPGDAT ppd;
   // alloca dati pagina
   if (!(ppd = (PPGDAT)malloc(sizeof(PGDAT)))) return NULL;
   memset(ppd, 0, sizeof(PGDAT));
   ppd->cb = sizeof(PGDAT);
   // ricava stile pagina da ordine pagina nella tab
   bkfl = MPFROM2SHORT((BKA_COMMON | pnbi->fs),
            (pprev? (pprev == NBINS_ISFIRST? BKA_FIRST: BKA_NEXT): BKA_LAST));
   // memorizza indirizzo dati inserzione pagina
   pbpi->ulPageData = (ULONG)ppd;
   pbpi->pPageDlgCreateParams = ppd;
   // memorizza attributi pagina
   ppd->fs = pnbi->fs;
   // memorizza flag definite dall'utente
   ppd->fl = pnbi->fl;
   // memorizza indirizzo dati definiti dall'utente
   ppd->pv = pnbi->pv;
   // ricava attributi pagina
   pbpi->fl = (pnbi->pgn == 1)? BFA_COMMON | BFA_MAJORTABTEXT: BFA_COMMON;
   // memorizza procedura dialogo
   pbpi->pfnPageDlgProc = (PFN)pnbi->pf;
   // memorizza id dialogo
   pbpi->idPageDlg = pnbi->iddlg;
   // memorizza statusline
   if (pnbi->idst) {
      if (flins & NBINS_PGXOFY) {
         WpageXofY(pnbi->idst, pnbi->pgn, pnbi->cpg, pbpi->pszStatusLine);
      } else {
         WgetStr(pnbi->idst, pbpi->pszStatusLine, 256);
      } /* endif */
   } /* endif */
   // memorizza stringa major tab
   if (pnbi->idmaj) WgetStr(pnbi->idmaj, pbpi->pszMajorTab, 256);
   // memorizza stringa minor tab
   if (pnbi->idmin) WgetStr(pnbi->idmin, pbpi->pszMinorTab, 256);
   // inserisce pagina
   if (!(ppd->pgid = (ULONG)WinSendMsg(pnbk->hwnd, BKM_INSERTPAGE, prevpg, bkfl)))
      goto error;
   // inizializza lunghezza stringhe)
   pbpi->cbStatusLine = strlen(pbpi->pszStatusLine);
   pbpi->cbMajorTab = strlen(pbpi->pszMajorTab);
   pbpi->cbMinorTab = strlen(pbpi->pszMinorTab);
   if (!(BOOL)WinSendMsg(pnbk->hwnd, BKM_SETPAGEINFO,
                         (MPARAM)ppd->pgid, (MPARAM)pbpi))
      goto error;
   // inserisce pagina nella lista:
   // se Š l'unica pagina ne memorizza l'indirizzo nella struttura notebook
   if (!pprev) {
      // i puntatori alla precedente e prossima struttura rimangono NULL
      pnbk->ppd = ppd;
   // se Š la prima pagina nel notebook aggiorna la linked list delle pagine
   } else if (pprev == NBINS_ISFIRST) {
      // il puntatore alla struttura precedente rimane NULL
      pnbk->ppd->pprv = ppd;
      ppd->pnxt = pnbk->ppd;
      pnbk->ppd = ppd;
   // se Š qualsiasi altra pagina
   } else {
      pprev->pnxt->pprv = ppd;
      ppd->pnxt = pprev->pnxt;
      pprev->pnxt = ppd;
      ppd->pprv = pprev;
   } /* endif */
   // incrementa numero pagine
   pnbk->cpgs++;
   // se richiesto memorizza indirizzo allocato
   if (pnbi->pppg) *pnbi->pppg = ppd;
   return ppd;
error:
   free(ppd);
   return NULL;
}
BOOL OSpinBtn::getCurrent(PVOID addr, USHORT size, USHORT control)
{
  return((BOOL)WinSendMsg (hwnd, SPBM_QUERYVALUE,
                     MPFROMP(addr),
                     MPFROM2SHORT(size,control)));
}