コード例 #1
0
static BOOL Slider_OnCreate (HWND hWindow, LPCREATESTRUCT lpCreateStruct)
/***********************************************************************/
{
	LPHSLIDERINFO lpInfo;
	if ( (lpInfo = (LPHSLIDERINFO)AllocX( sizeof(HSLIDERINFO), GMEM_ZEROINIT|GMEM_SHARE )) )
	{
		Slider_Init (lpInfo) ;
		SetWindowLong( hWindow, GWL_DATAPTR, (long)lpInfo );
	}
	else
		return FALSE;

	return TRUE;
}
コード例 #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;
}
コード例 #3
0
ファイル: ui_qmenu.c プロジェクト: baseas/aftershock
void Menu_AddItem(menuframework_s *menu, void *item)
{
	menucommon_s	*itemptr;

	if (menu->nitems >= MAX_MENUITEMS) {
		trap_Error ("Menu_AddItem: excessive items");
	}

	menu->items[menu->nitems] = item;
	((menucommon_s*)menu->items[menu->nitems])->parent = menu;
	((menucommon_s*)menu->items[menu->nitems])->menuPosition = menu->nitems;
	((menucommon_s*)menu->items[menu->nitems])->flags &= ~QMF_HASMOUSEFOCUS;

	// perform any item specific initializations
	itemptr = (menucommon_s*)item;
	if (!(itemptr->flags & QMF_NODEFAULTINIT)) {
		switch (itemptr->type) {
		case MTYPE_ACTION:
			Action_Init((menuaction_s*)item);
			break;

		case MTYPE_FIELD:
			MenuField_Init((menufield_s*)item);
			break;

		case MTYPE_SPINCONTROL:
			SpinControl_Init((menulist_s*)item);
			break;

		case MTYPE_RADIOBUTTON:
			RadioButton_Init((menuradiobutton_s*)item);
			break;

		case MTYPE_SLIDER:
			Slider_Init((menuslider_s*)item);
			break;

		case MTYPE_BITMAP:
			Bitmap_Init((menubitmap_s*)item);
			break;

		case MTYPE_TEXT:
			Text_Init((menutext_s*)item);
			break;

		case MTYPE_SCROLLLIST:
			ScrollList_Init((menulist_s*)item);
			break;

		case MTYPE_PTEXT:
			PText_Init((menutext_s*)item);
			break;

		case MTYPE_BTEXT:
			BText_Init((menutext_s*)item);
			break;

		case MTYPE_BUTTON:
			Button_Init((menubutton_s*)item);
			break;

		default:
			trap_Error(va("Menu_Init: unknown type %d", itemptr->type));
		}
	}

	menu->nitems++;
}
コード例 #4
0
HRESULT MainWindow::OnCreate()
{
	HRESULT hr = S_OK;

	// Create the background brush.
	brush = CreateHatchBrush(HS_BDIAGONAL, RGB(0, 0x80, 0xFF));
	if (brush == NULL)
	{
		hr = __HRESULT_FROM_WIN32(GetLastError());
	}

	// Create the rebar control.
	if (SUCCEEDED(hr))
	{
		hr = rebar.Create(m_hInstance, m_hwnd, IDC_REBAR_CONTROL);
	}

	// Create the toolbar control.
	if (SUCCEEDED(hr))
	{
		hr = toolbar.Create(m_hInstance, m_hwnd, IDC_TOOLBAR, TBSTYLE_FLAT | TBSTYLE_TOOLTIPS);
	}

	// Set the image list for toolbar buttons (normal state).
	if (SUCCEEDED(hr))
	{
		hr = toolbar.SetImageList(
			Toolbar::Normal,			// Image list for normal state
			IDB_TOOLBAR_IMAGES_NORMAL,	// Bitmap resource
			Size(48, 48),				// Size of each button
			5,							// Number of buttons
			RGB(0xFF, 0x00, 0xFF)		// Color mask
			);
	}

	// Set the image list for toolbar buttons (disabled state).
	if (SUCCEEDED(hr))
	{
		hr = toolbar.SetImageList(
			Toolbar::Disabled,			// Image list for normal state
			IDB_TOOLBAR_IMAGES_DISABLED,	// Bitmap resource
			Size(48, 48),				// Size of each button
			5,							// Number of buttons
			RGB(0xFF, 0x00, 0xFF)		// Color mask
			);
	}


	// Add buttons to the toolbar.
	if (SUCCEEDED(hr))
	{
		// Play
		hr = toolbar.AddButton(Toolbar::Button(ID_IMAGE_PLAY, IDC_BUTTON_PLAY));
	}
	
	if (SUCCEEDED(hr))
	{
		// Stop
		hr = toolbar.AddButton(Toolbar::Button(ID_IMAGE_STOP, IDC_BUTTON_STOP));
	}

	if (SUCCEEDED(hr))
	{
		// Pause
		hr = toolbar.AddButton(Toolbar::Button(ID_IMAGE_PAUSE, IDC_BUTTON_PAUSE));
	}

	if (SUCCEEDED(hr))
	{
		// Mute
		hr = toolbar.AddButton(Toolbar::Button(ID_IMAGE_MUTE_OFF, IDC_BUTTON_MUTE));
	}

	// Add the toolbar to the rebar control.
	if (SUCCEEDED(hr))
	{
		hr = rebar.AddBand(toolbar.Window(), 0);
	}

	//// Create the slider for seeking.

	if (SUCCEEDED(hr))
	{
		hr = Slider_Init();	// Initialize the Slider control.
	}

	if (SUCCEEDED(hr))
	{
		hr = seekbar.Create(m_hwnd, Rect(0, 0, 300, 16), IDC_SEEKBAR);
	}

	if (SUCCEEDED(hr))
	{
		hr = seekbar.SetThumbBitmap(IDB_SLIDER_THUMB);

		seekbar.SetBackground(CreateSolidBrush(RGB(239, 239, 231)));
		seekbar.Enable(FALSE);
	}

	if (SUCCEEDED(hr))
	{
		hr = rebar.AddBand(seekbar.Window(), 1);
	}

	//// Create the slider for changing the volume.

	if (SUCCEEDED(hr))
	{
		hr = volumeSlider.Create(m_hwnd, Rect(0, 0, 100, 32), IDC_VOLUME);
	}

	if (SUCCEEDED(hr))
	{
		hr = volumeSlider.SetThumbBitmap(IDB_SLIDER_VOLUME);

		volumeSlider.SetBackground(CreateSolidBrush(RGB(239, 239, 231)));
		volumeSlider.Enable(TRUE);

		// Set the range of the volume slider. In my experience, only the top half of the
		// range is audible.
		volumeSlider.SetRange(MIN_VOLUME / 2, MAX_VOLUME);
		volumeSlider.SetPosition(MAX_VOLUME);
	}

	if (SUCCEEDED(hr))
	{
		hr = rebar.AddBand(volumeSlider.Window(), 2);
	}



	// Create the DirectShow player object.
	if (SUCCEEDED(hr))
	{
		m_pPlayer = new DShowPlayer(m_hwnd);
		if (m_pPlayer == NULL)
		{
			hr = E_OUTOFMEMORY;
		}
	}

	// Set the event notification window.
	if (SUCCEEDED(hr))
	{
		hr = m_pPlayer->SetEventWindow(m_hwnd, WM_GRAPH_EVENT);
	}

	// Set default UI state.
	if (SUCCEEDED(hr))
	{
		UpdateUI();
	}

	return hr;
}