Example #1
0
void ConfigCOMi(HWND hwnd)
  {
  BOOL bSuccess = FALSE;
  HMODULE hMod;
  PFN pfnProcess;
  char szCaption[40];
  char szMessage[100];
  INFODLG stInfoDlg;

  stInst.bDDconfigured = FALSE;
  if (stInst.paszStrings[CONFIGDDLIBRARYSPEC][0] == 0)
    {
    if (PrfQueryProfileString(HINI_USERPROFILE,szConfigDDname,"Configuration",0L,
                                                stInst.paszStrings[CONFIGDDLIBRARYSPEC],
                                                stInst.ulMaxPathLen) == 0)
      sprintf(stInst.paszStrings[CONFIGDDLIBRARYSPEC],"COMi_CFG.DLL");
    }
  if (DosLoadModule(0,0,stInst.paszStrings[CONFIGDDLIBRARYSPEC],&hMod) != NO_ERROR)
    {
    sprintf(stInst.paszStrings[CONFIGDDLIBRARYSPEC],"%s\\%s.DLL",stInst.pszSourcePath,szConfigDDlibraryName);
    if (DosLoadModule(0,0,stInst.paszStrings[CONFIGDDLIBRARYSPEC],&hMod) != NO_ERROR)
      {
      sprintf(szCaption,"Configuration cannot be completed.");
      sprintf(szMessage,"Library %s is invalid or does not exist.",stInst.paszStrings[CONFIGDDLIBRARYSPEC]);
      WinMessageBox(HWND_DESKTOP,
                    stInst.hwndFrame,
                    szMessage,
                    szCaption,
                    HLPP_MB_LIBRARY_BAD,
                   (MB_OK | MB_HELP | MB_WARNING));
      sprintf(szBannerTwo,"Installation is not complete");
      szBannerOne[0] = 0;
      ClientPaint(hwndClient);
      return;
      }
    }
  else
    {
    if (DosQueryProcAddr(hMod,0,szConfigDDfunctionName,(PFN *)&pfnProcess) == NO_ERROR)
      {
      stCOMiCFG.pszPortName = NULL;
      stCOMiCFG.cbSize = sizeof(COMICFG);
      stCOMiCFG.bEnumCOMscope = FALSE;
      stCOMiCFG.bInstallCOMscope = bCOMscopeToInstall;
      stCOMiCFG.bInitInstall = TRUE;
      stCOMiCFG.hwndFrame = stInst.hwndFrame;
      stCOMiCFG.byOEMtype = (BYTE)ulOEMtype;
      stCOMiCFG.hab = stInst.hab;
      if (strlen(stCOMiCFG.pszDriverIniSpec) == 0)
        sprintf(stCOMiCFG.pszDriverIniSpec,"%s\\%s",stInst.pszAppsPath,szDDname);
      bSuccess = pfnProcess(&stCOMiCFG);
      }
    DosFreeModule(hMod);
    }
  if (bSuccess)
    {
    sprintf(szCaption,"Configuration is complete.");
    if (!stInst.bFilesCopied)
      sprintf(szMessage,"You must shut down and re-start your system for any configuration changes to take effect.");
    else
      sprintf(szMessage,"You must shut down your system to activate serial access.");
    WinMessageBox(HWND_DESKTOP,
                  stInst.hwndFrame,
                  szMessage,
                  szCaption,
                  HLPP_MB_CONFIG_OK,
                 (MB_OK | MB_HELP | MB_INFORMATION));
    szBannerOne[0] = 0;
    stInst.bDDconfigured = TRUE;
    if (stInst.bFilesCopied)
      {
      sprintf(szBannerTwo,"Installation is complete");
      if (!stInst.bAppConfigured)
        sprintf(szBannerOne,"%s configuration is complete",szConfigDDname);
      }
    else
      sprintf(szBannerTwo,"%s Configuration is complete",szConfigAppName);
    ClientPaint(hwndClient);
    if (stInst.bFilesCopied)
      {
      if (strlen(szInfoFileName) != 0)
        {
        stInfoDlg.cbSize = sizeof(INFODLG);
        stInfoDlg.pszFileName = szInfoFileName;
        stInfoDlg.pszCaption = szInfoCaption;
        WinDlgBox(HWND_DESKTOP,
                  hwnd,
           (PFNWP)fnwpInfoDlgProc,
            (LONG)NULL,
                  EVAL_MSG,
             (PVOID)&stInfoDlg);
        }
      }
    }
  else
    {
    if (stInst.bFilesCopied)
      {
      sprintf(szCaption,"Configuration is not complete.");
      sprintf(szMessage,"You must select the \"Configuration | %s...\" menu item again to complete installation.",szConfigDDname);
      WinMessageBox(HWND_DESKTOP,
                    stInst.hwndFrame,
                    szMessage,
                    szCaption,
                    HLPP_MB_CONFIG_BAD,
                   (MB_OK | MB_HELP | MB_WARNING));
      sprintf(szBannerTwo,"Installation is not complete");
      szBannerOne[0] = 0;
      ClientPaint(hwndClient);
      }
    }
  }
/****************************************************************************
 * ClientWndProc                                                            *
 *  - Typical PM client window procedure.  (see below)                      *
 *  - Standard client window I/O                                            *
 ****************************************************************************/
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
	   RECTL  rcl;
	   SWP	  swp;
	   HPS	  hpsPaint;

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

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

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

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

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

	return 0;

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

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

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

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

	return 0;

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

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

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

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

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

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

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

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

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

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

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

	return 0;

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

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

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

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

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

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

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

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

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

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

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

	return 0;

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

      }
    return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
Example #3
0
/*----------------------------------------------------------------------------*/                   
MRESULT EXPENTRY DLG_MAIN_Proc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)                    
/*----------------------------------------------------------------------------*/                   
/* This dialog proc initializes and handles all messages for the main         */
/* dialog.                                                                    */
/*----------------------------------------------------------------------------*/                   
{                                                                                                  
static HWND  ContextHwnd;  /* Handle of context menu                     */
static SHORT ContextIndx;  /* Index of item context menu was selected on */
                                                                                                   
  switch (msg) {                                                                                   
                                                                                                   
    case WM_INITDLG:                                                                               
      INSERTITEM(LIST, "Listbox item 0");
      INSERTITEM(LIST, "Listbox item 1");
      INSERTITEM(LIST, "Listbox item 2");
      INSERTITEM(LIST, "Listbox item 3");
      INSERTITEM(LIST, "Listbox item 4");
      INSERTITEM(LIST, "Listbox item 5");
      INSERTITEM(LIST, "Listbox item 6");
      INSERTITEM(LIST, "Listbox item 7");
      INSERTITEM(LIST, "Listbox item 8");
      INSERTITEM(LIST, "Listbox item 9");
      INSERTITEM(LIST, "Listbox item 10");
      INSERTITEM(LIST, "Listbox item 11");
      INSERTITEM(LIST, "Listbox item 12");
      INSERTITEM(LIST, "Listbox item 13");
      INSERTITEM(LIST, "Listbox item 14");
      INSERTITEM(LIST, "Listbox item 15");

      /* Add direct-manipulation capability to the listbox */
      DMLBInitialize(CONTROLHWND(LIST), NULLHANDLE);

      /* Load context menu for later use */
      ContextHwnd = WinLoadMenu(hwnd, NULLHANDLE, ID_MENU);

      return FALSE;                                           

    case WM_DESTROY:
      /* Free resources */
      WinDestroyWindow(ContextHwnd);
      break;
                                                              
    case WM_COMMAND:                                          
      switch (SHORT1FROMMP(mp1)) {                            

        /*******************************************************************/
        /* We get WM_COMMAND messages from the context menu.  The variable */
        /* ContextIndx already has the index of the item on which the      */
        /* context menu was requested (or LIT_NONE).                       */
        /*******************************************************************/

        case ID_MENU_EDIT: {  //------- Context menu "Edit" selected -----------
          char Buff[MAX_LEN];
          /* Run edit menu, update list if user selects OK button */
          QUERYITEMTEXT(LIST, ContextIndx, Buff, sizeof(Buff));
          if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff)
              == DID_OK)
            SETITEMTEXT(LIST, ContextIndx, Buff);
          return 0;
          }

        case ID_MENU_DELETE:  //------- Context menu "Delete" selected -----------
          WinSendMsg(CONTROLHWND(LIST), LM_DELETEITEM, MPFROMSHORT(ContextIndx), MPVOID);
          return 0;

        case ID_MENU_INSERT: {//------- Context menu "Insert" selected ----------
          char Buff[MAX_LEN];
          /* Run edit menu, insert into list if user selects OK button */
          Buff[0] = '\0';
          if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff)
              == DID_OK) {
            if (ContextIndx == LIT_NONE)  // Insert at end of list
              ContextIndx = LIT_END;
            else
              ContextIndx++;              // Insert AFTER selected item
            INSERTITEMAT(LIST, ContextIndx, Buff);
          }
          return 0;
          }

        case DID_OK: /*----------~OK (PUSHBUTTON)----------*/ 
          // Let default dialog proc terminate us
          break;                                              
      }                                                       
      break;                                                  
                                                              
    case WM_CONTROL:                                          
      switch SHORT1FROMMP(mp1) {                              
        case LIST: /*----------LIST (LISTBOX)----------*/     
 
          /*******************************************************************/
          /* Notification messages from the listbox come here.  These are    */
          /* the usual PM listbox messages, plus some new ones for DMLB.     */
          /*******************************************************************/
 
          switch (SHORT2FROMMP(mp1)) {
            case LN_SELECT:           
            case LN_ENTER:            
              /* User dbl-clicked an entry or pressed ENTER.  For this sample       */
              /* we do nothing.                                                     */
              return 0;

            case LN_DMLB_QRYDROP:
              /* A listbox item is about to be dropped on this listbox.  We must    */
              /* return a Ok-to-drop  indicator, and tell what to do with the       */
              /* original item (copy or move).  Since we have just one listbox in   */
              /* this sample, MOVE is the only thing that makes sense.              */
              return MRFROM2SHORT(TRUE, DROPMODE_MOVE);

            case LN_DMLB_CONTEXT: {
              /* The user has requested a context menu.  Short 1 of mp2 is the      */
              /* index of the listbox item under the pointer.                       */
              POINTL Point;
              ContextIndx = SHORT1FROMMP(mp2);
              if (ContextIndx == LIT_NONE) {
                // Disable Edit & Delete if pointer was not over a listbox item
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE),   MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
              } else {
                // Otherwise, enable Edit & Delete
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE),   MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED));
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED));
              }
              // It is not technically necessary to select the item on which the context
              // menu was selected, but it provides good visual feedback to the user to
              // show which item the context menu applies to.
              SETSELECTION(LIST, ContextIndx);

              // Popup the context menu at the pointer position.  The menu will
              // send us WM_COMMAND messages if a menu item is selected.
              WinQueryMsgPos((HAB)0, &Point);
              WinPopupMenu(HWND_DESKTOP, hwnd, ContextHwnd, Point.x, Point.y, 0, PU_HCONSTRAIN| PU_VCONSTRAIN
                                                            | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_MOUSEBUTTON3 
                                                            | PU_KEYBOARD );
              return (MRESULT)TRUE;
              }
          }                           
          break;                      
      }                               
      break; /* End of WM_CONTROL */          
                                              
  } /* End of (msg) switch */                 
                                              
  return WinDefDlgProc(hwnd, msg, mp1, mp2);  
                                              
} /* End dialog procedure */                  
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);
}
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);
    }
}
Example #6
0
MRESULT	EXPENTRY ROPsTestWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)

{
CHAR			szTitle[300];  /* Title	Bar Text		*/
HPS			hPS;	   /* Presentation Space Handle		*/
LONG			lClrBack;  /* Colour Holder			*/
LONG			lClrFore;  /* Colour Holder			*/
LONG			lScrollInc;/* Scroll Increment			*/
PBITMAPARRAYFILEHEADER	pbafh;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPARRAYFILEHEADER2	pbafh2;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPFILEHEADER	pbfh;	   /* Bitmap File Header Pointer	*/
PBITMAPFILEHEADER2	pbfh2;	   /* Bitmap File Header Pointer	*/
PBITMAPINFO		pbmi;	   /* Bitmap Info Pointer		*/
PBITMAPINFO2		pbmi2;	   /* Bitmap Info Pointer		*/
POINTL			ptl;	   /* Pointer Position			*/
RECTL			rcl;	   /* Window Rectangle			*/
register INT i;			   /* Index				*/

switch ( msg )
   {
/************************************************************************/
/* Window being	created, perform window	initialization			*/
/************************************************************************/

   case	WM_CREATE :

       hptrWait	 = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT,	FALSE);
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);

       cxScreen	= WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);

       hmenuROPs = WinWindowFromID(WinQueryWindow(hWnd,	QW_PARENT), FID_MENU);
       hwndHScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_HORZSCROLL);
       hwndVScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_VERTSCROLL);

		       /************************************************/
		       /* PDSGetTemplate is used to allow controls in  */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       PDSGetTemplate(hWnd, WIN_ROPSTEST);
       break;

/************************************************************************/
/* Window being	sized							*/
/************************************************************************/

   case	WM_SIZE	:
       if ( cBitmaps )
	   SizeBitmapStack(hWnd);

       WinQueryWindowRect(hWnd,	&rcl);

       if ( (lHorzRange	= cxROP	- (cxWindow = rcl.xRight - rcl.xLeft)) < 0L )
	   {
	   lHorzRange =	0L;
	   rclROP.xLeft	 = 0L;
	   rclROP.xRight = cxROP;
	   }
       else
	   rclROP.xRight = rclROP.xLeft	+ cxWindow;
       if ( (lVertRange	= cyROP	- (cyWindow = rcl.yTop - rcl.yBottom)) < 0L )
	   {
	   lVertRange =	0L;
	   rclROP.yBottom  = 0L;
	   rclROP.yTop	   = cyROP;
	   }
       else
	   rclROP.yBottom = (rclROP.yTop = cyROP - lVertPos) - cyWindow;

       WinSendMsg(hwndVScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lVertPos),
		  MPFROM2SHORT(0, lVertRange));
       WinSendMsg(hwndVScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cyWindow,	cyROP),	0L);

       WinSendMsg(hwndHScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lHorzPos),
		  MPFROM2SHORT(0, lHorzRange));
       WinSendMsg(hwndHScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cxWindow,	cxROP),	0L);
       WinInvalidateRect(hWnd, NULL, FALSE);
       break;

/************************************************************************/
/* Perform menu	initialization						*/
/************************************************************************/

   case	WM_INITMENU :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_DISPLAY :
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_BITMAPARRAY, TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? MIA_CHECKED : 0));
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_ROPARRAY,	TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? 0 : MIA_CHECKED));
	       break;

	   case	IDM_FILE :
	       break;

	   }
       break;

/************************************************************************/
/* Process key press from keyboard					*/
/************************************************************************/

   case	WM_CHAR	:
       if ( CHARMSG(&msg)->fs &	KC_VIRTUALKEY )
	   switch ( CHARMSG(&msg)->vkey	)
	       {
	       case VK_PAGEUP :
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEUP));
		   return(0L);

	       case VK_PAGEDOWN	:
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEDOWN));
		   return(0L);
	       }
		       /************************************************/
		       /* PDSKeyProc is	used to	allow controls in      */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       return(PDSKeyProc(hWnd, msg, mp1, mp2));

/************************************************************************/
/* Button 2 being depressed						*/
/************************************************************************/

   case	WM_BUTTON2DOWN :
       if ( !fBitmapArray && hbmROP )
	   {
	   lHorzPos = SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
	   lVertPos = SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));

	   lRop	= (lVertPos + (cyWindow	- SHORT2FROMMP(mp1))) /	cyImage	* 16 + (lHorzPos + SHORT1FROMMP(mp1)) /	cxImage;
	   WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)ViewROPDlgProc,
		     (HMODULE)NULL, DLG_VIEWROP, NULL);
	   }
       break;

/************************************************************************/
/* Process vertical scroll requests					*/
/************************************************************************/

   case	WM_VSCROLL :
       lVertPos	= SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINEUP :
	       lScrollInc = -cyImage;
	       break;

	   case	SB_LINEDOWN :
	       lScrollInc = cyImage;
	       break;

	   case	SB_PAGEUP :
	       lScrollInc = -cyWindow;
	       break;

	   case	SB_PAGEDOWN :
	       lScrollInc = cyWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lVertPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lVertPos,	min(lScrollInc,	lVertRange - lVertPos))	)
	   {
	   rclROP.yBottom = (rclROP.yTop = cyROP - (lVertPos +=	lScrollInc)) - cyWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndVScroll, SBM_SETPOS, MPFROM2SHORT(lVertPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process horizontal scroll requests					*/
/************************************************************************/

   case	WM_HSCROLL :
       lHorzPos	= SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINELEFT :
	       lScrollInc = -cxImage;
	       break;

	   case	SB_LINERIGHT :
	       lScrollInc = cxImage;
	       break;

	   case	SB_PAGELEFT :
	       lScrollInc = -cxWindow;
	       break;

	   case	SB_PAGERIGHT :
	       lScrollInc = cxWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lHorzPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lHorzPos,	min(lScrollInc,	lHorzRange - lHorzPos))	)
	   {
	   rclROP.xRight = (rclROP.xLeft = (lHorzPos +=	lScrollInc)) + cxWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndHScroll, SBM_SETPOS, MPFROM2SHORT(lHorzPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process control selections						*/
/************************************************************************/

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
	   }
       break;

/************************************************************************/
/* Process menu	and button selections					*/
/************************************************************************/

   case	WM_COMMAND :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_OPTIONS :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OptionsDlgProc,
			      (HMODULE)NULL, DLG_OPTIONS, NULL)	)
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;
	   case	IDM_OPEN :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OpenBitmapDlgProc,
			      (HMODULE)NULL, DLG_OPENBITMAP, NULL) )
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   hbmView = hbmGetBitmap(szBitmapFile);
		   SizeBitmap(hWnd);
		   if (	cBitmaps )
		       SizeBitmapStack(hWnd);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   strcat(memcpy(szTitle, "Bitmap Viewer - ", 17), szBitmapFile);
		   if (	fWindowsBitmap )
		       strcat(szTitle, " [Windows 3.x format]");
		   else
		       if ( f20Bitmap )
			   strcat(szTitle, " [OS/2 2.x format]");
		       else
			   strcat(szTitle, " [OS/2 1.x format]");
		   WinSetWindowText(hwndROPsFrame, szTitle);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;

	   case	IDM_ROPARRAY :
	       fBitmapArray = FALSE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;

	   case	IDM_BITMAPARRAY	:
	       fBitmapArray = TRUE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;
	   }
       break;

/************************************************************************/
/* Erase window	background						*/
/************************************************************************/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)LONGFROMMP(mp1), &rcl, CLR_PALEGRAY);
       break;

/************************************************************************/
/* Paint client	window							*/
/************************************************************************/

   case	WM_PAINT :
       GpiCreateLogColorTable(hPS = WinBeginPaint(hWnd,	(HPS)NULL, &rcl), 0UL, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

		       /* Display the bitmap array images side-by-side	*/
       if ( fBitmapArray )
	   {
	   WinFillRect(hPS, &rcl, RGBCLR_PALEGRAY);
	   for ( i = 0;	i < cBitmaps; i++ )
	       {
		       /* Check	to see if the image is a 2-colour which	*/
		       /* menas	that the colours have to be set		*/
		       /* explicitely					*/

	       if ( abm[i].cColours == 2L )
		   {
		   lClrBack = lClrFore = 0L;

		       /* Check	to see if a 2.x	format bitmap since the	*/
		       /* the structures are slightly different		*/

		   if (	f20Bitmap )
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh2 = (PBITMAPFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbfh2->bmp2;
			   }
		       else
			   {
			   pbafh2 = (PBITMAPARRAYFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbafh2->bfh2.bmp2;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi2->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi2->argbColor[1], 3);
		       }
		   else
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh	= (PBITMAPFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbfh->bmp;
			   }
		       else
			   {
			   pbafh = (PBITMAPARRAYFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbafh->bfh.bmp;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi->argbColor[1], 3);
		       }
			   /* Draw the 2-colour	bitmap using the	*/
			   /* provided colours from the	bitmap		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 lClrFore, lClrBack, DBM_NORMAL);
		   }
	       else
			   /* Draw the bitmap from the array		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 RGB_WHITE, RGB_BLACK, DBM_NORMAL);

			   /* Draw the 3-D frame around	the image	*/

	       GpiSetColor(hPS,	RGBCLR_SHADOW);
	       GpiMove(hPS, &abm[i].aptlArea[7]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[4]);

	       GpiSetColor(hPS,	RGB_WHITE);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[6]);

	       GpiSetColor(hPS,	RGB_BLACK);
	       GpiMove(hPS, &abm[i].aptlArea[3]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[0]);

	       GpiSetColor(hPS,	RGBCLR_PALEGRAY);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[2]);
	       }
	   }
       else
	   {
	   if (	(rclROP.xRight < cxWindow) || (rclROP.yTop < cyWindow) )
	       WinFillRect(hPS,	&rcl, RGBCLR_PALEGRAY);
	   ptl.x = ptl.y = 0L;
	   WinDrawBitmap(hPS, hbmROP, &rclROP, &ptl, 0L, 0L, DBM_NORMAL);
	   }
       WinEndPaint(hPS);
       break;

/************************************************************************/
/* Window being	destroyed, perform clean-up operations			*/
/************************************************************************/

   case	WM_DESTROY :
       for ( i = 0; i <	cBitmaps; i++ )
	   GpiDeleteBitmap(abm[i].hbm);

       if ( hbmROP )
	   GpiDeleteBitmap(hbmROP);

       if ( pb )
	   free(pb);
       break;

			/* Default message processing			*/
   default :
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
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); 
}
int CheckAttaches(PCHAR pchFiles, HWND hwndClient)
{
   PFILELIST pFileList=NULL, pLast=NULL;
   PFILELIST pTemp=NULL;
   PCHAR pchSingleFile=NULL;
   int returncode=0;
   CHECKATPAR CheckAtPar;
   ULONG ulCountRecords=0;

   if (pchFiles == NULL ||
       !pchFiles[0])
      return 1;

   pchSingleFile=strtok(pchFiles, " \t");

   if (!pchSingleFile)
      return 1;

   /* Jetzt sind echt Files da */
   do
   {
     /* Filedaten holen */
     pTemp = CheckFileMask(pchSingleFile);

     if (pFileList)
     {
        /* hinten anhaengen */
        pLast->next = pTemp;
     }
     else
        pFileList = pLast = pTemp;

     /* letzten Record wieder suchen */
     while(pLast->next)
        pLast = pLast->next;

   } while (pchSingleFile=strtok(NULL, " \t"));

   /* Ergebnis zaehlen */
   pLast = pFileList;
   while (pLast)
   {
      ulCountRecords++;
      pLast = pLast->next;
   }

   /* Ergebnis anzeigen */
   CheckAtPar.cb=sizeof(CHECKATPAR);
   CheckAtPar.pFileList=pFileList;
   CheckAtPar.ulCountRecords=ulCountRecords;

   WinDlgBox(HWND_DESKTOP, hwndClient, AttachStatProc, hmodLang,
             IDD_ATTACHSTAT, &CheckAtPar);

   /* Ganzen Krempel wieder freigeben */
   while (pFileList)
   {
      pTemp=pFileList->next;
      free(pFileList);
      pFileList=pTemp;
   }

   return returncode;
}
Example #9
0
MRESULT EXPENTRY fnwpReadColumnClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2)
  {
  static HDC hdcPs;
  RECTL   rclRect;
  POINTL ptl;
  LONG lSaveEdge;
  SWP swp;
  HWND hwndMenu;
  static USHORT usMenuStyle;
  static CLRDLG stColor;
  static USHORT usLastPopupItem;

  switch(msg)
    {
    case WM_CHAR:
      if (bSendNextKeystroke)
        if (ProcessKeystroke(&stCFG,mp1,mp2))
          return((MRESULT)TRUE);
      return( WinDefWindowProc(hwnd,msg,mp1,mp2));
    case WM_CREATE:
      hdcPs = WinOpenWindowDC(hwnd);
      usLastPopupItem = IDMPU_SYNC;
      stRead.lBackgrndColor = stCFG.lReadColBackgrndColor;
      stRead.bActive = FALSE;
      stRead.lScrollIndex = 0;
      stRead.hwndScroll = (HWND)NULL;
      stRead.wDirection = CS_READ;
      stColor.cbSize = sizeof(CLRDLG);
      usMenuStyle = (PU_POSITIONONITEM | PU_MOUSEBUTTON2 | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1);
      WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L);
      break;
    case WM_ACTIVATE:
      if(SHORT1FROMMP(mp1))
        {
        if (!bFrameActivated)
          {
          WinSetFocus(HWND_DESKTOP,hwndFrame);
          WinSendMsg(WinQueryHelpInstance(hwndClient),HM_SET_ACTIVE_WINDOW,0L,0L);
          bFrameActivated = TRUE;
          }
        }
      else
        bFrameActivated = FALSE;
      break;
    case WM_VSCROLL:
      switch(HIUSHORT(mp2))
        {
        case SB_LINEDOWN:
          ColScroll(&stRead,1,FALSE);
          break;
        case SB_LINEUP:
          ColScroll(&stRead,-1,FALSE);
          break;
        case SB_PAGEDOWN:
          ColScroll(&stRead,stRead.lCharHeight,FALSE);
          break;
        case SB_PAGEUP:
          ColScroll(&stRead,-stRead.lCharHeight,FALSE);
          break;
        case SB_SLIDERPOSITION:
          ColScroll(&stRead,LOUSHORT(mp2),TRUE);
          break;
        }
      break;
    case WM_COMMAND:
      switch (SHORT1FROMMP(mp1))
        {
        case IDMPU_ASCII_FONT:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_FONT;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (stCFG.wColReadFont != wASCIIfont)
            {
            stCFG.wColReadFont = wASCIIfont;
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        case IDMPU_HEX_FONT:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_FONT;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (stCFG.wColReadFont != wHEXfont)
            {
            stCFG.wColReadFont = wHEXfont;
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        case IDMPU_SYNC:
          usLastPopupItem = IDMPU_SYNC;
          if (bStopDisplayThread)
            stRead.lScrollIndex = stWrite.lScrollIndex;
          else
            stRead.lScrollIndex = 0;
          stRead.lScrollRow = GetColScrollRow(&stRead,0);
          WinSendMsg(stRead.hwndScroll,
                     SBM_SETPOS,
                     MPFROMSHORT(stRead.lScrollRow),
                     MPFROMSHORT(0));
          if (stRead.bSync)
            {
            stRow.lScrollIndex = stRead.lScrollIndex;
            stRow.lScrollRow = GetRowScrollRow(&stRow);
            }
          WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
          break;
         case IDMPU_COLORS:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_COLORS;
          else
            usLastPopupItem = IDMPU_SYNC;
          stColor.lForeground = stCFG.lReadColForegrndColor;
          stColor.lBackground = stCFG.lReadColBackgrndColor;
          sprintf(stColor.szCaption,"Lexical Receive Data Display Colors");
          if (WinDlgBox(HWND_DESKTOP,
                        hwnd,
                 (PFNWP)fnwpSetColorDlg,
                (USHORT)NULL,
                        CLR_DLG,
                MPFROMP(&stColor)))
            {
            stCFG.lReadColForegrndColor = stColor.lForeground;
            stCFG.lReadColBackgrndColor = stColor.lBackground;
            stRead.lBackgrndColor = stColor.lBackground;
            stRead.lForegrndColor = stColor.lForeground;
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        case IDMPU_LOCK_WIDTH:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_LOCK_WIDTH;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (stCFG.fLockWidth == LOCK_READ)
            stCFG.fLockWidth = LOCK_NONE;
          else
            {
            stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1);
            stCFG.fLockWidth = LOCK_READ;
            }
          break;
        case IDMPU_DISP_FILTERS:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_DISP_FILTERS;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (WinDlgBox(HWND_DESKTOP,
                        hwnd,
                 (PFNWP)fnwpDisplaySetupDlgProc,
                (USHORT)NULL,
                        DISP_FILTER_DLG,
                MPFROMP(&stRead)))
            {
            stCFG.bReadTestNewLine = stRead.bTestNewLine;
            stCFG.bSkipReadBlankLines = stRead.bSkipBlankLines;
            stCFG.byReadNewLineChar = stRead.byNewLineChar;
            stCFG.bFilterRead = stRead.bFilter;
            stCFG.fFilterReadMask = stRead.fFilterMask;
            stCFG.byReadMask = stRead.byDisplayMask;
            if (stRead.bSync)
              {
              if (!stCFG.bSyncToRead)
                {
                stWrite.bSync = FALSE;
                stCFG.bSyncToWrite = FALSE;
                stCFG.bSyncToRead = TRUE;
                if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE))
                  {
                  ClearColScrollBar(&stWrite);
                  SetupColScrolling(&stRead);
                  }
                }
              }
            else
              {
              if (stCFG.bSyncToRead)
                {
                stCFG.bSyncToRead = FALSE;
                if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE))
                  SetupColScrolling(&stWrite);
                }
              }
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        }
      break;
//    case WM_CHORD:
    case WM_BUTTON2DOWN:
      if(bFrameActivated)
        {
        hwndMenu = WinLoadMenu(stRead.hwnd,(HMODULE)NULL,IDMPU_COL_DISP_POPUP);
        if (mp1 != 0)
          {
          WinQueryPointerPos(HWND_DESKTOP,&ptl);
          if (!stCFG.bStickyMenus)
            usMenuStyle |= PU_MOUSEBUTTON2DOWN;
          else
            usMenuStyle &= ~PU_MOUSEBUTTON2DOWN;
          }
        else
          {
          usMenuStyle &= ~PU_MOUSEBUTTON2DOWN;
          WinQueryWindowPos(hwndFrame,&swp);
          ptl.x = (swp.x + (swp.cx - (swp.cx / 4)));
          ptl.y = (swp.y + (swp.cy / 2));
          }
        if (stCFG.wColReadFont == wASCIIfont)
          PopupMenuItemCheck(hwndMenu,IDMPU_ASCII_FONT,TRUE);
        else
          PopupMenuItemCheck(hwndMenu,IDMPU_HEX_FONT,TRUE);
        if (stCFG.fLockWidth == LOCK_READ)
          PopupMenuItemCheck(hwndMenu,IDMPU_LOCK_WIDTH,TRUE);
        if (!bStopDisplayThread)
          WinSendMsg(hwndMenu,MM_SETITEMTEXT,(MPARAM)IDMPU_SYNC,"~Reset Display");
        WinPopupMenu(HWND_DESKTOP,stRead.hwndClient,hwndMenu,ptl.x,ptl.y,usLastPopupItem,usMenuStyle);
        }
      else
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
      break;
    case WM_BUTTON1DOWN:
      if(bFrameActivated)
        {
        WinCopyRect(habAnchorBlock,&rclRect,&stRead.rcl);
        lSaveEdge = rclRect.xLeft;
        if (TrackChildWindow(habAnchorBlock,hwndClient,&rclRect,TF_LEFT))
          {
          if (rclRect.xLeft != lSaveEdge)
            {
            WinSendMsg(stWrite.hwndClient,UM_TRACKSIB,0L,(MPARAM)rclRect.xLeft);
            WinSendMsg(stRead.hwndClient,UM_TRACKSIB,(MPARAM)rclRect.xLeft,0L);
            if (stCFG.fLockWidth == LOCK_WRITE)
              stCFG.lLockWidth = ((stWrite.lWidth / stCell.cx) + 1);
            else
              stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1);
            }
          }
        }
      else
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
      break;
    case WM_DESTROY:
      GpiDestroyPS(hdcPs);
      break;
    case UM_SHOWNEW:
      stRead.lScrollIndex = 0;
      stRead.lScrollRow = 0;
      ClearColScrollBar(&stRead);
    case UM_SHOWAGAIN:
      stRead.bActive = TRUE;
      if ((stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) && !stCFG.bSyncToWrite)
        SetupColScrolling(&stRead);
      WinShowWindow(stRead.hwnd,TRUE);
      WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L);
      WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
      WinInvalidateRect(hwndStatus,(PRECTL)NULL,FALSE);
      break;
    case UM_HIDEWIN:
      ClearColScrollBar(&stRead);
      stRead.bActive = FALSE;
      WinShowWindow(hwnd,FALSE);
      WinSetWindowPos(stRead.hwnd,HWND_BOTTOM,0L,0L,0L,0L,(SWP_MOVE | SWP_SIZE | SWP_ZORDER));
      break;
    case WM_PAINT:
#ifdef this_junk
      if (!pstCFG->bDisplayingData && (stCFG.bSyncToRead || stCFG.bSyncToWrite))
        ColumnPaint(&stRead,WinPeekMsg(habAnchorBlock,&stQmsg,stWrite.hwndClient,WM_PAINT,WM_PAINT,PM_REMOVE));
      else
#endif
        ColumnPaint(&stRead);
      break;
    case UM_TRACKSIB:
      ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,TRUE);
      break;
    case UM_TRACKFRAME:
      ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,FALSE);
      break;
    case WM_ERASEBACKGROUND:
      return (MRESULT)(TRUE);
    case WM_CLOSE:
      WinPostMsg(hwnd,WM_QUIT,0L,0L);
    default:
      return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
  return(FALSE);
  }
Example #10
0
APIRET EXPENTRY HdwHandshakeDialog(HWND hwnd,COMCTL *pstComCtl)
  {
  return(WinDlgBox(HWND_DESKTOP,hwnd,(PFNWP)fnwpHandshakeDlg,hThisModule,HS_ALL_DLG,MPFROMP(pstComCtl)));
  }
Example #11
0
APIRET EXPENTRY HdwBaudRateDialog(HWND hwnd,COMCTL *pstComCtl)
  {
  return (WinDlgBox(HWND_DESKTOP,hwnd,(PFNWP)fnwpHdwBaudRateDlg,hThisModule,HWB_DLG,MPFROMP(pstComCtl)));
  }
MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
	static HWND hwndFrame, hwndButton[10];
	static INT  cxClient, cyClient, cyChar;
	static LONG ButtonWidth, ButtonHeight;
	static CLR  buttonColour;
	CHAR        szBuffer[32];
	FONTMETRICS fm;
	HAB         hab;
	HPS         hps;
	INT         id;
	RECTL       rcl;

	switch(msg) {
		case WM_CREATE:
			hab = WinQueryAnchorBlock(hwnd);
			hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
			hps = WinGetPS(hwnd);
			GpiQueryFontMetrics(hps, sizeof(fm),&fm);
			cyChar = fm.lMaxBaselineExt;
			WinReleasePS(hps);
			buttonColour.Index = 0x00CCCCCC;

// Buttons should be big enough to hold the pointer, with a 4 pixel border
			ButtonWidth = WinQuerySysValue(HWND_DESKTOP, SV_CXPOINTER) + 4;
			ButtonHeight = WinQuerySysValue(HWND_DESKTOP, SV_CYPOINTER) + 4;
			hwndButton[0] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "100", WS_VISIBLE | GBT_NORIGHTLINE | GBT_GRAPHIC, 0, 0, ButtonWidth, ButtonHeight, hwnd, HWND_BOTTOM, 0, NULL, NULL);
			hwndButton[1] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "101", WS_VISIBLE | GBT_NOLEFTLINE | GBT_GRAPHIC, 0, 0, ButtonWidth, ButtonHeight, hwnd, HWND_BOTTOM, 1, NULL, NULL);

// This is the status bar
			hwndButton[2] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "Status Bar", WS_VISIBLE | GBT_NOPUSH, 0, 0, 0, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 2, NULL, NULL);
			sprintf(szBuffer, "Red: %d Green: %d Blue: %d", buttonColour.rgb.red, buttonColour.rgb.green, buttonColour.rgb.blue);
			WinSetWindowText(hwndButton[2], szBuffer);

// Buttons to change the colour of the about button
			hwndButton[3] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "<", WS_VISIBLE | GBT_NORIGHTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 3, NULL, NULL);
			hwndButton[4] = WinCreateWindow(hwnd, SHADEDBTNCLASS, ">", WS_VISIBLE | GBT_NOLEFTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 4, NULL, NULL);
			hwndButton[5] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "<", WS_VISIBLE | GBT_NORIGHTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 5, NULL, NULL);
			hwndButton[6] = WinCreateWindow(hwnd, SHADEDBTNCLASS, ">", WS_VISIBLE | GBT_NOLEFTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 6, NULL, NULL);
			hwndButton[7] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "<", WS_VISIBLE | GBT_NORIGHTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 7, NULL, NULL);
			hwndButton[8] = WinCreateWindow(hwnd, SHADEDBTNCLASS, ">", WS_VISIBLE | GBT_NOLEFTLINE, 0, 0, ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 8, NULL, NULL);
// info about this program
			hwndButton[9] = WinCreateWindow(hwnd, SHADEDBTNCLASS, "About", WS_VISIBLE | GBT_RIGHTROUND | GBT_LEFTROUND, 0, 0, 2 * ButtonWidth, cyChar * 5 / 4, hwnd, HWND_BOTTOM, 9, NULL, NULL);

// change the colour of the buttons
			WinSendMsg(hwndButton[3], GBM_SETCOLOR, MPFROMLONG(0x00FFCCCC), NULL);
			WinSendMsg(hwndButton[4], GBM_SETCOLOR, MPFROMLONG(0x00FFCCCC), NULL);
			WinSendMsg(hwndButton[5], GBM_SETCOLOR, MPFROMLONG(0x00CCFFCC), NULL);
			WinSendMsg(hwndButton[6], GBM_SETCOLOR, MPFROMLONG(0x00CCFFCC), NULL);
			WinSendMsg(hwndButton[7], GBM_SETCOLOR, MPFROMLONG(0x00CCCCFF), NULL);
			WinSendMsg(hwndButton[8], GBM_SETCOLOR, MPFROMLONG(0x00CCCCFF), NULL);
			WinSendMsg(hwndButton[9], GBM_SETCOLOR, MPFROMLONG(buttonColour.Index), NULL);
			return 0;
		case WM_SIZE:
			hps = WinGetPS(hwnd);
			GpiQueryFontMetrics(hps, sizeof(fm),&fm);
			cyChar = fm.lMaxBaselineExt;
			WinReleasePS(hps);
			cxClient = SHORT1FROMMP(mp2);
			cyClient = SHORT2FROMMP(mp2);
// Center the buttons
			for(id = 0; id < 2; id++)
				WinSetWindowPos(hwndButton[id], NULLHANDLE, (cxClient >> 1) + ButtonWidth * (id - 1), (cyClient - ButtonHeight) >> 1, 0, 0, SWP_MOVE);
			for(id = 3; id < 9; id++)
				WinSetWindowPos(hwndButton[id], NULLHANDLE, (cxClient >> 1) + ButtonWidth * (-(id % 2)), ((cyClient + ButtonHeight) >> 1) + (3 - (id-1) / 2) * cyChar * 5 / 4, 0, 0, SWP_MOVE);
			WinSetWindowPos(hwndButton[9], NULLHANDLE, (cxClient >> 1) - ButtonWidth, ((cyClient - ButtonHeight) >> 1) - cyChar * 15 / 8, 0, 0, SWP_MOVE);
// make the status bar span the width of the window
			WinSetWindowPos(hwndButton[2], NULLHANDLE, 0, 0, cxClient, cyChar * 5 / 4, SWP_SIZE);

// Enable "Smaller" button if window is large enough for the buttons
			if (!WinIsWindowEnabled(hwndButton[0]) && ((9 * cxClient / 10) >= (2 * ButtonWidth)) && ((9  * cyClient / 10) >= (ButtonHeight + cyChar * 15 / 2)))
				WinEnableWindow(hwndButton[0], TRUE);
// Disable "Smaller" button if window is too small for the buttons
			if (WinIsWindowEnabled(hwndButton[0]) && (((9 * cxClient / 10) < (2 * ButtonWidth)) || ((9  * cyClient / 10) < (ButtonHeight + cyChar * 15 / 2))))
				WinEnableWindow(hwndButton[0], FALSE);
			return 0;
		case WM_COMMAND:
			WinQueryWindowRect(hwnd, &rcl);
			WinMapWindowPoints(hwnd, HWND_DESKTOP, (PPOINTL) &rcl, 2);

			switch(COMMANDMSG(&msg)->cmd) {
				case 0: // "Smaller"
					rcl.xLeft   += cxClient / 20;
					rcl.xRight  -= cxClient / 20;
					rcl.yBottom += cyClient / 20;
					rcl.yTop    -= cyClient / 20;
					break;
				case 1: // "Larger"
					rcl.xLeft   -= cxClient / 20;
					rcl.xRight  += cxClient / 20;
					rcl.yBottom -= cyClient / 20;
					rcl.yTop    += cyClient / 20;
					break;
				case 3: // change red
					buttonColour.rgb.red--;
					if (buttonColour.rgb.red == 0)
						WinEnableWindow(hwndButton[3], FALSE);
					if (!WinIsWindowEnabled(hwndButton[4]))
						WinEnableWindow(hwndButton[4], TRUE);
					break;
				case 4:
					buttonColour.rgb.red++;
					if (buttonColour.rgb.red == 255)
						WinEnableWindow(hwndButton[4], FALSE);
					if (!WinIsWindowEnabled(hwndButton[3]))
						WinEnableWindow(hwndButton[3], TRUE);
					break;
				case 5: // change green
					buttonColour.rgb.green--;
					if (buttonColour.rgb.green == 0)
						WinEnableWindow(hwndButton[5], FALSE);
					if (!WinIsWindowEnabled(hwndButton[6]))
						WinEnableWindow(hwndButton[6], TRUE);
					break;
				case 6:
					buttonColour.rgb.green++;
					if (buttonColour.rgb.green == 255)
						WinEnableWindow(hwndButton[6], FALSE);
					if (!WinIsWindowEnabled(hwndButton[5]))
						WinEnableWindow(hwndButton[5], TRUE);
					break;
				case 7:// change blue
					buttonColour.rgb.blue--;
					if (buttonColour.rgb.blue == 0)
						WinEnableWindow(hwndButton[7], FALSE);
					if (!WinIsWindowEnabled(hwndButton[8]))
						WinEnableWindow(hwndButton[8], TRUE);
					break;
				case 8:
					buttonColour.rgb.blue++;
					if (buttonColour.rgb.blue == 255)
						WinEnableWindow(hwndButton[8], FALSE);
					if (!WinIsWindowEnabled(hwndButton[7]))
						WinEnableWindow(hwndButton[7], TRUE);
					break;
				case 9:
					WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, NULLHANDLE, IDD_ABOUT, NULL);
					return 0;
			}
			sprintf(szBuffer, "Red: %d Green: %d Blue: %d", buttonColour.rgb.red, buttonColour.rgb.green, buttonColour.rgb.blue);
			WinSetWindowText(hwndButton[2], szBuffer);
			WinCalcFrameRect(hwndFrame, &rcl, FALSE);
			WinSetWindowPos(hwndFrame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE);
			WinPostMsg(hwndButton[9], GBM_SETCOLOR, MPFROMLONG(buttonColour.Index), NULL);
			return 0;
		case WM_ERASEBACKGROUND:
			WinFillRect((HPS)LONGFROMMP(mp1), PVOIDFROMMP(mp2), CLR_PALEGRAY);
			return 0;
	}
	return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
Example #13
0
void ConfigQuickPage(HWND hwnd)
  {
  BOOL bSuccess = FALSE;
  HMODULE hMod;
  PFN pfnProcess;
  char szCaption[40];
  char szMessage[100];
  INFODLG stInfoDlg;

  stInst.bAppConfigured = FALSE;
  if (stInst.paszStrings[CONFIGAPPLIBRARYSPEC][0] == 0)
    {
    if (PrfQueryProfileString(HINI_USERPROFILE,szConfigAppName,"Configuration",0L,
                                                stInst.paszStrings[CONFIGDDLIBRARYSPEC],
                                                stInst.ulMaxPathLen) == 0)
      strcpy(stInst.paszStrings[CONFIGAPPLIBRARYSPEC],"QPG_CFG.DLL");
    }
  if (DosLoadModule(0,0,stInst.paszStrings[CONFIGAPPLIBRARYSPEC],&hMod) != NO_ERROR)
    {
    sprintf(stInst.paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\QPG_CFG.DLL",stInst.pszSourcePath);
    if (DosLoadModule(0,0,stInst.paszStrings[CONFIGAPPLIBRARYSPEC],&hMod) != NO_ERROR)
      {
      sprintf(szCaption,"Configuration cannot be completed.");
      sprintf(szMessage,"Library %s is invalid or does not exist.",stInst.paszStrings[CONFIGAPPLIBRARYSPEC]);
      WinMessageBox(HWND_DESKTOP,
                    stInst.hwndFrame,
                    szMessage,
                    szCaption,
                    HLPP_MB_LIBRARY_BAD,
                   (MB_OK | MB_HELP | MB_WARNING));
      sprintf(szBannerTwo,"Installation is not complete");
      szBannerOne[0] = 0;
      ClientPaint(hwndClient);
      return;
      }
    }
  else
    {
    if (DosQueryProcAddr(hMod,0,szConfigAppFunctionName,(PFN *)&pfnProcess) == NO_ERROR)
      {
      stPageCFG.cbSize = sizeof(COMICFG);
      stPageCFG.hwndFrame = stInst.hwndFrame;
      stPageCFG.hab = stInst.hab;
      stPageCFG.pszHelpFileName = szConfigAppHelpFileName;
      stPageCFG.pszConfigFileName = szPagerFileName;
      stPageCFG.pszDestPath = pszPath;
      stPageCFG.pszDestPath = stInst.pszAppsPath;
      if (stInst.byItemCount == 0)
        stPageCFG.hObject = 0;
      bSuccess = pfnProcess(&stPageCFG);
      }
    DosFreeModule(hMod);
    }
  if (bSuccess)
    {
    sprintf(szCaption,"Configuration is complete.");
    sprintf(szMessage,"%s has been successfully configured.",szConfigAppName);
    WinMessageBox(HWND_DESKTOP,
                  stInst.hwndFrame,
                  szMessage,
                  szCaption,
                  HLPP_MB_CONFIG_OK,
                 (MB_OK | MB_HELP | MB_INFORMATION));
    stInst.bAppConfigured = TRUE;
//    szBannerOne[0] = 0;
    if (stInst.bFilesCopied)
      {
      if (!stInst.bDDconfigured)
        {
        sprintf(szBannerTwo,"%s Configuration is complete",szConfigAppName);
        sprintf(szBannerOne,"Select \"Configuration | %s...\" to complete Installation",szConfigDDname);
        }
      else
        sprintf(szBannerTwo,"Installation is complete");
      }
    else
      sprintf(szBannerTwo,"%s Configuration is complete",szConfigAppName);
    ClientPaint(hwndClient);
    if (stInst.bFilesCopied)
      {
      if (strlen(szInfoFileName) != 0)
        {
        stInfoDlg.cbSize = sizeof(INFODLG);
        stInfoDlg.pszFileName = szInfoFileName;
        stInfoDlg.pszCaption = szInfoCaption;
        WinDlgBox(HWND_DESKTOP,
                  hwnd,
           (PFNWP)fnwpInfoDlgProc,
            (LONG)NULL,
                  EVAL_MSG,
             (PVOID)&stInfoDlg);
        }
      }
    }
  else
    {
    if (stInst.bFilesCopied)
      {
      sprintf(szCaption,"Configuration is not complete.");
      sprintf(szMessage,"You must select the \"Configuration | %s...\" menu item again to complete installation.",szConfigAppName);
      WinMessageBox(HWND_DESKTOP,
                    stInst.hwndFrame,
                    szMessage,
                    szCaption,
                    HLPP_MB_CONFIG_BAD,
                   (MB_OK | MB_HELP | MB_WARNING));
      sprintf(szBannerTwo,"Installation is not complete");
      szBannerOne[0] = 0;
      ClientPaint(hwndClient);
      }
    }
  }
Example #14
0
void InstallCommand(HWND hwnd,USHORT Command)
  {
  USHORT wStatus;
  BYTE byStatus;
  char szCaption[40];
  char szMessage[100];
  char szObjName[100];
  APIRET rc;
  FILESTATUS3 stFileAttrs;
  ULONG ulStatus;
  HFILE hFile;
  int iLen;
  BOOL bSuccess;
  HMODULE hMod;
  PFN pfnProcess;
  BOOL bDoTransfer;
  INFODLG stInfoDlg;

  switch (Command)
    {
    case IDM_USINGHELP:
      HelpHelpForHelp();
      return;
    case IDM_GENERALHELP:
      DisplayHelpPanel(HLPP_GENERAL);
      return;
    case IDM_HELPINDEX:
      HelpIndex();
      return;
    case IDM_KEYSHELP:
      DisplayHelpPanel(HLPP_KEYS);
      return;
    case IDM_EXIT:
      WinPostMsg(hwnd,WM_QUIT,0L,0L);
      return;
    case IDM_TRANSFER:
      bShowingProgress = TRUE;
      if (WinDlgBox(HWND_DESKTOP,
                    hwnd,
             (PFNWP)fnwpTransferDlg,
              (LONG)NULL,
                    TRAN_DLG,
              (LONG)NULL))
        {
        if (strlen(szLicenseFileName) != 0)
          {
          stInfoDlg.cbSize = sizeof(INFODLG);
          stInfoDlg.pszFileName = szLicenseFileName;
          stInfoDlg.pszCaption = szLicenseCaption;
          if (WinDlgBox(HWND_DESKTOP,
                        hwnd,
                 (PFNWP)fnwpInfoDlgProc,
                  (LONG)NULL,
                        INST_MSG,
                (PVOID)&stInfoDlg))
            {
            if ((rc = DosLoadModule(0,0,stInst.paszStrings[XFERLIBRARYSPEC],&hMod)) == NO_ERROR)
              {
              if (DosQueryProcAddr(hMod,0,szTransferFunctionName,(PFN *)&pfnProcess) == NO_ERROR)
                {
                stInst.paszStrings[COMIVERSION] = szCOMiVersion;
                stInst.paszStrings[CONFIGDDLIBRARYNAME] = szConfigDDlibraryName;
                stInst.paszStrings[CONFIGDDHELPFILENAME] = szConfigDDhelpFileName;
                stInst.paszStrings[CONFIGAPPLIBRARYNAME] = szConfigAppLibraryName;
                stInst.paszStrings[CONFIGAPPHELPFILENAME] = szConfigAppHelpFileName;
                stInst.paszStrings[INIFILENAME] = szIniFileName;
                stInst.paszStrings[UNINSTALLINIFILENAME] = szUninstallIniFileName;
                stInst.paszStrings[DDNAME] = szDDname;
                stInst.paszStrings[CONFIGDDNAME] = szConfigDDname;
                stInst.paszStrings[CONFIGAPPNAME] = szConfigAppName;
                stInst.paszStrings[APPVERSION] = szAppVersion;
                stInst.paszStrings[APPICONFILE] = szAppIconFile;
                stInst.pfnPrintProgress = (PFN)PrintProgress;
                stInst.pAnyData = (PVOID)&stPageCFG.hObject;
                stInst.byItemCount = 0;
                PrfCloseProfile(hSourceProfile);
                if (pfnProcess(&stInst))
                  {
                  sprintf(szBannerOne,"Files successfully transferred.");
                  sprintf(szBannerTwo,"Select \"Configuration | %s...\" to complete installation.",szConfigDDname);
                  MenuItemEnable(stInst.hwndFrame,IDM_TRANSFER,FALSE);
                  MenuItemEnable(stInst.hwndFrame,IDM_CONFIG_APP,TRUE);
                  }
                else
                  {
                  szBannerOne[0] = 0;
                  sprintf(szBannerTwo,"File transfer incomplete.");
                  DosBeep(500,250);
                  }
                hSourceProfile = PrfOpenProfile(stInst.hab,stInst.pszSourceIniPath);
                }
              else
                {
                szBannerOne[0] = 0;
                sprintf(szBannerTwo,"Transfer Library function does not exist.");
                DosBeep(500,250);
                }
              DosFreeModule(hMod);
              }
            else
              {
              szBannerOne[0] = 0;
              sprintf(szBannerTwo,"Library \"%s\" is invalid, rc = %u.",stInst.paszStrings[XFERLIBRARYSPEC],rc);
              DosBeep(500,250);
              }
            }
          }
        }
      bShowingProgress = FALSE;
      WinInvalidateRect(hwndClient,0,FALSE);
      break;
    case IDM_UNINSTALL:
      WinDlgBox(HWND_DESKTOP,
                hwnd,
         (PFNWP)fnwpUninstallDlgProc,
          (LONG)NULL,
                UNINST_DLG,
          (LONG)NULL);
      WinInvalidateRect( hwnd, NULL, FALSE );
      break;
    case IDM_CONFIG_APP:
      ConfigQuickPage(hwnd);
      return;
    case IDM_CONFIG_DD:
      ConfigCOMi(hwnd);
      return;
    case IDM_PRODUCTINFORMATION:
      WinDlgBox( HWND_DESKTOP,
                 hwnd,
          (PFNWP)fnwpAboutBoxDlgProc,
                 (LONG)NULL,
                 VER_DLG,
                 (LONG)NULL);
      WinInvalidateRect( hwnd, NULL, FALSE );
      break;
    default:
      return;
    }
  }
Example #15
0
MRESULT EXPENTRY fnwpDeviceStatusDlg(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2)
  {
  USHORT idDlg;
  PFNWP  pfnDlgProc;
  static ULONG idTimer;
  char szStatus[80];
  WORD wStatus;
  static BOOL bShowingBits;
  static SHORT sCurrentFocus;

  switch (msg)
    {
    case WM_INITDLG:
      SetSystemMenu(hwnd);
      WinSendDlgItemMsg(hwnd,HWS_COMST,EM_SETREADONLY,MPFROMSHORT(TRUE),(MPARAM)NULL);
      WinSendDlgItemMsg(hwnd,HWS_COMERROR,EM_SETREADONLY,MPFROMSHORT(TRUE),(MPARAM)NULL);
      WinSendDlgItemMsg(hwnd,HWS_COMEVENT,EM_SETREADONLY,MPFROMSHORT(TRUE),(MPARAM)NULL);
      WinSendDlgItemMsg(hwnd,HWS_XMITST,EM_SETREADONLY,MPFROMSHORT(TRUE),(MPARAM)NULL);
      idTimer = 0L;
      bShowingBits = FALSE;
      sCurrentFocus = 0;
      CenterDlgBox(hwnd);
      break;
    case UM_INITLS:
      if (!bDDstatusActivated)
        {
        bDDstatusActivated = TRUE;
        if (lStatusWindowCount++ <= 0)
          MenuItemEnable(hwndFrame,IDM_SURFACE_THIS,TRUE);
        if (stCFG.bLoadWindowPosition && (hProfileInstance != NULL) && (stCFG.ptlDDstatusPos.y > -40))
          WinSetWindowPos(hwnd,HWND_TOP,stCFG.ptlDDstatusPos.x,stCFG.ptlDDstatusPos.y,0L,0L,SWP_MOVE);
        else
          MousePosDlgBox(hwnd);
        WinShowWindow(hwnd,TRUE);
        WinSetFocus(HWND_DESKTOP,hwnd);
        }
      UpdateDeviceStatusDlg(hwnd);
      idTimer = WinStartTimer(habAnchorBlock,
                              hwnd,
                              TID_STATDEV,
                              stCFG.wUpdateDelay);
    case UM_RESET_NAME:
      sprintf(szStatus,"%s - Device Driver Status",stCFG.szPortName);
      WinSetWindowText(hwnd,szStatus);
      break;
    case WM_CLOSE:
    case UM_KILL_MONITOR:
      bDDstatusActivated = FALSE;
      if (--lStatusWindowCount <= 0)
        MenuItemEnable(hwndFrame,IDM_SURFACE_THIS,FALSE);
      if (idTimer)
        {
        WinStopTimer(habAnchorBlock,
                     hwnd,
                     idTimer);
        idTimer = 0L;
        }
      return(WinDefDlgProc(hwnd,msg,mp1,mp2));
    case UM_RESETTIMER:
      if (idTimer != 0L)
        idTimer = WinStartTimer(habAnchorBlock,
                              hwnd,
                              idTimer,
                              stCFG.wUpdateDelay);
      break;
    case WM_CHAR:
      if ((sCurrentFocus != 0) && (!bShowingBits) && (SHORT1FROMMP(mp1) & KC_CHAR) && (SHORT1FROMMP(mp2) == ' '))
        {
        WinPostMsg(hwnd,UM_SHOWBITS,MPFROMSHORT(sCurrentFocus),(MPARAM)0L);
        bShowingBits = TRUE;
        }
      else
        return(WinDefDlgProc(hwnd,msg,mp1,mp2));
      break;
    case WM_BUTTON1UP:
      if ((sCurrentFocus != 0) && (!bShowingBits))
        {
        WinPostMsg(hwnd,UM_SHOWBITS,MPFROMSHORT(sCurrentFocus),(MPARAM)0L);
        bShowingBits = TRUE;
        }
      else
        return(WinDefDlgProc(hwnd,msg,mp1,mp2));
      break;
    case WM_CONTROL:
      if (!bShowingBits)
        {
        switch (SHORT2FROMMP(mp1))
          {
          case EN_SETFOCUS:
            sCurrentFocus = SHORT1FROMMP(mp1);
            break;
          case EN_KILLFOCUS:
            sCurrentFocus = 0;
            break;
          }
        }
      break;
    case UM_SHOWBITS:
        switch(SHORT1FROMMP(mp1))
          {
          case HWS_COMERROR:
            idDlg      = CER_DLG;
            pfnDlgProc = (PFNWP)fnwpCOMerrorStatesDlg;
            WinQueryDlgItemText(hwnd,HWS_COMERROR,sizeof(szStatus),szStatus);
            break;
          case HWS_COMEVENT:
            idDlg      = CEV_DLG;
            pfnDlgProc = (PFNWP)fnwpCOMeventStatesDlg;
            WinQueryDlgItemText(hwnd,HWS_COMEVENT,sizeof(szStatus),szStatus);
            break;
          case HWS_COMST:
            idDlg      = CST_DLG;
            pfnDlgProc = (PFNWP)fnwpCOMstatusStatesDlg;
            WinQueryDlgItemText(hwnd,HWS_COMST,sizeof(szStatus),szStatus);
            break;
          case HWS_XMITST:
            idDlg      = TST_DLG;
            pfnDlgProc = (PFNWP)fnwpXmitStatusStatesDlg;
            WinQueryDlgItemText(hwnd,HWS_XMITST,sizeof(szStatus),szStatus);
            break;
          default:
            return(FALSE);
          }
        wStatus = (WORD)ASCIItoBin(szStatus,16);
        WinDlgBox(HWND_DESKTOP,
                  hwnd,
                  pfnDlgProc,
                  NULLHANDLE,
                  idDlg,
                  &wStatus);
        WinSetFocus(HWND_DESKTOP,hwnd);
        bShowingBits = FALSE;
      break;
    case WM_TIMER:
      UpdateDeviceStatusDlg(hwnd);
      break;
    case WM_ACTIVATE:
      if (bDDstatusActivated)
        WinSetFocus(HWND_DESKTOP,hwnd);
      break;
    default:
      return(WinDefDlgProc(hwnd,msg,mp1,mp2));
    }
  return FALSE;
  }
Example #16
0
CreInstDlg::Run()
{
	WinDlgBox( hwndParent,hwndOwner,::DlgCallBack,Resource,ulDlgid,NULL);
	// Initialization data
   return(0);
}
Example #17
0
int main (void)
{

SHORT ix, iy;
SHORT iwidth, idepth;
SWP   swp;
ULONG ulResult;
int iRes;

static CHAR szClientClass[]="ZIN";
static ULONG flFrameFlags= FCF_TITLEBAR | FCF_SYSMENU |
                               FCF_TASKLIST | FCF_ICON | FCF_SHELLPOSITION|
                                FCF_BORDER | FCF_NOBYTEALIGN;

   
hab=WinInitialize(0);
hmq=WinCreateMsgQueue(hab, 0);

//Register processing class
WinRegisterClass(
            hab,
            szClientClass,
            ClientWndProc,
            CS_SIZEREDRAW,
            0);

//Create Window
hwndFrame=WinCreateStdWindow(
            HWND_DESKTOP,
            WS_VISIBLE,
            &flFrameFlags,
            szClientClass,
            NULL,
            0L,
            0,        //Module handle for resources
            ID_RESOURCE,        //ID of resources
            &hwndClient);


//Size window
WinSetWindowPos( hwndFrame, HWND_TOP, 0, 0, 640, 480, SWP_SIZE );            

//Center window
iwidth = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
idepth = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
WinQueryWindowPos( hwndFrame, (PSWP)&swp );
ix = (SHORT)(( iwidth  - swp.cx ) / 2);
iy = (SHORT)(( idepth  - swp.cy ) / 2);
WinSetWindowPos( hwndFrame, HWND_TOP, ix, iy, 0, 0, SWP_MOVE );            

//Set focus to edit window.
WinSetFocus(HWND_DESKTOP,hwndClient);

//Load application title
WinLoadString(hab, 0, ID_APPNAME, LITTLEBUF, (PSZ) szAppName);

//Set title of frame.
WinSetWindowText(hwndFrame, (PSZ) szAppName);
 
  
//Show the window
WinShowWindow(hwndFrame,TRUE);

//Get source directory.
GetCurrentDirectory(szSourceDir);


//Load first message
FIRSTMSG:
usResponse=MsgBox(ID_FIRSTMSG, ID_APPNAME, MB_OKCANCEL);
WinUpdateWindow(hwndClient);

if (usResponse==MBID_OK)
    {

    //Show readme.txt file
    ulResult=WinDlgBox(HWND_DESKTOP, hwndClient, ReadmeDlgProc,
                NULLHANDLE, IDD_README, NULL);

    if (ulResult==FALSE) 
        {
        //The installation has been cancelled.
        usResponse=MsgBox(ID_CANCELINSTALL, ID_APPNAME, MB_OK);    
        goto END_INSTALL;
        }


    ulResult=WinDlgBox(HWND_DESKTOP, hwndClient, GetDirDlgProc,
                NULLHANDLE, IDD_GETDIR, NULL);
    
    if (ulResult==FALSE) goto FIRSTMSG;

    //Update the window
    WinUpdateWindow(hwndClient);

    //Load status dialog
    LoadStatusDlg();

    //Make sure all files exist
    iRes=CheckFiles(szSourceDir);
    if (iRes!=0)
        {
        DestroyStatusDlg();
        usResponse=MsgBox(ID_FILENOTFOUND, ID_APPNAME, MB_OK);
        goto END_INSTALL;
        }

    //Copy the files
    iRes=CopyFiles(szSourceDir, szInstallDir);
    if (iRes!=0)
        {
        DestroyStatusDlg();
        usResponse=MsgBox(ID_FILESNOTCOPIED, ID_APPNAME, MB_OK);
        goto END_INSTALL;
        }

    iRes=PatchZed(szInstallDir);
    if (iRes!=0)
        {
        DestroyStatusDlg();
        usResponse=MsgBox(ID_PATCHFAILED, ID_APPNAME, MB_OK);
        goto END_INSTALL;
        }

    
    iRes=CreateObject(szInstallDir);
    if (iRes!=0) usResponse=MsgBox(ID_CANTCREATEOBJECT, ID_APPNAME, MB_OK);

    //unload status window
    DestroyStatusDlg();

    //Update the window
    WinUpdateWindow(hwndClient);

    //Success
    usResponse=MsgBox(ID_SUCCESS, ID_APPNAME, MB_OK);
    goto END_INSTALL;
    
    //Main message loop
    while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
        WinDispatchMsg(hab, &qmsg);

    }


if (usResponse==MBID_CANCEL)
    {
    //The installation has been cancelled.
    usResponse=MsgBox(ID_CANCELINSTALL, ID_APPNAME, MB_OK);    
    }

END_INSTALL:
//Cleanup
WinDestroyWindow(hwndFrame);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);

//End
return 0;
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static CHAR szErrorMsg [] = "File not found or could not be opened" ;
     static INT  cxClient, cyClient, cxChar, cyChar, cyDesc ;
     CHAR        *pcReadBuffer ;
     FILE        *fileInput ;
     FONTMETRICS fm ;
     HPS         hps ;
     INT         iLength ;
     POINTL      ptl ;

     switch (msg)
          {
          case WM_CREATE:
               hps = WinGetPS (hwnd) ;
               EzfQueryFonts (hps) ;

               if (!EzfCreateLogFont (hps, LCID_FIXEDFONT, FONTFACE_MONO,
                                                           FONTSIZE_10, 0))
                    {
                    WinReleasePS (hps) ;

                    WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
                         "Cannot find a fixed-pitch font.  Load the Courier "
                         "fonts from the Control Panel and try again.",
                         szClientClass, 0, MB_OK | MB_WARNING) ;

                    return MRFROMSHORT (1) ;
                    }

               GpiQueryFontMetrics (hps, (LONG) sizeof fm, &fm) ;
               cxChar = fm.lAveCharWidth ;
               cyChar = fm.lMaxBaselineExt ;
               cyDesc = fm.lMaxDescender ;

               GpiSetCharSet (hps, LCID_DEFAULT) ;
               GpiDeleteSetId (hps, LCID_FIXEDFONT) ;
               WinReleasePS (hps) ;
               return 0 ;
          
          case WM_SIZE:
               cxClient = SHORT1FROMMP (mp2) ;
               cyClient = SHORT2FROMMP (mp2) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case IDM_OPEN:
                         if (WinDlgBox (HWND_DESKTOP, hwnd, OpenDlgProc,
                                        NULLHANDLE, IDD_OPEN, NULL))
                              WinInvalidateRect (hwnd, NULL, FALSE) ;
                         return 0 ;

                    case IDM_ABOUT:
                         WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc,
                                    NULLHANDLE, IDD_ABOUT, NULL) ;
                         return 0 ;
                    }
               break ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;
               GpiErase (hps) ;

               if (szFileName [0] != '\0')
                    {
                    EzfCreateLogFont (hps, LCID_FIXEDFONT, FONTFACE_MONO,
                                           FONTSIZE_10,    0) ;
                    EzfCreateLogFont (hps, LCID_BOLDFONT,  FONTFACE_MONO,
                                           FONTSIZE_10,    FATTR_SEL_BOLD) ;

                    GpiSetCharSet (hps, LCID_BOLDFONT) ;
                    ptl.x = cxChar ;
                    ptl.y = cyClient - cyChar + cyDesc ;
                    GpiCharStringAt (hps, &ptl, strlen (szFileName),
                                     szFileName) ;
                    ptl.y -= cyChar ;
                                
                    if ((fileInput = fopen (szFileName, "r")) != NULL)
                         {
                         GpiSetCharSet (hps, LCID_FIXEDFONT) ;
                         pcReadBuffer = (PCHAR) malloc (cxClient / cxChar) ;

                         while ((ptl.y -= cyChar) > 0 &&
                                fgets (pcReadBuffer, cxClient / cxChar - 2,
                                       fileInput) != NULL)
                              {
                              iLength = strlen (pcReadBuffer) ;

                              if (pcReadBuffer [iLength - 1] == '\n')
                                   iLength-- ;

                              if (iLength > 0)
                                   GpiCharStringAt (hps, &ptl, iLength,
                                                    pcReadBuffer) ;
                              }
                         free (pcReadBuffer) ;
                         fclose (fileInput) ;
                         }
                    else           // file cannot be opened
                         {
                         ptl.y -= cyChar ;
                         GpiCharStringAt (hps, &ptl, strlen (szErrorMsg),
                                          szErrorMsg) ;
                         }
                    GpiSetCharSet (hps, LCID_DEFAULT) ;
                    GpiDeleteSetId (hps, LCID_FIXEDFONT) ;
                    GpiDeleteSetId (hps, LCID_BOLDFONT) ;
                    }
               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
Example #19
0
MRESULT EXPENTRY wpCD(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
	switch (msg)
	{
		case WM_INITDLG:
		{
			ULONG rc, i;
			HFILE CDDevice;
			ULONG action;
			ULONG len;
			struct
			{
				USHORT CountCD;
				USHORT FirstCD;
			} CDInfo;
			FIELDINFO *firstFieldInfo, *posFieldInfo, *splitFieldInfo;
			FIELDINFOINSERT fieldInfoInsert;
			CNRINFO cnrInfo;
			cnrInfo.cb = sizeof(cnrInfo);

			firstFieldInfo = posFieldInfo = allocaFieldInfo(hwnd, CT_TRACK, NUM_FIELDS);
			posFieldInfo->flData = CFA_BITMAPORICON | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Icon";
			posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,hptrIcon);
			fieldInfo[0] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Filename";
			posFieldInfo->offStruct = FIELDOFFSET(RECORDCORE,pszIcon);
			fieldInfo[1] = posFieldInfo;

			cnrInfo.pFieldInfoLast = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Track #";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,track);
			fieldInfo[2] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Type";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,typepointer);
			fieldInfo[3] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR | CFA_FIREADONLY;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Time";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,timepointer);
			fieldInfo[4] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Size";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,size);
			fieldInfo[5] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_ULONG | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "MP3 Size";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,mp3size);
			fieldInfo[6] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Title";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,titleptr);
			fieldInfo[7] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Artist";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,artistptr);
			fieldInfo[8] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Album";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,albumptr);
			fieldInfo[9] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Year";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,yearptr);
			fieldInfo[10] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Genre";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,genreptr);
			fieldInfo[11] = posFieldInfo;

			posFieldInfo = posFieldInfo->pNextFieldInfo;
			posFieldInfo->flData = CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
			posFieldInfo->flTitle = CFA_CENTER;
			posFieldInfo->pTitleData = "Comment";
			posFieldInfo->offStruct = FIELDOFFSET(CDTRACKRECORD,commentptr);
			fieldInfo[12] = posFieldInfo;

			fieldInfoInsert.cb = sizeof(fieldInfoInsert);
			fieldInfoInsert.pFieldInfoOrder = (FIELDINFO *) CMA_FIRST;
			fieldInfoInsert.fInvalidateFieldInfo = TRUE;
			fieldInfoInsert.cFieldInfoInsert = NUM_FIELDS;

			insertFieldInfo(hwnd, CT_TRACK, firstFieldInfo, &fieldInfoInsert);

			cnrInfo.xVertSplitbar = 100;
			cnrInfo.flWindowAttr = CV_DETAIL | CA_DETAILSVIEWTITLES;
			WinSendDlgItemMsg(hwnd,CT_TRACK,CM_SETCNRINFO, MPFROMP(&cnrInfo),
				MPFROMLONG(CMA_PFIELDINFOLAST | CMA_XVERTSPLITBAR | CMA_FLWINDOWATTR));


			loadConfig(CFGFILE, &grabbers, &countGrabbers);
			for(i = 0; i < countGrabbers; i++)
				insertItemText(hwnd,CB_GRABBER,LIT_END,grabbers[i].id);
			selectItem(hwnd,CB_GRABBER,0);

			setText(hwnd, EF_TITLE, "Title");

			/* wohw, this is too powerful, need cooling */

			len = sizeof(CDInfo);
			if(!DosOpen("\\DEV\\CD-ROM2$", &CDDevice, &action, 0,
							FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
							OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL))
			{
				if(!DosDevIOCtl(CDDevice, 0x82, 0x60, NULL, 0, NULL, &CDInfo, len, &len))
				{
					for(i = 0; i < CDInfo.CountCD; i++)
					{
						char driveLetter[3] = { (char) ('A' + CDInfo.FirstCD + i), ':', 0};
						insertItemText(hwnd,CB_DRIVE,LIT_END,driveLetter);
					}
				}
				DosClose(CDDevice);
			}

			selectItem(hwnd,CB_DRIVE,0);

			wpCT = WinSubclassWindow(WinWindowFromID(hwnd,CT_TRACK),wpCTTrack);

			dataIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_DATA);
			trackIco = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ICO_TRACK);
			loadIni(hwnd);
			return 0;
		}
		case WM_COMMAND:
			return processCommand(hwnd,mp1,mp2);
		case WM_CONTROL:
			return processControl(hwnd,mp1,mp2);
		case WM_ADJUSTFRAMEPOS:
		{
			SWP *pos = (SWP*) PVOIDFROMMP(mp1);
			static int bitRateCheck = 0;
			if(pos->fl & SWP_SIZE)
			{
				SWP ctpos;
				WinQueryWindowPos(WinWindowFromID(hwnd, CT_TRACK), &ctpos);
				WinSetWindowPos  (WinWindowFromID(hwnd, CT_TRACK), 0, 0, ctpos.y,
									  pos->cx, pos->cy - ctpos.y,
									  SWP_SIZE | SWP_SHOW | SWP_MOVE);
			}

			if((pos->fl & SWP_SHOW) && bitRateChanged != bitRateCheck)
			{
				bitRateCheck = bitRateChanged;
				refreshFieldInfo(hwnd, CT_TRACK);
			}
			break;
		}

		case WM_MENUEND:
			removeSourceEmphasis(HWNDFROMMP(mp2),&sourceEmphasisInfo);
			return 0;

		case WM_CLOSE:
		{
			WinDestroyPointer(dataIco);
			WinDestroyPointer(trackIco);
			free(grabbers);
			saveIni(hwnd);

			/* delete all current records */
			CDTRACKRECORD *record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, NULL, CMA_FIRST);
			while(record && record != (CDTRACKRECORD *) -1)
			{
				free(record->record.pszIcon);
				record = (CDTRACKRECORD *) enumRecords(hwnd, CT_TRACK, (RECORDCORE *) record, CMA_NEXT);
			}

			removeRecords(hwnd, CT_TRACK, NULL, 0);

			removeFieldInfo(hwnd,CT_TRACK, NULL, 0);
			return 0;
		}

		case WM_CHAR:
			if(SHORT2FROMMP(mp2) == VK_ESC)
				return 0;
			else
				break;

		/* back from worker thread */
		case DLGCD_REFRESH:
			dlgcd_refresh2(mp1,mp2);
			return 0;

      case CDDB_FUZZYMATCH:
		{
			CDDBQUERY_DATA *matches = (CDDBQUERY_DATA *) mp1,
								*chosen	= (CDDBQUERY_DATA *) mp2;
         FUZZYMATCHCREATEPARAMS data = {matches,chosen};

			WinDlgBox(HWND_DESKTOP, hwnd, wpMatch, NULLHANDLE, DLG_MATCH, &data);
              
			return 0;
		}

	}

	return WinDefDlgProc( hwnd, msg, mp1, mp2 );
}
Example #20
0
MRESULT PMfrCommands (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
     {
     /*
        These are the routnes that handle the commands issued by
        the FRACTINT for PM menus.

        In most cases, they call another support routine to
        handle or schedule the event requested by the user.
     */

     SHORT sCommand = SHORT1FROMMP(mp1);


     switch (sCommand)
          {
          case IDM_GO:
               /* fire up the subtask */
               cp.fContinueCalc = TRUE ;
               if (npNewParms.fNewParms)
                  {
                  CopyParmsToBase();
                  /* GetMemoryBitmap(); */
                  SetSwitchEntry (hwnd, szTitleBar,
                                  GetFractalName(cp.iFractType) );
                  }

               cp.sSubAction = SUB_ACT_CALC;   /* we want a Calculation */

               DosSemClear (&cp.ulSemTrigger) ;  /* release the subthread */

               sStatus = STATUS_WORKING ;
               /* WinInvalidateRect (hwnd, NULL, FALSE) ; */
               UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt);
               EnableMenuItem (hwnd, IDM_GO, FALSE) ;
               EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ;
               /* WinStartTimer (hab, hwnd, ID_TIMER, 5000); */
               return 0 ;

          case IDM_PAN:
               /* Pan selected.  Pan to where the cross hairs were */
               PanNewCenter(hwnd);
               fGoodPan = FALSE;
               return 0;

          case IDM_ZIN_WIN:
               /* Zoom to the Window selected. */
               EraseZoomBox(hwnd);
               ZoomNewWindow(hwnd, TRUE);   /* zoom in */
               fGoodZoom = FALSE;
               return 0;

          case IDM_ZOUT_WIN:
               /* Zoom to the Window selected. */
               EraseZoomBox(hwnd);
               ZoomNewWindow(hwnd, FALSE);   /* zoom out */
               fGoodZoom = FALSE;
               return 0;

          case IDM_FREEZE_HALT:
               if (sStatus == STATUS_WORKING)
                  {
                  /* schedule the subthread to find a stopping place */
                  cp.fContinueCalc = FALSE ;
                  EnableMenuItem (hwnd, IDM_FREEZE_HALT, FALSE) ;
                  }
               if (sStatus == STATUS_READY)
                  {
                  /* we Freeze to play with parms repeatedly */
                  /* make a copy to play with.  We will keep */
                  /* working with only this copy */
                  InitNewParms(NULL);
                  /* now change state */
                  sStatus = STATUS_FROZEN;
                  EnableMenuItem (hwnd, IDM_FREEZE_HALT, FALSE);
                  }

               return 0 ;

          case IDM_ABOUT:
               /* send up the About box */
               WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc,
                    (HMODULE) 0, IDD_ABOUT, NULL) ;

               return 0 ;

          case IDM_NEW_FRACTAL:
               /*
                * send up the Select Fractal Type box.
                * On OK return, schedule the new parameters.
                * Handle the special cases needing files or other data
                * as part of exiting the initial dialog box.
               */
               if (WinDlgBox (HWND_DESKTOP, hwnd, SelFractalDlgProc,
                       (HMODULE) 0, IDD_SET_FRACTTYPE, NULL) )
                  ScheduleNewParms (hwnd);

               return 0 ;

          case IDM_SET_PARAMS:
               /*
                * send up the Set Paramters box.
                * On OK return, schedule the new parameters.
               */
               if (WinDlgBox (HWND_DESKTOP, hwnd, SetParametersDlgProc,
                       (HMODULE) 0, IDD_SET_PARAMS, NULL) )
               ScheduleNewParms (hwnd);

               return 0 ;

          case IDM_SET_OPTIONS:
               /*
                * send up the Set Options box.
                * On OK return, schedule the new parameters.
               */
               if (WinDlgBox (HWND_DESKTOP, hwnd, SetOptionsDlgProc,
                       (HMODULE) 0, IDD_SET_OPTIONS, NULL) )
               ScheduleNewParms (hwnd);

               return 0 ;

          case IDM_SET_IMAGE:
               /*
                * send up the Set Image box.
                * On OK return, schedule the new parameters.
               */
               if (WinDlgBox (HWND_DESKTOP, hwnd, SetImageDlgProc,
                       (HMODULE) 0, IDD_SET_IMAGE, NULL) )
               ScheduleNewParms (hwnd);

               return 0 ;

          case IDM_SET_PALETTE:
               /*
                * send up the Set Palette box.
                * Return is not checked because effects are immediate
               */
               WinDlgBox (HWND_DESKTOP, hwnd, SetPaletteDlgProc,
                       (HMODULE) 0, IDD_SET_PALETTE, NULL) ;

               return 0 ;

          case IDM_ZIN_PICK:
          case IDM_ZOUT_PICK:
               /*
                * Send up the Zoom Value dialog box.
                * On OK return, schedule the new parameters.
               */
               if ( WinDlgBox (HWND_DESKTOP, hwnd, ZoomValueDlgProc,
                        (HMODULE) 0, IDD_NUMBER_PICK,
                        MPFROMP((PVOID) &COMMANDMSG(&msg)->cmd)) )
                  ScheduleNewParms (hwnd);

               return 0 ;

          case IDM_ZIN_2:
          case IDM_ZIN_5:
          case IDM_ZIN_10:
               /*
                * Zoom in by fixed value.
                * Schedule the new parameters.
               */
               InitNewParms(NULL);
               CalcZoomValues(&npNewParms,
                      (double) (sCommand), TRUE );
               npNewParms.fNewParms = TRUE;
               ScheduleNewParms(hwnd);

               return 0;

          case IDM_ZOUT_2:
          case IDM_ZOUT_5:
          case IDM_ZOUT_10:
               /*
                * Zoom out by fixed value.
                * Schedule the new parameters.
               */
               InitNewParms(NULL);
               CalcZoomValues(&npNewParms,
                      (double) (sCommand - 10), FALSE );
               npNewParms.fNewParms = TRUE;
               ScheduleNewParms(hwnd);

               return 0;

          case IDM_SET_EXTENTS:
               /*
                * Send up the Set Extents dialog box.
                * On OK return, schedule the new parameters.
               */
               if ( WinDlgBox (HWND_DESKTOP, hwnd, SetExtentsDlgProc,
                      (HMODULE) 0, IDD_SET_EXTENTS, NULL) )
                   ScheduleNewParms (hwnd);

               return 0;

          case IDM_SET_SWAP:
               /* swap Mandel for Julia or vice versa.
                  Handle it as a parm change */
               InitNewParms(NULL);
               if (fractalspecific[npNewParms.iFractType].tojulia != NOFRACTAL
                      && npNewParms.param[0] == 0.0
                      && npNewParms.param[1] == 0.0)
                  {
                  /* switch to corresponding Julia set */
                  npNewParms.iFractType =
                         fractalspecific[npNewParms.iFractType].tojulia;
                  npNewParms.param[0] = npNewParms.XCenter;
                  npNewParms.param[1] = npNewParms.YCenter;

                  npNewParms.mxXL = fractalspecific[npNewParms.iFractType].xmin;
                  npNewParms.mxXR = fractalspecific[npNewParms.iFractType].xmax;
                  npNewParms.mxYB = fractalspecific[npNewParms.iFractType].ymin;
                  npNewParms.mxYT = fractalspecific[npNewParms.iFractType].ymax;

                  }

               else if (fractalspecific[npNewParms.iFractType].tomandel != NOFRACTAL)
                  {
                  /* switch to corresponding Mandel set */
                  npNewParms.iFractType =
                         fractalspecific[npNewParms.iFractType].tomandel;
                  npNewParms.param[0] = 0.0;
                  npNewParms.param[1] = 0.0;
                  npNewParms.mxXL = fractalspecific[npNewParms.iFractType].xmin;
                  npNewParms.mxXR = fractalspecific[npNewParms.iFractType].xmax;
                  npNewParms.mxYB = fractalspecific[npNewParms.iFractType].ymin;
                  npNewParms.mxYT = fractalspecific[npNewParms.iFractType].ymax;
                  }

               npNewParms.fNewParms = TRUE;
               ScheduleNewParms (hwnd);
               return 0;

          case IDM_SET_RESET:
               /* copy the work copy of the parms back from the
                  set used by the calculation engine.
                  This resets any dicking around done with the
                  dialogs.
                  Note: this is only active during FREEZE mode.
               */

               CopyParmsToNew();

               return 0;

          case IDM_HELP_INTRO:
               /* basic Introductory Help */
               SimpleHelp(hab, hwnd, szTitleBar,
                         (HMODULE) 0, IDT_TEXT, IDT_HELP_INTRO);
               return 0;

          case IDM_HELP_FRACTTYPE:
               /* Fractal list Help */
               SimpleHelp(hab, hwnd, szTitleBar,
                         (HMODULE) 0, IDT_TEXT, IDT_HELP_TYPES);
               return 0;

          case IDM_HELP_OPERATE:
               /* Menu Help */
               SimpleHelp(hab, hwnd, szTitleBar,
                       (HMODULE) 0, IDT_TEXT, IDT_HELP_OPERATE);
               return 0;

          case IDM_PRINT_FILE:
               /* Send up the Print Where Dialog.
                  On OK return, fire up the subtask */
               if ( WinDlgBox(HWND_DESKTOP, hwnd, PrintOptionsDlgProc,
                    (HMODULE) 0, IDD_PRINT, NULL) )
                  {
                  /* fire up the subtask */
                  cp.sSubAction = SUB_ACT_PRINT;   /* we want a Print */

                  cp.fContinueCalc = TRUE;
                  DosSemClear (&cp.ulSemTrigger) ;  /* release the subthread */

                  sStatus = STATUS_WORKING ;
                  UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt);
                  EnableMenuItem (hwnd, IDM_GO, FALSE) ;
                  EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ;
                  cp.fSuppressPaint = TRUE;
                  WinInvalidateRect(hwnd, NULL, FALSE);
                  }

               return 0 ;

          case IDM_READ_FILE:
               /* Send up the Load/Save Format Dialog to find
                  out the format we will read.
                  Then send up the generic Open File dialog.
                  On OK return, fire up the subtask */
               {
               DLF dlf;
               HFILE hfDummy;
               PSZ pszExt;

               if ( WinDlgBox(HWND_DESKTOP, hwnd, LoadSaveFmtDlgProc,
                    (HMODULE) 0, IDD_LOADSAVE_TYPE, szLoadWhatFmt) )
                  {

                  FileFmtExt (&pszExt);

                  SetupDLF (&dlf, DLG_OPENDLG, &hfDummy,
                            pszExt, szTitleBar,
                            szOpenTitle, szOpenHelp);

                  if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) )
                     {
                     /* close the dummy file handle */
                     DosClose(hfDummy);
                     /* fire up the subtask */
                     cp.sSubAction = SUB_ACT_LOAD;   /* we want a Load */
                     cp.sSubFunction = cp.sLastLoadSaveType;
                     _fstrcpy(cp.szFileName, dlf.szOpenFile);

                     cp.fContinueCalc = TRUE;
                     DosSemClear (&cp.ulSemTrigger) ;  /* release the subthread */

                     sStatus = STATUS_WORKING ;
                     UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt);
                     EnableMenuItem (hwnd, IDM_GO, FALSE) ;
                     EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ;
                     cp.fSuppressPaint = TRUE;
                     WinInvalidateRect(hwnd, NULL, FALSE);
                     }
                  }

               return 0 ;
               }

          case IDM_SAVE_FILE:
               /* Send up the Load/Save Format Dialog to find
                  out the format we will be writing.
                  Then send up the generic Save File dialog.
                  On OK return, fire up the subtask */
               {
               DLF dlf;
               HFILE hfDummy;
               PSZ pszExt;

               if ( WinDlgBox(HWND_DESKTOP, hwnd, LoadSaveFmtDlgProc,
                    (HMODULE) 0, IDD_LOADSAVE_TYPE, szSaveWhatFmt) )
                  {

                  FileFmtExt (&pszExt);

                  SetupDLF (&dlf, DLG_SAVEDLG, &hfDummy,
                            pszExt, szTitleBar,
                            szOpenTitle, szOpenHelp);
                  _fstrcpy(dlf.szOpenFile, cp.szFileName);

                  if (TDF_NOSAVE != DlgFile(hwnd, &dlf) )
                     {
                     /* close the dummy file handle */
                     DosClose(hfDummy);
                     /* and delete the dummy file */
                     DosDelete(dlf.szOpenFile, 0);
                     /* fire up the subtask */
                     cp.sSubAction = SUB_ACT_SAVE;   /* we want a Save */
                     cp.sSubFunction = cp.sLastLoadSaveType;
                     _fstrcpy(cp.szFileName, dlf.szOpenFile);

                     cp.fContinueCalc = TRUE;
                     DosSemClear (&cp.ulSemTrigger) ;  /* release the subthread */

                     sStatus = STATUS_WORKING ;
                     UpdateMenuText (hwnd, IDM_FREEZE_HALT, szHalt);
                     EnableMenuItem (hwnd, IDM_GO, FALSE) ;
                     EnableMenuItem (hwnd, IDM_FREEZE_HALT, TRUE) ;
                     cp.fSuppressPaint = TRUE;
                     WinInvalidateRect(hwnd, NULL, FALSE);
                     }
                 }

               return 0 ;
               }

          case IDM_READ_COLORMAP:
               /* Send up the generic Open File dialog.
                  On OK return, read in the file via subroutine. */
               {
               DLF dlf;
               HFILE hfDummy;

               SetupDLF (&dlf, DLG_OPENDLG, &hfDummy,
                         "\\*.map", szTitleBar,
                         szColorMapTitle, szColorMapHelp);

               if (TDF_OLDOPEN == DlgFile(hwnd, &dlf) )
                  {
                  /* close the dummy file handle */
                  DosClose(hfDummy);
                  /* throw up the hour-glass */
                  WinSetCapture(HWND_DESKTOP, hwnd);
                  WinSetPointer(HWND_DESKTOP, hptrWait);
                  /* read it in */
                  LoadColorMap(dlf.szOpenFile);
                  /* now clean up */
                  WinSetPointer(HWND_DESKTOP, hptrArrow);
                  WinSetCapture(HWND_DESKTOP, (HWND) NULL);
                  }
               }

               return 0;

          case IDM_WRITE_COLORMAP:
               /* Send up the generic Save File dialog.
                  On OK return, write the file via subroutine */
               {
               DLF dlf;
               HFILE hfDummy;

               SetupDLF (&dlf, DLG_SAVEDLG, &hfDummy,
                         "\\*.map", szTitleBar,
                         szColorMapTitle, szColorMapHelp);

               if (TDF_NOSAVE != DlgFile(hwnd, &dlf) )
                  {
                  /* close the dummy file handle */
                  DosClose(hfDummy);
                  /* throw up the hour-glass */
                  WinSetCapture(HWND_DESKTOP, hwnd);
                  WinSetPointer(HWND_DESKTOP, hptrWait);
                  /* write it out */
                  SaveColorMap(dlf.szOpenFile);
                  /* now clean up */
                  WinSetPointer(HWND_DESKTOP, hptrArrow);
                  WinSetCapture(HWND_DESKTOP, (HWND) NULL);
                  }
               }

               return 0;

          case IDM_CLEAR_CLPB:
               /* clear the current contents of the clipboard */
               WinOpenClipbrd (hab);
               WinEmptyClipbrd (hab);
               WinCloseClipbrd (hab);

               return 0;

          case IDM_PASTE:
               {  /* paste from the clipboard into us */
               USHORT usClipBrdInfo;

               if ( WinQueryClipbrdFmtInfo(hab, CF_BITMAP, &usClipBrdInfo) )
                  {  /* we have a bitmap to fetch */
                  /* draw the curtain over the display */
                  cp.fSuppressPaint = TRUE;
                  WinInvalidateRect(hwnd, NULL, FALSE);
                  WinUpdateWindow(hwnd);
                  /* throw up the hour-glass */
                  WinSetCapture(HWND_DESKTOP, hwnd);
                  WinSetPointer(HWND_DESKTOP, hptrWait);
                  /* fetch the bitmap */
                  PMfrFetchClipbrdBmp(hab);
                  /* now clean up */
                  WinSetPointer(HWND_DESKTOP, hptrArrow);
                  WinSetCapture(HWND_DESKTOP, (HWND) NULL);
                  /* and schedule redrawing the window */
                  SetSwitchEntry (hwnd, szTitleBar,
                                  GetFractalName(cp.iFractType) );
                  cp.fSuppressPaint = FALSE;
                  WinInvalidateRect(hwnd, NULL, FALSE);
                  }
               }

               return 0;

          case IDM_COPY_BMP:
               {  /* copy to the clipboard from us */

               /* throw up the hour-glass */
               WinSetCapture(HWND_DESKTOP, hwnd);
               WinSetPointer(HWND_DESKTOP, hptrWait);
               /* write the bitmap */
               PMfrWriteClipbrdBmp(hab);
               /* now clean up */
               WinSetPointer(HWND_DESKTOP, hptrArrow);
               WinSetCapture(HWND_DESKTOP, (HWND) NULL);

               }

               return 0;

          }

     return 0;

     }
Example #21
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);
          }
        }
void        Command( HWND hwnd, ULONG ulCmd)

{
    switch (ulCmd)
    {
        case IDM_DELETE:
            ToggleDelete();
        break;

        case IDM_DELETEALL:
            SetDelete( TRUE);
        break;

        case IDM_UNDELETEALL:
            SetDelete( FALSE);
        break;

        case IDM_OPEN:
            OpenObject( hwnd);
        break;

        case IDM_LOCATE:
            LocateObject( hwnd);
        break;

        case IDM_MENU:
            ShowObjMenu( hwnd);
        break;

        case IDM_SORTDEL:
        case IDM_SORTNBR:
        case IDM_SORTVIEW:
        case IDM_SORTTITLE:
        case IDM_SORTSIZE:
        case IDM_SORTKEY:
        case IDM_SORTPATH:
            SetSortColumn( ulCmd - IDM_SORTFIRST);
            break;

        case IDM_SORTDONE:
            break;

        case IDM_GETDATA:
            if (SaveChanges( "Reload", TRUE))
                GetData();
            break;

        case IDM_RESETCOL:
            ResetColumnWidths();
            break;

        case IDM_SAVE:
            SaveChanges( "Save now", FALSE);
            break;

        case IDM_OPTDLG:
            WinDlgBox( HWND_DESKTOP,       // parent-window
                       hwnd,               // owner-window
                       OptionsDlgProc,     // dialog proc
                       NULLHANDLE,         // EXE module handle
                       IDD_OPTIONS,        // dialog id
                       NULL);              // pointer to create params
            break;
    }

    return;
}
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));
}
BOOL        SaveChanges( char * pszTitle, BOOL fExit)

{
    BOOL            fRtn = TRUE;
    ULONG           ul;
    PMINIRECORDCORE pRec;
    PMINIRECORDCORE pRecNext;
    char            szText[32];

do
{
    // if nothing to do, exit
    if (ulDelCnt == 0)
        break;

    // show confirmation dialog
    ul = WinDlgBox( HWND_DESKTOP, hDlg, SaveDlgProc, NULLHANDLE,
                    (fExit ? IDD_SAVEEXIT : IDD_SAVE), pszTitle);

    // if the answer was No or Cancel, exit;
    // returning false cancels the operation
    if (ul != MBID_YES)
    {
        if (ul != MBID_NO)
            fRtn = FALSE;
        break;
    }

    // get the first record
    pRecNext = WinSendMsg( hCnr, CM_QUERYRECORD, 0,
                           MPFROM2SHORT( CMA_FIRST, CMA_ITEMORDER));

    while (pRecNext != 0)
    {
        // if there's an error, we have to abort
        if ((LONG)pRecNext == -1)
        {
            printf( "invalid record - aborting\n");
            fRtn = FALSE;
            break;
        }

        // identify the next record before we delete the current one
        pRec = pRecNext;
        pRecNext = WinSendMsg( hCnr, CM_QUERYRECORD, pRec,
                               MPFROM2SHORT( CMA_NEXT, CMA_ITEMORDER));

        // if this record isn't marked for deletion, continue
        if (((PULONG)&pRec[1])[eDEL] != hDelIco)
            continue;

        // save the key for use with the error msgs below
        strcpy( szText, ((char **)&pRec[1])[eKEY]);

        // delete the ini entry corresponding to this record
        if (PrfWriteProfileData( HINI_USERPROFILE, "PM_Workplace:FolderPos",
                                 ((char **)&pRec[1])[eKEY], 0, 0) == FALSE)
        {
            fRtn = FALSE;
            printf( "PrfWriteProfileData() failed for key %s\n", szText);
        }

        // if the user chose Exit or Reload, the records will be
        // removed by GetData(), so there's no need to do that here
        if (fExit)
            continue;

        // update the stats, even if the deletion failed because the most
        // common cause of failure is that the key has already been deleted
        ulTotCnt--;
        ulDelCnt--;
        ulTotSize -= ((PULONG)&pRec[1])[eSIZE];
        ulDelSize -= ((PULONG)&pRec[1])[eSIZE];

        // remove the record & free it
        if (WinSendMsg( hCnr, CM_REMOVERECORD, (MP)&pRec,
                        MPFROM2SHORT( 1, CMA_FREE)) == (MRESULT)-1)
        {
            fRtn = FALSE;
            printf( "CM_REMOVERECORD failed for key %s\n", szText);
        }
    }

    // if this was a 'Save Now', update the cnr & the status line
    if (fExit == FALSE)
    {
        WinSendMsg( hCnr, CM_INVALIDATERECORD, 0, 0);
        UpdateStatus( (fRtn ? 0 : "Error(s) deleting items"));
    }

    // signal that the requested operation should proceed
    fRtn = TRUE;

} while (fFalse);

    return (fRtn);
}
Example #25
0
MRESULT EXPENTRY fnwpClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2)
{
    RECTL   rcl;
    USHORT   Command;
    ULONG *pulPtr;

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

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

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

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

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

        WinPostMsg(hwnd,UM_INIT,0L,0L);
        break;
    case WM_ACTIVATE:
        if(LOUSHORT(LONGFROMMP(mp1)))
            WinSetFocus(HWND_DESKTOP,hwnd);
        break;
    case UM_INIT:
        if (szPortName[0] != 0)
            WinSetWindowText(hwndFrame,szPortName);
        else
            MenuItemEnable(hwndFrame,IDM_PROCESS,FALSE);
        WinShowWindow(hwndFrame,TRUE);
        WinQueryWindowRect(hwndClient,&rcl);
        ulWindowWidth = rcl.xRight;
        ulWindowHeight = rcl.yTop;
        ClearScreen();
        break;
    case WM_PAINT:
        Paint();
        break;
    case WM_SIZE:
        WndSize(hwnd,mp2);
        ClearScreen();
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
    case WM_COMMAND:
        switch (SHORT1FROMMP(mp1))
        {
        case IDM_SELECT:
            if (WinDlgBox(HWND_DESKTOP,
                          hwnd,
                          (PFNWP)fnwpSelectPortDlg,
                          (USHORT)NULL,
                          PS_DLG,
                          NULL))
                WinSetWindowText(hwndFrame,szPortDesc);
            break;
        case IDM_RECOVER_USER_INI:
            RecoverProfile(HINI_USERPROFILE);
            break;
        case IDM_RECOVER_SYS_INI:
            RecoverProfile(HINI_SYSTEMPROFILE);
            break;
        case IDM_EXIT:
            WinPostMsg(hwnd,WM_QUIT,0L,0L);
            break;
        case IDM_SETUP:
            SetupPort();
            break;
        case IDM_REMOVE:
            RemovePort();
            break;
        case IDM_INSTALL:
            InstallPort();
            break;
        case IDM_INIT:
            InitializePort();
            break;
        case IDM_TERM:
            TerminatePort();
//          TerminatePort(szPortName);
            break;
        case IDM_QUERY:
            ulItemCount = QueryPort(achBuffer,4096);
            break;
        default:
            return WinDefWindowProc(hwnd,msg,mp1,mp2);
        }
        break;
    case WM_CLOSE:
        WinPostMsg(hwnd,WM_QUIT,0L,0L);  /* Cause termination     */
        break;
    default:
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
    return(FALSE);
}
Example #26
0
MRESULT EXPENTRY XLogoWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  HPS hps;
  HWND hwndMenu;                                        /* Menu resource */
  RECTL rcl;                    /* For finding current window dimensions */
  BOOL fSuccess;

  switch(msg)
  {
   case WM_ERASEBACKGROUND:
      /*
       * Return TRUE to request PM to paint the window background
       * in SYSCLR_WINDOW.
       */
      return (MRESULT)( TRUE );

    case WM_PAINT:
      /*
       * Window contents are drawn here in WM_PAINT processing.
       */
      {                                
      HPS    hps;                        /* Presentation Space handle    */
      RECTL  rc;                         /* Rectangle coordinates        */
      POINTL pt;                         /* String screen coordinates    */
      LONG   Lx, Ly;
                                    /* Starting points for paths A and B */
      POINTL PathAStart,
             PathBStart;

      POINTL PathAPolygon[5], PathBPolygon[5]; /* Paths A, B definitions */

                                         /* Create a presentation space  */
      hps = WinBeginPaint( hwnd, 0L, &rc );

      GpiSetColor(hps, CLR_BLACK);              /* colour of the text,   */
      GpiSetBackColor(hps, CLR_BACKGROUND);     /* its background and    */
      GpiSetBackMix(hps, BM_OVERPAINT);         /* how it mixes,         */
                                                /* and draw the string...*/

      WinFillRect( hps, &rc, SYSCLR_WINDOW);
      WinQueryWindowRect(hwnd, &rcl);

      Lx = rcl.xRight - rcl.xLeft;       /* Calculate window dimensions! */
      Ly = rcl.yTop   - rcl.yBottom;

            /* Find starting points of the two paths which make up the X */

      PathAStart.x = 0.061 * Lx;
      PathAStart.y = Ly;
      PathBStart.x = 0.864 * Lx;
      PathBStart.y = Ly;

                  /* Find the points for path A, the left half of the X */

      PathAPolygon[0].x = 0.404 * Lx;
      PathAPolygon[0].y = 0.483 * Ly;

      PathAPolygon[1].x = 0.06  * Lx;
      PathAPolygon[1].y = 0;

      PathAPolygon[2].x = 0.141 * Lx;
      PathAPolygon[2].y = 0;

      PathAPolygon[3].x = 0.556 * Lx;
      PathAPolygon[3].y = 0.589 * Ly;

      PathAPolygon[4].x = 0.288 * Lx;
      PathAPolygon[4].y = Ly;

                  /* Find the points for path B, the right half of the X */

      PathBPolygon[0].x = 0.455 * Lx;
      PathBPolygon[0].y = 0.417 * Ly;

      PathBPolygon[1].x = 0.722 * Lx;
      PathBPolygon[1].y = 0;

      PathBPolygon[2].x = 0.939 * Lx;
      PathBPolygon[2].y = 0;

      PathBPolygon[3].x = 0.6   * Lx;
      PathBPolygon[3].y = 0.517 * Ly;

      PathBPolygon[4].x = 0.939 * Lx;
      PathBPolygon[4].y = Ly;
                                               /* Define and draw path A */
      GpiBeginPath(hps, 1L);
      GpiMove(hps, &PathAStart);
      GpiPolyLine(hps, 5L, PathAPolygon);
      GpiCloseFigure(hps);
      GpiEndPath(hps);
      GpiFillPath(hps, 1L, FPATH_ALTERNATE);

                      /* Define and draw path B. Path number must be 1L */
      GpiBeginPath(hps, 1L);
      GpiMove(hps, &PathBStart);
      GpiPolyLine(hps, 5L, PathBPolygon);
      GpiCloseFigure(hps);
      GpiEndPath(hps);
      GpiFillPath(hps, 1L, FPATH_ALTERNATE);

      WinEndPaint(hps);
      break;
      }

   case WM_BUTTON2DOWN:
      {           /* Opens the popup menu at current mouse co-ordinates */

      hwndMenu = WinLoadMenu(hwnd, (HMODULE)NULL, ID_X);

      fSuccess = WinPopupMenu(hwnd,
                              hwndFrame,
                              hwndMenu,
                              MOUSEMSG(&msg)->x,              
                              MOUSEMSG(&msg)->y,
                              IDM_EXIT,
                              PU_POSITIONONITEM   |
                              PU_HCONSTRAIN       |
                              PU_VCONSTRAIN       |
                              PU_MOUSEBUTTON2DOWN |
                              PU_MOUSEBUTTON2);

      break;
      }

    case WM_CLOSE:
      /*
       * This is the place to put your termination routines
       */
      WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );
      break;

    case WM_COMMAND:
       switch (SHORT1FROMMP (mp1))
        {
        case IDM_ABOUT:          /* Show Product information dialog box */

          WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc,
                    0, IDD_ABOUT, 0);

          return ((MRESULT)0);
        case IDM_EXIT:
          WinSendMsg (hwnd, WM_CLOSE, 0L, 0L);
          return ((MRESULT)0);
        }
      break;

    default:
      /*
       * Everything else comes here.  This call MUST exist
       * in your window procedure.
       */

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

  return (MRESULT)FALSE;
} /* End of XLogoWndProc */
Example #27
0
/****************************************************************************
 * DoCommand								    *
 *  - Handles WM_COMMAND messages for client window.			    *
 *  - Standard client window I/O                                            *
 ****************************************************************************/
VOID DoCommand(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    switch (SHORT1FROMMP(mp1)) {
      case IDM_START1: case IDM_START2:
	/* Start a new 1 or 2 player game. */
        if (iGameMode == GAME_MODE_INIT1 || iGameMode == GAME_MODE_INIT2) {
            TogglePause(FORCE_UNPAUSE);
	    StartGame(SHORT1FROMMP(mp1)-IDM_START);
        }
	break;

      case IDM_PAUSE:
	/* Toggle pause state. */
	TogglePause(TOGGLE);
	break;

      case IDM_STOP:
	/* End game, but don't exit */
	WinPostMsg(hwnd, WM_INITGAME, (MPARAM) 0L, MPVOID);
	break;

      case IDM_3SHIPS: case IDM_4SHIPS: case IDM_5SHIPS:
	/* Select 3, 4, or 5 ships */
	CheckMenuItem(hwndMenu, IDM_SHIPS+prfProfile.iSHIPS, FALSE);
	prfProfile.iSHIPS = SHORT1FROMMP(mp1) - IDM_SHIPS;
	CheckMenuItem(hwndMenu, IDM_SHIPS+prfProfile.iSHIPS, TRUE);
	break;

      case IDM_3PHOTONS: case IDM_4PHOTONS:
      case IDM_6PHOTONS: case IDM_8PHOTONS:
	/* Select 3, 4, 6, or 8 photons */
	CheckMenuItem(hwndMenu, IDM_PHOTONS+prfProfile.iPHOTONS, FALSE);
	prfProfile.iPHOTONS = SHORT1FROMMP(mp1) - IDM_PHOTONS;
	CheckMenuItem(hwndMenu, IDM_PHOTONS+prfProfile.iPHOTONS, TRUE);
	break;

      case IDM_RAPIDFIRE:
	/* Select rapidfire option */
	if (prfProfile.bRAPIDFIRE = !prfProfile.bRAPIDFIRE) {
	    CheckMenuItem(hwndMenu, IDM_RAPIDFIRE, TRUE);
	    EnableMenuItem(hwndMenu, IDM_FIRERATE, TRUE);
	    }
	else {
	    CheckMenuItem(hwndMenu, IDM_RAPIDFIRE, FALSE);
	    EnableMenuItem(hwndMenu, IDM_FIRERATE, FALSE);
	    }
	break;

      case IDM_SLOWRATE: case IDM_MEDRATE: case IDM_FASTRATE:
	CheckMenuItem(hwndMenu, IDM_FIRERATE+prfProfile.iFIRERATE, FALSE);
	prfProfile.iFIRERATE = SHORT1FROMMP(mp1) - IDM_FIRERATE;
	CheckMenuItem(hwndMenu, SHORT1FROMMP(mp1), TRUE);
	break;

      case IDM_SHIELD:
	/* Select shield option */
	if (prfProfile.bSHIELD = !prfProfile.bSHIELD)
	    CheckMenuItem(hwndMenu, IDM_SHIELD, TRUE);
	else
	    CheckMenuItem(hwndMenu, IDM_SHIELD, FALSE);
	break;

      case IDM_MOUSE:
      	/* Allow mouse input for ship control */
        if (prfProfile.bMOUSECONTROL = !prfProfile.bMOUSECONTROL) {
	    /* Hide the pointer if playing a game */
            ShowMouse(FALSE);
            CheckMenuItem(hwndMenu, IDM_MOUSE, TRUE);
        } else {
	    /* Show the pointer if it is currently hidden */
            ShowMouse(TRUE);
            CheckMenuItem(hwndMenu, IDM_MOUSE, FALSE);
        }
        break;
        
      case IDM_KEYS:
	/* Pop up key definition dialog box */
	WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)KeyDlgProc, NULLHANDLE, IDD_KEY,
        	  NULL);
	break;

      case IDM_FRAME:
	/* This case does not come from the menu, but instead from the	*
	 * accelerator table.						*/
	if (prfProfile.bCONTROLS = !prfProfile.bCONTROLS)
	    ShowFrameControls();
	else
	    HideFrameControls();
	break;

      case IDM_BACKGRND:
	CheckMenuItem(hwndMenu, IDM_BACKGRND,
	    prfProfile.bBACKGRND = !prfProfile.bBACKGRND);
	break;


      case IDM_HELPFORHELP:
	WinSendMsg(hwndHelp, HM_DISPLAY_HELP, MPVOID, MPVOID);
	break;

      case IDM_EXTENDEDHELP:
	WinSendMsg(hwndHelp, HM_EXT_HELP, MPVOID, MPVOID);
	break;

      case IDM_KEYSHELP:
	WinSendMsg(hwndHelp, HM_KEYS_HELP, MPVOID, MPVOID);
	break;

      case IDM_HELPINDEX:
	WinSendMsg(hwndHelp, HM_HELP_INDEX, MPVOID, MPVOID);
	break;

      case IDM_EXIT:
	/* On cancel, tell application to terminate */
	WinPostMsg(hwndFrame, WM_QUIT, MPVOID, MPVOID);
	break;

      case IDM_ABOUT:
	/* Pop up about dialog box */
	WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)AboutDlgProc, NULLHANDLE,
		  IDD_ABOUT, NULL);
	break;
      }
}
Example #28
0
File: gvpmeas.c Project: 131/gsview
void
show_calc_dialog(void)
{
   WinDlgBox(HWND_DESKTOP, hwnd_measure, CalcDlgProc, hlanguage, IDD_CALC, NULL);
}
Example #29
0
/*
	SAVER_PROC
	This is the entry point into the saver module that is called by
	the ScreenSaver program.
	There should be no reason to alter the code.
	Depending on the requested function, the following tasks
	are performed:
	* set the name of the INI file to store and query settings
	* call the configuration dialog of the saver module
	* copy the name of the saver module into the supplied buffer
	* tell if the saver module is enabled
	* set the "enabled" state of the saver module
	* start the saver
	* stop the saver
	Note that before any processing is done, module configuration data is
	loaded from the INI-files.
*/
void	EXPENTRY SAVER_PROC(int function, HAB _hab, HWND hwndOwner, char *appname, void *buffer)
{
	hab = _hab;
	application_name = appname;
	hwndApplication = hwndOwner;
	/* load all configuration data from INI-file */
	if(function != FUNCTION_SETINIFILENAME)
		load_configuration_data();
	switch(function){
	case FUNCTION_SETINIFILENAME:
		if(buffer != NULL)
			strcpy(ini_filename, (char *)buffer);
		else
			strcpy(ini_filename, "");
		return;
	case FUNCTION_CONFIGURE:
	    /* call the configuration dialog */
		WinDlgBox(HWND_DESKTOP, hwndOwner, ConfigureDlgProc,
		  hmodDLL, IDD_CONFIGURE, application_name);
		return;
	case FUNCTION_STARTSAVER:
	    /* start the saver */
	    /* get "low priority" state from supplied buffer (BOOL *) */
		low_priority = *((BOOL *)buffer);
		/* query size of screen */
		screenSizeX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
		screenSizeY = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
		/* register window class for the saver window */
		WinRegisterClass(hab, (PSZ)modulename,
		  (PFNWP)SaverWindowProc, 0, 0);
		/* create the saver window */
		hwndSaver = WinCreateWindow(HWND_DESKTOP, (PSZ)modulename,
		  (PSZ)NULL, WS_VISIBLE, 0, 0, screenSizeX, screenSizeY,
		  HWND_DESKTOP, HWND_TOP, 0, NULL, NULL);
		return;
	case FUNCTION_STOPSAVER:
	    /* stop the saver */
		if(low_priority){
			stop_priority_thread = TRUE;
			DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, 0, tidPriority);
			DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, 0, tidDraw);
			DosWaitThread(&tidPriority, DCWW_WAIT);
/*			  DosKillThread(tidPriority);	***** kills thread 1 under OS/2 2.11 */
		}
		/* tell drawing-thread to stop */
		stop_draw_thread = TRUE;
		if(DosWaitThread(&tidDraw, DCWW_NOWAIT) == ERROR_THREAD_NOT_TERMINATED){
		    /* if priority of drawing-thread was set to idle time */
		    /* priority, set it back to normal value */
			DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, PRTYD_MAXIMUM, tidDraw);
			/* wait until drawing-thread has ended */
			DosWaitThread(&tidDraw, DCWW_WAIT);
		}

		if(hwndSaver != NULLHANDLE){
		    /* move saver window to front */
			WinSetWindowPos(hwndSaver, HWND_TOP,
			  0, 0, 0, 0, SWP_ZORDER);
			/* destroy saver window */
			WinDestroyWindow(hwndSaver);
			hwndSaver = NULLHANDLE;
		}
		return;
	case FUNCTION_QUERYNAME:
	    /* copy module name to supplied buffer (CHAR *) */
		strcpy(buffer, modulename);
		return;
	case FUNCTION_QUERYENABLED:
	    /* copy "enabled" state to supplied buffer (BOOL *) */
		*((BOOL *)buffer) = configuration_data.enabled;
		return;
	case FUNCTION_SETENABLED:
	    /* get new "enabled" state from supplied buffer (BOOL *) */
		configuration_data.enabled = *((BOOL *)buffer);
		write_profile_data();
		return;
	}

	/* illegal function request */
	WinAlarm(HWND_DESKTOP, WA_ERROR);
	return;
}
Example #30
0
// exported extern windows callback routine (doet alle belangrijke stuff)
MRESULT EXPENTRY ClientWndProc(HWND hwnd,ULONG messg,MPARAM mp1,MPARAM mp2)
{
HPS         hps;
static HWND hMenu;
RECTL       rc;
static INT xView, yView;
int count,zoom,tel;
float tmpangle;
BOOL stat;
SIZEL sizel;
POINTL ptl;
switch (messg)
			 {
			 case DM_CHECKSCORE:
					count = check_hiscores(mp1);
					if (count != 10)
						{
						WinDlgBox(HWND_DESKTOP,hwnd,EnterHiScore,NULLHANDLE,DRIFT_HISCORE,NULL);
						if (glb_name[0] == 0)
							strcpy(HiTable[count].name,"Cthulhu");
						else
							strcpy(HiTable[count].name,glb_name);
						}
						break;
		 case WM_SIZE:
						xView = SHORT1FROMMP(mp2);
						yView = SHORT2FROMMP(mp2);
						break;
		 case WM_CREATE:
						init_logo();
						load_hiscores();
						// initialize the settings
            //hMenu=WinQueryWindow(hwnd,QW_PARENT);
						hMenu=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_MENU);
						// uncheck detaillevel
						stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
            // uncheck save on exit
            stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
						load_settings();
						// check to correct menu item detaillevel
						stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
            if (saveonexit)
            	stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
						switch (detaillevel)
							{
							case IDM_HIGHDET:
											game_bigex = 36;
											game_mediumex = 18;
											game_smallex = 9;
											maxthrustpixels = 9;
											break;
							case IDM_MEDIUMDET:
											game_bigex = 18;
											game_mediumex = 18;
											game_smallex = 9;
											maxthrustpixels = 5;
											break;
							case IDM_LOWDET:
											game_bigex = 9;
											game_mediumex = 9;
											game_smallex = 9;
											maxthrustpixels = 3;
											break;
							}
						if (saveonexit == TRUE)
								stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
						else
								stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
						break;
		 case WM_TIMER:
						hps = WinGetPS(hwnd) ;
            sizel.cx = 2000 ;
            sizel.cy = 2000 ;
            GpiSetPS (hps, &sizel, PU_PELS) ;

						GpiQueryPageViewport(hps,&rc);
						rc.xLeft   = 0;//xView / 2 ;
            rc.xRight  = xView ;
            rc.yBottom = 0;//yView / 2 ;
            rc.yTop    = yView;

            GpiSetPageViewport (hps, &rc) ;

						 switch (game_status)
							{
							case GAME_INTRO :
												stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE);
												stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE);
												stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE);
												zoom = (game_duration - 100)/3;
												if (zoom < 5)
													zoom = 5;
												D->angle += 10;
												D->zoom = zoom;
												R->angle += 10;
												R->zoom = zoom;
												I->angle += 10;
												I->zoom = zoom;
												F->angle += 10;
												F->zoom = zoom;
												T->angle += 10;
												T->zoom = zoom;
												game_duration --;
												if (game_duration == 0)
													{
                          game_status = GAME_HISCORE;
                          game_duration = 200;                          if (random(2) == 0)
                            {
                            // insert the hiscore table
													  insert_message(1800,0,"D R I F T  F O R  O S / 2  H I S C O R E S");
													  insert_message(1600,0,"Rank    Name          Score  Level");
													  for (tel = 0; tel < 10; tel++)
														  insert_message(1460-(tel*100),0,"%2d     %-12s %5d    %2d",tel+1,HiTable[tel].name,HiTable[tel].score,HiTable[tel].level);
                            }
                          else
                            {
                            // insert help message
                            insert_message(1800,0,"DRIFT WARPSPEED FOR OS/2 WARP");
                            insert_message(1600,0,"By Dirk Vandenheuvel /c/ 1995");
                            insert_message(1400,0,"Keys");
                            insert_message(1200,0,"UP                     Thrust");
                            insert_message(1100,0,"LEFT                Turn left");
                            insert_message(1000,0,"RIGHT              Turn right");
                            insert_message(900,0, "SPACE            Fire missile");
                            }
                          WinInvalidateRect(hwnd,NULL,TRUE);
													}
												else
													intro(hps);
												break;
							case GAME_HISCORE:
												game_duration --;
												if (game_duration == 0)
													{
													// free the effekts list
													free_all();
													game_status = GAME_INTRO;
													game_duration = 200;
													WinInvalidateRect(hwnd,NULL,TRUE);
													}
												break;
							case GAME_PLAYING: // play
												check_keys();
												if (game_shooting)
													game_shooting--;
												game(hps);
												break;
							}
               WinReleasePS(hps);
               break;
		 case WM_SYSCOMMAND:
							/*switch(mp1)
								{
								case SC_MINIMIZE:
											if (!game_pauze)
												SendMessage(hwnd,WM_COMMAND,IDM_PAUZE,0);
											break;
											}
								return(DefWindowProc(hwnd,messg,mp1,mp2));*/
								break;
		 case WM_COMMAND:
								switch (COMMANDMSG(&messg)->cmd)
									{
									case IDM_SAVEONEXIT:
															if (saveonexit == TRUE) // already checked
																{
																stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
																saveonexit = FALSE;
																save_settings(); // save the "do not save on exit" setting
																}
															else
																{
																stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
																saveonexit = TRUE;
																}
															break;
									case IDM_HIGHDET : // set to high
															game_bigex = 36;
															game_mediumex = 18;
															game_smallex = 9;
															maxthrustpixels = 9;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_MEDIUMDET:
															game_bigex = 18;
															game_mediumex = 18;
															game_smallex = 9;
															maxthrustpixels = 5;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_LOWDET:
															game_bigex = 9;
															game_mediumex = 9;
															game_smallex = 9;
															maxthrustpixels = 3;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_ABOUT:
															WinDlgBox(HWND_DESKTOP,hwnd,AboutDiaProc,NULLHANDLE,IDD_ABOUT,NULL);
															break;
									case IDM_HELP :
															//WinHelp (hwnd,"drift.hlp",HELP_INDEX,0);
															break;
									case IDVK_ESCAPE: // escape key pressed
															//SendMessage (hwnd, WM_SYSCOMMAND,SC_MINIMIZE,0);
															break;
									case IDM_PAUZE:
															if (game_status != GAME_PLAYING)
																break;
															if (game_pauze != TRUE)
																{
                                WinStopTimer(hab,hwndClient,idTimer);
                                stat = WinCheckMenuItem(hMenu,IDM_PAUZE,TRUE);
																game_pauze = TRUE;
																}
															else
																{
																game_pauze = FALSE;
																// gets a timer
																idTimer = WinStartTimer(hab,hwndClient,ID_TIMER,30);
																stat = WinCheckMenuItem(hMenu,IDM_PAUZE,FALSE);
																WinInvalidateRect(hwnd, NULL, TRUE);
																}
															break;
									case IDM_QUIT:
															stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE);
															stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE);
															stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE);
															free_all();
															game_status = GAME_INTRO;
															if (game_pauze)
																{
																game_pauze = FALSE;
																//while (!SetTimer(hwnd,ID_TIMER,10,NULL))
																//if (IDCANCEL == MessageBox (hwnd, "Cannot get timer handle!", szProgName,MB_ICONEXCLAMATION | MB_RETRYCANCEL))
																//exit(0); // add a better shutdown here
																//CheckMenuItem(hmenu,IDM_PAUZE,MF_UNCHECKED);
																}
															game_duration = 200;
															WinInvalidateRect(hwnd, NULL, TRUE);
															break;
									case IDM_PLAY:
															free_all();
															stat = WinEnableMenuItem(hMenu,IDM_PLAY,FALSE);
															stat = WinEnableMenuItem(hMenu,IDM_QUIT,TRUE);
															stat = WinEnableMenuItem(hMenu,IDM_PAUZE,TRUE);
															init_objekts();
															game_level = 1;
															// init powerups to default
															game_pauze = FALSE;
															game_maxshots = MAXSHOT;
															game_shots = 1;
															game_turning = 10;
															game_shotlife = 20;
															game_rearshot = FALSE;
															game_shieldduration = 0;
															init_game();
															game_status = GAME_PLAYING;
															game_score = 0;
															game_duration = 25;
                              game_life = 3;
															WinInvalidateRect(hwnd, NULL, TRUE);
															break;
									default:    break;
									}
									break;
			 case WM_PAINT:
									hps = WinBeginPaint(hwnd,NULLHANDLE,&rc);
									WinQueryWindowRect(hps,&rc);
            			WinFillRect(hps,&rc,CLR_BLACK);
                  sizel.cx = 2000 ;
                  sizel.cy = 2000 ;
            			GpiSetPS (hps, &sizel, PU_PELS) ;

									GpiQueryPageViewport(hps,&rc);
									rc.xLeft   = 0;//xView / 2 ;
            			rc.xRight  = xView ;
            			rc.yBottom = 0;//yView / 2 ;
            			rc.yTop    = yView;

            			GpiSetPageViewport (hps, &rc) ;
                  if (game_status == GAME_HISCORE)
                    hiscore(hps);
                  if (game_status == GAME_PLAYING && game_pauze)
										game(hps);
									WinEndPaint(hps);
									break;
        default:   return(WinDefWindowProc(hwnd,messg,mp1,mp2));
			 }
return(MRESULT)0L;
}