Ejemplo n.º 1
0
int StMObPopup(LVAL menu, int left, int top, LVAL window)
{
  HMENU theMenu;
  HWND w;
  POINT pt;

  if (window == NIL || (w = GETWINDOWADDRESS(window)) == 0)
    w = hWndFrame;

  pt.x = left; pt.y = top;
  ClientToScreen((HWND) w, &pt);
  left = pt.x; top = pt.y;

  InPopup = TRUE;
  PopupItem = 0;
  StMObAllocate(menu);
  theMenu = get_menu_address(menu);
  if (TrackPopupMenu((HMENU) theMenu, 0, left, top, 0, (HWND) w, NULL)) {
    MSG msg;
    extern HWND hWndClient;
    extern HACCEL hAccel;
    if (PeekMessage(&msg, w, WM_COMMAND, WM_COMMAND, PM_REMOVE) &&
        ! TranslateMDISysAccel(hWndClient, &msg) &&
        ! TranslateAccelerator(hWndFrame, hAccel, &msg)) {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
  }
  StMObDispose(menu);
  InPopup = FALSE;

  return(PopupItem);
}
Ejemplo n.º 2
0
/*
================
rvGEApp::TranslateAccelerator

Translate any accelerators destined for this window
================
*/
bool rvGEApp::TranslateAccelerator ( LPMSG msg )
{
    HWND focus;

    if ( msg->message == WM_SYSCHAR )
    {
        SetFocus ( GetMDIClient ( ) );
        msg->hwnd = GetMDIClient ( );
    }

    if ( mViewer )
    {
        return false;
    }

    focus = GetActiveWindow ( );

    // Only use accelerators when on the main window or navigator window
    if ( focus == mMDIClient || focus == mMDIFrame ||
            focus == GetNavigator().GetWindow ( ) )
    {
        if ( ::TranslateAccelerator ( mMDIFrame, mAccelerators, msg ) )
        {
            return true;
        }
    }

    if ( TranslateMDISysAccel ( mMDIClient, msg ) )
    {
        return true;
    }

    return false;
}
Ejemplo n.º 3
0
WPARAM mdi_window::messageLoop()
{
  MSG	msg;  
  
  bool done = false;
  while (!done)
  {     
    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))	               
    {
      if (msg.message == WM_QUIT)
        done = true;					
      else							
      {
        if (!TranslateMDISysAccel(&msg))
        {
          TranslateMessage(&msg);				// Translate The Message
          DispatchMessage(&msg);				// Dispatch The Message
        }
        
        switch (msg.message)
        {
          case WM_KEYDOWN: keys[msg.wParam] =  true; break;
          case WM_KEYUP:   keys[msg.wParam] = false; break;
        }
      }
    }
  }
  
  return msg.wParam;
}
/****************************************************************************
*
*     FUNCTION: WinMain
*
*     PURPOSE:  Main entry point for this app
*
*     PARAMS:   HANDLE hInstance     - This instance
*               HANDLE hPrevInstance - Previous instance
*               LPSTR  lpszCmdLine   - Command Line
*               int    nCmdShow      - Desired window status
*
*     RETURNS:  int - return code
*
* History:
*                July '95 - Created
*
\****************************************************************************/
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
    MSG msg;

    // standard init stuff
    if( ! hPrevInstance )
    {
        if( ! InitApplication( hInstance ) )
        {
            return FALSE;
        }
    }
    if( ! InitInstance( hInstance, nCmdShow ) )
    {
        return FALSE;
    }

    // Standard message loop
    while (GetMessage(&msg, (HWND) NULL, 0, 0)) 
    {
        if( !TranslateMDISysAccel(hMDIClientWnd, &msg) )
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    return msg.wParam;
}
Ejemplo n.º 5
0
/*
 * WinMain - main entry point
 */
int WINMAINENTRY WinMain( HINSTANCE currinst, HINSTANCE previnst,
                          LPSTR cmdline, int cmdshow )
{
    MSG         msg;

    cmdline = cmdline;
#if defined( __NT__ ) && !defined( __WATCOMC__ )
    _argc = __argc;
    _argv = __argv;
#endif
    WRInit();

    if( _argc > 1 ) {
        parseArgs( _argc, _argv );
    }

    if( !imgEditInit( currinst, previnst, cmdshow ) ) {
        if( ImgedIsDDE ) {
            IEDDEDumpConversation( currinst );
        }
        return( 0 );
    }

    if( ImgedIsDDE ) {
        if( IEDDEStart( currinst ) ) {
            if( !IEDDEStartConversation() ) {
                WImgEditError( WIE_DDE_INIT_FAILED, NULL );
                PostMessage( HMainWindow, WM_CLOSE, (WPARAM)1, 0 );
            }
        } else {
            WImgEditError( WIE_DDE_INIT_FAILED, NULL );
            PostMessage( HMainWindow, WM_CLOSE, (WPARAM)1, 0 );
        }
    }

    IEEnableMenuInput( TRUE );

    if( _argc > 1 ) {
        parseCmdLine( _argc, _argv );
    }

    while( GetMessage( &msg, (HWND)NULL, 0, 0 ) ) {
        if( !TranslateMDISysAccel( ClientWindow, &msg ) &&
            !TranslateAccelerator( HMainWindow, hAccel, &msg ) ) {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
    }

    if( ImgedIsDDE ) {
        IEDDEEndConversation();
        IEDDEEnd();
    }

    imgEditFini();
    WRFini();
    return( 1 );

} /* WinMain */
Ejemplo n.º 6
0
bool WdeWasAcceleratorHandled( MSG *msg )
{
    if( !TranslateMDISysAccel( hWinWdeMDIClient, msg ) &&
        !TranslateAccelerator( hWinWdeMain, WdeAccel, msg ) ) {
        return( FALSE );
    }
    return( TRUE );
}
Ejemplo n.º 7
0
Bool WREWasAcceleratorHandled( MSG *msg )
{
    if( !TranslateMDISysAccel( WREMDIWin, msg ) &&
            !TranslateAccelerator( WREMainWin, WREAccel, msg ) ) {
        return( FALSE );
    }
    return( TRUE );
}
Ejemplo n.º 8
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
		LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wc;
	wc.cbSize			= sizeof(WNDCLASSEX);
	wc.style			= 0;
	wc.lpfnWndProc		= WndProc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hInstance		= hInstance;
	wc.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground	= (HBRUSH)(COLOR_WINDOW + 1);
	wc.lpszMenuName		= MAKEINTRESOURCE(IDR_MAINMENU);
	wc.lpszClassName	= g_szClassName;
	wc.hIconSm			= LoadIcon(NULL, IDI_APPLICATION);

	if (!RegisterClassEx(&wc))
	{
		MessageBox(NULL, "Window Registration Failed", "Error", MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	if (!SetUpMDIChildWindowClass(hInstance))
		return 0;

	HWND hwnd;
	hwnd = CreateWindowEx(
			0, 
			g_szClassName, 
			"theForger's Tutorial Application",
			WS_OVERLAPPEDWINDOW,
			CW_USEDEFAULT, CW_USEDEFAULT, 480, 320,
			NULL, NULL, hInstance, NULL);

	if (hwnd == NULL)
	{
		MessageBox(NULL, "Window Creation Failed!", "Error!",
				MB_ICONEXCLAMATION | MB_OK);
		return 0;
	}

	g_hMainWindow = hwnd;

	ShowWindow(hwnd, nCmdShow);
	UpdateWindow(hwnd);

	MSG Msg;
	while (GetMessage(&Msg, NULL, 0, 0) > 0)
	{
		if (!TranslateMDISysAccel(g_hMDIClient, &Msg))
		{
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}
	}
	return Msg.wParam;
}
Ejemplo n.º 9
0
void HandleCleanRequest (CrossCallInfo * pcci)
{
	switch (pcci->mess)
	{
		case CcRqDOMESSAGE: 	// idleTimerOn, sleeptime; no result.
			{
				MSG ms;
				int msgresult;

				msgresult  = GetMessageQuickly ((BOOL)pcci->p1, (int)pcci->p2, &ms);

				if (msgresult == -1)
					ErrorExit ("Fatal error: CcRqDoMessage, GetMessage result is -1");
				else if (msgresult == FALSE)
					ErrorExit ("Fatal error: CcRqDoMessage, GetMessage result is FALSE (WM_QUIT)");
				else
				{
					if (!gActiveDialog || !IsDialogMessage (gActiveDialog, &ms))
					{
						if (ghActiveClientWindow==NULL || !TranslateMDISysAccel (ghActiveClientWindow, &ms))
						{
							if (!gAcceleratorTableIsUpToDate)
							{	// Verify the correctness of gAcceleratorTable
								gAcceleratorTable = UpdateAcceleratorTable (gAcceleratorTable,ghActiveFrameWindow);
							}

							if (gAcceleratorTable==NULL || !TranslateAccelerator (ghActiveFrameWindow, gAcceleratorTable, &ms))
							{
								{
									TranslateMessage (&ms);
									DispatchMessage (&ms);
								}
							}
						}
					}
					MakeReturn0Cci (pcci);
				}
			}
			break;
		default:
			{
				CrossCallProcedure action;

				action = FindCrossCallEntry (gCrossCallProcedureTable, pcci->mess);

				if (action == NULL)
				{	// Cross call request code not installed.
					ErrorExit ("\'HandleCleanRequest\' got uninstalled CcRq request code from Clean: %d\n", pcci->mess);
				}
				else
				{	// Cross call request code found. Apply it to pcci.
					action (pcci);
				}
			}
	}
	KickCleanThread (pcci);
}	/* HandleCleanRequest */
Ejemplo n.º 10
0
//
/// Preprocess messages in order to translate MDI accelerator keys
///
/// If the specified msg is one of WM_KEYDOWN or WM_SYSKEYDOWN, then the keyboard
/// accelerators are translated for the MDI client.
//
bool
TMDIClient::PreProcessMsg(MSG& msg)
{
  if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN)
    return TranslateMDISysAccel(GetHandle(), &msg);

  else
    return false;
}
Ejemplo n.º 11
0
/*------------------------------------------------------------------------
Procedure:     WinMain ID:1
Purpose:       Entry point for windows programs.
Input:
Output:
Errors:
------------------------------------------------------------------------*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
	MSG msg;
	HANDLE hAccelTable;
	char consoleTitle[512];
	HWND hwndConsole;

	CurrentEditBuffer = (EditBuffer*)SafeMalloc(sizeof(EditBuffer));
	CurrentEditBuffer->LineCount = 0;
	CurrentEditBuffer->Lines = NULL;

	//setup the history index pointer
	historyEntry = NULL;

	// Setup the hInst global
	hInst = hInstance;
	// Do the setup
	if (!Setup(&hAccelTable))
		return 0;
	// Need to set up a console so that we can send ctrl-break signal
	// to inferior Caml
	AllocConsole();
	GetConsoleTitle(consoleTitle,sizeof(consoleTitle));
	hwndConsole = FindWindow(NULL,consoleTitle);
	ShowWindow(hwndConsole,SW_HIDE);
	// Create main window and exit if this fails
	if ((hwndMain = CreateinriaWndClassWnd()) == (HWND)0)
		return 0;
	// Create the status bar
	CreateSBar(hwndMain,"Ready",2);
	// Show the window
	ShowWindow(hwndMain,SW_SHOW);
	// Create the session window
	hwndSession = MDICmdFileNew("Session transcript",0);
	// Get the path to ocaml.exe
	GetOcamlPath();
	// Start the interpreter
	StartOcaml();
	// Show the session window
	ShowWindow(hwndSession, SW_SHOW);
	// Maximize it
	SendMessage(hwndMDIClient, WM_MDIMAXIMIZE, (WPARAM) hwndSession, 0);

	PostMessage(hwndMain,WM_USER+1000,0,0);
	while (GetMessage(&msg,NULL,0,0)) {
		if (!TranslateMDISysAccel(hwndMDIClient, &msg))
			if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
				TranslateMessage(&msg);  // Translates virtual key codes
				DispatchMessage(&msg);   // Dispatches message to window
			}
	}
	WriteToPipe("#quit;;\r\n\032");
	KillTimer((HWND) 0, TimerId);
	return msg.wParam;
}
Ejemplo n.º 12
0
int CMainWindow::DoModal()
{
    MSG msg;

    while (GetMessage(&msg, NULL, 0, 0)) 
    {
        if (!TranslateMDISysAccel(m_hMDIClient, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}
Ejemplo n.º 13
0
BOOL
MainWndTranslateMDISysAccel(HWND hwnd,
                            LPMSG lpMsg)
{
    PMAIN_WND_INFO Info;

    /* Get the window context */
    Info = (PMAIN_WND_INFO)GetWindowLongPtr(hwnd,
                                            GWLP_USERDATA);
    if (Info != NULL && Info->hMdiClient != NULL)
    {
        return TranslateMDISysAccel(Info->hMdiClient,
                                    lpMsg);
    }

    return FALSE;
}
/*
	WinMain
*/
int CALLBACK WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    MSG    msg;
    HANDLE hAccel;

	// Store our module handle
    ghModule = GetModuleHandle(NULL);

	// Initialize QuickTime Media Layer
	InitializeQTML(0);

	// Initialize QuickTime
	EnterMovies();

	// Initialize the app
    if (!InitializeApp()) 
    {
        MessageBox(ghwndMain, "MDI: InitializeApp failure!", "Error", MB_OK);
        return 0;
    }

	// Load our accelerator keys
    if (!(hAccel = LoadAccelerators (ghModule, MAKEINTRESOURCE(ACCEL_ID))))
        MessageBox(ghwndMain, "MDI: Load Accel failure!", "Error", MB_OK);

	// Parse the command line for drag and drop
	ParseCmdLinePriv(NULL);

	// Loop for messages
    while (GetMessage(&msg, NULL, 0, 0)) {
        if (!TranslateAccelerator( ghwndMain, hAccel, &msg) &&
            !TranslateMDISysAccel(  ghwndClient, &msg)          ) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

	// Deinitialize QuickTime
	ExitMovies();

	// Deinitialize QTML
	TerminateQTML();

    return TRUE;
}
Ejemplo n.º 15
0
Archivo: main.c Proyecto: GYGit/reactos
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    MSG msg;
//    HACCEL hAccel;
    HWND hMDIClient;

    // Initialize global strings
    LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadString(hInstance, IDC_MDI_APP, szFrameClass, MAX_LOADSTRING);
    LoadString(hInstance, IDC_MDI_APP_CHILD, szChildClass, MAX_LOADSTRING);

    // Allow only one running instance
    EnumWindows(EnumWndProc, (LPARAM)szFrameClass);
    if (g_foundPrevInstance)
        return 1;

    // Store instance handle in our global variable
    hInst = hInstance;

    // Perform application initialization:
    if (!InitInstance(hInstance, nCmdShow)) {
        return FALSE;
    }
//    hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_MDI_APP);
    hMDIClient = GetWindow(hFrameWnd, GW_CHILD);

    // Main message loop:
    while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
        if (!TranslateMDISysAccel(hMDIClient, &msg) &&
            !TranslateAccelerator(hFrameWnd, hAccel, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    ExitInstance();
    return msg.wParam;
}
Ejemplo n.º 16
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 显示主窗口,并建立消息循环,等待运行完成
VOID CMainWnd::Show(PCTSTR ptzCmdLine, INT iCmdShow)
{
	MSG msgMsg;
	HACCEL hAccel;

	// 显示主窗口
	if (iCmdShow <= SW_NORMAL)
	{
		iCmdShow = _Bound(CIni::GetInt(INI_WindowState), SW_NORMAL, SW_MAX);
	}
	ShowWindow(m_hWnd, iCmdShow);

	// 载入菜单加速键
	hAccel = LoadAccelerators(g_hInst, MAKEINTRESOURCE(IDR_Accel));

	// 处理命令行
	if (ptzCmdLine && ptzCmdLine[0])
	{
		OnFileOpen(ptzCmdLine);
	}
	else if (CIni::GetInt(INI_ShowOpen))
	{
		PostMessage(m_hWnd, WM_COMMAND, IDM_File_Open, 0);
	}

	// 消息循环
	while (GetMessage(&msgMsg, NULL, 0, 0))
	{
		if ((TranslateMDISysAccel(CClientWnd::m_hWnd, &msgMsg) == 0) &&
			(TranslateAccelerator(m_hWnd, hAccel, &msgMsg) == 0))
		{
			TranslateMessage(&msgMsg);
			DispatchMessage(&msgMsg);
		}
	}
}
Ejemplo n.º 17
0
/*
 * MessageLoop - wait for a message to occur
 */
void MessageLoop( bool block )
{
    MSG         msg;
    UINT        rc;

    if( block ) {
        if( !PeekMessage( &msg, (HWND)NULLHANDLE, 0, 0, PM_NOYIELD | PM_NOREMOVE ) ) {
            CloseStartupDialog();
            rc = GetMessage( &msg, (HWND)NULLHANDLE, 0, 0 );
            if( !rc ) {
                exit( msg.wParam );
            }
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
    }
    if( !EditFlags.KeyOverride ) {
        while( PeekMessage( &msg, (HWND)NULLHANDLE, 0, 0, PM_NOYIELD | PM_NOREMOVE ) ) {
            rc = GetMessage( &msg, (HWND)NULLHANDLE, 0, 0 );
            if( !rc ) {
                exit( msg.wParam );
            }
            if( (hColorbar == 0 || !IsDialogMessage( hColorbar, &msg )) &&
                (hSSbar == 0 || !IsDialogMessage( hSSbar, &msg )) &&
                (hFontbar == 0 || !IsDialogMessage( hFontbar, &msg )) &&
                !TranslateMDISysAccel( EditContainer, &msg ) ) {
                TranslateMessage( &msg );
                DispatchMessage( &msg );
                if( EditFlags.KeyOverride ) {
                    break;
                }
            }
        }
    }

} /* MessageLoop */
Ejemplo n.º 18
0
/******************************************************************************
 *  int WinMain(
 *      HINSTANCE hinstCurrent,
 *      HINSTANCE hinstPrevious,
 *      LPSTR     lpszCmdLine,
 *      int       nCmdShow);
 * 
 *  windows initialization and exit
 *
 *  parameters:
 *      hinstCurrent - handle to this instance of minerva
 *      hinstPrevious - handle to previous instance of minerva. If hinstPrevious is
 *          NULL, no other instance is active (this is the first and only instance).
 *      lpszCmdLine - command line parameters to this instance
 *      nCmdShow - see ShowWindow() documentation
 *
 *  returns:  
 *      value to be set as exit code for application
 *
 *  notes:
 *      WinMain is called as the application is starting up.  When WinMain returns,
 *      the application is terminated.
 ******************************************************************************/
int PASCAL WinMain(
    HINSTANCE hinstCurrent,     /* handle to this instance */
    HINSTANCE hinstPrevious,    /* handle to previous instance or NULL */
    LPSTR     lpszCmdLine,      /* command line */
    int       nCmdShow)         /* see ShowWindow() documentation */
{
    MSG msg;
	LPCSTR psz;
    
    NOREFERENCE(lpszCmdLine);

    /* make SURE that (LPBITMAPINFO)&PIC_PARM.Head is valid */
    assert(offsetof(PIC_PARM,   ColorTable) - offsetof(PIC_PARM,   Head) ==
           offsetof(BITMAPINFO, bmiColors)  - offsetof(BITMAPINFO, bmiHeader));
    
    hinstThis = hinstCurrent;   /* instance handle is globally accessible */

    /* allow ctl3d to hook us */
    Ctl3dRegister(hinstThis);
    /* dialogs and controls are automatically 3d */
    Ctl3dAutoSubclass(hinstThis);
    
    if ( hinstPrevious == NULL )
        {
        /* register window classes for first instance only
            hinstPrevious == NULL if and only if this is the only active
            instance of minerva */
        if ( !RegisterWindowClasses() )
            {
            Ctl3dUnregister(hinstCurrent);
            return ( 0 );
            }
        }

    /* keyboard accelerators for menu commands */
    hAcceleratorTable = LoadAccelerators(hinstThis, "MinervaAccelerators");
    if ( hAcceleratorTable == NULL )
        {
        ErrorMessage(STYLE_FATAL, IDS_LOADACCELERATORS);
        /* "An unexpected LoadAccelerators error occurred. Minerva cannot continue." */
        Ctl3dUnregister(hinstCurrent);
        return ( 0 );
        }

    if ( !CreateFrameWindow(nCmdShow) )
        {
        Ctl3dUnregister(hinstCurrent);
        return ( 0 );
        }

    /* load MRU file list from minerva.ini and update File menu */
    if ( !MruLoadList(hwndFrame, APPLICATION_INIFILENAME) )
        {
        DestroyWindow(hwndFrame);
        Ctl3dUnregister(hinstCurrent);
        return ( 0 );
        }

    hWaitCursor  = LoadCursor(NULL, IDC_WAIT);
    hArrowCursor = LoadCursor(NULL, IDC_ARROW);
    hHandCursor  = LoadCursor(hinstThis, MAKEINTRESOURCE(IDC_HAND));
    assert(hWaitCursor != NULL && hArrowCursor != NULL && hHandCursor != NULL);
    
    /* load PIC opcode DLL's */
    InitOpList();

    bDisableRDTSC = GetPrivateProfileInt("Settings", "DisableRDTSC", 0, APPLICATION_INIFILENAME);
	psz = lpszCmdLine + _fstrspn(lpszCmdLine, " ");
	while ( psz != 0 && ( *psz == '-' || *psz == '/' || *psz == '+' ) )
	{
		if ( _fstrnicmp(psz + 1, "RDTSC", sizeof("RDTSC") - 1) == 0 && psz[sizeof("RDTSC")] <= ' ' )
			bDisableRDTSC = *psz != '+';
		psz = _fstrpbrk(psz, " ");
		if ( psz != 0 )
			psz += _fstrspn(psz, " ");
	}
	if ( !bDisableRDTSC )
		MiscTickCount();	// calibrate the RDTSC ticks

    while ( GetMessage(&msg, NULL, 0, 0) )
        {
        if ( !TranslateMDISysAccel(hwndMDIClient, &msg) &&
             !TranslateAccelerator(hwndFrame, hAcceleratorTable, &msg) )
            {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
            }
        }
        
    DestroyCursor(hHandCursor);
    /* unload PIC opcode DLL's */
    CleanupOpList();

    /* save MRU file list to minerva.ini */
    MruSaveList(APPLICATION_INIFILENAME);

    Ctl3dUnregister(hinstCurrent);

    return ( msg.wParam );
}
Ejemplo n.º 19
0
int CALLBACK WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR theCmdLine, int nCmdShow)
{
	HANDLE				myAccel;
	HWND				myWindowFrame;
	MSG					myMsg;
    WNDCLASSEX			myWC;
	char				myFileName[MAX_PATH];
	DWORD				myLength;
	OSErr				myErr = noErr;

	ghInst = hInstance;
	gCmdLine = theCmdLine;
	
	if (hPrevInstance == NULL) {
		LoadString(hInstance, IDS_APPNAME, gAppName, sizeof(gAppName));
		
		// register the frame window class
		myWC.cbSize        = sizeof(WNDCLASSEX);
		myWC.style         = CS_HREDRAW | CS_VREDRAW;
		myWC.lpfnWndProc   = (WNDPROC)QTFrame_FrameWndProc;
		myWC.cbClsExtra    = 0;
		myWC.cbWndExtra    = 0;
		myWC.hInstance     = hInstance;
		myWC.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
		myWC.hCursor       = LoadCursor(NULL, IDC_ARROW);
		myWC.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
		myWC.lpszMenuName  = gAppName;
		myWC.lpszClassName = gAppName;
		myWC.hIconSm       = LoadImage(hInstance, MAKEINTRESOURCE(IDI_APPICON), IMAGE_ICON, 16, 16, 0);
									 
		if (!RegisterClassEx(&myWC)) {
			if (!RegisterClass((LPWNDCLASS)&myWC.style))
        		return(0);
		}

		// register the movie child window class
		myWC.cbSize        = sizeof(WNDCLASSEX);
		myWC.style         = 0;
		myWC.lpfnWndProc   = (WNDPROC)QTFrame_MovieWndProc;
		myWC.cbClsExtra    = 0;
		myWC.cbWndExtra    = 0;
		myWC.hInstance     = hInstance;
		myWC.hIcon         = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CHILDICON));
		// to avoid having QuickTime VR "fight" with the system over the cursor,
		// we set the client area cursor to NULL; this means that for QuickTime
		// movies, we'll need to change the cursor to an arrow manually; see the
		// handling of the WM_MOUSEMOVE message in QTFrame_MovieWndProc
		myWC.hCursor       = NULL;
		myWC.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
		myWC.lpszMenuName  = NULL;
		myWC.lpszClassName = gChildName;
		myWC.hIconSm       = LoadImage(hInstance, MAKEINTRESOURCE(IDI_CHILDICON), IMAGE_ICON, 16, 16, 0);
									 
		if (!RegisterClassEx(&myWC)) {
			if (!RegisterClass((LPWNDCLASS)&myWC.style))
        		return(0);
		}
	}

	// load accelerators
	myAccel = LoadAccelerators(hInstance, gAppName);

	// initialize QuickTime Media Layer and QuickTime; alert the user and return 0 if unsuccessful
	myErr = InitializeQTML(0L);
	if (myErr != noErr) {
		MessageBox(NULL, "QuickTime is not installed on this computer. Exiting.", gAppName, MB_OK | MB_APPLMODAL);
		return(0);
	}
	
	myErr = EnterMovies();
	if (myErr != noErr) {
		MessageBox(NULL, "Could not initialize QuickTime. Exiting.", gAppName, MB_OK | MB_APPLMODAL);
		return(0);
	}

	// get the application's resource file, if it exists
	myLength = GetModuleFileName(NULL, myFileName, MAX_PATH);		// NULL means: the current process
	if (myLength != 0) {
		NativePathNameToFSSpec(myFileName, &gAppFSSpec, kFullNativePath);

		gAppResFile = FSpOpenResFile(&gAppFSSpec, fsRdWrPerm);
		if (gAppResFile != kInvalidFileRefNum)
			UseResFile(gAppResFile);
	}
	
	// do any application-specific initialization that must occur before the frame window is created
	QTApp_Init(kInitAppPhase_BeforeCreateFrameWindow);
	
	// create the main frame window
	myWindowFrame = CreateWindow(gAppName, gAppName, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                               		CW_USEDEFAULT, 
                               		CW_USEDEFAULT,
                             		CW_USEDEFAULT, 
                             		CW_USEDEFAULT,
                             		NULL, 
                             		NULL, 
                             		hInstance, 
                             		NULL);
	ghWnd = myWindowFrame;
	
	// make sure we got a frame window
	if (myWindowFrame == NULL)
		return(0);
		
	// show the window
	ShowWindow(myWindowFrame, nCmdShow);
	UpdateWindow(myWindowFrame);
	
	// do any application-specific initialization that must occur after the frame window is created
	QTApp_Init(kInitAppPhase_AfterCreateFrameWindow);
	
	// get and process events until the user quits
    while (GetMessage(&myMsg, NULL, 0, 0)) {	
		if (!TranslateMDISysAccel(ghWndMDIClient, &myMsg)) {
        	if (!TranslateAccelerator(myWindowFrame, myAccel, &myMsg)) {
                TranslateMessage(&myMsg);
                DispatchMessage(&myMsg);
			}
		}
    }

	// close the application's resource file, if it was previously opened
	if (gAppResFile != kInvalidFileRefNum)
		CloseResFile(gAppResFile);

	// terminate the QuickTime Media Layer
	ExitMovies();
	TerminateQTML();

	return(myMsg.wParam);			// returns the value from PostQuitMessage
}
Ejemplo n.º 20
0
WPARAM CFidgetApp::Run(void)
{
    HACCEL hAccelTable = LoadAccelerators(m_hInstance, (LPCTSTR)IDC_FIDGET);

    // Main message loop:
    //
    WPARAM iReturn = 0;
    bool bFinished = false;
    while (!bFinished)
    {
        CLinearTimeAbsolute ltaCurrent;
        ltaCurrent.GetUTC();

        // Execute background tasks at specifically scheduled times.
        //
        scheduler.RunTasks(ltaCurrent);
        CLinearTimeAbsolute ltaWakeUp;
        if (!scheduler.WhenNext(&ltaWakeUp))
        {
            ltaWakeUp = ltaCurrent + time_30m;
        }
        else if (ltaWakeUp < ltaCurrent)
        {
            // This is necessary to deal with computer time jumping backwards
            // which can happen when someone sets or resets the computer clock.
            //
            ltaWakeUp = ltaCurrent;
        }

        CLinearTimeDelta ltdTimeOut = ltaWakeUp - ltaCurrent;
        DWORD dwTimeout = ltdTimeOut.ReturnMilliseconds();

        DWORD nHandles = 0;
        DWORD dwObject = MsgWaitForMultipleObjectsEx(nHandles, NULL, dwTimeout, QS_ALLINPUT, 0);
        if (WAIT_OBJECT_0 + nHandles == dwObject)
        {
            for (; !bFinished;)
            {
                // There is at least one new message waiting to be processed.
                //
                MSG msg;
                BOOL bGM = GetMessage(&msg, NULL, 0, 0);
                if (0 == bGM)
                {
                    // WM_QUIT message was received. It is time to terminate
                    // ourselves.
                    //
                    iReturn = msg.wParam;
                    bFinished = true;
                }
                else if (-1 == bGM)
                {
                    // An unexpected problem occured.
                    //
                    bFinished = true;
                }
                else
                {
                    // Translate and dispatch message to Windows Procedure.
                    //
                    if (  (  NULL == m_hwndNewSession
                          || !IsDialogMessage(m_hwndNewSession, &msg))
                       && (  NULL == m_hwndAbout
                          || !IsDialogMessage(m_hwndAbout, &msg))
                       && !TranslateMDISysAccel(g_theApp.m_pMainFrame->m_pMDIControl->m_hwnd, &msg)
                       && !TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                    {
                        TranslateMessage(&msg);
                        DispatchMessage(&msg);
                    }
                }

                // We must process all messages in the queue before making
                // another MsgWaitForMultipleObjectsEx() call.
                //
                if (!PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE|PM_NOYIELD))
                {
                    break;
                }
            }
        }
        else if (WAIT_TIMEOUT != dwObject)
        {
            // An unexpected event occured.
            //
            bFinished = true;
        }

        // It's time to perform some background task.
        //
    }
    DestroyAcceleratorTable(hAccelTable);
    return iReturn;
}
Ejemplo n.º 21
0
int PASCAL WinMain(
    HINSTANCE hinst,
    HINSTANCE hinstPrev,
    LPSTR lpCmdLine,
    int nCmdShow)
{
    MSG msg;
    int RemoveCursor = TRUE;

    ghinst = hinst;


    // if command line option exist

    if (lpCmdLine[0]) {
	LPSTR cmdArg;
	if ( cmdArg = strstr ( lpCmdLine, "-a"))     //automation switch
	    AutoRun = TRUE;
	if ( cmdArg = strstr ( lpCmdLine, "-m"))     //cursor stays
	    RemoveCursor = FALSE;
    }

    /*
     * If this is the first instance of the app. register window classes
     */

    if (hinstPrev == NULL)
        if (!InitializeApplication())
            return 0;

    /*
     * Create the frame and do other initialization
     */

    if (!InitializeInstance(nCmdShow))
        return 0;


    if (RemoveCursor)
	ShowCursor(0);

    /*
     * Enter main message loop
     */

    while (GetMessage(&msg, NULL, 0, 0)) {

	if (AutoRun) {
	    AutoTest();
	    break;
	}

        /*
         * If a keyboard message is for the MDI, let the MDI client
         * take care of it.  Otherwise, check to see if it's a normal
         * accelerator key (like F3 = find next).  Otherwise, just handle
         * the message as usual.
         */
        if (!TranslateMDISysAccel(ghwndMDIClient, &msg) &&
                !TranslateAccelerator(ghwndFrame, ghaccel, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    if (AutoRun)
	PostQuitMessage(0);


    return 0;
}
Ejemplo n.º 22
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	MSG msg;
    INITCOMMONCONTROLSEX ctrls;
	HACCEL haccel;
	static char *class_name="DB_UTIL_CLASS";
	int first_instance=TRUE;
	int debug=0;

	first_instance=set_single_instance(TRUE);

	ghinstance=hInstance;
	init_ini_file();

#ifdef _DEBUG
	debug=1;
#else
	get_ini_value("SETTINGS","DEBUG",&debug);
#endif
	if(debug!=0){
		open_console();
	}

	{
		int val=0;
		get_ini_value("SETTINGS","SINGLE_INSTANCE",&val);
		if(val && (!first_instance)){
			COPYDATASTRUCT cd={0};
			HWND hdbutil;
			cd.cbData=nCmdShow;
			cd.cbData=strlen(lpCmdLine)+1;
			cd.lpData=lpCmdLine;
			hdbutil=FindWindow("DB_UTIL_CLASS",NULL);
			if(hdbutil!=0){
				int sw;
				SendMessage(hdbutil,WM_COPYDATA,hInstance,&cd);
				if (IsZoomed(hdbutil))
					sw=SW_MAXIMIZE;
				else if(IsIconic(hdbutil))
					sw=SW_RESTORE;
				else
					sw=SW_SHOW;
				ShowWindow(hdbutil,sw);
				SetForegroundWindow(hdbutil);
			}
			return TRUE;
		}
		set_single_instance(val);
	}
	init_mdi_stuff();

	LoadLibrary("RICHED20.DLL");
	LoadLibrary("Msftedit.dll");

	ctrls.dwSize=sizeof(ctrls);
    ctrls.dwICC = ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES;
	InitCommonControlsEx(&ctrls);
	
	InitializeCriticalSection(&mutex);

	start_worker_thread();
	start_intellisense_thread();

	setup_mdi_classes(ghinstance);
	
	ghmenu=LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1));
	ghmainframe=create_mainwindow(&WndProc,ghmenu,hInstance,class_name,"DB_UTIL");

	ShowWindow(ghmainframe,nCmdShow);
	UpdateWindow(ghmainframe);

	haccel=LoadAccelerators(ghinstance,MAKEINTRESOURCE(IDR_ACCELERATOR1));

	process_cmd_line(lpCmdLine);

    while(GetMessage(&msg,NULL,0,0)){
		if(!custom_dispatch(&msg))
		if(!TranslateMDISysAccel(ghmdiclient, &msg) && !TranslateAccelerator(ghmainframe,haccel,&msg)){
			TranslateMessage(&msg);
			//if(msg!=WM_MOUSEFIRST&&msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_NOTIFY)
			if(FALSE)
			if(msg.message!=0x118&&msg.message!=WM_NCHITTEST&&msg.message!=WM_SETCURSOR&&msg.message!=WM_ENTERIDLE&&msg.message!=WM_NCMOUSEMOVE&&msg.message!=WM_MOUSEFIRST)
			{
				static DWORD tick=0;
				if((GetTickCount()-tick)>500)
					printf("--\n");
				printf("x");
				print_msg(msg.message,msg.lParam,msg.wParam,msg.hwnd);
				tick=GetTickCount();
			}
			DispatchMessage(&msg);
		}
    }
	DeleteCriticalSection(&mutex);
    return msg.wParam;
	
}
static BOOL ProcessMDIAccels(LPMSG PMessage, PTApplication Application)
{
        return (PTWindowsObject)(Application->MainWindow->GetClient()) &&
           TranslateMDISysAccel(
            ((PTWindowsObject)(Application->MainWindow->GetClient()))->HWindow, PMessage);
}
Ejemplo n.º 24
0
//
// Main Program
//
int WINAPI WinMain(
  HINSTANCE Instance,
  HINSTANCE /* Previous_Instance */,
  LPSTR     Command_Line,
  int       Command_Show
  )
  {
    HWND    Frame_Window;  // Handle to the main application window.
    HWND    Client_Window; // Handle to the MDI client window (the workspace).
    MSG     Message;

    try {

      // Initialize global data as needed.
      Global::Set_Instance(Instance);
      Global::Set_CommandLine(Command_Line);
      Global::Set_CommandShow(Command_Show);

      // These strings are initialized here to be sure the "Big String Lock"
      // has been initialized before these Strings are constructed. Also for
      // the destructor (actually these strings are currently not destoryed.
      //
      Version_Number = new spica::String("1.0");
      Full_Name      = new spica::String;
      Email_Address  = new spica::String;

      Tracer(1, "NBread initializing...");

      // Read the registry to see how we are configured (or dialog with the user).
      Check_Configuration();

      string *Top_Path = spica::lookup_parameter("Noticeboard_Root");
      if (Top_Path == 0)
        throw spica::Win32::API_Error("Can't locate the noticeboard directory tree");

      // This object manages the read notice database (the "history").
      // It must be created before any topic is created because the
      // topic's constructor will reference this database. Similarly
      // this object must persist after all topics have been destroyed
      // to insure that the most up to date history file will be written
      // back to disk.
      // 
      History Read_Notices;
      History_Database = &Read_Notices;

      // This object represents the top level topic. All the subtopics
      // and notices are contained in this object. When this object is
      // destroyed all the contained objects and subobects will also be
      // destroyed.
      //
      NB_Topic Top_Level(Top_Path->c_str());
      Current_Topic = &Top_Level;

      // Set up the various window classes that we'll need.
      Set_Classes();
      InitCommonControls();

      // Create a main window and display it.
      Frame_Window = CreateWindow(
        Frame_ClassName,
        "VTC Noticeboard Reader",
        WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        0,
        0,
        Instance,
        0
      );
      if (Frame_Window == 0)
        throw spica::Win32::API_Error("Can't create the frame window");

      Tracer(1, "Finished creating the MDI frame window.");
	
      // Get the MDI client window's handle.
      Client_Window = GetWindow(Frame_Window, GW_CHILD);

      ShowWindow(Frame_Window, Command_Show);
      UpdateWindow(Frame_Window);

      Tracer(1, "Entering main message dispatching loop...");

      // Get the next message from the application's message queue.
      while (GetMessage(&Message, 0, 0, 0)) {

        if (!TranslateMDISysAccel(Client_Window, &Message)) {
          TranslateMessage(&Message);
          DispatchMessage(&Message);
        }
      }

    }
    catch (spica::Win32::API_Error We) {
      spica::Win32::notifystream Error_Message;

      Error_Message << "Exception caught in WinMain\r" << We.what() << ends;
      Error_Message.say();
      return FALSE;
    }
    catch (...) {
      spica::Win32::notifystream Error_Message;

      Error_Message << "Unknown exception caught in WinMain" << ends;
      Error_Message.say();
      return FALSE;
    }

    return Message.wParam;
  }
Ejemplo n.º 25
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
#endif
{
  setbuf(stderr, 0);
  bool console = false;
  m_hInstResDLL = NULL;
  m_hInstResDLL = LoadLibrary("lang.dll");
  if (m_hInstResDLL==NULL)
  {
	  m_hInstResDLL = hInstance;
  }
  if (strcmp(szCmdLine,"")==0) command_line=false;
  
  LoadString(m_hInstResDLL, IDS_A1, sz_A1, 64 -1);
  LoadString(m_hInstResDLL, IDS_A2, sz_A2, 64 -1);
  LoadString(m_hInstResDLL, IDS_A3, sz_A3, 64 -1);
  LoadString(m_hInstResDLL, IDS_A4, sz_A4, 64 -1);
  LoadString(m_hInstResDLL, IDS_A5, sz_A5, 64 -1);
  LoadString(m_hInstResDLL, IDS_B1, sz_B1, 64 -1);
  LoadString(m_hInstResDLL, IDS_B2, sz_B2, 64 -1);
  LoadString(m_hInstResDLL, IDS_B3, sz_B3, 64 -1);
  LoadString(m_hInstResDLL, IDS_C1, sz_C1, 64 -1);
  LoadString(m_hInstResDLL, IDS_C2, sz_C2, 64 -1);
  LoadString(m_hInstResDLL, IDS_C3, sz_C3, 64 -1);
  LoadString(m_hInstResDLL, IDS_D1, sz_D1, 64 -1);
  LoadString(m_hInstResDLL, IDS_D2, sz_D2, 64 -1);
  LoadString(m_hInstResDLL, IDS_D3, sz_D3, 64 -1);
  LoadString(m_hInstResDLL, IDS_D4, sz_D4, 64 -1);
  LoadString(m_hInstResDLL, IDS_D5, sz_D5, 64 -1);
  LoadString(m_hInstResDLL, IDS_D6, sz_D6, 64 -1);
  LoadString(m_hInstResDLL, IDS_D7, sz_D7, 64 -1);
  LoadString(m_hInstResDLL, IDS_D8, sz_D8, 64 -1);
  LoadString(m_hInstResDLL, IDS_D9, sz_D9, 64 -1);
  LoadString(m_hInstResDLL, IDS_D10, sz_D10, 64 -1);
  LoadString(m_hInstResDLL, IDS_D11, sz_D11, 64 -1);
  LoadString(m_hInstResDLL, IDS_D12, sz_D12, 64 -1);
  LoadString(m_hInstResDLL, IDS_D13, sz_D13, 64 -1);
  LoadString(m_hInstResDLL, IDS_D14, sz_D14, 64 -1);
  LoadString(m_hInstResDLL, IDS_D15, sz_D15, 64 -1);
  LoadString(m_hInstResDLL, IDS_D16, sz_D16, 64 -1);
  LoadString(m_hInstResDLL, IDS_D17, sz_D17, 64 -1);
  LoadString(m_hInstResDLL, IDS_D18, sz_D18, 64 -1);
  LoadString(m_hInstResDLL, IDS_D19, sz_D19, 64 -1);
  LoadString(m_hInstResDLL, IDS_D20, sz_D20, 64 -1);
  LoadString(m_hInstResDLL, IDS_D21, sz_D21, 64 -1);
  LoadString(m_hInstResDLL, IDS_D22, sz_D22, 64 -1);
  LoadString(m_hInstResDLL, IDS_D23, sz_D23, 64 -1);
  LoadString(m_hInstResDLL, IDS_D24, sz_D24, 64 -1);
  LoadString(m_hInstResDLL, IDS_D25, sz_D25, 64 -1);
  LoadString(m_hInstResDLL, IDS_D26, sz_D26, 64 -1);
  LoadString(m_hInstResDLL, IDS_D27, sz_D27, 64 -1);
  LoadString(m_hInstResDLL, IDS_D28, sz_D28, 64 -1);
  LoadString(m_hInstResDLL, IDS_E1, sz_E1, 64 -1);
  LoadString(m_hInstResDLL, IDS_E2, sz_E2, 64 -1);
  LoadString(m_hInstResDLL, IDS_F1, sz_F1, 64 -1);
  LoadString(m_hInstResDLL, IDS_F3, sz_F3, 64 -1);
  LoadString(m_hInstResDLL, IDS_F4, sz_F4, 64 -1);
  LoadString(m_hInstResDLL, IDS_F5, sz_F5, 128 -1);
  LoadString(m_hInstResDLL, IDS_F6, sz_F6, 64 -1);
  LoadString(m_hInstResDLL, IDS_F7, sz_F7, 128 -1);
  LoadString(m_hInstResDLL, IDS_F8, sz_F8, 128 -1);
  LoadString(m_hInstResDLL, IDS_F10, sz_F10, 64 -1);
  LoadString(m_hInstResDLL, IDS_F11, sz_F11, 64 -1);
  LoadString(m_hInstResDLL, IDS_G1, sz_G1, 64 -1);
  LoadString(m_hInstResDLL, IDS_G1, sz_G2, 64 -1);
  LoadString(m_hInstResDLL, IDS_G1, sz_G3, 64 -1);

  LoadString(m_hInstResDLL, IDS_H1, sz_H1, 64 -1);
  LoadString(m_hInstResDLL, IDS_H2, sz_H2, 64 -1);
  LoadString(m_hInstResDLL, IDS_H3, sz_H3, 128 -1);
  LoadString(m_hInstResDLL, IDS_H4, sz_H4, 64 -1);
  LoadString(m_hInstResDLL, IDS_H5, sz_H5, 64 -1);
  LoadString(m_hInstResDLL, IDS_H6, sz_H6, 64 -1);
  LoadString(m_hInstResDLL, IDS_H7, sz_H7, 64 -1);
  LoadString(m_hInstResDLL, IDS_H8, sz_H8, 64 -1);
  LoadString(m_hInstResDLL, IDS_H9, sz_H9, 64 -1);
  LoadString(m_hInstResDLL, IDS_H10, sz_H10, 64 -1);
  LoadString(m_hInstResDLL, IDS_H11, sz_H11, 64 -1);
  LoadString(m_hInstResDLL, IDS_H12, sz_H12, 64 -1);
  LoadString(m_hInstResDLL, IDS_H13, sz_H13, 64 -1);
  LoadString(m_hInstResDLL, IDS_H14, sz_H14, 64 -1);
  LoadString(m_hInstResDLL, IDS_H15, sz_H15, 64 -1);
  LoadString(m_hInstResDLL, IDS_H16, sz_H16, 64 -1);
  LoadString(m_hInstResDLL, IDS_H17, sz_H17, 64 -1);
  LoadString(m_hInstResDLL, IDS_H18, sz_H18, 64 -1);
  LoadString(m_hInstResDLL, IDS_H19, sz_H19, 64 -1);
  LoadString(m_hInstResDLL, IDS_H20, sz_H20, 64 -1);
  LoadString(m_hInstResDLL, IDS_H21, sz_H21, 64 -1);
  LoadString(m_hInstResDLL, IDS_H22, sz_H22, 64 -1);
  LoadString(m_hInstResDLL, IDS_H23, sz_H23, 64 -1);
  LoadString(m_hInstResDLL, IDS_H24, sz_H24, 64 -1);
  LoadString(m_hInstResDLL, IDS_H25, sz_H25, 64 -1);
  LoadString(m_hInstResDLL, IDS_H26, sz_H26, 64 -1);
  LoadString(m_hInstResDLL, IDS_H27, sz_H27, 64 -1);
  LoadString(m_hInstResDLL, IDS_H28, sz_H28, 64 -1);
  LoadString(m_hInstResDLL, IDS_H29, sz_H29, 64 -1);
  LoadString(m_hInstResDLL, IDS_H30, sz_H30, 64 -1);
  LoadString(m_hInstResDLL, IDS_H31, sz_H31, 64 -1);
  LoadString(m_hInstResDLL, IDS_H32, sz_H32, 64 -1);
  LoadString(m_hInstResDLL, IDS_H33, sz_H33, 64 -1);
  LoadString(m_hInstResDLL, IDS_H34, sz_H34, 64 -1);
  LoadString(m_hInstResDLL, IDS_H35, sz_H35, 64 -1);
  LoadString(m_hInstResDLL, IDS_H36, sz_H36, 64 -1);
  LoadString(m_hInstResDLL, IDS_H37, sz_H37, 64 -1);
  LoadString(m_hInstResDLL, IDS_H38, sz_H38, 128 -1);
  LoadString(m_hInstResDLL, IDS_H39, sz_H39, 64 -1);
  LoadString(m_hInstResDLL, IDS_H40, sz_H40, 64 -1);
  LoadString(m_hInstResDLL, IDS_H41, sz_H41, 64 -1);
  LoadString(m_hInstResDLL, IDS_H42, sz_H42, 64 -1);
  LoadString(m_hInstResDLL, IDS_H43, sz_H43, 128 -1);
  LoadString(m_hInstResDLL, IDS_H44, sz_H44, 64 -1);
  LoadString(m_hInstResDLL, IDS_H45, sz_H45, 64 -1);
  LoadString(m_hInstResDLL, IDS_H46, sz_H46, 128 -1);
  LoadString(m_hInstResDLL, IDS_H47, sz_H47, 64 -1);
  LoadString(m_hInstResDLL, IDS_H48, sz_H48, 64 -1);
  LoadString(m_hInstResDLL, IDS_H49, sz_H49, 64 -1);
  LoadString(m_hInstResDLL, IDS_H50, sz_H50, 64 -1);
  LoadString(m_hInstResDLL, IDS_H51, sz_H51, 64 -1);
  LoadString(m_hInstResDLL, IDS_H52, sz_H52, 64 -1);
  LoadString(m_hInstResDLL, IDS_H53, sz_H53, 64 -1);
  LoadString(m_hInstResDLL, IDS_H54, sz_H54, 64 -1);
  LoadString(m_hInstResDLL, IDS_H55, sz_H55, 64 -1);
  LoadString(m_hInstResDLL, IDS_H56, sz_H56, 64 -1);
  LoadString(m_hInstResDLL, IDS_H57, sz_H57, 64 -1);

  LoadString(m_hInstResDLL, IDS_H58, sz_H58, 64 -1);
  LoadString(m_hInstResDLL, IDS_H59, sz_H59, 64 -1);
  LoadString(m_hInstResDLL, IDS_H60, sz_H60, 64 -1);
  LoadString(m_hInstResDLL, IDS_H61, sz_H61, 64 -1);
  LoadString(m_hInstResDLL, IDS_H62, sz_H62, 64 -1);
  LoadString(m_hInstResDLL, IDS_H63, sz_H63, 64 -1);
  LoadString(m_hInstResDLL, IDS_H64, sz_H64, 64 -1);
  LoadString(m_hInstResDLL, IDS_H65, sz_H65, 64 -1);
  LoadString(m_hInstResDLL, IDS_H66, sz_H66, 64 -1);
  LoadString(m_hInstResDLL, IDS_H67, sz_H67, 64 -1);
  LoadString(m_hInstResDLL, IDS_H68, sz_H68, 64 -1);
  LoadString(m_hInstResDLL, IDS_H69, sz_H69, 64 -1);
  LoadString(m_hInstResDLL, IDS_H70, sz_H70, 64 -1);
  LoadString(m_hInstResDLL, IDS_H71, sz_H71, 64 -1);
  LoadString(m_hInstResDLL, IDS_H72, sz_H72, 128 -1);
  LoadString(m_hInstResDLL, IDS_H73, sz_H73, 64 -1);

  
	LoadString(m_hInstResDLL, IDS_I1, sz_I1, 64 -1);
	LoadString(m_hInstResDLL, IDS_I2, sz_I2, 64 -1);
	LoadString(m_hInstResDLL, IDS_I3, sz_I3, 64 -1);

	LoadString(m_hInstResDLL, IDS_J1, sz_J1, 128 -1);
	LoadString(m_hInstResDLL, IDS_J2, sz_J2, 64 -1);

	LoadString(m_hInstResDLL, IDS_K1, sz_K1, 64 -1);
	LoadString(m_hInstResDLL, IDS_K2, sz_K2, 64 -1);
	LoadString(m_hInstResDLL, IDS_K3, sz_K3, sizeof(sz_K3)/sizeof(sz_K3[0]));
	LoadString(m_hInstResDLL, IDS_K4, sz_K4, 64 -1);
	LoadString(m_hInstResDLL, IDS_K5, sz_K5, 64 -1);
	LoadString(m_hInstResDLL, IDS_K6, sz_K6, 64 -1);

	LoadString(m_hInstResDLL, IDS_L1, sz_L1, 64 -1);
	LoadString(m_hInstResDLL, IDS_L2, sz_L2, 64 -1);
	LoadString(m_hInstResDLL, IDS_L3, sz_L3, 64 -1);
	LoadString(m_hInstResDLL, IDS_L4, sz_L4, 64 -1);
	LoadString(m_hInstResDLL, IDS_L5, sz_L5, 64 -1);
	LoadString(m_hInstResDLL, IDS_L6, sz_L6, 64 -1);
	LoadString(m_hInstResDLL, IDS_L7, sz_L7, 64 -1);
	LoadString(m_hInstResDLL, IDS_L8, sz_L8, 64 -1);
	LoadString(m_hInstResDLL, IDS_L9, sz_L9, 64 -1);
	LoadString(m_hInstResDLL, IDS_L10, sz_L10, 64 -1);
	LoadString(m_hInstResDLL, IDS_L11, sz_L11, 64 -1);
	LoadString(m_hInstResDLL, IDS_L12, sz_L12, 64 -1);
	LoadString(m_hInstResDLL, IDS_L13, sz_L13, 64 -1);
	LoadString(m_hInstResDLL, IDS_L14, sz_L14, 64 -1);
	LoadString(m_hInstResDLL, IDS_L15, sz_L15, 64 -1);
	LoadString(m_hInstResDLL, IDS_L16, sz_L16, 64 -1);
	LoadString(m_hInstResDLL, IDS_L17, sz_L17, 64 -1);
	LoadString(m_hInstResDLL, IDS_L18, sz_L18, 64 -1);
	LoadString(m_hInstResDLL, IDS_L19, sz_L19, 64 -1);
	LoadString(m_hInstResDLL, IDS_L20, sz_L20, 64 -1);
	LoadString(m_hInstResDLL, IDS_L21, sz_L21, 64 -1);
	LoadString(m_hInstResDLL, IDS_L22, sz_L22, 64 -1);
	LoadString(m_hInstResDLL, IDS_L23, sz_L23, 64 -1);
	LoadString(m_hInstResDLL, IDS_L24, sz_L24, 64 -1);
	LoadString(m_hInstResDLL, IDS_L25, sz_L25, 64 -1);
	LoadString(m_hInstResDLL, IDS_L26, sz_L26, 64 -1);
	LoadString(m_hInstResDLL, IDS_L27, sz_L27, 64 -1);
	LoadString(m_hInstResDLL, IDS_L28, sz_L28, 64 -1);
	LoadString(m_hInstResDLL, IDS_L29, sz_L29, 64 -1);
	LoadString(m_hInstResDLL, IDS_L30, sz_L30, 64 -1);
	LoadString(m_hInstResDLL, IDS_L31, sz_L31, 64 -1);
	LoadString(m_hInstResDLL, IDS_L32, sz_L32, 64 -1);
	LoadString(m_hInstResDLL, IDS_L33, sz_L33, 64 -1);
	LoadString(m_hInstResDLL, IDS_L34, sz_L34, 64 -1);
	LoadString(m_hInstResDLL, IDS_L35, sz_L35, 64 -1);
	LoadString(m_hInstResDLL, IDS_L36, sz_L36, 64 -1);
	LoadString(m_hInstResDLL, IDS_L37, sz_L37, 64 -1);
	LoadString(m_hInstResDLL, IDS_L38, sz_L38, 64 -1);
	LoadString(m_hInstResDLL, IDS_L39, sz_L39, 64 -1);
	LoadString(m_hInstResDLL, IDS_L40, sz_L40, 64 -1);
	LoadString(m_hInstResDLL, IDS_L41, sz_L41, 64 -1);
	LoadString(m_hInstResDLL, IDS_L42, sz_L42, 64 -1);
	LoadString(m_hInstResDLL, IDS_L43, sz_L43, 64 -1);
	LoadString(m_hInstResDLL, IDS_L44, sz_L44, 64 -1);
	LoadString(m_hInstResDLL, IDS_L45, sz_L45, 64 -1);
	LoadString(m_hInstResDLL, IDS_L46, sz_L46, 64 -1);
	LoadString(m_hInstResDLL, IDS_L47, sz_L47, 64 -1);
	LoadString(m_hInstResDLL, IDS_L48, sz_L48, 64 -1);
	LoadString(m_hInstResDLL, IDS_L49, sz_L49, 64 -1);
	LoadString(m_hInstResDLL, IDS_L50, sz_L50, 64 -1);
	LoadString(m_hInstResDLL, IDS_L51, sz_L51, 128 -1);
	LoadString(m_hInstResDLL, IDS_L52, sz_L52, 64 -1);
	LoadString(m_hInstResDLL, IDS_L53, sz_L53, 64 -1);
	LoadString(m_hInstResDLL, IDS_L54, sz_L54, 64 -1);
	LoadString(m_hInstResDLL, IDS_L55, sz_L55, 64 -1);
	LoadString(m_hInstResDLL, IDS_L56, sz_L56, 64 -1);
	LoadString(m_hInstResDLL, IDS_L57, sz_L57, 64 -1);
	LoadString(m_hInstResDLL, IDS_L58, sz_L58, 64 -1);
	LoadString(m_hInstResDLL, IDS_L59, sz_L59, 64 -1);
	LoadString(m_hInstResDLL, IDS_L60, sz_L60, 64 -1);
	LoadString(m_hInstResDLL, IDS_L61, sz_L61, 64 -1);
	LoadString(m_hInstResDLL, IDS_L62, sz_L62, 64 -1);
	LoadString(m_hInstResDLL, IDS_L63, sz_L63, 64 -1);
	LoadString(m_hInstResDLL, IDS_L64, sz_L64, 64 -1);
	LoadString(m_hInstResDLL, IDS_L65, sz_L65, 64 -1);
	LoadString(m_hInstResDLL, IDS_L66, sz_L66, 64 -1);
	LoadString(m_hInstResDLL, IDS_L67, sz_L67, 64 -1);
	LoadString(m_hInstResDLL, IDS_L68, sz_L68, 64 -1);
	LoadString(m_hInstResDLL, IDS_L69, sz_L69, 64 -1);
	LoadString(m_hInstResDLL, IDS_L70, sz_L70, 64 -1);
	LoadString(m_hInstResDLL, IDS_L71, sz_L71, 64 -1);
	LoadString(m_hInstResDLL, IDS_L72, sz_L72, 64 -1);
	LoadString(m_hInstResDLL, IDS_L73, sz_L73, 64 -1);
	LoadString(m_hInstResDLL, IDS_L74, sz_L74, 64 -1);
	LoadString(m_hInstResDLL, IDS_L75, sz_L75, 64 -1);
	LoadString(m_hInstResDLL, IDS_L76, sz_L76, 64 -1);
	LoadString(m_hInstResDLL, IDS_L77, sz_L77, 128 -1);
	LoadString(m_hInstResDLL, IDS_L78, sz_L78, 64 -1);
	LoadString(m_hInstResDLL, IDS_L79, sz_L79, 64 -1);
	LoadString(m_hInstResDLL, IDS_L80, sz_L80, 64 -1);
	LoadString(m_hInstResDLL, IDS_L81, sz_L81, 128 -1);
	LoadString(m_hInstResDLL, IDS_L82, sz_L82, 64 -1);
	LoadString(m_hInstResDLL, IDS_L83, sz_L83, 64 -1);
	LoadString(m_hInstResDLL, IDS_L84, sz_L84, 64 -1);
	LoadString(m_hInstResDLL, IDS_L85, sz_L85, 64 -1);
	LoadString(m_hInstResDLL, IDS_L86, sz_L86, 64 -1);
	LoadString(m_hInstResDLL, IDS_L87, sz_L87, 64 -1);
	LoadString(m_hInstResDLL, IDS_L88, sz_L88, 64 -1);
	LoadString(m_hInstResDLL, IDS_L89, sz_L89, 64 -1);
	LoadString(m_hInstResDLL, IDS_L90, sz_L90, 64 -1);
	LoadString(m_hInstResDLL, IDS_L91, sz_L91, 64 -1);
	LoadString(m_hInstResDLL, IDS_L92, sz_L92, 64 -1);
	LoadString(m_hInstResDLL, IDS_L93, sz_L93, 64 -1);
	LoadString(m_hInstResDLL, IDS_L94, sz_L94, 64 -1); 

    // 14 April 2008 jdp
	LoadString(m_hInstResDLL, IDS_H94, sz_H94, 64 -1);
	LoadString(m_hInstResDLL, IDS_H95, sz_H95, 64 -1);
	LoadString(m_hInstResDLL, IDS_H96, sz_H96, 64 -1);
	LoadString(m_hInstResDLL, IDS_H97, sz_H97, 64 -1);
	LoadString(m_hInstResDLL, IDS_H98, sz_H98, 64 -1);
	LoadString(m_hInstResDLL, IDS_H99, sz_H99, 64 -1);
    LoadString(m_hInstResDLL, IDS_H100, sz_H100, 64 -1);
    LoadString(m_hInstResDLL, IDS_H101, sz_H101, 64 -1);
    LoadString(m_hInstResDLL, IDS_H102, sz_H102, 128 -1);



  

  
  /////////////////////////////////////////////////////////////

	// The state of the application as a whole is contained in the one app object
	#ifdef _WIN32_WCE
		VNCviewerApp app(hInstance, szCmdLine);
	#else
		VNCviewerApp32 app(hInstance, szCmdLine);
	#endif

    console = app.m_options.m_logToConsole;

	// Start a new connection if specified on command line, 
	// or if not in listening mode
	MSG msg;
	if (!app.m_options.m_configSpecified) StartWindows(&app,0);
	else StartWindows(&app,1);
	while(!g_stop)
		{
			g_passwordfailed=false;
			if (app.m_options.m_connectionSpecified)
				app.NewConnection(app.m_options.m_host_options, app.m_options.m_port);

			try
			{
				while ( GetMessage(&msg, NULL, 0,0) )
					{
						if(!TranslateMDISysAccel(m_hMDIClient, &msg))
							{
								if (!TheAccelKeys.TranslateAccelKeys(&msg))
									{
										TranslateMessage(&msg);
										DispatchMessage(&msg);
									}
							} 
					}
			}
			catch (WarningException &e)
			{
				e.Report();
			}
			catch (QuietException &e)
			{
				e.Report();
			}
		}
		// Clean up winsock
		WSACleanup();
	
	    vnclog.Print(3, _T("Exiting\n"));

    if (console) Sleep(2000);

	return msg.wParam;
}
Ejemplo n.º 26
0
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
{
    MSG msg;
    INITCOMMONCONTROLSEX icex;

    /*
     * Set our shutdown parameters: we want to shutdown the very last,
     * but before any TaskMgr instance (which has a shutdown level of 1).
     */
    SetProcessShutdownParameters(2, 0);

    Globals.hInstance    = hInstance;
    Globals.hGroups      = NULL;
    Globals.hActiveGroup = NULL;

    /* Load Program Manager's settings */
    MAIN_LoadSettings();

    /* Load the default icons */
    Globals.hDefaultIcon       = LoadIconW(NULL, MAKEINTRESOURCEW(IDI_WINLOGO));
    Globals.hMainIcon          = LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(IDI_APPICON));
    Globals.hPersonalGroupIcon = LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(IDI_GROUP_PERSONAL_ICON));
    Globals.hCommonGroupIcon   = LoadIconW(Globals.hInstance, MAKEINTRESOURCEW(IDI_GROUP_COMMON_ICON));

    /* Initialize the common controls */
    icex.dwSize = sizeof(icex);
    icex.dwICC  = ICC_HOTKEY_CLASS | ICC_LISTVIEW_CLASSES; // | ICC_STANDARD_CLASSES;
    InitCommonControlsEx(&icex);

    /* Register the window classes */
    if (!hPrevInstance) // FIXME: Unused on Win32!
    {
        if (!MAIN_RegisterMainWinClass())   goto Quit;
        if (!GROUP_RegisterGroupWinClass()) goto Quit;
    }

    /* Set up the strings, the main window, the accelerators, the menu, and the MDI child window */
    STRING_LoadStrings();
    MAIN_CreateMainWindow();
    Globals.hAccel = LoadAcceleratorsW(Globals.hInstance, MAKEINTRESOURCEW(IDA_ACCEL));
    STRING_LoadMenus();
    MAIN_CreateMDIWindow();

    /* Load all the groups */
    // MAIN_CreateGroups();
    MAIN_LoadGroups();

    /* Load the Startup group: start the initial applications */
    MAIN_AutoStart();

    /* Message loop */
    while (GetMessageW(&msg, NULL, 0, 0))
    {
        if (!TranslateMDISysAccel(Globals.hMDIWnd, &msg) &&
            !TranslateAcceleratorW(Globals.hMainWnd, Globals.hAccel, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

Quit:

    /* Save the settings, close the registry keys and quit */

    // MAIN_SaveSettings();
    RegCloseKey(Globals.hKeyCommonGroups);
    RegCloseKey(Globals.hKeyUnicodeGroups);
    RegCloseKey(Globals.hKeyAnsiGroups);
    RegCloseKey(Globals.hKeyPMUnicodeGroups);
    RegCloseKey(Globals.hKeyPMAnsiGroups);
    RegCloseKey(Globals.hKeyPMCommonGroups);
    RegCloseKey(Globals.hKeyPMSettings);
    RegCloseKey(Globals.hKeyProgMan);

    return 0;
}