Exemplo n.º 1
0
int WINAPI _tWinMain(HINSTANCE  hInstance,
                     HINSTANCE  /*hPrevInstance*/,
                     LPTSTR     lpstrCmdLine,
                     int        nCmdShow)
{

    g_hInstance = hInstance;

	HRESULT hr =    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

    if (FAILED(hr))
    {
        MessageBox(NULL, TEXT("CoInitialize failed."), NULL, MB_ICONSTOP);
        return 1;
    }

	MainDialog *pDlg = new MainDialog();
	if (pDlg == NULL)
	{
        MessageBox(NULL, TEXT("Out of memory."), NULL, MB_ICONSTOP);
	}
	else
	{
		pDlg->ShowDialog(hInstance, NULL);

		delete pDlg;
	}




    CoUninitialize();

    return 0;
}
Exemplo n.º 2
0
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPWSTR /*lpCmdLine*/, INT /*nCmdShow*/)
{
    (void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);

    // Initialize the COM library.
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);

    if (FAILED(hr))
    {
        MessageBox(NULL, L"CoInitialize failed.", NULL, MB_ICONSTOP);
        return 0;
    }

    // Initialize the common control library.
    INITCOMMONCONTROLSEX icc;
    icc.dwSize = sizeof(icc);
    icc.dwICC = ICC_STANDARD_CLASSES | ICC_BAR_CLASSES;
    if (!InitCommonControlsEx(&icc))
    {
        MessageBox(NULL, L"InitCommonControlsEx failed.", NULL, MB_ICONSTOP);
        CoUninitialize();
        return 0;
    }

    // Initialize our custom slider class.
    hr = Slider_Init(); 
    if (FAILED(hr))
    {
        MessageBox(NULL, L"Slider_Init failed.", NULL, MB_ICONSTOP);
        CoUninitialize();
        return 0;
    }

    // Create and show the dialog.
    MainDialog *pDlg = new (std::nothrow) MainDialog();
    if (pDlg == NULL)
    {
        MessageBox(NULL, L"Out of memory.", NULL, MB_ICONSTOP);
    }
    else
    {
        pDlg->ShowDialog(hInstance);

        delete pDlg;
    }

    CoUninitialize();
    return 0;
}
Exemplo n.º 3
0
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPWSTR /*lpCmdLine*/, INT /*nCmdShow*/)
{
    // Create and show the dialog, we changed the application to support Modeless dialog
    MainDialog *pDlg = new (std::nothrow) MainDialog();
    if (pDlg == NULL)
    {
        MessageBox(NULL, TEXT("Out of memory."), NULL, MB_ICONSTOP);
    }
    else
    {
        // create and show window
        pDlg->ShowDialog(hInstance);
    }

    MSG msg = {};

    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MODELESS_DLG_ACCL));

    /* while (TRUE)
    {
        if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
        {
            if (Msg.message == WM_QUIT)
                break;
            else
            {
                if (Msg.message == WM_KEYDOWN || Msg.message == WM_LBUTTONDOWN)
                {
                    if (Msg.wParam == VK_END)
                        Msg.wParam = VK_TAB;
                    if (!IsDialogMessage(hwnd, &Msg))
                    {
                        TranslateMessage(&Msg);
                        DispatchMessage(&Msg);
                    }
                }
            }// els
        }
    }*/

    /*iRet = GetMessage(&msg, NULL, 0, 0);
    We need to pre translate keyboard events here, so can't use GetMessage

    solution is to use PeekMessage, ref: http://stackoverflow.com/questions/2441457/keyboard-input-the-win32-message-loop
    */
    __pragma(warning(disable:4127))

    while (TRUE)
    { 
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
            if (msg.message == WM_QUIT) {
                PostQuitMessage(0);
                break;
            }

            if (msg.message != WM_INITDIALOG) {
                if (msg.message == WM_KEYUP) {
                    if (pDlg != NULL)
                    {
                        pDlg->ProcessMessage(pDlg->m_hDlg, msg.message, msg.wParam, msg.lParam);
                    }
                }
            }
            
            if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg) || !IsDialogMessage(pDlg->GetHwnd(), &msg))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
    }

    // time to destroy the dialog box
    delete pDlg;

    return msg.wParam;
}