Esempio n. 1
0
BOOL CMsgOnlyWnd::OnInit()
{
	if (InitWndClass())
	{
		hwnd_ = CreateWindowEx(0, s_szMessageOnlyWindowName, s_szMessageOnlyWindowName, WS_OVERLAPPED, 0, 0, 0, 0, 
			HWND_MESSAGE, NULL, s_wndClassEx.hInstance, NULL);
		SetWindowLongPtr(hwnd_, GWL_USERDATA,reinterpret_cast<LONG_PTR>(this));

	}
	return hwnd_ != NULL;
}
Esempio n. 2
0
int WINAPI _tWinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
    BOOL success;
    MSG msg;

    _generator._instance = hInstance;

    ::LoadString ( _generator._instance, IDR_PLAYLIST, _generator._window_name, MAX_PATH );
    ::LoadString ( _generator._instance, IDC_PLAYLISTCLASS, _generator._class_name, MAX_PATH );

#ifdef _DEBUG

	//  Enable memory checking to avoid buffer overflow and leak detection

	_ASSERTE ( _CrtCheckMemory() == TRUE );
	_CrtSetDbgFlag (  _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF );

#endif	// _DEBUG

    //  Initialize all control classes

    /*
        Causes W2k to fail

    if ( !InitControlClasses ( ) )
        return -1;
    */


    //  Need to initialize COM to take advantage of the Shell API calls

    if ( FAILED ( ::CoInitializeEx ( NULL, COINIT_APARTMENTTHREADED ) ) )
        return -2;

    //  Create and register the window class

    if ( !InitWndClass ( ) )
        return -3;

    //  Create the application frame window

    if ( !CreateAppFrameWindow ( ) )
        return -4;

    //  Force update of window

    ::ShowWindow ( _generator._main_hwnd, nCmdShow );
    ::UpdateWindow ( _generator._main_hwnd );

    //  Pump for messages

    while( ( success = ::GetMessage( & msg, NULL, 0, 0 ) ) != 0 )
    { 
        if ( success == -1 )
        {
            // handle the error and possibly exit
        }
        else
        {
            ::TranslateMessage ( & msg ); 
            ::DispatchMessage ( & msg ); 
        }
    }

    ::CoUninitialize ( );
    
    return msg.wParam;
}