示例#1
0
MRESULT EXPENTRY aboutProcR( HWND hwndDlg, ULONG msg,
			    MPARAM mp1, MPARAM mp2 )
{
INT i;
switch ( msg )
   {
   case WM_INITDLG:
      return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );

   case WM_COMMAND:
      switch( SHORT1FROMMP( mp1 ) )
	 {
	 case DID_CANCEL :
	    WinShowWindow(WinWindowFromID(hwndDlg, DID_CANCEL), FALSE);
	    for( i=0;i<4;i++ )
	       {
	       WinShowWindow(WinWindowFromID(hwndDlg, ID_BEGSCREEN), FALSE);
	       DosSleep(200);
	       WinShowWindow(WinWindowFromID(hwndDlg, ID_BEGSCREEN), TRUE);
	       DosSleep(200);
	       }
	    WinDismissDlg( hwndDlg, TRUE );
	    break;

	 default :
	    return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
	 }
      break;
   default :
      return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
   }
return (MRESULT) FALSE;
}
示例#2
0
void ShowKeyboard(BOOL fHexOct, USHORT uBinMode)
{
   if (fHexOct) {
      WinSetWindowText(hwndsig, "A");
      WinSetWindowText(hwnd1x, "B");
      WinSetWindowText(hwndroo, "C");
      WinSetWindowText(hwndlog, "D");
      WinSetWindowText(hwndln, "E");
      WinSetWindowText(hwndsin, "And");
      WinSetWindowText(hwndcos, "Or");
      WinSetWindowText(hwndtan, "F");
      WinSetWindowText(hwndeex, "Xor");
      WinSetWindowText(hwnddot, "ONEs");
      WinSetWindowText(hwndsst, ">");
      WinShowWindow(hwndxeq, TRUE);
      ShowHexOct(uBinMode);
   } else {
      WinSetWindowText(hwndsig, "\344+");
      WinSetWindowText(hwnd1x, "1/x");
      WinSetWindowText(hwndroo, "\373x");
      WinSetWindowText(hwndlog, "Lo~g");
      WinSetWindowText(hwndln, "L~N");
      WinSetWindowText(hwndsin, "~Sin");
      WinSetWindowText(hwndcos, "~Cos");
      WinSetWindowText(hwndtan, "~Tan");
      WinSetWindowText(hwndeex, "~EEx");
      WinSetWindowText(hwnddot, "\371");
      WinSetWindowText(hwndsst, "Cls");
      WinShowWindow(hwndxeq, FALSE);
      ShowHexOct(MODE_HEX);
   } /* endif */
}
static MRESULT EXPENTRY pfnwpRexxErrorProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 )
{
  switch (msg)
    {
    case WM_COMMAND:
      if(SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON) {
        switch(SHORT1FROMMP(mp1))
          {
          case DID_OK:
            WinShowWindow(hwnd, FALSE);
            break;
          default:
            break;
          }
      }
      return MRFALSE;
    case WM_CLOSE:
      WinShowWindow(hwnd, FALSE);
      return MRFALSE;
    default:
      break;
    }

  return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
static void _showSingleSessionCntrls(HWND hwnd, BOOL bEnable)
{
  /* hwnd:    Dialog-HWND
     bEnable: New enable state */

  WinShowWindow(WinWindowFromID(hwnd,IDGB_MERGESESSION),bEnable);//Groupbox
  WinShowWindow(WinWindowFromID(hwnd,IDST_SINGLESESSION),bEnable);//Text

}
static void _showBootCDCntrls(HWND hwnd, BOOL bEnable)
{
  /* hwnd:    Dialog-HWND
     bEnable: New enable state */

  WinShowWindow(WinWindowFromID(hwnd,IDGB_BOOTCD),bEnable);
  WinShowWindow(WinWindowFromID(hwnd,IDST_BOOTIMAGE),bEnable);
  WinShowWindow(WinWindowFromID(hwnd,IDST_BOOTCATALOG),bEnable);
  WinShowWindow(WinWindowFromID(hwnd,IDPB_BOOTCDCONFIGURE),bEnable);
}
/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:     SetAlarmField
 *
 *  Purpose:
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns:
 *          1 - if successful execution completed
 *          0 - if error
\****************************************************************/
VOID SetAlarmField(HWND hwnd,UCHAR uchHours,UCHAR uchMinutes)
{
   UCHAR achHourMinutes[6];

   if (bTwelveHourFormat)
   {
      if (uchHours >= 12)
      {
         uchHours -= 12;
         WinSendDlgItemMsg(hwnd,
                           RB_PM,
                           BM_SETCHECK,
                           MPFROMLONG(1),
                           MPVOID);
        if (uchHours == 0)
           uchHours = 12;
      }
      else
      {
         if (uchHours == 0)
            uchHours = 12;
         WinSendDlgItemMsg(hwnd,
                           RB_AM,
                           BM_SETCHECK,
                           MPFROMLONG(1),
                           MPVOID);
      }
   }
   else
   {
       WinShowWindow(WinWindowFromID(hwnd,RB_PM),FALSE);
       WinShowWindow(WinWindowFromID(hwnd,RB_AM),FALSE);
   }
   _itoa(uchHours, achHourMinutes,10);
   _itoa(uchMinutes, &achHourMinutes[3],10);
   achHourMinutes[2] = szTimeSep[0];
   if (achHourMinutes[1] == 0)
   {
      achHourMinutes[1] = achHourMinutes[0];
      achHourMinutes[0] = ' ';
   }
   if (achHourMinutes[4] == 0)
   {
      achHourMinutes[4] = achHourMinutes[3];
      achHourMinutes[3] = '0';
   }
   WinSetDlgItemText(hwnd, IDC_HOURMINUTES, achHourMinutes);
}
示例#7
0
 int icqskin_setVisible(SKINDATA *cfg, BOOL visible)
 {
    DBGTrace(visible);
    DBGTracex(cfg->frame);
    WinShowWindow(cfg->frame,visible);
    return 0;
 }
/*--------------------------------------------------
 * Makes the window visible
 *--------------------------------------------------*/
PMWindow& PMWindow::show( BOOL state )
{
  if( !WinShowWindow( win_handle, state ? SWP_SHOW : SWP_HIDE ))
    PM_THROW_GUIERROR();

  return *this;
}
示例#9
0
static VOID _wmActive(PGROPDATA pGrop, BOOL fActive)
{
  if ( pGrop->fFullscreen )
  {
    if ( fActive )
    {
      _setFullscreen( pGrop, pGrop->ulModeIdx );
      pGrop->pVideoSys->fnUpdate( pGrop->pVSData, pGrop, 0, NULL );
    }
    else
    {
      _setDesktop( pGrop );

      _captureMouse( pGrop, FALSE );
      WinShowWindow( pGrop->hwndFrame, FALSE );
    }
  }
  else
    _captureMouse( pGrop, pGrop->fCapture && fActive );

  pGrop->fActive = fActive;

  if ( pGrop->stCallback.fnActive != NULL )
    pGrop->stCallback.fnActive( pGrop, GROUP_ACTIVATE_WINDOW, fActive );
}
示例#10
0
static BOOL init_instance( int show )
{
    HWND        frame_hwnd;
    ULONG       flags = FCF_SIZEBORDER | FCF_TITLEBAR
                | FCF_SYSMENU | FCF_MENU | FCF_MINMAX | FCF_SHELLPOSITION;

    frame_hwnd = WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE,
                &flags, "DrawDemo", "Draw a Picture", WS_VISIBLE,
                0, 200, &hwnd );

    /* If window could not be created, return "failure" */

    if( hwnd == 0 || frame_hwnd == 0 ) {
        return (FALSE);
    }

    /* Make the window visible; update its client area; and return "success" */

    WinSetWindowPos( frame_hwnd, HWND_TOP, 50, 50, 200, 200, show );

    make_buttons( hwnd );

    WinShowWindow( frame_hwnd, TRUE );
    WinUpdateWindow( frame_hwnd );
    return( TRUE );
}
示例#11
0
static void reposic(HWND hwnd,USHORT mCx,USHORT mCy)
{
   SLIDERDATA    *cfg = WinQueryWindowPtr(hwnd,0);
   SHORT        x,y,cx,cy;

   if(!(cfg->cx || cfg->cy))
   {
      WinShowWindow(hwnd,FALSE);
      return;
   }

   x  = cfg->x  < 0 ? (mCx + cfg->x) - cfg->cx  : cfg->x;
   y  = cfg->y  < 0 ? (mCy + cfg->y) - cfg->cy  : cfg->y;

   cx = cfg->cx < 0 ? mCx + cfg->cx : cfg->cx;
   cy = cfg->cy < 0 ? mCy + cfg->cy : cfg->cy;

   WinSetWindowPos(     hwnd,
                        0,
                        x,y,
                        cx,cy,
                        SWP_MOVE|SWP_SIZE|SWP_SHOW );


}
示例#12
0
文件: xpi.c 项目: rn10950/RetroZilla
void InitProgressDlg()
{
  if(sgProduct.ulMode != SILENT)
  {
    dlgInfo.hWndDlg = WinLoadDlg(HWND_DESKTOP, hWndMain, ProgressDlgProc, hSetupRscInst, DLG_EXTRACTING, NULL);
    WinShowWindow(dlgInfo.hWndDlg, TRUE);
  }
}
示例#13
0
void CPlugin::showGUI(ShowGUI sg)
{
  switch (sg)
  {
    case sg_manual:
      WinShowWindow(m_hWndManual, TRUE);
      WinShowWindow(m_hWndAuto, FALSE);
      break;
    case sg_auto:
      WinShowWindow(m_hWndManual, FALSE);
      WinShowWindow(m_hWndAuto, TRUE);
      break;
    default:
      assert(0);
      break;
  }
}
示例#14
0
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, MPARAM mParam)
{
  CPlugin * pPlugin = (CPlugin *)mParam;
  WinSetWindowPtr(hWnd, QWL_USER, (PVOID)pPlugin);

  int iTopMargin = 188;
  WinSetWindowPos(hWnd, NULL, 0, iTopMargin, 0, 0, SWP_SHOW );  

  WinSetWindowText(WinWindowFromID(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), pPlugin->m_Pref_szScriptFile);

  WinSetWindowText(WinWindowFromID(hWnd, IDC_STATIC_REPETITIONS_LEFT), "");
  WinShowWindow(WinWindowFromID(hWnd, IDC_STATIC_REPETITIONS_LABEL), FALSE);

  WinShowWindow(WinWindowFromID(hWnd, IDC_BUTTON_GO), TRUE);
  WinShowWindow(WinWindowFromID(hWnd, IDC_BUTTON_STOP), FALSE);

  return TRUE;
}
/*@ XToolBar::Show(const BOOL show)
@group display
@remarks Show/hide the toolbar
@parameters BOOL show            TRUE=show, FALSE=hide
*/
void XToolBar::Show(const BOOL show)
{
   if (cutWindow)
   {
      cutWindow->Show(show);
      return;
   }
   if (show)
   {
      WinShowWindow(winhandle, TRUE);
      SetHeight(cy);
   }
   else
   {
      WinShowWindow(winhandle, FALSE);
      SetHeight(0);
   }
}
示例#16
0
VOID TOOLBAR :: Show (BOOL f)
{
    SWP swp;
    WinQueryWindowPos (hwndFrame, &swp);

    if (f)
    {
        fHidden = FALSE;
        WinSetWindowPos (hwndFrame, NULLHANDLE, 0,0,
                         swp.cx, swp.cy+CY_TOOLBAR, SWP_SIZE | SWP_SHOW);
        WinShowWindow (hwnd, TRUE);
    }
    else
    {
        fHidden = TRUE;
        WinSetWindowPos (hwndFrame, NULLHANDLE, 0,0,
                         swp.cx, swp.cy-CY_TOOLBAR, SWP_SIZE | SWP_SHOW);
        WinShowWindow (hwnd, FALSE);
    }
}
示例#17
0
 /* ##END User defined messages */
   default :
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
     return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
   } /* end switch for main msg dispatch */
   return (MRESULT)FALSE;
} /* end dialog procedure */
HWND OpenSETTINGS(HWND hwndOwner, PVOID pInfo)
{
   HWND hwndFrame;
   if (WinQueryWindowUShort(hwndOwner, QWS_ID) == FID_CLIENT)
      hwndOwner = WinQueryWindow(hwndOwner, QW_PARENT);
   hwndFrame =(HWND) WinLoadDlg(HWND_DESKTOP,
           hwndOwner,   
           SETTINGSDlgProc, 
           0, ID_SETTINGSFORM, 
           pInfo); 
   WinShowWindow(hwndFrame, TRUE);
   return hwndFrame;
}
static void _showTrackCntrls(HWND hwnd, BOOL bEnable2)
{
  /* hwnd:    Dialog-HWND
     bEnable2: New enable state */

  WinShowWindow(WinWindowFromID(hwnd,IDGB_TRACKTYPE),bEnable2);
  WinShowWindow(WinWindowFromID(hwnd,IDRB_TRACKDATA),bEnable2);
  WinShowWindow(WinWindowFromID(hwnd,IDRB_TRACKMODE2),bEnable2);
  WinShowWindow(WinWindowFromID(hwnd,IDRB_TRACKXA1),bEnable2);
  WinShowWindow(WinWindowFromID(hwnd,IDRB_TRACKXA2),bEnable2);
  WinShowWindow(WinWindowFromID(hwnd,IDRB_TRACKCDI),bEnable2);
  WinShowWindow(WinWindowFromID(hwnd,IDCB_FIXDISK),bEnable2);
}
示例#19
0
/*
 *   Modified by Chris Wohlgemuth 2001 for use with CandyFolder
 */
BOOL winhAssertWarp4Notebook(HWND hwndDlg,
                    USHORT usIdThreshold,    // in: ID threshold
                    ULONG ulDownUnits)       // in: dialog units or 0
{
    BOOL brc = FALSE;
    POINTL ptl;
    HAB hab = WinQueryAnchorBlock(hwndDlg);
    BOOL    fIsVisible = WinIsWindowVisible(hwndDlg);
    if (ulDownUnits) {
        ptl.x = 0;
        ptl.y = ulDownUnits;
        WinMapDlgPoints(hwndDlg, &ptl, 1, TRUE);
    }

    WinEnableWindowUpdate(hwndDlg, FALSE);

    if (cwQueryOSRelease()>=40) {
        HENUM henum = WinBeginEnumWindows(hwndDlg);
        HWND hwndItem;
        while ((hwndItem = WinGetNextWindow(henum))!=NULLHANDLE) {
            USHORT usId = WinQueryWindowUShort(hwndItem, QWS_ID);

            if (usId <= usIdThreshold) {
                // pushbutton to change:
              WinSetWindowBits(hwndItem, QWL_STYLE,
                        BS_NOTEBOOKBUTTON, BS_NOTEBOOKBUTTON);
                brc = TRUE;
            } else
                // no pushbutton to change: move downwards
                // if desired
                if (ulDownUnits)
                {
                    SWP swp;

                    WinQueryWindowPos(hwndItem, &swp);
                    WinSetWindowPos(hwndItem, 0,
                        swp.x,
                        swp.y - ptl.y,
                        0, 0,
                        SWP_MOVE);
                }
        }
        WinEndEnumWindows(henum);
    }
    if (fIsVisible)
        WinShowWindow(hwndDlg, TRUE);
    return (brc);
}
//---------------------------------------------------------------
void hide_scrollbars( HWND hwnd )
{
  HENUM henum;
  HWND  hwndNext;
  CHAR  szClass[8];

  henum = WinBeginEnumWindows(hwnd);
  while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE) {
    WinQueryClassName( hwndNext, strlen(szClass), szClass );
    if (!strncmp(WC_SCROLLBAR, szClass, strlen(szClass) )) {
      WinShowWindow( hwndNext, FALSE );
      }
    else hide_scrollbars( hwndNext );          // recursive!
    }
  WinEndEnumWindows(henum);
  }
//--------------------------------------------------------------------------
//
//  main() procedure.
//   --> Initialize PM for this process
//   --> Create our message queue
//   --> Create frame and client windows
//   --> Show the window
//   --> Enter our message dispatching loop
//
//
// --------------------------------------------------------------------------
void cdecl main(VOID)
{
   HMQ hmq;
   HWND hwndclient;
   QMSG qmsg;

   ULONG flCreateFlags =   FCF_BORDER     | FCF_SHELLPOSITION |
                           FCF_TASKLIST   | FCF_TITLEBAR      | FCF_SYSMENU |
                           FCF_SIZEBORDER | FCF_MINMAX        | FCF_MENU ;

   hab = WinInitialize( (USHORT)NULL );

   hmq=WinCreateMsgQueue( hab,0 );


   WinRegisterClass( hab
                   , XFORM_CLASSNAME
                   , (PFNWP)ClientWndProc
                   , (ULONG)CS_SIZEREDRAW
                   , (USHORT)256 );

   hwndFrame = WinCreateStdWindow( HWND_DESKTOP
                                 ,  0UL
                                 ,  &flCreateFlags
                                 ,  XFORM_CLASSNAME
                                 ,  "Xform - Model transform examples"
                                 ,  WS_VISIBLE
                                 ,  (HMODULE)0
                                 ,  ID_PIN
                                 ,  &hwndclient );


   WinShowWindow( hwndFrame, TRUE );

   while ( WinGetMsg( hab,&qmsg, (HWND)0, 0, 0 ) )
   {
     WinDispatchMsg( hab,&qmsg );
   }

   if ( hwndFrame )
   {
     WinDestroyWindow(hwndFrame);
     WinDestroyMsgQueue(hmq);
     WinTerminate(hab);
   }
}
void InitRecorder(PRECORDER_PARM prec)
{
   SWP             swp;
   CHAR            szTemp[CCHMAXPATH];
   ULONG           dummy = errAEBadParm;

   if(prec->pmp->Profile.testrec_cx != 0)
   {
     WinSetWindowPos(prec->hwnd,
                     HWND_TOP,
                     prec->pmp->Profile.testrec_x,
                     prec->pmp->Profile.testrec_y,
                     prec->pmp->Profile.testrec_cx,
                     prec->pmp->Profile.testrec_cy,
                     SWP_MOVE | SWP_SIZE);
     WinSetWindowPos(prec->hwndStatus,
                     HWND_TOP,
                     prec->pmp->Profile.testrecStat_x,
                     prec->pmp->Profile.testrecStat_y,
                     prec->pmp->Profile.testrecStat_cx,
                     prec->pmp->Profile.testrecStat_cy,
                     SWP_MOVE | SWP_SIZE);
   }
   else
   {
    WinQueryTaskSizePos(WinQueryAnchorBlock(prec->hwnd),0,&swp);
    WinSetWindowPos(prec->hwnd,
                    HWND_TOP,
                    swp.x,
                    swp.y,
                    swp.cx,
                    swp.cy,
                    SWP_MOVE );
   }
   WinSetWindowULong(prec->hwnd, QWL_USER, (ULONG) prec );

   prec->pmp->hwndRecordEvent = prec->hwnd;

   prec->hwndStatus = WinWindowFromID(prec->hwnd, IDD_ODRECSTATUS);
   WinSetWindowText(prec->hwndStatus, "idle");
   prec->recording = FALSE;
   WinShowWindow(prec->hwnd,TRUE);
}
示例#23
0
 /* ##END User defined messages */
   default :
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
     return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
   } /* end switch for main msg dispatch */
   return (MRESULT)FALSE;
} /* end dialog procedure */
HWND OpenVIEWMR(HWND hwndOwner, PVOID pInfo)
{
   HWND hwndFrame;
   HWND hwndClient;
   FRAMECDATA frameData;
   frameData.cb=sizeof(FRAMECDATA);
   frameData.flCreateFlags= FCF_NOBYTEALIGN | FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU | FCF_TASKLIST | FCF_MAXBUTTON | FCF_MINBUTTON | FCF_ICON ;
   frameData.hmodResources=0;
   frameData.idResources=ID_VIEWMRFORM;
   if (WinQueryWindowUShort(hwndOwner, QWS_ID) == FID_CLIENT)
      hwndOwner = WinQueryWindow(hwndOwner, QW_PARENT);
   hwndFrame=WinCreateWindow(HWND_DESKTOP, WC_FRAME, "", 0,0,0,0,0,hwndOwner,HWND_TOP,ID_VIEWMRFORM,&frameData,0);
   if (hwndFrame) {
      hwndClient =(HWND) WinLoadDlg(hwndFrame,
              hwndFrame,   
              VIEWMRDlgProc, 
              0, ID_VIEWMRFORM, 
              pInfo); 
      WinShowWindow(hwndFrame, TRUE);
   }
   return hwndFrame;
}
/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:ClkCreate()
 *
 *  Purpose:Intialize a newly created client window
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns:
 *          1 - if sucessful execution completed
 *          0 - if error
\****************************************************************/
VOID ClkCreate ( HWND hwnd )
{
    LONG cxScreen , cyScreen;  /* screen dimensions */
    LONG xLeft , yBottom ;      /* frame window location */
    ULONG cbBuf;
    LONG cyHeight;
    LONG cxWidth;

    hwndClient = hwnd;

    WinLoadString(hab, NULLHANDLE, IDS_TITLE,  0, (PSZ)szTitle   );
    WinLoadString(hab, NULLHANDLE, IDS_HELPTITLE, 256, (PSZ)szHelpTitle);
    GetCountryDependent();
    /* we are called before the global hwndFrame is valid */
    hwndFrame = WinQueryWindow ( hwnd , QW_PARENT) ;
    hwndTitleBar = WinWindowFromID ( hwndFrame , FID_TITLEBAR ) ;
    hwndSysMenu = WinWindowFromID ( hwndFrame , FID_SYSMENU ) ;
    hwndMinMax = WinWindowFromID ( hwndFrame , FID_MINMAX ) ;

    /* load our menus */
    hwndMenu = WinLoadMenu (hwndFrame, NULLHANDLE, IDR_MAIN);
    /* determine screen dimensions */
    /* open a device context and create a presentation space */

    hdc = WinOpenWindowDC (hwnd);
    hps = GpiCreatePS (hab, hdc, &sizl, PU_ARBITRARY | GPIT_MICRO |
            GPIA_ASSOC);

    /*
     * Create our off-screen 'buffer'.
     */
    hdcBuffer = DevOpenDC ( (HAB)0L, OD_MEMORY, "*", 0L, NULL, hdc);
    hpsBuffer = GpiCreatePS (hab, hdcBuffer, &sizl, PU_ARBITRARY |
                               GPIT_MICRO | GPIA_ASSOC);

    GpiCreateLogColorTable (hpsBuffer, 0, LCOLF_RGB, 0, 0, (PLONG)NULL);

    /* get the device resolutions so we can make the face appear circular */
    DevQueryCaps (hdc, (LONG)CAPS_VERTICAL_RESOLUTION,(LONG) 1L, &cyRes);
    DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION, 1L, &cxRes);
    DevQueryCaps (hdc, CAPS_COLOR_PLANES, 1L, &cColorPlanes);
    DevQueryCaps (hdc, CAPS_COLOR_BITCOUNT, 1L, &cColorBitcount);

    cxScreen = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
    cyScreen = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);

    /*
     * Calculate an initial window position and size.
     */
    xLeft = cxScreen / 8;
    yBottom = cyScreen / 2;
    cxWidth = cxScreen / 3;
    cyHeight = cyScreen / 2;
    WinSetWindowPos (hwndFrame, NULLHANDLE, xLeft, yBottom,
                       cxWidth, cyHeight,
                       SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);

    cbBuf = sizeof(cp);
    if (!PrfQueryProfileData(HINI_USER, SZ_APPNAME, SZ_KEYNAME, &cp, &cbBuf))
    {
        cp.usMajorTickPref = CLKTM_ALWAYS;
        cp.usMinorTickPref = CLKTM_NOTICONIC;
        cp.clrBackground = 0x00008080;
        cp.clrFace = 0x00008080;
        cp.clrHourHand = RGB_RED;
        cp.clrMinuteHand = RGB_RED;
        cp.fControlsHidden = FALSE;
        cp.usDispMode = DM_TIME | DM_ANALOG | DM_SECONDHAND;
        cp.alarm.uchHour = 0;
        cp.alarm.uchMinutes = 0;
        cp.alarm.usMode = 0;
        SetRGBColors();
        /* position the window and make it visible */
        WinSetWindowPos( hwndFrame , NULLHANDLE ,
                           xLeft , yBottom ,
                           cxWidth , cyHeight ,
                           SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);
        WinQueryWindowPos(hwndFrame, &cp.swp);
    }
    else
    { /*Protect against garbage swp*/

        cp.swp.hwnd = hwndFrame;
        cp.swp.hwndInsertBehind = HWND_TOP;

        cp.swp.fl = (cp.swp.fl & (SWP_MINIMIZE | SWP_MAXIMIZE)) | SWP_SIZE | SWP_MOVE | SWP_ACTIVATE;
        SetRGBColors();
        WinSetMultWindowPos(hab, &cp.swp, 1);
    }

    if (cp.fControlsHidden)
        ClkHideFrameControls (hwndFrame);

    /*
     * Check relevant items.
     */
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_TIME)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( (!(cp.usDispMode & DM_TIME))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_DATE, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_DATE)?  MIA_CHECKED
                                      : ~MIA_CHECKED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TIME, TRUE),
                MPFROM2SHORT( MIA_DISABLED,
                              ( ((!(cp.usDispMode & DM_DATE) || (cp.usDispMode & DM_ANALOG)))?  MIA_DISABLED
                                      : ~MIA_DISABLED) ) );
    WinSendMsg( hwndMenu,
                MM_SETITEMATTR,
                MPFROM2SHORT( (cp.usDispMode & DM_DIGITAL)
                                                          ?IDM_DIGITAL
                                                          :IDM_ANALOG,
                               TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              MIA_CHECKED));

    WinSendMsg(hwndMenu, MM_SETITEMATTR, MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT( MIA_CHECKED,
                              ( (cp.usDispMode & DM_SECONDHAND) ? MIA_CHECKED
                                      : ~MIA_CHECKED)));


    /*
     * Disable these items if the digital clock is visible
     * since they won't apply.
     */
    if (cp.usDispMode & DM_DIGITAL)
    {
        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT(IDM_SECONDHAND, TRUE),
                MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));

        WinSendMsg (hwndMenu, MM_SETITEMATTR,
                MPFROM2SHORT( IDM_TICKS, TRUE), MPFROM2SHORT( MIA_DISABLED,
                MIA_DISABLED));
    }

    /* have we been asked to start as an icon? */
    if (fStartAsIcon)
        WinSetWindowPos(hwndFrame, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);

    WinShowWindow(hwndFrame, TRUE);

    /* get the time in a format for dislaying */
    DosGetDateTime(&dt);
    dt.hours = (UCHAR )(dt.hours * (UCHAR) 5) % (UCHAR) 60 + dt.minutes / (UCHAR)12;

    /* start a timer */
    WinStartTimer (hab, hwnd, IDR_MAIN, 1000);

    WinLoadString(hab, NULLHANDLE, IDS_TITLE, 80, (PSZ)szTitle);
    GetCountryDependent();

}
static MRESULT EXPENTRY AreaGenSettProc(HWND parent, ULONG message, MPARAM mp1, MPARAM mp2)
{
   HWND hwndList;
   extern USERDATAOPT userdaten;
   extern AREALIST arealiste;
   extern TEMPLATELIST templatelist;
   SHORT sItem=0, sSelect=0;
   static AREADEFLIST *pArea=NULL;
   char pchTemp[LEN_PATHNAME+1];
   static HWND hwndSettingsFrame;
   PMSGTEMPLATE pTemplate;
   AREADEFLIST *pAreaTemp;

   switch(message)
   {
      case WM_INITDLG:
         pArea=((PAREAPAR)mp2)->pAreaDef;

         if (!((PAREAPAR)mp2)->bMultiple)
         {
            SendMsg(hwndSettingsFrame=WinQueryWindow(parent, QW_PARENT),
                       APM_SETTITLE, pArea->areadata.areatag, NULL);
            WinSendDlgItemMsg(parent,IDD_AS_GENERAL+3,
                              EM_SETTEXTLIMIT,
                              MPFROMSHORT(LEN_AREATAG),
                              (MPARAM) NULL);

            WinSendDlgItemMsg(parent,IDD_AS_GENERAL+5,
                              EM_SETTEXTLIMIT,
                              MPFROMSHORT(LEN_AREADESC),
                              (MPARAM) NULL);
         }
         else
         {
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+2), FALSE);
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+3), FALSE);
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+4), FALSE);
            WinShowWindow(WinWindowFromID(parent, IDD_AS_GENERAL+5), FALSE);
         }

         /* Adressen eintragen */
         hwndList=WinWindowFromID(parent, IDD_AS_GENERAL+9);
         SendMsg(hwndList, LM_DELETEALL, (MPARAM)0, (MPARAM)0);
         sItem=0;
         sSelect = LIT_NONE;
         while(sItem<MAX_ADDRESSES && userdaten.address[sItem][0])
         {
            SendMsg(hwndList, LM_INSERTITEM,
                       MPFROMSHORT(LIT_END),
                       (MPARAM) userdaten.address[sItem]);
            if (pArea && !strcmp(pArea->areadata.address, userdaten.address[sItem]))
               sSelect = sItem;
            sItem++;
         }
         SendMsg(hwndList, LM_SELECTITEM, MPFROMSHORT(sSelect), (MPARAM) TRUE);

         /* Namen eintragen */
         hwndList=WinWindowFromID(parent, IDD_AS_GENERAL+12);
         SendMsg(hwndList, LM_DELETEALL, (MPARAM)0, (MPARAM)0);
         sItem=0;
         sSelect = LIT_NONE;
         while(sItem<MAX_USERNAMES && userdaten.username[sItem][0])
         {
            SendMsg(hwndList, LM_INSERTITEM,
                       MPFROMSHORT(LIT_END),
                       (MPARAM) userdaten.username[sItem]);
            if (pArea && !strcmp(pArea->areadata.username, userdaten.username[sItem]))
               sSelect = sItem;
            sItem++;
         }
         SendMsg(hwndList, LM_SELECTITEM, MPFROMSHORT(sSelect), (MPARAM) TRUE);

         if (pArea)
         {
            WinSetDlgItemText(parent, IDD_AS_GENERAL+3,
                              pArea->areadata.areatag);
            WinSetDlgItemText(parent, IDD_AS_GENERAL+5,
                              pArea->areadata.areadesc);

            if (pArea->areadata.ulAreaOpt & AREAOPT_FROMCFG)
               WinSendDlgItemMsg(parent, IDD_AS_GENERAL+3, EM_SETREADONLY,
                                 (MPARAM)TRUE, NULL);
         }

         /* Template-Namen eintragen */
         pTemplate = templatelist.pTemplates;
         while (pTemplate)
         {
            sItem = (SHORT) WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_INSERTITEM,
                                              MPFROMSHORT(LIT_SORTASCENDING),
                                              pTemplate->TName);
            WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_SETITEMHANDLE,
                              MPFROMSHORT(sItem),
                              MPFROMLONG(pTemplate->ulID));
            if (pArea && pTemplate->ulID == pArea->areadata.ulTemplateID)
               WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_SELECTITEM,
                                 MPFROMSHORT(sItem), MPFROMSHORT(TRUE));

            pTemplate = pTemplate->next;
         }
         break;

      case WM_CLOSE:
      case WM_DESTROY:
         if (!WinQueryWindowULong(parent, QWL_USER))
         {
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+3, LEN_AREATAG+1,
                                pchTemp);
            if (strcmp(pArea->areadata.areatag, pchTemp))
            {
               strcpy(pArea->areadata.areatag, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+5, LEN_AREADESC+1,
                                pchTemp);
            if (strcmp(pArea->areadata.areadesc, pchTemp))
            {
               strcpy(pArea->areadata.areadesc, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+9, LEN_5DADDRESS+1,
                                pchTemp);
            if (strcmp(pArea->areadata.address, pchTemp))
            {
               strcpy(pArea->areadata.address, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            WinQueryDlgItemText(parent, IDD_AS_GENERAL+12, LEN_USERNAME+1,
                                pchTemp);
            if (strcmp(pArea->areadata.username, pchTemp))
            {
               strcpy(pArea->areadata.username, pchTemp);
               arealiste.bDirty = TRUE;
               pArea->dirty=TRUE;
            }
            sItem = (SHORT)WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_QUERYSELECTION,
                                               MPFROMSHORT(LIT_FIRST), NULL);
            if (sItem >= 0)
            {
               ULONG ulID;

               ulID = (ULONG) WinSendDlgItemMsg(parent, IDD_AS_GENERAL+14, LM_QUERYITEMHANDLE,
                                                MPFROMSHORT(sItem), NULL);
               if (ulID != pArea->areadata.ulTemplateID)
               {
                  pArea->areadata.ulTemplateID = ulID;
                  arealiste.bDirty = TRUE;
                  pArea->dirty=TRUE;
               }
            }
         }
         break;

      case WM_COMMAND:
         return (MRESULT) FALSE;

      case WM_CONTROL:
         if (SHORT1FROMMP(mp1)==IDD_AS_GENERAL+3)
            if (SHORT2FROMMP(mp1)==EN_KILLFOCUS)
            {
               char pchTempTag[LEN_AREATAG+1];

               WinQueryDlgItemText(parent, IDD_AS_GENERAL+3, LEN_AREATAG+1, pchTempTag);
               SendMsg(hwndSettingsFrame,
                          APM_SETTITLE, pchTempTag, NULL);
            }
         if (SHORT1FROMMP(mp1) == IDD_AS_GENERAL+15)
            if (SHORT2FROMMP(mp1) == BN_CLICKED ||
                SHORT2FROMMP(mp1) == BN_DBLCLICKED)
            {
               if (WinQueryButtonCheckstate(parent, IDD_AS_GENERAL+15))
                  WinEnableControl(parent, IDD_AS_GENERAL+7, FALSE);
               else
                  WinEnableControl(parent, IDD_AS_GENERAL+7, TRUE);
            }
         break;

      case APM_REQCLOSE:
         WinQueryDlgItemText(parent, IDD_AS_GENERAL+3, LEN_AREATAG+1,
                             pchTemp);
         if (pchTemp[0] == 0)
         {
            /* Fehler, kein Area-Tag */
            if (MessageBox(parent, IDST_MSG_NOAREATAG, 0,
                           IDD_NOAREATAG, MB_RETRYCANCEL | MB_ERROR) == MBID_CANCEL)
                return (MRESULT) 2;
            else
                return (MRESULT) 1;
         }
         else
         {
            pAreaTemp = AM_FindArea(&arealiste, pchTemp);
            if (pAreaTemp && pAreaTemp != pArea)
            {
               /* Fehler, schon vorhanden */
               if (MessageBox(parent, IDST_MSG_ALREADYHAVEAREA, 0,
                              IDD_ALREADYHAVEAREA, MB_RETRYCANCEL | MB_ERROR) == MBID_CANCEL)
                   return (MRESULT) 2;
               else
                   return (MRESULT) 1;
            }
         }
         return (MRESULT) 0;

      case APM_CANCEL:
         WinSetWindowULong(parent, QWL_USER, 1);
         break;

      default:
         break;
   }
   return WinDefDlgProc(parent,message,mp1,mp2);
}
示例#26
0
MRESULT EXPENTRY DirDialogProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   switch ( msg ) {
      case WM_INITDLG:
         {
         SWP swpFileST;
         SWP swpDirST;
         SWP swpDirLB;
         SWP swpDriveST;
         SWP swpDriveCB;
         SWP swpDriveCBEF;
         SWP swpOK;
         SWP swpCancel;
         HWND hwndFileST;
         HWND hwndDirST;
         HWND hwndDirLB;
         HWND hwndDriveST;
         HWND hwndDriveCB;
         HWND hwndOK;
         HWND hwndCancel;
         HENUM henum;
         HWND hwndNext;
         ULONG ulCurY, ulCurX;
         LONG lScreenX, lScreenY, lDlgFrameX, lDlgFrameY, lTitleBarY;

         lScreenX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
         lScreenY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
         lDlgFrameX = WinQuerySysValue(HWND_DESKTOP, SV_CXDLGFRAME);
         lDlgFrameY = WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME);
         lTitleBarY = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);

         hwndFileST = WinWindowFromID(hwndDlg, DID_FILENAME_TXT);
         hwndDirST = WinWindowFromID(hwndDlg, DID_DIRECTORY_TXT);
         hwndDirLB = WinWindowFromID(hwndDlg, DID_DIRECTORY_LB);
         hwndDriveST = WinWindowFromID(hwndDlg, DID_DRIVE_TXT);
         hwndDriveCB = WinWindowFromID(hwndDlg, DID_DRIVE_CB);
         hwndOK = WinWindowFromID(hwndDlg, DID_OK);
         hwndCancel = WinWindowFromID(hwndDlg, DID_CANCEL);
         
#define SPACING 10
         // Reposition drives combobox
         ulCurY = SPACING;
         ulCurX = SPACING + lDlgFrameX;
         WinQueryWindowPos(hwndOK, &swpOK);
         WinSetWindowPos(hwndOK, 0, ulCurX, ulCurY, 0, 0, SWP_MOVE);
         ulCurY += swpOK.cy + SPACING;
         WinQueryWindowPos(hwndCancel, &swpCancel);
         WinSetWindowPos(hwndCancel, 0, ulCurX+swpOK.cx+10, SPACING, 0, 0, SWP_MOVE);
         WinQueryWindowPos(hwndDirLB, &swpDirLB);
         WinSetWindowPos(hwndDirLB, 0, ulCurX, ulCurY, swpDirLB.cx, swpDirLB.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpDirLB.cy + SPACING;
         WinQueryWindowPos(hwndDirST, &swpDirST);
         WinSetWindowPos(hwndDirST, 0, ulCurX, ulCurY, swpDirST.cx, swpDirST.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpDirST.cy + SPACING;
         WinQueryWindowPos(hwndDriveCB, &swpDriveCB);
         WinQueryWindowPos(WinWindowFromID(hwndDriveCB, CBID_EDIT), &swpDriveCBEF);
         WinSetWindowPos(hwndDriveCB, 0, ulCurX, ulCurY-(swpDriveCB.cy-swpDriveCBEF.cy)+5,
                                         swpDirLB.cx,
                                         swpDriveCB.cy,
                                         SWP_SIZE | SWP_MOVE);
         ulCurY += swpDriveCBEF.cy + SPACING;
         WinQueryWindowPos(hwndDriveST, &swpDriveST);
         WinSetWindowPos(hwndDriveST, 0, ulCurX, ulCurY, swpDriveST.cx, swpDriveST.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpDriveST.cy + SPACING;
         WinQueryWindowPos(hwndFileST, &swpFileST);
         WinSetWindowPos(hwndFileST, 0, ulCurX, ulCurY, swpFileST.cx, swpFileST.cy, SWP_MOVE | SWP_SIZE);
         ulCurY += swpFileST.cy + SPACING;

         // Hide unused stuff
         henum = WinBeginEnumWindows(hwndDlg);
         while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE)
         {
           USHORT usID = WinQueryWindowUShort(hwndNext, QWS_ID);
           if (usID != DID_FILENAME_TXT &&
               usID != DID_DIRECTORY_TXT &&
               usID != DID_DIRECTORY_LB &&
               usID != DID_DRIVE_TXT &&
               usID != DID_DRIVE_CB &&
               usID != DID_OK &&
               usID != DID_CANCEL &&
               usID != FID_TITLEBAR &&
               usID != FID_SYSMENU &&
               usID != FID_MINMAX) 
           {
             WinShowWindow(hwndNext, FALSE);
           }
         }

         WinSetWindowPos(hwndDlg,
                         HWND_TOP,
                         (lScreenX/2)-((swpDirLB.cx+2*SPACING+2*lDlgFrameX)/2),
                         (lScreenY/2)-((ulCurY+2*lDlgFrameY+lTitleBarY)/2),
                         swpDirLB.cx+2*SPACING+2*lDlgFrameX,
                         ulCurY+2*lDlgFrameY+lTitleBarY,
                         SWP_MOVE | SWP_SIZE);
         }
         break;
      case WM_CONTROL:
         {
         PFILEDLG pfiledlg;
         pfiledlg = (PFILEDLG)WinQueryWindowPtr(hwndDlg, QWL_USER);

         HPS           hps;
         SWP           swp;
         HWND          hwndST;
         RECTL         rectlString = {0,0,1000,1000};
         char          *ptr = NULL;
         int           iHalfLen;
         int           iLength;
         CHAR          szString[CCHMAXPATH];

         hwndST = WinWindowFromID(hwndDlg, DID_FILENAME_TXT);
       
         strcpy(szString, pfiledlg->szFullFile);
         iLength = strlen(pfiledlg->szFullFile);
         /* If we are not just a drive */
         if (iLength > 3) {
           if (szString[iLength-1] == '\\') {
             szString[iLength-1] = '\0';
             iLength--;
           }
         }
       
         hps = WinGetPS(hwndST);
         WinQueryWindowPos(hwndST, &swp);
       
         WinDrawText(hps, iLength, szString,
                          &rectlString, 0, 0, 
                          DT_BOTTOM | DT_QUERYEXTENT | DT_TEXTATTRS);
         while(rectlString.xRight > swp.cx)
         {
           iHalfLen = iLength / 2;
           if(iHalfLen == 2)
             break;
       
           ptr = szString + iHalfLen;
           memmove(ptr - 1, ptr, strlen(ptr) + 1);
           szString[iHalfLen - 2] = '.';
           szString[iHalfLen - 1] = '.';
           szString[iHalfLen]     = '.';
           iLength = strlen(szString);
           rectlString.xLeft = rectlString.yBottom = 0;
           rectlString.xRight = rectlString.yTop = 1000;
           WinDrawText(hps, iLength, szString,
                       &rectlString, 0, 0, 
                       DT_BOTTOM | DT_QUERYEXTENT | DT_TEXTATTRS);
         }
       
         WinReleasePS(hps);
         WinSetWindowText(hwndST, szString);
         }
         break;
   }      
   return WinDefFileDlgProc(hwndDlg, msg, mp1, mp2);
}
/* This Proc handles the on-the-fly data CD writing */
MRESULT EXPENTRY onTheFlyStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  char text[CCHMAXPATH*2+10];
  char title[CCHMAXPATH];
  char *textPtr;
  char *textPtr2; 
  static LONG lCDSize;
  static LONG lImageSize;
  SWCNTRL swctl;
  PID pid;

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

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

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

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

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

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

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

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

            iPercent=LONGFROMMP(mp2);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          }
          textPtr=strstr(ptrLocalMem,"-o-print-size");
          if(textPtr) {
            *textPtr=' ';
            textPtr++;
            *textPtr=' ';
          }
          /* Copy updated command line to parameter file */
          if((file=fopen(params[4],"wb"))!=NULL) {
            fwrite(ptrLocalMem, sizeof(char), SHAREDMEM_SIZE, file);
            fclose(file); 
          }
          /* logfilename as a parameter */
          buildLogName(title, logName,  sizeof(title));
          snprintf(text, sizeof(text), "\"%s\" \"%s\"" ,params[4], title);
          /* Launch the helper program */
          launchWrapper( text, chrInstallDir, hwnd,"prntsize.exe", "Query image size");          
          break;
          }
        default:
          break;
        }/* switch */
      }/* if(thisPtr) */           
      return WinDefWindowProc( hwnd, msg, mp1, mp2);
    default:
      break;
    }
    return WinDefDlgProc(hwnd, msg, mp1, mp2);    
}
示例#28
0
MRESULT EXPENTRY fnwpMain(HWND hwndFrame, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    PSZ             szData;
    PDDESTRUCT      pddeStruct;
    ULONG           mem;

    CHAR            szBuffer[200];

    switch (msg)
    {

        // all answers to the WinDDEInitate call arrive here
        case WM_DDE_INITIATEACK:
        {
            PDDEINIT        pddeInit;
            PSZ             szInApp, szInTopic;
            static BOOL bNetscapeAnswered = FALSE;

            pddeInit = (PDDEINIT)mp2;
            szInApp = pddeInit->pszAppName;
            szInTopic = pddeInit->pszTopic;
            G_hServerWnd = (HWND)mp1;

            ShowMessage("WM_DDE_INITIATEACK (resp to WinDDEInitiate)");
            ShowMessage("  application: \"%s\"",
                        pddeInit->pszAppName);
            ShowMessage("  topic: \"%s\"",
                        pddeInit->pszTopic);

            // RDP 2000-07-07 07:24:18
            // There was no check on which application responded.
            // This made NETSCDDE fail when another DDE-aware application,
            // like EPM, was running.
            // Now the handle from mp1 is only assigned if the application
            // responding is Netscape.
            // If the app is not Netscape then the handle is nullified.
            // I don't know if assigning 0 to the handle is correct but
            // is seems to solve the problem.

            // V0.9.19 (2002-03-28) [umoeller]
            // Opera fix: use stricmp instead of strcmp
            if (!stricmp(pddeInit->pszAppName,
                         G_szDDENetscape))     // V0.9.16 (2001-10-02) [umoeller]
            {
                // ShowMessage("!! Netscape answered.");
                G_hServerWnd = (HWND)mp1;
                bNetscapeAnswered = TRUE;
            }
            else
            {
                // ShowMessage("!! Other application aswered.");
                G_hServerWnd = (HWND)0;
            }
        }
        break;

        // all answers to DDE requests arrive here
        case WM_DDE_DATA:
        {
            ShowMessage("!! Received data from Netscape: ");
            pddeStruct = (PDDESTRUCT) mp2;
            DosGetSharedMem(pddeStruct, PAG_READ | PAG_WRITE);
            szData = (BYTE *) (pddeStruct + (pddeStruct->offabData));
            ShowMessage(szData);
        }
        break;

        // menu item processing (in debug mode, otherwise these
        // WM_COMMAND msgs have been posted automatically)
        case WM_COMMAND:
            switch (SHORT1FROMMP(mp1))
            {
                // start DDE conversation: this was posted
                // by "main" before the PM loop was entered
                // (even if we're in debug mode)
                case IDM_INITIATE:
                    // WinPostMsg(G_hwndListbox, LM_DELETEALL, 0, 0);
                    ShowMessage("IDM_INITIATE:");
                    ShowMessage("Topic: \"%s\"", G_szOpenURLTopic);
                    G_context.cb = sizeof(CONVCONTEXT);
                    G_context.fsContext = 0;
                    WinDdeInitiate(hwndFrame, G_szDDENetscape,
                                   G_szOpenURLTopic, &G_context);
                    if (!G_optDebug)
                        // if we're not in debug mode, post subsequent
                        // menu commands automatically
                        WinPostMsg(hwndFrame, WM_COMMAND, MPFROM2SHORT(IDM_CHAIN2, 0), 0);
                break;

                // "Open URL": request data from server
                case IDM_OPENURL:
                {
                    ShowMessage("IDM_OPENURL");
                    ShowMessage("  URL: \"%s\"", G_szURL);
                    strlcpy(szBuffer, G_szURL, sizeof(szBuffer));
                    strlcat(szBuffer, ",,0xFFFFFFFF,0x0", sizeof(szBuffer));
                    DDERequest(hwndFrame, szBuffer);
                }
                break;

                // "Open URL in new window": request data from server,
                // but with different parameters
                case IDM_OPENURLNEW:
                {
                    ShowMessage("IDM_OPENURLNEW");
                    ShowMessage("  URL: \"%s\"", G_szURL);
                    strlcpy(szBuffer, G_szURL, sizeof(szBuffer));
                    strlcat(szBuffer, ",,0x0,0x0", sizeof(szBuffer));
                    DDERequest(hwndFrame, szBuffer);
                }
                break;

                /*
                 * IDM_CHAIN2:
                 *      this is posted after DDE_INITIATE was
                 *      successful
                 */

                case IDM_CHAIN2:
                {
                    if (G_optNewWindow)
                        WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_OPENURLNEW, 0), 0);
                    else
                        WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_OPENURL, 0), 0);
                    WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_CHAIN3, 0), 0);
                }
                break;

                /*
                 * IDM_CHAIN3:
                 *      this is posted to close the whole thing; we just need
                 *      another msg before going for IDM_CLOSE, or some DDE
                 *      msgs might get lost
                 */

                case IDM_CHAIN3:
                    WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_CLOSE, 0), 0);
                break;

                case IDM_FULLSEQUENCE:
                    WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_INITIATE, 0), 0);
                    WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_CHAIN2, 0), 0);
                break;


                /*
                 * IDM_CLOSE:
                 *      this is posted to close the whole thing
                 */

                case IDM_CLOSE:
                    WinDdePostMsg(G_hServerWnd,
                                  hwndFrame,
                                  WM_DDE_TERMINATE,
                                  NULL,
                                  DDEPM_RETRY);
                    ShowMessage("DDE connection closed.");

                    if (!G_optDebug)
                        WinPostMsg(hwndFrame, WM_COMMAND, MPFROM2SHORT(IDM_DELAYEXIT, 0), 0);
                break;

                /*
                 * IDM_DELAYEXIT:
                 *      this is posted after IDM_CLOSE; we will now
                 *      check for whether the DDE conversation with
                 *      Netscape was successful and, if not, start
                 *      a new instance of Netscape according to the
                 *      command line parameters
                 */

                case IDM_DELAYEXIT:
                {
                    if (    (!G_NetscapeFound)
                         && (G_optExecute)
                       )
                    {
                        CHAR szStart[256];
                        GetNLSString(szStart, sizeof(szStart), ID_NDSI_STARTNETSCAPE);

                        // confirm start netscape
                        if (    (!G_optConfirmStart)
                             // get rid of this hideously ugly dialog
                             || (WinMessageBox(HWND_DESKTOP,
                                               HWND_DESKTOP,
                                               szStart,
                                               (PSZ)NETSCDDE_TITLE,
                                               0,
                                               MB_YESNO | MB_MOVEABLE)
                                       == MBID_YES)
                                               /* WinCenteredDlgBox(HWND_DESKTOP,
                                                   G_hwndDebug,
                                                   WinDefDlgProc,
                                                   G_hmodNLS,
                                                   ID_NDD_QUERYSTART,
                                                   NULL)
                                      == DID_OK) */
                           )
                        {
                            UCHAR           achObjBuf[256] = "";

                            CHAR            szArgs[CCHMAXPATH];

                            HWND            hwndNotify = HWND_DESKTOP;
                            PROGDETAILS     pd;
                            HAPP            happ;

                            // destroy "Contacting", create "Starting Netscape"
                            // window
                            WinDestroyWindow(G_hwndContacting);
                            G_hwndContacting = NULLHANDLE;

                            if (!G_optQuiet)
                            {
                                G_hwndContacting = WinLoadDlg(HWND_DESKTOP, G_hwndDebug,
                                                            WinDefDlgProc,
                                                            G_hmodNLS, ID_NDD_STARTING,
                                                            0);
                                WinShowWindow(G_hwndContacting, TRUE);
                            }

                            strlcpy(szArgs, G_szNetscapeParams, sizeof(szArgs));
                            strlcat(szArgs, " ", sizeof(szArgs));
                            strlcat(szArgs, G_szURL, sizeof(szArgs));

                            // now start app
                            memset(&pd, 0, sizeof(pd));
                            pd.Length = sizeof(pd);
                            pd.progt.progc = PROG_DEFAULT;
                            pd.progt.fbVisible = SHE_VISIBLE;
                            pd.pszExecutable = G_szNetscapeApp;
                            pd.pszParameters = szArgs;
                            pd.pszStartupDir = G_szStartupDir;

                            if (!(happ = WinStartApp(NULLHANDLE,
                                                     &pd,
                                                     szArgs,
                                                     NULL,
                                                     SAF_INSTALLEDCMDLINE)))
                            {
                                DisplayError("WinStartApp failed for app \"%s\", params \"%s\", startup dir \"%s\"",
                                             G_szNetscapeApp,
                                             szArgs,
                                             G_szStartupDir);
                            }
                        }
                    }
                    // keep "Contacting" / "Starting" window visible for two seconds
                    G_idTimer = WinStartTimer(G_hab, hwndFrame, 1, 2000);
                    break;
                }

                // User closes the window
                case IDM_EXIT:
                    WinPostMsg(hwndFrame, WM_CLOSE, 0, 0);
                break;
            }
            break;

        case WM_TIMER:
            // after two seconds, close status window
            WinStopTimer(G_hab, hwndFrame, G_idTimer);
            WinPostMsg(hwndFrame, WM_CLOSE, 0, 0);
        break;

        // Send the message to the usual WC_FRAME WndProc
        default:
            return G_SysWndProc(hwndFrame, msg, mp1, mp2);
    }

    return FALSE;
}
示例#29
0
int main(int argc,
         char *argv[])
{
    HMQ             hmq;
    FRAMECDATA      fcd;
    QMSG            qmsg;
    BOOL            Proceed = TRUE;

    if (!(G_hab = WinInitialize(0)))
        return 1;

    if (!(hmq = WinCreateMsgQueue(G_hab, 0)))
        return 1;

    // now attempt to find the XWorkplace NLS resource DLL,
    // which we need for all resources (new with XWP 0.9.0)
    Proceed = LoadNLS();

    // load browser path from USER_INI
    // V0.9.19 (2002-03-28) [umoeller]
    if (PrfQueryProfileString(HINI_USERPROFILE,
                              "WPURLDEFAULTSETTINGS", "DefaultBrowserExe",
                              (PSZ)DEFAULT_BROWSER,
                              G_szNetscapeApp,
                              sizeof(G_szNetscapeApp)))
    {
        // make sure this is not NETSCDDE.EXE, or we'll have
        // plenty of problems restarting ourselves infinitely
        // V0.9.19 (2002-04-02) [umoeller]
        if (strhistr(G_szNetscapeApp, "netscdde.exe"))
            strlcpy(G_szNetscapeApp, DEFAULT_BROWSER, sizeof(G_szNetscapeApp));
    }

    // load browser startup dir from USER_INI
    // V0.9.19 (2002-03-28) [umoeller]
    PrfQueryProfileString(HINI_USERPROFILE,
                          "WPURLDEFAULTSETTINGS", "DefaultWorkingDir",
                          "",
                          G_szStartupDir,
                          sizeof(G_szStartupDir));

    if (Proceed)
    {
        // parse parameters on cmd line
        if (argc > 1)
        {
            SHORT           i = 0;

            while (i++ < argc - 1)
            {
                if (argv[i][0] == '-')
                {
                    SHORT           i2;

                    for (i2 = 1; i2 < strlen(argv[i]); i2++)
                    {
                        switch (argv[i][i2])
                        {
                            case 'n':
                                G_optNewWindow = TRUE;
                                break;

                            case 'x':
                                G_optExecute = FALSE;
                                break;

                            case 'm':
                                G_optMinimized = TRUE;
                                break;

                            case 'h':
                                G_optHidden = TRUE;
                                break;

                            case 'X':
                                G_optConfirmStart = FALSE;
                                break;

                            case 'p':   // netscape path

                                if (i < argc)
                                {
                                    strlcpy(G_szNetscapeApp, argv[i + 1], sizeof(G_szNetscapeApp));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;

                            case 's':   // startup dir V0.9.16 (2001-10-02) [umoeller]
                            {
                                if (i < argc)
                                {
                                    strlcpy(G_szStartupDir, argv[i + 1], sizeof(G_szStartupDir));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;
                            }

                            case 'S':   // DDE server name V0.9.16 (2001-10-02) [umoeller]
                                if (i < argc)
                                {
                                    strlcpy(G_szDDENetscape, argv[i + 1], sizeof(G_szDDENetscape));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;

                            case 'P':   // netscape parameters

                                if (i < argc)
                                {
                                    strlcpy(G_szNetscapeParams, argv[i + 1], sizeof(G_szNetscapeParams));
                                    i++;
                                    i2 = 1000;
                                }
                                else
                                {
                                    ExplainParams();
                                    Proceed = FALSE;
                                }
                                break;

                            case 'D':   // debug, show list box window w/ DDE msgs

                                G_optDebug = TRUE;
                                break;

                            case 'q': // added V0.9.1 (2000-02-07) [umoeller]
                                G_optQuiet = TRUE;
                                break;

                            default:    // unknown parameter
                                ExplainParams();
                                Proceed = FALSE;
                                break;
                        }
                    }
                }
                else
                {
                    // no option ("-"): seems to be URL
                    _PmpfF(("got URL [%s]", argv[i]));
                    // if the URL contains spaces, we enclose it in quotes
                    // V1.0.0 (2002-09-09) [umoeller]: not only spaces,
                    // but other weird characters too
                    if (strpbrk(argv[i], " &|="))
                        sprintf(G_szURL, "\"%s\"", argv[i]);
                    else
                        strlcpy(G_szURL, argv[i], sizeof(G_szURL));
                }
            }
        }

        if (strlen(G_szURL) == 0)
        {
            // no URL given: explain
            ExplainParams();
            Proceed = FALSE;
        }

        if (Proceed)
        {
            // OK, parameters seemed to be correct:
            // create the main window, which is only
            // visible in Debug mode ("-D" param). But
            // even if not in debug mode, this window is
            // used for DDE message processing.
            fcd.cb = sizeof(FRAMECDATA);
            fcd.flCreateFlags = FCF_TITLEBAR |
                                   FCF_SYSMENU |
                                   FCF_MENU |
                                   FCF_SIZEBORDER |
                                   FCF_SHELLPOSITION |
                                   FCF_MINMAX |
                                   FCF_TASKLIST;

            fcd.hmodResources = NULLHANDLE;
            // set our resource key (so PM can find menus, icons, etc).
            fcd.idResources = DDEC;
            // create the frame
            G_hwndDebug = WinCreateWindow(HWND_DESKTOP,
                                          WC_FRAME,
                                          (PSZ)NETSCDDE_TITLE,
                                          0, 0, 0, 0, 0,
                                          NULLHANDLE,
                                          HWND_TOP,
                                          DDEC,
                                          &fcd,
                                          NULL);

            if (!G_hwndDebug)
                return 1;

            // set the NetscDDE icon for the frame window
            WinSendMsg(G_hwndDebug,
                       WM_SETICON,
                       (MPARAM)WinLoadPointer(HWND_DESKTOP, G_hmodNLS,
                                              ID_ND_ICON),
                       NULL);

            // create a list window child
            G_hwndListbox = WinCreateWindow(G_hwndDebug,
                                            WC_LISTBOX,
                                            NULL,
                                            LS_HORZSCROLL,
                                            0, 0, 0, 0,
                                            G_hwndDebug,
                                            HWND_BOTTOM,
                                            FID_CLIENT,
                                            NULL,
                                            NULL);

            // we must intercept the frame window's messages;
            // we save the return value (the current WndProc),
            // so we can pass it all the other messages the frame gets.
            G_SysWndProc = WinSubclassWindow(G_hwndDebug, (PFNWP) fnwpMain);

            // the window we just created is normally invisible; we
            // will only display it if the (undocumented) "-D" option
            // was given on the command line.
            if (G_optDebug)
            {
                WinShowWindow(G_hwndDebug, TRUE);
                ShowMessage("Entering msg loop");
            }

            // now show "Contacting Netscape"
            if (!G_optQuiet)
            {
                G_hwndContacting = WinLoadDlg(HWND_DESKTOP, G_hwndDebug,
                                            WinDefDlgProc,
                                            G_hmodNLS, ID_NDD_CONTACTING,
                                            0);
                WinShowWindow(G_hwndContacting, TRUE);
            }

            // now post msg to main window to initiate DDE
            if (!G_optDebug)
                WinPostMsg(G_hwndDebug, WM_COMMAND, MPFROM2SHORT(IDM_INITIATE, 0), 0);

            //  standard PM message loop
            while (WinGetMsg(G_hab, &qmsg, NULLHANDLE, 0, 0))
            {
                WinDispatchMsg(G_hab, &qmsg);
            }
        }                           // end if (proceed)

        // clean up on the way out
        WinDestroyWindow(G_hwndContacting);
        G_hwndContacting = NULLHANDLE;
    }

    WinDestroyMsgQueue(hmq);
    WinTerminate(G_hab);

    return 0;
}
示例#30
0
//************************************************************************************************
// The allmighty StartupThread
//************************************************************************************************
void _Optlink StartupThread(void *pArg)
{
   AnchorBlock    ab;
   MessageQueue   mq(ab);
   PINITDATA      pinit = (PINITDATA)pArg;
   int            i;
   USHORT         usDeviceIndex = 0;     // default use default deviceindex
   USHORT         usVolume = 75;         // default 75% volume
   ULONG          ulError = 0;           // mci error
   MCI_OPEN_PARMS mciOpenParms;
   BOOL           fDeviceOpen = FALSE;

   //*********************************************************************************************
   // Set the lowest posible priority to make us systemfriendly
   //*********************************************************************************************
   DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, PRTYD_MINIMUM, 0);


   //*********************************************************************************************
   // Clear some evetual garbage, just in case....
   //*********************************************************************************************
   WinSetWindowPtr(pinit->hWnd, QWP_PLAYLIST, NULL);
   WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, NULL);
   WinSetWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES, 0);
   WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, 0);
   WinSetWindowULong(pinit->hWnd, QWL_LOOP, 0);   // do not loop by default


   //*********************************************************************************************
   // Parse the commandline
   //*********************************************************************************************
   for(i = 1; i < pinit->argc; i++)
   {
      switch(pinit->argv[i][0])
      {
         case '/':
         case '-':
            switch(pinit->argv[i][1])
            {
               case 'i':
               case 'I':
                  usDeviceIndex = (USHORT)atoi(&pinit->argv[i][2]);
                  break;

               case 'l':
               case 'L':
                  WinSetWindowULong(pinit->hWnd, QWL_LOOP, 1);
                  break;

               case 'v':
               case 'V':
                  usVolume = (USHORT)atoi(&pinit->argv[i][2]);
                  break;
            }
            break;

         default:
            AddToPlaylist(pinit->hWnd, pinit->argv[i]);
            break;
      }
   }

   // make sure we're at the first entry of the playlist
   WinSetWindowPtr(pinit->hWnd, QWP_CURRENTENTRY, WinQueryWindowPtr(pinit->hWnd, QWP_PLAYLIST));


   //*********************************************************************************************
   // open the waveaudio device
   //*********************************************************************************************
   memset((void*)&mciOpenParms, 0, sizeof(mciOpenParms));

   mciOpenParms.pszDeviceType = (PSZ)MAKEULONG(MCI_DEVTYPE_WAVEFORM_AUDIO, usDeviceIndex);
   ulError = mciSendCommand((USHORT)0, MCI_OPEN, MCI_WAIT | MCI_OPEN_TYPE_ID, (PVOID)&mciOpenParms, 0);

   if(LOUSHORT(ulError) == MCIERR_SUCCESS)
   {
      fDeviceOpen = TRUE;
      WinSetWindowUShort(pinit->hWnd, QWS_DEVICEID, mciOpenParms.usDeviceID);
   }

   if((fDeviceOpen == TRUE) && (WinQueryWindowULong(pinit->hWnd, QWL_PLAYLISTENTRIES) != 0))
   {
      MCI_SET_PARMS        msp;

      msp.ulLevel = usVolume;
      msp.ulAudio = MCI_SET_AUDIO_ALL;
      ulError = mciSendCommand(mciOpenParms.usDeviceID, MCI_SET, MCI_WAIT | MCI_SET_AUDIO | MCI_SET_VOLUME, (PVOID)&msp, 0);

      if(LOUSHORT(ulError) == MCIERR_SUCCESS)
      {
         WinSendMsg(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), MPFROMSHORT(usVolume));
         WinEnableWindow(WinWindowFromID(pinit->hWnd, SLRD_VOLUME), TRUE);
      }

      if((BOOL)WinSendMsg(pinit->hWnd, WMU_LOAD, NULL, NULL))
      {
         WinSendMsg(pinit->hWnd, WMU_PLAY, NULL, NULL);
      }
   }


   //*********************************************************************************************
   // free the initdata buffer
   //*********************************************************************************************
   delete pinit;

   // show the window
   SWP   swp;
   ULONG pulBufferMax = sizeof(swp);
   if(PrfQueryProfileData(HINI_USERPROFILE, "WavePlayer", "WindowPosition", (PVOID)&swp, &pulBufferMax))
      WinSetWindowPos(WinQueryWindow(pinit->hWnd, QW_PARENT), HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_SHOW | SWP_MOVE | SWP_SIZE);
   else
      WinShowWindow(WinQueryWindow(pinit->hWnd, QW_PARENT), TRUE);

   // bye, bye!
   _endthread();
}