Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// Does:   Open a Resource And Load It Into IPicture (Interface)
// ~~~~    (.BMP .DIB .EMF .GIF .ICO .JPG .WMF)
//
// Note:   When Adding a Bitmap Resource It Would Automatically Show On "Bitmap"
// ~~~~    This NOT Good Coz We Need To Load It From a Custom Resource "BMP"
//         To Add a Custom Rresource: Import Resource -> Open As -> Custom
//         (Both .BMP And .DIB Should Be Found Under "BMP")
//
// InPut:  ResourceName - As a UINT Defined (Example: IDR_PICTURE_RESOURCE)
// ~~~~~   ResourceType - Type Name (Example: "JPG")
//
// OutPut: TRUE If Succeeded...
// ~~~~~~
//-----------------------------------------------------------------------------
BOOL CPicture_Ex::Load(HINSTANCE hInstance,LPCTSTR lpszResourceName, LPCSTR ResourceType)
//=============================================================================
{
 HGLOBAL  hGlobal = NULL;
 HRSRC  hSource = NULL;
 LPVOID  lpVoid  = NULL;
 int   nSize   = 0;
 BOOL  bResult=FALSE;
 if(m_pPict != NULL) UnloadPicture(); // Important - Avoid Leaks...



 hSource = FindResource(hInstance, lpszResourceName, ResourceType);



 if(hSource == NULL)
  {
  HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
  MessageBoxEx(hWnd, "FindResource() Failed\t", "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
  return(FALSE);
  }



 hGlobal = LoadResource(hInstance, hSource);
 if(hGlobal == NULL)
  {
  HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
  MessageBoxEx(hWnd, "LoadResource() Failed\t", "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
  return(FALSE);
  }



 lpVoid = LockResource(hGlobal);
 if(lpVoid == NULL)
  {
  HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
  MessageBoxEx(hWnd, "LockResource() Failed\t", "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
  return(FALSE);
  }



 nSize = (UINT)SizeofResource(hInstance, hSource);
 if(LoadPictureData((BYTE*)hGlobal, nSize)) bResult = TRUE;



 UnlockResource(hGlobal); // 16Bit Windows Needs This
 FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release)
 return(bResult);
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// Does:   Read The Picture Data From a Source (File / Resource)
// ~~~~    And Load It Into The Current IPicture Object In Use
//
// InPut:  Buffer Of Data Source (File / Resource) And Its Size
// ~~~~~   
//
// OutPut: Feed The IPicture Object With The Picture Data
// ~~~~~~  (Use Draw Functions To Show It On a Device Context)
//         TRUE If Succeeded...
//-----------------------------------------------------------------------------
BOOL CPicture_Ex::LoadPictureData(BYTE *pBuffer, int nSize)
//=============================================================================
{
 BOOL bResult = FALSE;
 HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, nSize);



 if(hGlobal == NULL)
  {
  HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
  MessageBoxEx(hWnd, "Can not allocate enough memory\t", "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
  return(FALSE);
  }



 void* pData = GlobalLock(hGlobal);
 memcpy(pData, pBuffer, nSize);
 GlobalUnlock(hGlobal);



 IStream* pStream = NULL;



 if(CreateStreamOnHGlobal(hGlobal, TRUE, &pStream) == S_OK)
  {
  HRESULT hr;
  if((hr = OleLoadPicture(pStream, nSize, FALSE, IID_IPicture, (LPVOID *)&m_pPict)) == E_NOINTERFACE)
   {
   HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
   MessageBoxEx(hWnd, "IPicture interface is not supported\t", "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
   return(FALSE);
   }
  else // S_OK
   {
   pStream->Release();
   pStream = NULL;
   bResult = TRUE;
   
   }
  }



 FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release)



 return(bResult);
}
Exemplo n.º 3
0
static int s_MessageBoxTimeout( IN HWND hWnd,
                                IN LPCTSTR lpText, IN LPCTSTR lpCaption,
                                IN UINT uType, IN WORD wLanguageId,
                                IN DWORD dwMilliseconds )
{
   /* undocumented Windows API */
   typedef int ( __stdcall * _HB_MSGBOXTOUT )( IN HWND hWnd,
                                               IN LPCTSTR lpText, IN LPCTSTR lpCaption,
                                               IN UINT uType, IN WORD wLanguageId,
                                               IN DWORD dwMilliseconds );
   static _HB_MSGBOXTOUT s_pMessageBoxTimeout = ( _HB_MSGBOXTOUT ) -1;

   if( s_pMessageBoxTimeout == ( _HB_MSGBOXTOUT ) -1 )
   {
      HMODULE hModule = GetModuleHandle( TEXT( "user32.dll" ) );
      s_pMessageBoxTimeout = hModule == NULL ? NULL : ( _HB_MSGBOXTOUT )
               HB_WINAPI_GETPROCADDRESST( hModule, "MessageBoxTimeout" );
   }

   return s_pMessageBoxTimeout ?
            s_pMessageBoxTimeout( hWnd, lpText, lpCaption, uType,
                                  wLanguageId, dwMilliseconds ) :
#if ! defined( HB_OS_WIN_CE )
            MessageBoxEx( hWnd, lpText, lpCaption, uType, wLanguageId );
#else
            MessageBox( hWnd, lpText, lpCaption, uType );
#endif
}
Exemplo n.º 4
0
/*
    Default log output is just to the console
 */
static void logHandler(int flags, int level, cchar *msg)
{
    if (flags & MPR_USER_MSG) {
        MessageBoxEx(NULL, msg, mprGetAppTitle(), MB_OK, 0);
    }
    mprWriteToOsLog(msg, 0, 0);
}
Exemplo n.º 5
0
static long msgProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
    MprThread   *tp;
    char        buf[ME_MAX_FNAME];

    switch (msg) {
    case WM_DESTROY:
    case WM_QUIT:
        mprShutdown(0, -1, 0);
        break;
    
    case APPWEB_MONITOR_MESSAGE:
        return monitorEvent(hwnd, wp, lp);

    case WM_COMMAND:
        switch (LOWORD(wp)) {
        case MA_MENU_STATUS:
            break;

        case MA_MENU_DOC:
            runBrowser("http://embedthis.com/appweb/doc/index.html");
            break;

#if UNUSED
        case MA_MENU_MANAGE:
            runBrowser("/index.html");
            break;
#endif
        case MA_MENU_START:
            tp = mprCreateThread("startService", startService, 0, 0);
            mprStartThread(tp);
            break;

        case MA_MENU_STOP:
            tp = mprCreateThread("stopService", stopService, 0, 0);
            mprStartThread(tp);
            break;

        case MA_MENU_ABOUT:
            /*
                Single-threaded users beware. This blocks !!
             */
            fmt(buf, sizeof(buf), "%s %s", ME_TITLE, ME_VERSION);
            MessageBoxEx(hwnd, buf, mprGetAppTitle(), MB_OK, 0);
            break;

        case MA_MENU_EXIT:
            PostMessage(hwnd, WM_QUIT, 0, 0L);
            break;

        default:
            return (long) DefWindowProc(hwnd, msg, wp, lp);
        }
        break;

    default:
        return (long) DefWindowProc(hwnd, msg, wp, lp);
    }
    return 0;
}
Exemplo n.º 6
0
static long msgProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp)
{
    MprThread   *tp;
    char        buf[MPR_MAX_FNAME];

    switch (msg) {
    case WM_DESTROY:
    case WM_QUIT:
        mprTerminate(MPR_EXIT_GRACEFUL, -1);
        break;
    
    case APPWEB_MONITOR_MESSAGE:
        return monitorEvent(hwnd, wp, lp);

    case WM_COMMAND:
        switch (LOWORD(wp)) {
        case MA_MENU_STATUS:
            break;

        case MA_MENU_DOC:
            runBrowser("/doc/index.html");
            break;

        case MA_MENU_MANAGE:
            runBrowser("/index.html");
            break;

        case MA_MENU_START:
            tp = mprCreateThread("startService", startService, 0, 0);
            mprStartThread(tp);
            break;

        case MA_MENU_STOP:
            tp = mprCreateThread("stopService", stopService, 0, 0);
            mprStartThread(tp);
            break;

        case MA_MENU_ABOUT:
            /*
                Single-threaded users beware. This blocks !!
             */
            mprSprintf(buf, sizeof(buf), "%s %s-%s", BIT_TITLE, BIT_VERSION, BIT_BUILD_NUMBER);
            MessageBoxEx(hwnd, buf, mprGetAppTitle(), MB_OK, 0);
            break;

        case MA_MENU_EXIT:
            PostMessage(hwnd, WM_QUIT, 0, 0L);
            break;

        default:
            return (long) DefWindowProc(hwnd, msg, wp, lp);
        }
        break;

    default:
        return (long) DefWindowProc(hwnd, msg, wp, lp);
    }
    return 0;
}
Exemplo n.º 7
0
void DSound51::Configure(HWND parent)
{
	INT_PTR ret;
	ret=DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DSOUND51),GetActiveWindow(),(DLGPROC)ConfigProc,1);
	if(ret==-1)
	{
		MessageBoxEx(GetActiveWindow(),"Error Opening the config dialog.","OMG ERROR!",MB_OK,0);
		return;
	}
}
Exemplo n.º 8
0
void OpenDialog()
{
	INT_PTR ret = DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_CONFIG_DEBUG),GetActiveWindow(),(DLGPROC)DialogProc,1);
	if(ret == -1)
	{
		MessageBoxEx(GetActiveWindow(),_T("Error Opening the debug configuration dialog."),_T("OMG ERROR!"),MB_OK,0);
		return;
	}
	ReadSettings();
}
Exemplo n.º 9
0
static long msgProc(HWND hwnd, uint msg, uint wp, long lp)
{
	char	buf[MPR_MAX_FNAME];
	int		sock, winMask;

	switch (msg) {
	case WM_DESTROY:
	case WM_QUIT:
		mp->terminate(1);
		break;
	
	case APPWEB_SOCKET_MESSAGE:
		sock = wp;
		winMask = LOWORD(lp);
		// errCode = HIWORD(lp);
		mp->serviceIO(sock, winMask);
		break;

	case APPWEB_TRAY_MESSAGE:
		return trayEvent(hwnd, wp, lp);
		break;

	case WM_COMMAND:
		switch (LOWORD(wp)) {
		case MPR_HTTP_MENU_CONSOLE:
			runBrowser("/admin/index.html");
			break;

		case MPR_HTTP_MENU_HELP:
			runBrowser("/doc/product/index.html");
			break;

		case MPR_HTTP_MENU_ABOUT:
			//
			//	Single-threaded users beware. This blocks !!!
			//
			mprSprintf(buf, sizeof(buf), "Embedthis %s %s-%s", 
				BLD_NAME, BLD_VERSION, BLD_NUMBER);
			MessageBoxEx(NULL, buf, mp->getAppTitle(), MB_OK, 0);
			break;

		case MPR_HTTP_MENU_STOP:
			mp->terminate(1);
			break;

		default:
			return DefWindowProc(hwnd, msg, wp, lp);
		}
		break;

	default:
		return DefWindowProc(hwnd, msg, wp, lp);
	}
	return 0;
}
Exemplo n.º 10
0
void configure()
{
	INT_PTR ret;
	ReadSettings();
	ret=DialogBoxParam(hinst,MAKEINTRESOURCE(IDD_CONFIG),GetActiveWindow(),(DLGPROC)ConfigProc,1);
	if(ret==-1)
	{
		MessageBoxEx(GetActiveWindow(),"Error Opening the config dialog.","OMG ERROR!",MB_OK,0);
		return;
	}
	ReadSettings();
}
Exemplo n.º 11
0
void MprLogToWindow::logEvent(char *module, int flags, int level, char *thread,
	char *msg)
{
#if WIN
	Mpr		*mpr;

	mpr = mprGetMpr();
	if (!mpr->getHeadless() && (flags & MPR_USER)) {
		MessageBoxEx(NULL, msg, mpr->getAppTitle(), MB_OK, 0);
	}
#endif
}
Exemplo n.º 12
0
bool ApiErrorCheck(T t,T okValue,bool cmpEq)
{
	bool cond=(t==okValue);

	if(!cmpEq) cond=!cond;

	if(!cond)
	{
		static char buff[1024];
		DWORD ec = GetLastError();
		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,NULL,ec,0,buff,1023,NULL);
		MessageBoxEx(0,buff,"ERROR?!",MB_OK,0);
	}
	return cond;
}
Exemplo n.º 13
0
int _tmain(int argc, _TCHAR* argv[])
{
  std::string foo("foo");
  TestDLL_dll_FakeLoadLibrary();

  MessageBoxEx(0, TEXT("MessageBox Message"), TEXT("MessageBox Caption!"), 0, 0);
  //__pfnDliNotifyHook2 = &MyHook;
  printf("Init...\n");
  fnTestDLL();
  printf("After...\n");
  fnTestDLL();
  printf("After2...\n");

  TestDLL_dll_FakeFreeLibrary();
	return 0;
}
Exemplo n.º 14
0
//-----------------------------------------------------------------------------
// Does:   Open a File And Load It Into IPicture (Interface)
// ~~~~    (.BMP .DIB .EMF .GIF .ICO .JPG .WMF)
//
// InPut:  sFilePathName - Path And FileName Target To Save
// ~~~~~   
//
// OutPut: TRUE If Succeeded...
// ~~~~~~
//-----------------------------------------------------------------------------
BOOL CPicture_Ex::Load(CString sFilePathName)
//=============================================================================
{
 //if(!PathFileExists(sFilePathName))return FALSE;
/*
			CFile file;
			if (!file.Open(sFilePathName, CFile::modeRead/ *|CFile::shareDenyWrite* /))
				return FALSE;*/
		
		
 BOOL bResult = FALSE;
 CFile PictureFile;
 CFileException e;
 int nSize = 0;



 if(m_pPict != NULL) UnloadPicture(); // Important - Avoid Leaks...



 if(PictureFile.Open(sFilePathName, CFile::modeRead | CFile::typeBinary, &e))
  {
  nSize = PictureFile.GetLength();
  BYTE* pBuffer = new BYTE[nSize];
 
  if(PictureFile.Read(pBuffer, nSize) > 0)
   {
   if(LoadPictureData(pBuffer, nSize)) bResult = TRUE;
   }



  PictureFile.Close();
  delete [] pBuffer;
  }
 else // Open Failed...
  {
  TCHAR szCause[255];
  e.GetErrorMessage(szCause, 255, NULL);
  HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
  MessageBoxEx(hWnd, szCause, "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
  bResult = FALSE;
  }
 return(bResult);
}
Exemplo n.º 15
0
extern "C" int __declspec(dllexport) Load()
{
	// set the memory, lists & utf8 managers
	mir_getXI(&xi);
	mir_getTMI(&tmi);
	mir_getLP(&pluginInfo);
	mir_getCLI();

	{
		INT_PTR result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&FIP);
		if (FIP == NULL || result != S_OK) {
			MessageBoxEx(NULL, TranslateT("Fatal error, image services not found. Jabber Protocol will be disabled."), _T("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0);
			return 1;
		}
	}

	WORD v[4];
	CallService(MS_SYSTEM_GETFILEVERSION, 0, (LPARAM)v);
	mir_sntprintf(szCoreVersion, SIZEOF(szCoreVersion), _T("%d.%d.%d.%d"), v[0], v[1], v[2], v[3]);

	CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&g_cbCountries, (LPARAM)&g_countries);

	hExtListInit = CreateHookableEvent(ME_JABBER_EXTLISTINIT);
	hDiscoInfoResult = CreateHookableEvent(ME_JABBER_SRVDISCOINFO);

	// Register protocol module
	PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
	pd.szName = "JABBER";
	pd.fnInit = (pfnInitProto)jabberProtoInit;
	pd.fnUninit = (pfnUninitProto)jabberProtoUninit;
	pd.type = PROTOTYPE_PROTOCOL;
	CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);

	g_IconsInit();
	g_XstatusIconsInit();
	// Init extra icons
	hExtraActivity = ExtraIcon_Register("activity", LPGEN("Jabber Activity"), "jabber_dancing");
	hExtraMood = ExtraIcon_Register("mood", LPGEN("Jabber Mood"), "jabber_contemplative");
	g_MenuInit();
	HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
	JabberUserInfoInit();
	return 0;
}
Exemplo n.º 16
0
static void DialogCacheSaveThread(void *unused)
{
	int success = 0;

	// TODO: port the following code to write to the helppack file instead
	// (netlib code already removed)
	/*
	{	WCHAR *szDecoded;
	char *szEncoded=mir_strdup(dialogCache[i].control[j].szText);
	if (mir_utf8decode(szEncoded, &szDecoded)) {
		[...]
		mir_free(szDecoded)
	}
	mir_free(szEncoded); // does NULL check
	}


	int i, j;
	struct ResizableCharBuffer data={0}, dlgId={0};

	for (i = 0; i < dialogCacheCount; i++) {
		if(!dialogCache[i].changes) continue;

		AppendToCharBuffer(&data, "t <dialog id=\"%s\" module=\"%s\">\r\n", dialogCache[i].szId, dialogCache[i].szModule);
		for (j = 0; j < dialogCache[i].controlCount; j++) {
			AppendToCharBuffer(&data, "<control id=%d type=%d>\r\n", dialogCache[i].control[j].id, dialogCache[i].control[j].type);
			if (dialogCache[i].control[j].szTitle)
				AppendToCharBuffer(&data, "<title>%s</title>\r\n", dialogCache[i].control[j].szTitle);
			if (dialogCache[i].control[j].szText)
				AppendToCharBuffer(&data, "<text>%s</text>\r\n", dialogCache[i].control[j].szText);
			AppendToCharBuffer(&data, "</control>\r\n");
		}
		AppendToCharBuffer(&data, "</dialog>");
	}

	if(success) {
		dialogCache[i].changes = 0;
		dialogCache[i].timeLoaded = GetTickCount();
	}
	*/
	MessageBoxEx(NULL, success ? TranslateT("Help saving complete.") : TranslateT("Help saving failed!"), TranslateT("Help editor"), (success ? MB_ICONINFORMATION : MB_ICONERROR) | MB_OK | MB_SETFOREGROUND | MB_TOPMOST | MB_TASKMODAL, LANGIDFROMLCID(Langpack_GetDefaultLocale()));
}
Exemplo n.º 17
0
/*
 *  Default log output is just to the console
 */
static void logHandler(MprCtx ctx, int flags, int level, cchar *msg)
{
    MessageBoxEx(NULL, msg, mprGetAppTitle(ctx), MB_OK, 0);
}
Exemplo n.º 18
0
static long msgProc(HWND hwnd, uint msg, uint wp, long lp)
{
    char    buf[MPR_MAX_FNAME];

    switch (msg) {
    case WM_DESTROY:
    case WM_QUIT:
        mprSignalExit(mpr);
        break;
    
    case APPWEB_MONITOR_MESSAGE:
        return monitorEvent(hwnd, wp, lp);

    case WM_COMMAND:
        switch (LOWORD(wp)) {
        case MA_MENU_STATUS:
            break;

        case MA_MENU_DOC:
            runBrowser("/doc/index.html");
            break;

        case MA_MENU_MANAGE:
            runBrowser("/index.html");
            break;

        case MA_MENU_START:
            startService();
            break;

        case MA_MENU_STOP:
            stopService();
            break;

        case MA_MENU_ABOUT:
            /*
             *  Single-threaded users beware. This blocks !!
             */
            mprSprintf(buf, sizeof(buf), "%s %s-%s", BLD_NAME, BLD_VERSION, BLD_NUMBER);
            MessageBoxEx(NULL, buf, mprGetAppTitle(mpr), MB_OK, 0);
            break;

        case MA_MENU_EXIT:
            /* 
             *  FUTURE
             *
             *  h = CreateDialog(appInst, MAKEINTRESOURCE(IDD_EXIT), appHwnd, dialogProc);
             *  ShowWindow(h, SW_SHOW);
             */
            PostMessage(hwnd, WM_QUIT, 0, 0L);
            break;

        default:
            return DefWindowProc(hwnd, msg, wp, lp);
        }
        break;

    default:
        return DefWindowProc(hwnd, msg, wp, lp);
    }
    return 0;
}
Exemplo n.º 19
0
// Does:   Saves The Picture That Is Stored In The IPicture Object As a Bitmap
// ~~~~    (Converts From Any Known Picture Type To a Bitmap / Icon File)
//
// InPut:  sFilePathName - Path And FileName Target To Save
// ~~~~~
//
// OutPut: TRUE If Succeeded...
// ~~~~~~
//-----------------------------------------------------------------------------
BOOL CPicture_Ex::SaveAsBitmap(CString sFilePathName)
//=============================================================================
{
 BOOL bResult = FALSE;
 ILockBytes *Buffer = 0;
 IStorage   *pStorage = 0;
 IStream    *FileStream = 0;
 BYTE    *BufferBytes;
 STATSTG  BytesStatistics;
 DWORD  OutData;
 long  OutStream;
 CFile  BitmapFile; CFileException e;
 double  SkipFloat = 0;
 DWORD  ByteSkip = 0;
 _ULARGE_INTEGER RealData;



 CreateILockBytesOnHGlobal(NULL, TRUE, &Buffer); // Create ILockBytes Buffer



 HRESULT hr = ::StgCreateDocfileOnILockBytes(Buffer,
     STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, &pStorage);



 hr = pStorage->CreateStream(L"PICTURE",
   STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, 0, &FileStream);



 m_pPict->SaveAsFile(FileStream, TRUE, &OutStream); // Copy Data Stream
 FileStream->Release();
 pStorage->Release();
 Buffer->Flush(); 



 // Get Statistics For Final Size Of Byte Array
 Buffer->Stat(&BytesStatistics, STATFLAG_NONAME);



 // Cut UnNeeded Data Coming From SaveAsFile() (Leave Only "Pure" Picture Data)
 SkipFloat = (double(OutStream) / 512); // Must Be In a 512 Blocks...
 if(SkipFloat > DWORD(SkipFloat)) ByteSkip = (DWORD)SkipFloat + 1;
 else ByteSkip = (DWORD)SkipFloat;
 ByteSkip = ByteSkip * 512; // Must Be In a 512 Blocks...
 
 // Find Difference Between The Two Values
 ByteSkip = (DWORD)(BytesStatistics.cbSize.QuadPart - ByteSkip);



 // Allocate Only The "Pure" Picture Data
 RealData.LowPart = 0;
 RealData.HighPart = 0;
 RealData.QuadPart = ByteSkip;
 BufferBytes = (BYTE*)malloc(OutStream);
 if(BufferBytes == NULL)
  {
  Buffer->Release();
  HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
  MessageBoxEx(hWnd, "Can not allocate enough memory\t", "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
  }



 Buffer->ReadAt(RealData, BufferBytes, OutStream, &OutData);



 if(BitmapFile.Open(sFilePathName, CFile::typeBinary | CFile::modeCreate | CFile::modeWrite, &e))
  {
  BitmapFile.Write(BufferBytes, OutData);
  BitmapFile.Close();
  bResult = TRUE;
  }
 else // Write File Failed...
  {
  TCHAR szCause[255];
  e.GetErrorMessage(szCause, 255, NULL);
  HWND hWnd = AfxGetApp()->GetMainWnd()->m_hWnd;
  MessageBoxEx(hWnd, szCause, "ERROR"/*ERROR_TITLE*/, MB_OK | MB_ICONSTOP, LANG_ENGLISH);
  bResult = FALSE;
  }
 
 Buffer->Release();
 free(BufferBytes);



 return(bResult);
}
Exemplo n.º 20
0
void
PrtDistSMExceptionHandler(
__in PRT_STATUS exception,
__in void* vcontext
)
{

	PRT_MACHINEINST *context = (PRT_MACHINEINST*)vcontext;
	PRT_STRING MachineName = context->process->program->machines[context->instanceOf].name;
	PRT_UINT32 MachineId = context->id->valueUnion.mid->machineId;


	FILE *logFile;
	PRT_MACHINEINST_PRIV *c = (PRT_MACHINEINST_PRIV*)vcontext;

	PrtLockMutex(((PRT_PROCESS_PRIV*)c->process)->processLock);
	PRT_CHAR fileName[100] = "PRT_CONTAINER_LOG_";
	PRT_CHAR processId[100];
	_itoa(c->id->valueUnion.mid->processId.data1, processId, 10);
	strcat_s(fileName, 100, processId);
	strcat_s(fileName, 100, ".txt");
	logFile = fopen(fileName, "a+");
	PRT_CHAR log[100];

	switch (exception)
	{
	case PRT_STATUS_EVENT_UNHANDLED:
		sprintf(log,
			"<EXCEPTION> Machine %s(%d) : Unhandled Event Exception\n",
			MachineName,
			MachineId);
		break;
	case PRT_STATUS_EVENT_OVERFLOW:
		sprintf(log,
			"<EXCEPTION> Machine %s(%d) : MaxInstance of Event Exceeded Exception\n",
			MachineName,
			MachineId);
		break;
	case PRT_STATUS_QUEUE_OVERFLOW:
		sprintf(log,
			"<EXCEPTION> Queue Size Exceeded Max Limits in Machine %s(%d)\n",
			MachineName,
			MachineId);
		break;
	case PRT_STATUS_ILLEGAL_SEND:
		sprintf(log,
			"<EXCEPTION> Machine %s(%d) : Illegal use of send for sending message across process (source and target machines are in different process) ", 
			MachineName,
			MachineId);
		break;
	default:
		sprintf(log,
			"<EXCEPTION> Machine %s(%d) : Unknown Exception\n",
			MachineName,
			MachineId);
		break;
	}

	fputs(log, logFile);
	fflush(logFile);
	PrtUnlockMutex(((PRT_PROCESS_PRIV*)c->process)->processLock);

#ifdef PRT_DEBUG
	int msgboxID = MessageBoxEx(
		NULL,
		log,
		fileName,
		MB_OK,
		LANG_NEUTRAL
		);

	switch (msgboxID)
	{
	case IDOK:
		exit(0);
	default:
		exit(-1);
	}
#endif
	exit(-1);

}
Exemplo n.º 21
0
/*
    Default log output is just to the console
 */
static void logHandler(cchar *tags, int level, cchar *msg)
{
    MessageBoxEx(NULL, msg, mprGetAppTitle(), MB_OK, 0);
}
Exemplo n.º 22
0
BOOL CH3CDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码

	CreateMutex(NULL, true, _T("Huawei"));
	if(GetLastError() == ERROR_ALREADY_EXISTS)   
	{   
		MessageBoxEx(NULL, 
			_T("已经有一个实例在运行!"),
			_T("H3C 802.1x"),
			MB_OK|MB_APPLMODAL|MB_ICONEXCLAMATION,
			0x0804);
		Shell_NotifyIcon(NIM_DELETE,&tnd);
		PostQuitMessage(0);
		return FALSE;   
	}

	// 读取信息
	GetConfig();

	PIP_ADAPTER_INFO pAdapter = NULL;
	DWORD dwRetVal = 0;

	pAdapterInfo = (IP_ADAPTER_INFO *) malloc( sizeof(IP_ADAPTER_INFO) );
	ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);

// Make an initial call to GetAdaptersInfo to get
// the necessary size into the ulOutBufLen variable
	if (GetAdaptersInfo( pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) 
	{
		free(pAdapterInfo);
		pAdapterInfo = (IP_ADAPTER_INFO *)malloc(ulOutBufLen); 
	}

	int devCount = 0;
	if ((dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen)) == NO_ERROR) 
	{
		pAdapter = pAdapterInfo;
		while (pAdapter) 
		{
			string strDescri(pAdapter->Description);
			m_device.AddString(strtotstr(strDescri).c_str());

			string strMac = GetMac(pAdapter);
			if(m_deviceUsed == strMac)
				m_deviceNum = devCount;
			
			pAdapter = pAdapter->Next;
			++devCount;
		}
	}
	//else 
	//{
	//	printf("Call to GetAdaptersInfo failed.\n");
	//}

	if(m_deviceNum >= devCount)
		m_deviceNum = 0;
	GetMac(m_deviceNum);

	UpdateData(FALSE);
	
	CStrVector Paras = ParseCmdLine();
	for(CStrVector::iterator ite = Paras.begin(); ite != Paras.end(); ++ite)
		if(!(*ite).Compare(_T("-mini")))
			SetTimer(1, 200, NULL);

	SetCtrls(FALSE);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
Exemplo n.º 23
0
/**
 * This function is called by Miranda to initialize the plugin.
 *
 * @return	0
 **/
extern "C" INT __declspec(dllexport) Load(PLUGINLINK *link)
{
	INITCOMMONCONTROLSEX ccEx;

	pluginLink = link;
	if (link && CoreCheck())
	{
		mir_getLP(&pluginInfo);
		// init common controls
		ccEx.dwSize = sizeof(ccEx);
		ccEx.dwICC = ICC_WIN95_CLASSES|ICC_DATE_CLASSES;
		InitCommonControlsEx(&ccEx);

		ZeroMemory(&myGlobals, sizeof(MGLOBAL));

		// init miranda's memory interface
		if (!mir_getMMI(&mmi) && !mir_getLI(&li) && !mir_getUTFI(&utfi) /*&& mir_getXI(&xi)*/)
		{

			// init clist interface
			pcli = (CLIST_INTERFACE*)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)0);

			// init new miranda timezone interface
			mir_getTMI(&tmi);

			// init freeimage interface
			INT_PTR result = CALLSERVICE_NOTFOUND;
			if(ServiceExists(MS_IMG_GETINTERFACE))
				result = CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&FIP);

			if(FIP == NULL || result != S_OK) {
				MessageBoxEx(NULL, TranslateT("Fatal error, image services not found. Flags Module will be disabled."), _T("Error"), MB_OK | MB_ICONERROR | MB_APPLMODAL, 0);
				return 1;
			}

			if (IsWinVerVistaPlus())
			{
				HMODULE hDwmApi = LoadLibraryA("dwmapi.dll");
				if (hDwmApi)
				{
					dwmIsCompositionEnabled = (pfnDwmIsCompositionEnabled)GetProcAddress(hDwmApi,"DwmIsCompositionEnabled");
				}
			}

			// check for dbx_tree
			myGlobals.UseDbxTree = ServiceExists("DBT/Entity/GetRoot");

			// load icon library
			IcoLib_LoadModule();

			SvcFlagsLoadModule();
			tmi.getTimeZoneTime ? SvcTimezoneLoadModule() : SvcTimezoneLoadModule_old();
			SvcContactInfoLoadModule();
			SvcEMailLoadModule();
			SvcRefreshContactInfoLoadModule();

			CtrlContactLoadModule();
			// load my button class
			CtrlButtonLoadModule();
			// initializes the Ex/Import Services
			SvcExImport_LoadModule();
			// load the UserInfoPropertySheet module
			DlgContactInfoLoadModule();

			// Anniversary stuff
			DlgAnniversaryListLoadModule();
			SvcReminderLoadModule();

			// Now the module is loaded! Start initializing certain things
			ghModulesLoadedHook		= HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
			ghTopToolBarLoaded		= HookEvent(ME_TTB_MODULELOADED, OnTopToolBarLoaded);
			ghModernToolBarLoaded	= HookEvent(ME_TB_MODULELOADED, OnModernToolBarLoaded);
			ghShutdownHook			= HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
			return 0;
		}
	}
	return 1;
}
Exemplo n.º 24
0
BOOL _EndTask(
    HWND hwnd,
    BOOL fShutdown,
    BOOL fMeanKill)
{
    PCSR_THREAD pcsrt = CSR_SERVER_QUERYCLIENTTHREAD();
    PCSR_THREAD pcsrtKill;
    DWORD dwThreadId;
    DWORD dwProcessId;
    LPWSTR lpszMsg;
    BOOL fAllocated;
    DWORD dwCmd;

    /*
     * Note: fShutdown isn't used for anything in this routine!
     * They are still there because I haven't removed them: the old endtask
     * code relied on them.
     */
    UNREFERENCED_PARAMETER(fShutdown);

    /*
     * Get the process and thread that owns hwnd.
     */
    dwThreadId = GetWindowThreadProcessId(hwnd, &dwProcessId);
    if (dwThreadId == 0)
        return TRUE;

    /*
     * If this is a console window, then just send the close message to
     * it, and let console clean up the processes in it.
     */
    if ((HANDLE)GetWindowLong(hwnd, GWL_HINSTANCE) == hModuleWin) {
        PostMessage(hwnd, WM_CLOSE, 0, 0);
        return TRUE;
    }

    /*
     * Find the CSR_THREAD for the window.
     */
    LeaveCrit();
    CsrLockThreadByClientId((HANDLE)dwThreadId, &pcsrtKill);
    EnterCrit();
    if (pcsrtKill == NULL)
        return TRUE;
    CsrReferenceThread(pcsrtKill);
    CsrUnlockThread(pcsrtKill);

    /*
     * If this is a WOW app, then shutdown just this wow application.
     */
    if (!fMeanKill) {
        /*
         * Find out what to do now - did the user cancel or the app cancel,
         * etc? Only allow cancelling if we are not forcing the app to
         * exit.
         */
        dwCmd = MySendEndSessionMessages(hwnd, pcsrtKill, TRUE, 0);
        switch (dwCmd) {
        case CMDEND_APPSAYSNOTOK:
            /*
             * App says not ok - this'll let taskman bring up the "are you sure?"
             * dialog to the user.
             */
            CsrDereferenceThread(pcsrtKill);
            return FALSE;

        case CMDEND_USERSAYSCANCEL:
            /*
             * User hit cancel on the timeout dialog - so the user really meant
             * it. Let taskman know everything is ok by returning TRUE.
             */
            CsrDereferenceThread(pcsrtKill);
            return TRUE;
        }
    }

    /*
     * Kill the application now.  If the thread has not been destroyed,
     * nuke the task.  If WowExitTask returns that the thread is not
     * a WOW task, terminate the process.
     */
    if (!(pcsrtKill->Flags & CSR_THREAD_DESTROYED) && !WowExitTask(pcsrtKill)) {

        /*
         * Calling ExitProcess() in the app's context will not always work
         * because the app may have .dll termination deadlocks: so the thread
         * will hang with the rest of the process. To ensure apps go away,
         * we terminate the process with NtTerminateProcess().
         *
         * Pass this special value, DBG_TERMINATE_PROCESS, which tells
         * NtTerminateProcess() to return failure if it can't terminate the
         * process because the app is being debugged.
         */
        if (!NT_SUCCESS(NtTerminateProcess(pcsrtKill->Process->ProcessHandle,
                DBG_TERMINATE_PROCESS))) {
            /*
             * If the app is being debugged, don't close it - because that can
             * cause a hang to the NtTerminateProcess() call.
             */
            lpszMsg = ServerLoadString(hModuleWin, STR_APPDEBUGGED,
                    NULL, &fAllocated);
            if (lpszMsg) {
                if (NT_SUCCESS(NtUserSetInformationThread(NtCurrentThread(),
                        UserThreadUseDesktop, &pcsrt->ThreadHandle, sizeof(HANDLE)))) {
                    HANDLE hNull = NULL;

                    LeaveCrit();
                    MessageBoxEx(NULL, lpszMsg, NULL,
                                    MB_OK | MB_SETFOREGROUND, 0);
                    EnterCrit();
                    NtUserSetInformationThread(NtCurrentThread(), UserThreadUseDesktop,
                            &hNull, sizeof(HANDLE));
                }
                LocalFree(lpszMsg);
            }
        } else {
            pcsrtKill->Process->Flags |= CSR_PROCESS_TERMINATED;
        }
    }
    CsrDereferenceThread(pcsrtKill);

    return TRUE;
}
Exemplo n.º 25
0
static int
__ShowLocalizedMsgEx(const UINT type, LPCTSTR caption, const UINT stringId, va_list args)
{
    return MessageBoxEx(NULL, __LoadLocalizedString(stringId, args), caption,
        type | MB_SETFOREGROUND, GetGUILanguage());
}