|
Hello,
I need to develop a WinForm application which can play .mp3 music files.
I want to have complete control over the UI - no visibly embedded Media Player if possible.
I also need to be able to programatically stop/play/pause/resume/change volume/change songs.
Any ideas on how to do this?
Thanks,
Roy.
|
|
|
|
|
This[^] video might help you.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Hi,
Thanks for the link. it helped.
|
|
|
|
|
hi i am using vs 2005 c# to make a simple window form which can load an excel file INTO the window form. and then manipulating the loaded excel with interlop
i have tried using webbrowser at How to Integrate Excel in a Windows Form Application using the WebBrowser[^]
however instead of loaded into the webbrowser it always open into the whole file instead of into the webbrowser.
does anyone mind suggesting an alternative or how to solve the webbrowser problem?
|
|
|
|
|
|
prerakpatel wrote: How to Integrate Excel in a Windows Form Application using the WebBrowser[^]
He already define this link and searching how to recover from problem which occur in WebBrowser.
|
|
|
|
|
neodeaths wrote: does anyone mind suggesting an alternative
Here[^] it is
I are Troll
|
|
|
|
|
Hi folks.
I need a little inspiration.
I want to program a Windows program that can display a calendar in the desktop background. It should be possible to interact with this calendar (add appointments etc).
I know there are other programs that do this very well (eg. Active Desktop Calendar http://www.xemico.com/adc/) but my program must have some other features than the alternatives currently on the market.
I plan to make it an open source project.
My biggest problem is how to go about it grapples with creating an interactive desktop background? Anyone who has tried it or have experience with something similar? Possibly a link to some guides, or some API names that I should look at?
I have experience in C #, C + +, C, Java, Visual Basic. But I am also willing to look at another programming language if it can solve my problem in a better way. I'm not looking for a sidebar solution.
Hope you can help.
|
|
|
|
|
hansdam wrote: or some API names that I should look at?
SetWindowPos with HWND_BOTTOM
I are Troll
|
|
|
|
|
I have my filtered combo boxes working in a datagridview thanks to a Linda Liu sample. Now when I enter a row I want to see the data from a row in a sequence of text boxes below the grid - but for the combo boxes I only see the index, when I would prefer to see the information e.g. route description. Here is a cutdown version of From1.h:
namespace DataGridViewComboEx5 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Collections::Generic;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::IO;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::DataGridView^ gridPassenger;
private: System::Windows::Forms::DataGridViewComboBoxColumn^ dgRoute;
private: System::Windows::Forms::DataGridViewComboBoxColumn^ dgStage;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ dgPerson;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ lblPerson;
private: System::Windows::Forms::Label^ lblStage;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ lblRoute;
private: System::Windows::Forms::Label^ label5;
:
:
ref class ViewPassengerData
{
private:
int m_Route;
int m_Stage;
String ^m_Person;
public:
ViewPassengerData(int Route, int Stage, String^ Person)
{
m_Route = Route;
m_Stage = Stage;
m_Person = gcnew String(Person);
}
property int RouteID
{
int get()
{
return m_Route;
}
void set(int value)
{
m_Route = value;
}
}
property int StageID
{
int get()
{
return m_Stage;
}
void set(int value)
{
m_Stage = value;
}
}
property String^ Person
{
String^ get()
{
return m_Person;
}
void set(String^ value)
{
m_Person = value;
}
}
};
private:
List<ViewPassengerData^> ^m_DataList;
DataSet ^RouteStages;
DataTable ^dtRoute;
DataTable ^dtStages;
BindingSource ^bsRoute;
BindingSource ^childBS;
BindingSource ^filteredStages;
bool m_LoadComplete;
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
m_LoadComplete = false;
RouteStages = gcnew DataSet();
dtRoute = gcnew DataTable("dtRoute");
dtStages = gcnew DataTable("dtStages");
bsRoute = gcnew BindingSource();
childBS = gcnew BindingSource();
filteredStages = gcnew BindingSource();
DataColumn ^col = gcnew DataColumn("RouteID", int::typeid);
dtRoute->Columns->Add(col);
col = gcnew DataColumn("RouteDescription");
dtRoute->Columns->Add(col);
col = gcnew DataColumn("StageID", int::typeid);
dtStages->Columns->Add(col);
col = gcnew DataColumn("StageDescription");
dtStages->Columns->Add(col);
col = gcnew DataColumn("RouteID", int::typeid);
dtStages->Columns->Add(col);
RouteStages->Tables->Add(dtRoute);
RouteStages->Tables->Add(dtStages);
DataRow ^row = RouteStages->Tables["dtRoute"]->NewRow();
row[0] = 3;
row[1] = "Route 3";
RouteStages->Tables["dtRoute"]->Rows->Add(row);
row = RouteStages->Tables["dtRoute"]->NewRow();
row[0] = 2;
row[1] = "Route 2";
RouteStages->Tables["dtRoute"]->Rows->Add(row);
row = RouteStages->Tables["dtStages"]->NewRow();
row[0] = 44122;
row[1] = "Stage 1";
row[2] = 3;
RouteStages->Tables["dtStages"]->Rows->Add(row);
row = RouteStages->Tables["dtStages"]->NewRow();
row[0] = 53404;
row[1] = "Stage 2";
row[2] = 3;
RouteStages->Tables["dtStages"]->Rows->Add(row);
row = RouteStages->Tables["dtStages"]->NewRow();
row[1] = "Stage A";
row[2] = 2;
row[0] = 60601;
RouteStages->Tables["dtStages"]->Rows->Add(row);
row = RouteStages->Tables["dtStages"]->NewRow();
row[0] = 94105;
row[1] = "Stage B";
row[2] = 2;
RouteStages->Tables["dtStages"]->Rows->Add(row);
bsRoute->DataSource = RouteStages;
bsRoute->DataMember = "dtRoute";
childBS->DataSource = RouteStages;
childBS->DataMember = "dtStages";
filteredStages->DataSource = RouteStages;
filteredStages->DataMember = "dtStages";
this->dgRoute->DataSource = bsRoute;
this->dgRoute->DisplayMember = "RouteDescription";
this->dgRoute->ValueMember = "RouteID";
this->dgStage->DataSource = childBS;
this->dgStage->DisplayMember = "StageDescription";
this->dgStage->ValueMember = "StageID";
DataTable ^dtViewPassengerData = gcnew DataTable("ViewPassengerData");
dtViewPassengerData->Columns->Add("RouteID", Int32::typeid);
dtViewPassengerData->Columns->Add("StageID", Int32::typeid);
dtViewPassengerData->Columns->Add("Person", String::typeid);
DataRow ^dr = dtViewPassengerData->NewRow();
dr["RouteID"] = 3;
dr["StageID"] = 44122;
dr["Person"] = "Thomas";
dtViewPassengerData->Rows->Add(dr);
dr = dtViewPassengerData->NewRow();
dr["RouteID"] = 2;
dr["StageID"] = 60601;
dr["Person"] = "Edward";
dtViewPassengerData->Rows->Add(dr);
gridPassenger->AutoGenerateColumns = false;
gridPassenger->DataSource = dtViewPassengerData;
gridPassenger->Columns[0]->DataPropertyName = "RouteID";
gridPassenger->Columns[1]->DataPropertyName = "StageID";
gridPassenger->Columns[dgPerson->Index]->DataPropertyName = "Person";
m_LoadComplete = true;
}
private: System::Void gridPassenger_CellValueChanged(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
if ((e->ColumnIndex == dgRoute->Index)
&&(e->RowIndex>= 0))
{
if (gridPassenger->DataSource->GetType() == DataTable::typeid)
{
gridPassenger->Rows[e->RowIndex]->Cells[dgStage->Index]->Value = DBNull::Value;
}
else
{
gridPassenger->Rows[e->RowIndex]->Cells[dgStage->Index]->Value = nullptr;
}
}
}
private: System::Void gridPassenger_DataError(System::Object^ sender,
System::Windows::Forms::DataGridViewDataErrorEventArgs^ e) {
if (e->ColumnIndex != dgStage->Index)
{
MessageBox::Show("Data error occurs:" + e->Exception->Message);
}
}
private: System::Void gridPassenger_EditingControlShowing(System::Object^ sender, System::Windows::Forms::DataGridViewEditingControlShowingEventArgs^ e) {
if (this->gridPassenger->CurrentCell->ColumnIndex == dgStage->Index)
{
DataGridViewComboBoxEditingControl ^control = dynamic_cast<DataGridViewComboBoxEditingControl^>(e->Control);
BindingSource ^bs = dynamic_cast<BindingSource^>(control->DataSource);
if (bs != nullptr)
{
(dynamic_cast<ComboBox^>(e->Control))->DataSource = filteredStages;
Object ^Routevalue = this->gridPassenger->Rows[this->gridPassenger->CurrentCell->RowIndex]->Cells[dgRoute->Index]->Value;
if (Routevalue == DBNull::Value || Routevalue == nullptr)
{
filteredStages->Filter = "RouteID=-1";
}
else
{
filteredStages->Filter = "RouteID=" + Routevalue->ToString();
}
if (this->gridPassenger->CurrentCell->Value != DBNull::Value
&& this->gridPassenger->CurrentCell->Value != nullptr)
{
control->SelectedValue = this->gridPassenger->CurrentCell->Value;
}
}
} }
private: System::Void gridPassenger_RowEnter(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) {
if (m_LoadComplete&& e->RowIndex < gridPassenger->RowCount)
{
lblPerson->Text = gridPassenger->Rows[e->RowIndex]->Cells[dgPerson->Name]->Value->ToString();
lblRoute->Text = gridPassenger->Rows[e->RowIndex]->Cells[dgRoute->Name]->Value->ToString();
lblStage->Text = gridPassenger->Rows[e->RowIndex]->Cells[dgStage->Name]->Value->ToString();
}
}
};
}
Ger
modified on Wednesday, December 8, 2010 11:44 PM
|
|
|
|
|
When you have code like this, please wrap the block of code in a <pre> </pre> tags. It makes it easier to read.
|
|
|
|
|
Done - wasn't aware of them - and I've chopped out much of the autogenerated code.
Ger
Ger
|
|
|
|
|
Ger Hayden wrote: wasn't aware of them
See point 7 in the Forum Guidelines[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
In the 24 hours since my original post I have made no progress and huge progress. None in that the problem persists, but I have learned volumes about how the combo column behaves.
Here is my original post:
My application reads bus routes into a combo column on a datagrid view. For each Route the Stages column is reloaded.
Each Passenger on Route 1 has its correct stage displayed, but the grid fails to show the stages for passengers on Route 2.
When I step through the code, I can see the Stage column reload and the correct stage picked from the list for Route 2, but its never shown. Not only that, it throws in the Datagrid View Default Error Dialog for good measure.
I am using VS2008, C++/CLI grid is entirely unbound and I am not employing datasoures, so setting displaymember/valuemember is not available to me.
void VTPassenger::frmPassengerMaster::Load_RouteStages(int arg_Route_ID)
{
dgStage->Items->Clear();
dgStage->Items->Add("0 <--- Undefined --->");
// then the Stages for this Route
List<CRouteStage^>^ RouteStageList = gcnew List<CRouteStage^>();
try
{
RouteStageList = CComs_RS::Fetch_RouteStage(m_LocalConnection,1,arg_Route_ID);
}
catch(Exception ^e)
{
String ^MessageString = " SQL Error retrieving Route Stages: " + e->Message;
MessageBox::Show(MessageString, "RouteStage Techincal Error");
return;
}
if (RouteStageList->Count == 0)// No records so no Ticket types defined
{
return;
}
for each(CRouteStage^ candidate in RouteStageList)
{
array<Object^>^ itemRec = gcnew array<Object^> {candidate->p_Stage_ID,
candidate->p_StageName
};
String^ AddString;
AddString = String::Format("{0} - {1}", candidate->p_Stage_ID, candidate->p_StageName);
this->dgStage->Items->Add(AddString);
}
}
And now for the progress.
This will work very well as is if the passenger list is sorted in route order, but do not consider this a suitable workaround. Learning that forced me to reflect on the design. For five hundered passengers distributed over a pair of short routes, 500 database visits doesnt make sense for essentially the same route stages - but what if there were 300 routes involved for our little outfit? Then front loading and holding 300 sets of route stages in a collection in memory doesn't sit well.
So programmatically I have created a datatable and read in my route stages upon which I attempted a filter in the sytle of spidernet's DataGridView FAQ bound in the code to the datatable, but changing the contents of the filter for each route change plus searching the list threw up issues.
So now I have two choices - a collection of filtered stage sets, one per route which will work well while the number of routes operated is low, or expand on my original idea but attempt to implement it a cell level - where I have just commenced research.
Ger
modified on Tuesday, November 30, 2010 11:51 PM
|
|
|
|
|
If users rarely make a selection from the combo then only request the data when the user edits the cell. This may or may not be acceptable.
You may also want to cache the results in a HashTable (route, collection of stages) so before you request the data, see if it already exists in the HashTable. If so, you will be able to access the data in the HashTable and avoid the round trip to the DB.
|
|
|
|
|
Thanks Robert.
I found an example that is very similar to your second suggestion. See my next post for details on how I applied it.
Ger
Ger
|
|
|
|
|
I have a textbox, a standard button and a toolstrip containing a couple of buttons.
In the validating event of the textbox i coded to check whether it is blank.
If yes then it shows a message 'Enter Value'. When the standard button is clicked while
the textbox is empty, it's validating properly and showing the message but when the
toolstripbutton is clicked it's not not validating the textbox and no message is being
shown. It seems that I gotto write the validation code explicitly in the
toolstripbutton_click event which is too troublesome when there are multiple textboxes
and toolstripbuttons on a single form. What I want to know is whether the
textbox_validating can be fired while the toolstripbutton is clicked?
Handling toolstrips is really a headache.
Please help. I'm badly in need of it. Regards.
|
|
|
|
|
This is an undocumented feature and appears to be by design. (don't you just hate that terminology) I guess it makes sense in a non-OOP way. When an event in the ToolStrip is raised, the control within the form that has focus, does not lose that focus! Therefore the validated/validating events of the control that has focus, are not raised.
The approach I take is to refactor each validation and provide a method that calls all validations within a single method. It's nice to provide control by control validation but there is no guarantee that a control will ever gain or lose focus. You need an overall validation method to handle this.
If your dealing with an underlying data source you may also want to look at the IDataErrorInfo interface.
|
|
|
|
|
priyamtheone wrote: Please help. I'm badly in need of it
Oh! your question will be more clear when you mention your code so please mention it.
whatever,
you can create a function and call it as many time you want to perform it. you don't need to create command every time for same work.
|
|
|
|
|
Well, calling common functionalities using methods is well known to everyone. That's not my question. What I asked for is whether textbox or other standard controls can be validated while toolstripbutton is clicked? As I learned gradually that toolstrip is not a control but a component and toolstripitems don't have CausesValidation property to cause them to validate any standard control on a form.
|
|
|
|
|
So, if you want to validate your TextBox, you have to call the method from within your ToolStripItem_Click event handler.
i.e. :
private myToolStripItem_Click(object sender, ClickEventArgs e)
{
myTextBox_LostFocus(myTextBox, EventArgs.Empty);
...
}
|
|
|
|
|
I wrote a small test form that allows the user to click on a control and then move the control to the desired location using mouse down and mouse up events. I have placed a groupbox on the form and then am dynamically creating a combox and placing it in the group box.
I can get it to move the control ok, but it does not end up in the position where the user lets up the mouse button. I am using PointToClient but it is not working. Here is the code:
public Form1()
{
InitializeComponent();
ComboBox cb = new ComboBox();
cb.Parent = groupBox;
cb.Location = new Point(60, 15);
cb.MouseDown +=new MouseEventHandler(cb_MouseDown);
cb.MouseUp +=new MouseEventHandler(cb_MouseUp);
}
private void cb_MouseDown (object sender, MouseEventArgs e )
{
Cursor = Cursors.SizeAll;
}
private void cb_MouseUp (object sender, MouseEventArgs e)
{
ComboBox cb = ((ComboBox) sender);
cb.Location = PointToClient (new Point(e.X, e.Y));
Cursor = Cursors.Default;
}
|
|
|
|
|
it ain't that simple. First of all, mouse events provide locations relative to the top lefthand corner of the control that reports the mouse actions, so any movement you want to accomplish needs at least to do the following:
finalLocation = originalLocation - mouseDownLocation + mouseUpLocation.
Furthermore, you have some functional shortcomings:
1.
you probably want to see the drag going on, which means you need MouseMove as well.
2.
when the mouse leaves the container, your container no longer gets mouse events, unless you have captured the mouse first.
3.
when you want context menus you need to process right-clicks; you then don't want to move the control I guess.
|
|
|
|
|
Thanks Luc! This is what I needeed.
|
|
|
|
|
Don't use location use Left and Top
private void cb_MouseUp(object sender, MouseEventArgs e)
{
ComboBox box = sender as ComboBox;
box.Left += e.X;
box.Top += e.Y;
Cursor = Cursors.Default;
}
If you're moving it from one container into another, You're going to have to work out which container and then remove control from original container and add to new container.
Sounds like fun
|
|
|
|