Example #1
0
/***************************************************************************\
 * GetBrushesAndPens()
 *
 * Entry: none
 * Exit:  Initializes the program brushes, pens, and palette array
\***************************************************************************/
void GetBrushesAndPens(void)
{
    int index;     // index to pens or brushes, for initialization

    // set up background brush
    g.BlankBrush = CreateSolidBrush(BLANK_COLOR);
    if (!g.BlankBrush)
        ErrorExit(MyLoadString(IDS_BADBRUSH));

    // set up palette
    g.crPalette[BLUE_INDEX]  = BLUE_COLOR;
    g.crPalette[RED_INDEX]   = RED_COLOR;
    g.crPalette[GREEN_INDEX] = GREEN_COLOR;
    g.crPalette[BLACK_INDEX] = BLACK_COLOR;

    // initialize brushes and pens
    for (index=0; index<NUM_COLORS; index++)
    {
        g.hbrPalette[index]  = CreateSolidBrush(g.crPalette[index]);
        g.hpPalette[index]   = CreatePen(PS_SOLID, 1, g.crPalette[index]);
	if ((!g.hbrPalette[index]) || (!g.hpPalette[index]))
            ErrorExit(MyLoadString(IDS_BADBRUSH));
    }

    // set up default coloring, later can be user settable
    g.ibrProcess = BLUE_INDEX;
    g.ibrThread = RED_INDEX;
    g.ibrAxis = BLACK_INDEX;

    return;
}
Example #2
0
void GDisplay::DrawDescription(HDC hDC, LPRECT lpRect)
{
	TCHAR szTitle[LONG_STR_LEN];
	size_t nSize;

	HFONT hOldFont = (HFONT)::SelectObject(hDC, m_hFont);

	for (int k = 0; k < m_nChartCount; k++)
	{
		UINT id = SIMVAR_BASE_ID + m_nSimVarID[k];
		if(MyLoadString(id, szTitle, LONG_STR_LEN))
		{
			if(SUCCEEDED(StringCbLength(szTitle, LONG_STR_LEN, &nSize)))
			{
				SetTextColor(hDC, m_clrMarker[k]);

				TextOut(hDC, 
					lpRect->left - m_dxText, 
					lpRect->bottom + 16 + 18*k, 
					szTitle, (int)nSize/sizeof(TCHAR));	
			}
		}
	}

	::SelectObject(hDC, hOldFont);

}
Example #3
0
int NEAR PASCAL MyGetProfileInt(WORD wAppName, WORD wKey, int nDefault)
{
   HANDLE hAppName, hKey;

   if(!(hAppName=MyLoadString(wAppName, NULL, LMEM_MOVEABLE)))
      goto Error1;
   if(!(hKey=MyLoadString(wKey, NULL, LMEM_MOVEABLE)))
      goto Error2;

   nDefault = GetProfileInt(LocalLock(hAppName), LocalLock(hKey), nDefault);

   LocalUnlock(hKey);
   LocalUnlock(hAppName);
Error2:
   LocalFree(hKey);
Error1:
   LocalFree(hAppName);
   return(nDefault);
}
Example #4
0
void	EdFail_WriteToLog (char *pmString1, char *pmString2, ...)
{
    va_list 		myArgList;
    char		myMessage [1024];
    FilePath		myPanicLogName;
    FileEntryPtr	myPanicFile;
    int			myErrorCode;
    
    myMessage [0] = 0;
    
    if (pmString1 != NULL)
    {
    	strcpy (myMessage, pmString1);
    	strcat (myMessage, ": ");
    }
        
    if (pmString2 != NULL)
    {    
    	va_start (myArgList, pmString2);
    	wvsprintf (&myMessage [strlen (myMessage)], pmString2, myArgList);
    	va_end (myArgList);
    }
    else
    {
    	strcat (myMessage, "<NULL>");
    }
    
    //
    // Write to panic.log
    //
    
    // Get file name.  If EdProp has not been initialized, this will be
    // an empty directory, in which case, use the current directory (which
    // will be the correct one about 90% of the time.
    strcpy (myPanicLogName, EdProp_GetStartupDirectory ());
    if (myPanicLogName [0] == 0)
    {
    	EdFile_GetCurrentDirectory (myPanicLogName);
    }

    MyLoadString (IDS_PANIC_LOG_FILE, &myPanicLogName [strlen (myPanicLogName)], 
        sizeof (myPanicLogName), PANIC_LOG_FILE_REPL);
    myPanicFile = EdFile_OpenFileForWrite (myPanicLogName, &myErrorCode,
    	BUFFER_OUTPUT, APPEND_TO_FILE);
    if (myPanicFile == NULL)
    {
    	EdGUI_Message (pmString1, myMessage);
    }
    else
    {
    	EdFile_WritelnString (myPanicFile, myMessage);
    	EdFile_CloseFile (myPanicFile);
    }
} // EdFail_WriteToLog
Example #5
0
VOID NEAR PASCAL WriteProfileInt(WORD wAppName, WORD wKey, int nVal)
{
   HANDLE hAppName, hKey;
   char buf[10];

   if(!(hAppName=MyLoadString(wAppName, NULL, LMEM_MOVEABLE)))
      goto Error1;
   if(!(hKey=MyLoadString(wKey, NULL, LMEM_MOVEABLE)))
      goto Error2;

   wsprintf(buf, "%d", nVal);
   WriteProfileString(LocalLock(hAppName), LocalLock(hKey), buf);

   LocalUnlock(hKey);
   LocalUnlock(hAppName);
Error2:
   LocalFree(hKey);
Error1:
   LocalFree(hAppName);
}
Example #6
0
UString MyLoadStringW(HINSTANCE hInstance, UINT resourceID)
{
  if (g_IsNT)
  {
    UString s;
    int size = 256;
    int len;
    do
    {
      size += 256;
      len = ::LoadStringW(hInstance, resourceID, s.GetBuffer(size - 1), size);
    }
    while (size - len <= 1);
    s.ReleaseBuffer();
    return s;
  }
  return GetUnicodeString(MyLoadString(hInstance, resourceID));
}
Example #7
0
// #define ONLYID
VOID NEAR PASCAL MyHelp(HWND hWnd, WORD wCommand, DWORD wId)
{
#ifdef ONLYID
   if(wCommand != HELP_QUIT)
      MyMessageBox(hWnd, IDS_HELP, MB_OK, 0, wId);
#else
   HANDLE hHelpFile;
   PSTR pHelpFile;

   if(!(hHelpFile=MyLoadString(wHelpMain==IDW_SDKMAIN ?
	 IDS_SDKHELPFILE : IDS_HELPFILE, NULL, LMEM_MOVEABLE)))
      return;

   if(!WinHelp(hWndMain, pHelpFile=LocalLock(hHelpFile), wCommand, wId))
      MyMessageBox(hWnd, IDS_HELPERR, MB_OK, 0);
   else
      WinHelp(hWndMain, pHelpFile, HELP_SETINDEX, wHelpIndex);

   LocalUnlock(hHelpFile);
   LocalFree(hHelpFile);
#endif
}
Example #8
0
int NEAR cdecl MyMessageBox(HWND hWnd, WORD wText, WORD wType, WORD wExtra, ...)
{
   HANDLE hText, hRText;
   PSTR pText, pRText;
   WORD wSize;
   int result = 0;

   if(wText == IDS_OUTOFMEMORY)
      goto Error1;

   if(!(hText=MyLoadString(wText, &wSize, LMEM_MOVEABLE)))
      goto Error1;

   /* We allocate enough room for a bunch of numbers and the strings
    */
   if(!(hRText=LocalAlloc(LMEM_MOVEABLE, 2*wSize + wExtra)))
      goto Error2;
   if(!(pRText=LocalLock(hRText)))
      goto Error3;

   pText = LocalLock(hText);
   wvsprintf(pRText, pText, (LPSTR)(&wExtra+1));
   result = MessageBox(hWnd, pRText, pszLongName, wType);

   LocalUnlock(hText);
   LocalUnlock(hRText);
Error3:
   LocalFree(hRText);
Error2:
   LocalFree(hText);
Error1:
   if(!result) {
      MessageBox(hWnd, pszOutOfMemory, pszLongName,
            MB_ICONHAND | MB_SYSTEMMODAL | MB_OK);
   }

   return(result);
}
Example #9
0
static void	MyFailErrorBox (BOOL pmFatal, int pmReason, char *pmFile, 
		     		int pmLine, int pmErrorCode, va_list pmArgs)
{
    int			myTitleStringRsrc;
    char		myWindowTitle [80];
    char		myFinalMessage [4096], *myFinalPtr;
    char		myString [1024], myPartialString [1024];
    char		myFullString [1024];    
    int			myResult;
    ErrorBuffer		myErrorBuffer;
    FilePath		myPanicLogName;
    FileEntryPtr	myPanicFile;
    int			myErrorCode;
//    char		myDateTimeString [256];
    char		*myPtr, *myNewPtr, *myPtr1, *myPtr2;
#ifndef TPROLOG
    StackDumpThreadInfo	myStackDumpThreadInfo;
    HANDLE		myStackDumpThread;
    DWORD		myThreadID;
#endif // #ifndef TPROLOG
        
    if (pmFatal) 
    {
        myTitleStringRsrc = IDS_FATALWINDOWTITLE;
    }
    else
    {
        myTitleStringRsrc = IDS_WARNWINDOWTITLE;
    }
    
    // Get file name.  If EdProp has not been initialized, this will be
    // an empty directory, in which case, use the current directory (which
    // will be the correct one about 90% of the time.
    strcpy (myPanicLogName, EdProp_GetStartupDirectory ());
    if (myPanicLogName [0] == 0)
    {
    	EdFile_GetCurrentDirectory (myPanicLogName);
    }

    MyLoadString (IDS_PANIC_LOG_FILE, &myPanicLogName [strlen (myPanicLogName)], 
        sizeof (myPanicLogName), PANIC_LOG_FILE_REPL);

    // Get the window title (e.g. "Turing Internal Error")
    strcpy (myWindowTitle, gProgram.environmentName);
    strcat (myWindowTitle, " ");
    MyLoadString (myTitleStringRsrc, &myWindowTitle [strlen (myWindowTitle)], 
    		  sizeof (myWindowTitle) - strlen (myWindowTitle),
    		  WINDOW_TITLE_REPL);

    // Get the preamble (e.g. "An unexpected error... Please record...")
    MyLoadString (IDS_FAILPREAMBLE1, myFinalMessage, sizeof (myFinalMessage),
    		  FAIL_PREAMBLE_REPL1);
    strcat (myFinalMessage, myPanicLogName);
    myFinalPtr = myFinalMessage + strlen (myFinalMessage);
    MyLoadString (IDS_FAILPREAMBLE2, myFinalPtr, 
    		  sizeof (myFinalMessage) - strlen (myFinalMessage),
    		  FAIL_PREAMBLE_REPL2);
        		
    // Get the error message (e.g. "LoadAccelerators failed (%d)")
    myResult = LoadString (gProgram.applicationInstance, pmReason,
			   myString, sizeof (myString));
			   
    // Compose the error message			   
    if (myResult == 0)	  
    {
    	// Get the reason not found error message (e.g. "Error code = %d")
    	MyLoadString (IDS_FAILREASONNOTFOUND, myString, sizeof (myString),
    		      FAIL_REASON_NOT_FOUND_REPL);

	wsprintf (myFullString, myString, pmReason);
    }
    else
    {
    	wvsprintf (myPartialString, myString, pmArgs);
    	
    	// Get the reason found error message (e.g. "Error code = %s (%d)")
    	MyLoadString (IDS_FAILREASONFOUND, myString, sizeof (myString),
    		      FAIL_REASON_FOUND_REPL);
	
	wsprintf (myFullString, myString, myPartialString, pmReason);
    }
    strcat (myFinalMessage, myFullString);

    // Compose the Windows error message
    if (pmErrorCode != 0)
    {
        // Get the line/file part (e.g. "Windows error = %s (%d)\n")
        MyLoadString (IDS_FAILWINDOWSERROR, myString, sizeof (myString),
        	      FAIL_WINDOWS_ERROR_REPL);

	EdFail_GetErrorMessage1 (myErrorBuffer, pmErrorCode);

	if (myErrorBuffer [0] == 0)
	{
            MyLoadString (IDS_FAILWINDOWSUNKNOWNERROR, myString, 
			  sizeof (myString), FAIL_WINDOWS_UNKNOWN_ERROR_REPL);
    	    wsprintf (myFullString, myString, pmErrorCode);
	}
	else
	{
    	    wsprintf (myFullString, myString, myErrorBuffer, pmErrorCode);
	}

	strcat (myFinalMessage, myFullString);
    }

    
    // Get the line/file part (e.g. "File=%s\nLine=%s\n")
    MyLoadString (IDS_FAILFILELINE, myString, sizeof (myString), 
    		  FAIL_FILE_LINE_REPL);
    
    wsprintf (myFullString, myString, pmFile, pmLine);
    strcat (myFinalMessage, myFullString);

    if (pmFatal)
    {
        MyLoadString (IDS_FAILSAVEFILE, myString, sizeof (myString),
        	      FAIL_SAVE_FILE_REPL);
    	
    	strcat (myFinalMessage, myString);
    }
    
    // Display the error message    		
    MessageBox (NULL, myFinalMessage, myWindowTitle, 
        MB_OK | MB_ICONERROR | MB_TASKMODAL);
    
    //
    // Write to panic.log
    //
    
    myPanicFile = EdFile_OpenFileForWrite (myPanicLogName, &myErrorCode,
    	BUFFER_OUTPUT, APPEND_TO_FILE);
    if (myPanicFile == NULL)
    {
    	// Write to log
    	EdGUI_Message ("Panic log failure", 
    	    "Unable to open panic log file (\"%s\") for writing.\n"
    		"Error = %d", myPanicLogName, myErrorCode);
    	return;
    }
   
    // Write preamble
    //          *** Fatal Error in Ready 0.98 at Date:Time
    //          Message
    //		----
    if (pmFatal)
    {          
        EdFile_WriteString (myPanicFile, "*** FATAL INTERNAL ERROR");
    }
    else
    {
        EdFile_WriteString (myPanicFile, "*** NON-FATAL INTERNAL ERROR");
    }
    EdFile_WriteString (myPanicFile, " in ");
    EdFile_WriteString (myPanicFile, gProgram.environmentName);
    EdFile_WritelnString (myPanicFile, " ***");

    // Get information about the application and save it to the crash buffer
    stCrashBufferPtr = stCrashBuffer;
    stCrashBufferLeft = CRASH_BUFFER_SIZE - 10;
    MyGetEnvironmentInfo ();
    
#ifndef TPROLOG
    // Add previous operations
    MyAddPreviousCommandsToBuffer ();	    
#endif // #ifndef TPROLOG

/*  GetDateFormat (LOCALE_USER_DEFAULT, 0, NULL, "MMM d yyyy", 
        myDateTimeString, sizeof (myDateTimeString));
    EdFile_WriteString (myPanicFile, myDateTimeString);
    
    GetTimeFormat (LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, 
        myDateTimeString, sizeof (myDateTimeString));
    EdFile_WriteString (myPanicFile, " ");
    EdFile_WriteString (myPanicFile, myDateTimeString);
*/    
    EdFile_WritelnString (myPanicFile, stCrashBuffer);
    
    // Write the message, writing each line seperately
    myPtr = myFinalMessage;
    myPtr1 = strchr (myPtr, '\n');
    myPtr2 = strchr (myPtr, '\r');
    while ((myPtr1 != NULL) || (myPtr2 != NULL))
    {
    	if (myPtr2 < myPtr1 - 1)
    	{
    	    *myPtr2 = 0;
    	    myNewPtr = myPtr2 + 1;
    	}
    	else if (myPtr2 == myPtr1 - 1)
    	{
    	    *myPtr2 = 0;
    	    myNewPtr = myPtr1 + 1;
	}
	else
	{
    	    *myPtr1 = 0;
    	    myNewPtr = myPtr1 + 1;
	}
    	EdFile_WritelnString (myPanicFile, myPtr);
    	myPtr = myNewPtr;
    	myPtr1 = strchr (myPtr, '\n');
    	myPtr2 = strchr (myPtr, '\r');
    }
    if (*myPtr != 0)
    {
    	EdFile_WritelnString (myPanicFile, myPtr);
    }
    
#ifndef TPROLOG
    //
    // Add a stack dump
    //
    
    // First, we need to get the context of the current thread.  To do this,
    // we must suspend the current thread and have another thread actually
    // do the stack dump.
    DuplicateHandle (GetCurrentProcess(), GetCurrentThread (),
                     GetCurrentProcess(), &myStackDumpThreadInfo.thread, 0, FALSE, 
                     DUPLICATE_SAME_ACCESS);
    myStackDumpThreadInfo.file = myPanicFile;
    myStackDumpThread = CreateThread (NULL, 0, 
        (LPTHREAD_START_ROUTINE) MyStackDump, &myStackDumpThreadInfo, 0, 
        &myThreadID);
    if (myStackDumpThread != NULL)
    {
    	// Sleep for two seconds while the stack dump is taking place.
	WaitForSingleObject (myStackDumpThread, 15000);
    }
#endif // #ifndef TPROLOG

    EdFile_WritelnString (myPanicFile, LINE_OF_DASHES);
    EdFile_CloseFile (myPanicFile);
} // MyFailErrorBox   
Example #10
0
long	EdFail_CrashHandler (struct _EXCEPTION_POINTERS *pmExceptionInfo)
{
    static int		stInCrashHandler = 0;
    static FilePath	stMyPanicLogName, stMyAltPanicLogName;
    static HANDLE	stMyPanicFile;
    static DWORD	stMyNumBytesWritten;
    static int		stMyFileOpenStatus;
    static int		stMyFileOpenError;
        
    stCrashing = TRUE;
    
    if (stCrashBuffer == NULL)
    {
    	return EXCEPTION_EXECUTE_HANDLER;
    }

    if (stInCrashHandler > 1)
    {
    	return EXCEPTION_EXECUTE_HANDLER;
    }
    
    stInCrashHandler++;
    
    if (stInCrashHandler == 2)
    {
    	MyAddToBuffer ("\r\nCrashed in Crash Handler!\r\n");
    }
    else
    {
    	// Get file name
    	strcpy (stMyPanicLogName, EdProp_GetStartupDirectory ());

    	MyLoadString (IDS_PANIC_LOG_FILE, 
    	    &stMyPanicLogName [strlen (stMyPanicLogName)], 
            sizeof (stMyPanicLogName), PANIC_LOG_FILE_REPL);
            
	// Try opening the file.            
    	stMyPanicFile = CreateFile (stMyPanicLogName, GENERIC_WRITE, 0, NULL,
    	    OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

	// If opening the file failed, then try current directory instead.    	    
    	if (stMyPanicFile != (HANDLE) INVALID_HANDLE_VALUE)
    	{
    	    // File opened successfully.  Now close it
	    stMyFileOpenStatus = OPEN_SUCCESS;
    	    CloseHandle (stMyPanicFile);
    	}
    	else
	{
    	    stMyFileOpenError = GetLastError ();
    	    
	    // If the opening failed, try using the current directory.
	    EdFile_GetCurrentDirectory (stMyAltPanicLogName);
	    
	    if (strcmp (stMyAltPanicLogName, 
	    		EdProp_GetStartupDirectory ()) == 0)
	    {
	    	stMyFileOpenStatus = OPEN_FAIL_CURRENT_IS_STARTUP;
	    }
	    else
	    {
    	    	MyLoadString (IDS_PANIC_LOG_FILE, 
    	    	    &stMyAltPanicLogName [strlen (stMyAltPanicLogName)], 
            	    sizeof (stMyAltPanicLogName), PANIC_LOG_FILE_REPL);
            
	    	// Try opening the file.            
    	    	stMyPanicFile = CreateFile (stMyAltPanicLogName, GENERIC_WRITE, 
    	    			  	    0, NULL, OPEN_ALWAYS, 
    	    			  	    FILE_ATTRIBUTE_NORMAL, NULL);
    	    	if (stMyPanicFile != (HANDLE) INVALID_HANDLE_VALUE)
    	    	{
    	    	    // File opened successfully.  Now close it
	    	    stMyFileOpenStatus = OPEN_SUCCESS;
    	    	    CloseHandle (stMyPanicFile);
    	    	    strcpy (stMyPanicLogName, stMyAltPanicLogName);
    	    	}
    	    	else
	    	{
    	    	    stMyFileOpenError = GetLastError ();
	    	    stMyFileOpenStatus = OPEN_FAIL_BOTH_FAILED;
	    	}    	    
            }
	}

    	//
    	// Display the crash dialog box
    	//
    	stCrashBufferPtr = stCrashBuffer;
    	stCrashBufferLeft = CRASH_BUFFER_SIZE - 10;
        
    	// Get the window title (e.g. "Turing Internal Error")
    	MyLoadString (IDS_FATALWINDOWTITLE, stWindowTitle, 
    		      sizeof (stWindowTitle), WINDOW_TITLE_REPL);
    
    	// Get the preamble (e.g. "An unexpected error... Please record...")
    	MyLoadString (IDS_CRASHPREAMBLE1, stCrashBufferPtr, stCrashBufferLeft,
    		      CRASH_PREAMBLE_REPL1);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);
    	MyAddToBuffer (stMyPanicLogName);
    	MyLoadString (IDS_CRASHPREAMBLE2, stCrashBufferPtr, stCrashBufferLeft,
    		      CRASH_PREAMBLE_REPL2);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);

    	// Add the reason for the crash
    	MyAddToBuffer ("Cause of Crash: ");
    	EdCrash_GetExceptionName (stCrashBufferPtr, 
    			pmExceptionInfo -> ExceptionRecord -> ExceptionCode);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);
    	MyAddToBuffer ("\r\n\r\n");
	
    	// Add the register dump
    	EdCrash_RegisterDump (stCrashBufferPtr, pmExceptionInfo -> ContextRecord);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);
    	MyAddToBuffer ("\r\n");

    	// Add the saving files message    
    	MyLoadString (IDS_FAILSAVEFILE, stCrashBufferPtr, stCrashBufferLeft,
        	      FAIL_SAVE_FILE_REPL);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);
    
    	// Display the error message    		
    	MessageBox (NULL, stCrashBuffer, stWindowTitle, 
            MB_OK | MB_ICONERROR | MB_TASKMODAL);

    	//
    	// Write to panic.log
    	//
    	stCrashBufferPtr = stCrashBuffer;
    	stCrashBufferLeft = CRASH_BUFFER_SIZE - 10;
   
    	// Title
    	MyAddToBuffer ("*** ENVIRONMENT CRASH ***\r\n\r\n");
    	
    	// Get environment information
    	MyGetEnvironmentInfo ();

    	// Add the reason for the crash
    	MyAddToBuffer ("\r\n\r\n");
    	MyAddToBuffer ("Cause of Crash: ");
        EdCrash_GetExceptionName (stCrashBufferPtr, 
    			pmExceptionInfo -> ExceptionRecord -> ExceptionCode);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);

	// Add previous operations
	MyAddPreviousCommandsToBuffer ();
	    
    	// Add the register dump
    	EdCrash_RegisterDump (stCrashBufferPtr, pmExceptionInfo -> ContextRecord);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);
    	MyAddToBuffer ("\r\n\r\n");

    	// Add the stack dump    
    	EdCrash_StackDump (stCrashBufferPtr, stCrashBufferLeft, 
    		           pmExceptionInfo -> ContextRecord);
    	stCrashBufferLeft -= strlen (stCrashBufferPtr);
    	stCrashBufferPtr += strlen (stCrashBufferPtr);

	MyAddToBuffer (LINE_OF_DASHES);
    	MyAddToBuffer ("\r\n");
    }

    if (stMyFileOpenStatus != OPEN_SUCCESS)
    {
    	if (stMyFileOpenStatus == OPEN_FAIL_CURRENT_IS_STARTUP)
    	{
    	    EdGUI_Message ("Panic log failure", 
    	        "Unable to open \"%s\" for writing.\nError = %d", 
    	        stMyPanicLogName, stMyFileOpenError);
    	}
    	else
    	{
	    EdGUI_Message ("Panic log failure", 
	    	"Unable to open \"%s\" or \"%s\" for writing.\nError = %d", 
	    	stMyPanicLogName, stMyAltPanicLogName, stMyFileOpenError);
	}	    	
    	return EXCEPTION_EXECUTE_HANDLER;
    }

    stMyPanicFile = CreateFile (stMyPanicLogName, GENERIC_WRITE, 0, NULL,
    	OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (stMyPanicFile == (HANDLE) INVALID_HANDLE_VALUE)
    {
    	EdGUI_Message ("Panic log failure", 
    	    "Unable to open \"%s\" for writing.\nError = %d", 
    	    stMyPanicLogName, GetLastError ());
    	return EXCEPTION_EXECUTE_HANDLER;
    }
    
    // Move to the end of the file
    SetFilePointer (stMyPanicFile, 0, NULL, FILE_END);

    if (!WriteFile (stMyPanicFile, stCrashBuffer, strlen (stCrashBuffer),
    		    &stMyNumBytesWritten, NULL))
    {
    	EdGUI_Message ("Panic log failure",
    	    "Unable to write to \"%s\"\nError = %d", 
    	    stMyPanicLogName, GetLastError ());
    	return EXCEPTION_EXECUTE_HANDLER;
    }
    if (stMyNumBytesWritten != strlen (stCrashBuffer))
    {
    	EdGUI_Message ("Panic log failure",
    	    "Unable to write to \"%s\"\n%d bytes written instead of %d bytes",
    	    stMyPanicLogName, stMyNumBytesWritten, strlen (stCrashBuffer));
    	return EXCEPTION_EXECUTE_HANDLER;
    }
    if (!FlushFileBuffers (stMyPanicFile))
    {
    	EdGUI_Message ("Panic log failure",
    	    "Unable to flush buffers of \"%s\"\nError = %d", 
    	    stMyPanicLogName, GetLastError ());
    	return EXCEPTION_EXECUTE_HANDLER;
    }

    if (!CloseHandle (stMyPanicFile))
    {
    	EdGUI_Message ("Panic log failure",
    	    "Unable to close \"%s\"\nError = %d", 
    	    stMyPanicLogName, GetLastError ());
    	return EXCEPTION_EXECUTE_HANDLER;
    }

    return EXCEPTION_EXECUTE_HANDLER;
} // EdFail_CrashHandler
Example #11
0
CSysString MyLoadString(UINT resourceID)
{
  return MyLoadString(g_hInstance, resourceID);
}
Example #12
0
static int	MyCreateSplashWindow (HWND pmSplashWindow, BOOL pmAbout)
{
    HINSTANCE		myApplicationInstance;
    SplashWindowInfoPtr	myInfo;
    HDC			myDisplayContext, myMemDC;
    BITMAP		myBitmap;
    RECT		myRect, myScreenRect;
    int			cnt;
    
    // Get the program instance
    myApplicationInstance = 
        (HINSTANCE) GetWindowLong (pmSplashWindow, GWL_HINSTANCE);
        
    //
    // Initialize the extra window memory
    //
	
    // Set the window type            
    SetWindowLong (pmSplashWindow, WINDOW_MEM_WINDOW_TYPE, 
        (long) WINDOW_TYPE_SPLASH);

    // Set the window initialized                
    SetWindowLong (pmSplashWindow, WINDOW_MEM_WINDOW_INITIALIZED, (long) FALSE);
            
    // Create the ddit window information
    myInfo = MyCreateSplashWindowInfo ();
    if (myInfo == NULL)
    {
    	return -1;
    }
    SetWindowLong (pmSplashWindow, WINDOW_MEM_WINDOW_INFO, (long) myInfo);
    	    
    //
    // Add the elements to the window
    //
    
    // Add the picture
    if (gProgram.isJava)
    {
    	myInfo -> picture = LoadImage (myApplicationInstance, 
    	    	MAKEINTRESOURCE (READY_SPLASH_IMAGE), IMAGE_BITMAP, 0, 0,
    	    	LR_CREATEDIBSECTION);
    }
    else if (gProgram.isTuring)
    {
    	if (EdGUI_GetColourDepth () == 8)
    	{
    	    myInfo -> picture = LoadImage (myApplicationInstance, 
    	    	MAKEINTRESOURCE (TURING_256_SPLASH_IMAGE), IMAGE_BITMAP, 0, 0,
    	    	LR_CREATEDIBSECTION);
    	}
    	else
    	{
    	    myInfo -> picture = LoadImage (myApplicationInstance, 
    	    	MAKEINTRESOURCE (TURING_SPLASH_IMAGE), IMAGE_BITMAP, 0, 0,
    	    	LR_CREATEDIBSECTION);
    	}
    }
    	
    // Get the version number
    MyGetVersionNumberAndTradmarkInfo (&(myInfo -> versionString), 
        &(myInfo -> trademarkMsg));
    
    // Get the rest of the information
    if (gProgram.isTuring)
    {
    	myInfo -> productNameMsg [0] = 
    				MyLoadString (IDS_TURING_PRODUCT_NAME, "");
	myInfo -> productNameLines = 1;    				
    }
    else if (gProgram.isJava)
    {
    	myInfo -> productNameMsg [0] = 
    				MyLoadString (IDS_JAVA_PRODUCT_NAME_1, "");
    	myInfo -> productNameMsg [1] = 
    				MyLoadString (IDS_JAVA_PRODUCT_NAME_2, "");
	myInfo -> productNameLines = 2;
    }
    myInfo -> createdByMsg = MyLoadString (IDS_CREATED_BY, "");
    myInfo -> assistedByMsg = MyLoadString (IDS_IBM_ASSIST, "");
    myInfo -> leadProgrammerMsg = MyLoadString (IDS_LEAD_PROGRAMMER, "");
    myInfo -> miniMsg [0] = MyLoadString (IDS_MINI_MSG_1, gProgram.licensedTo);
    myInfo -> miniMsg [1] = MyLoadString (IDS_MINI_MSG_2, "");
    myInfo -> miniMsg [2] = MyLoadString (IDS_MINI_MSG_3, "");
    myInfo -> evalMsg [0] = MyLoadString (IDS_EVAL_MSG_1, "");
    myInfo -> evalMsg [1] = MyLoadString (IDS_EVAL_MSG_2, "");
    myInfo -> evalMsg [2] = MyLoadString (IDS_EVAL_MSG_3, "");
    if (strlen (gProgram.expiryDateString) > 0)
    {
    	myInfo -> evalMsg [3] = MyLoadString (IDS_EVAL_MSG_4, 
    					  gProgram.expiryDateString);
    }
    else
    {
    	myInfo -> evalMsg [3] = EdGlob_MallocString ("    ");
    }    					  
    myInfo -> restrictMsg [0] = MyLoadString (IDS_RESTRICT_MSG_1, "");
    myInfo -> restrictMsg [1] = MyLoadString (IDS_RESTRICT_MSG_2, "");
    myInfo -> restrictMsg [2] = MyLoadString (IDS_RESTRICT_MSG_3, "");
    myInfo -> restrictMsg [3] = MyLoadString (IDS_RESTRICT_MSG_4, 
    					  gProgram.expiryDateString);
    for (cnt = 0 ; cnt < 10 ; cnt++)
    {
        myInfo -> miniEdMsg [cnt] = MyLoadString (IDS_MINIED_MSG_1 + cnt, "");
    }        

    myInfo -> betaMsg [0] = MyLoadString (IDS_BETA_MSG_1, "");
    myInfo -> betaMsg [1] = MyLoadString (IDS_BETA_MSG_2, "");
    myInfo -> betaMsg [2] = MyLoadString (IDS_BETA_MSG_3, "");
    myInfo -> betaMsg [3] = MyLoadString (IDS_BETA_MSG_4, 
    					  gProgram.expiryDateString);
    myInfo -> siteMsg = MyLoadString (IDS_SITE_MSG_1, gProgram.licensedTo);
    myInfo -> personalMsg = MyLoadString (IDS_PERSONAL_MSG_1, 
    					  gProgram.licensedTo);
    myInfo -> redistribMsg = MyLoadString (IDS_REDISTRIB_MSG_1, 
    					   gProgram.licensedTo);
    myInfo -> usingJikesMsg = MyLoadString (IDS_USES_JIKES, "");
    myInfo -> win95Msg = MyLoadString (IDS_WIN_95_JRE_131, "");
    myInfo -> jreLevelMsg =  MyLoadString (IDS_JRE_LEVEL, "");
   
    // Create the fonts
    myInfo -> productNameFont = EdGUI_CreateFont (pmSplashWindow, NULL,
        "Times New Roman", 30, BOLD, NO_ITALIC);
        
    myInfo -> createdByFont = EdGUI_CreateFont (pmSplashWindow, NULL,
        "Times New Roman", 12, BOLD, NO_ITALIC);

    myInfo -> chiefProgrammerFont = EdGUI_CreateFont (pmSplashWindow, NULL,
        "Times New Roman", 10, NO_BOLD, NO_ITALIC);

    myInfo -> versionFont = EdGUI_CreateFont (pmSplashWindow, NULL,
        "Times New Roman", 12, BOLD, NO_ITALIC);

    myInfo -> usingJikesFont = EdGUI_CreateFont (pmSplashWindow, NULL,
        "Times New Roman", 12, NO_BOLD, ITALIC);

    myInfo -> trademarkFont = EdGUI_CreateFont (pmSplashWindow, NULL,
        "Arial", 8, NO_BOLD, NO_ITALIC);

    myDisplayContext = GetDC (pmSplashWindow);
    
    // Get bitmap size
    myMemDC = CreateCompatibleDC (myDisplayContext);
    SelectBitmap (myMemDC, myInfo -> picture);
    GetObject(myInfo -> picture, sizeof(BITMAP), (LPSTR) &myBitmap);
    DeleteDC (myMemDC);

    ReleaseDC (pmSplashWindow, myDisplayContext);

    // If the font properties have not already been determined, 
    // determine them now (we needed a window to do so).  This must be
    // called *after* the top widow and status window created
    EdSplash_PropertiesImplementChanges ();

    // Set the window to initialized
    SetWindowLong (pmSplashWindow, WINDOW_MEM_WINDOW_INITIALIZED, (long) TRUE);

    // Save the bitmap's height    
    myInfo -> bitmapHeight = myBitmap.bmHeight;
    
    // Set the window size.  If the splash window would not fit onto the
    // screen, use a text header.
    myRect.left = 0;
    myRect.right = myBitmap.bmWidth;
    if (gProgram.isJava)
    {
    	myRect.right += 2 * MARGIN;
    }
    myRect.top = 0;
    MyGetSplashWindowInfo (pmSplashWindow) -> usePicture = TRUE;
    myRect.bottom = MyPaintSplash (pmSplashWindow, FALSE) + 2;
    myScreenRect = EdGUI_GetWorkArea ();
    if (myRect.bottom >= myScreenRect.bottom - myScreenRect.top)
    {
    	MyGetSplashWindowInfo (pmSplashWindow) -> usePicture = FALSE;
        myRect.bottom = MyPaintSplash (pmSplashWindow, FALSE) + 2;
    }
    AdjustWindowRect (&myRect, WS_POPUP | WS_DLGFRAME, FALSE);
        	    
    // Set the window to the correct position
    SetWindowPos (pmSplashWindow, HWND_TOP, 0, 0,
    	myRect.right - myRect.left, myRect.bottom - myRect.top, SWP_NOMOVE);

    myInfo -> windowWidth = myRect.right - myRect.left;
        	
    EdGUI_CentreDialogBox (pmSplashWindow);

    ShowWindow (pmSplashWindow, SW_NORMAL);
    
    // If this is the initial splash screen, set the timer.
    if (!pmAbout)
    {
    	SetTimer (pmSplashWindow, SPLASH_TIMER, SPLASH_TIME_IN_MILLISEC, NULL);
    }
    
    return 0;
} // MyCreateSplashWindow
void MyLoadString(UINT resourceID, UString &dest)
{
  MyLoadString(g_hInstance, resourceID, dest);
}