|
What is sequance to stop Backgroundworker?, what function to use to stop it?
|
|
|
|
|
|
Hi,
Should this be enough to draw a dotted rectangle on my form?
private void Form1_click(object sender, System.EventArgs e)<br />
{<br />
Rectangle r = new Rectangle(5,5,15,15);<br />
ControlPaint.DrawReversibleFrame(r, Color.Red, FrameStyle.Dashed);<br />
}
If not, what am I missing?
Thanks!
Mel
|
|
|
|
|
Only if your form happens to be where you draw the rectangle on the screen.
Perhaps you should ask about what you are trying to accomplish, instead.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you, that makes sense. (I wasn't thinking and expected to see it at 5,5,15,15 on the form rather than the screen.)
Another question though. I'd actually like to use DrawFocusRectangle on a button, and did get it working yesterday, but after I changed a couple properties of my button (like tabstop #, size, and location), it stopped working. I added a MessageBox just before the DrawFocusRectangle call and after I hit the ok button, the focus rectangle did draw (code below). I also added a Click event (on some label) and moved the code below (without the MessageBox ) to the event, and then it worked too.
button2.Focus();<br />
int x = button2.ClientRectangle.Location.X + 3;<br />
int y = button2.ClientRectangle.Location.Y + 3;<br />
int w = button2.ClientRectangle.Width - 6;<br />
int h = button2.ClientRectangle.Height - 6;<br />
Rectangle r = new Rectangle(x,y,w,h); <br />
MessageBox.Show(""); ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(button2.Handle), r, Color.Black, Color.Black);
Anyone know why it won't work without some external help?
Thanks again!!!
Mel
|
|
|
|
|
You are calling the Focus event, I assume that this will redraw the control to reflect the changed status. That redraw will however not take place until you returned control to the system. Without the message box that will not happen until after you have drawn the rectangle, so it would just be drawn over.
When you show a message box that gives the control to the system. Calling DoEvents will have the same result.
However, just drawing on top of a control is not the well behaved way to change the apperance of the control. You should subscribe to the OnPaint event to do it properly. Then you don't have the problem that the rectangle disappears whenever the control is redrawn.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you very much for that explanation! That clears up one of the mysteries.
What my problem has been from the start is that when I load a tabpage, if the first control is one of my buttons, it doesn't highlight and you can't tell that it has focus. What I've been doing to get around this is to focus on the control that's one tabstop before my button and SendKeys.Send("{Tab}"); which does highlight the button. As soon as a button on the tabpage has been highlighted, all buttons will highlight when focused on until I leave the tabpage and return again.
So I've deleted the focus call since the button has tabstop 0. I want the rectangle to disappear when focus is lost, so if it would just draw this first time, I'd be happy (is there a way to tell the system that it has control without having to call anything?). But nothing at all draws after deleting the button2.Focus() , regardless of whether there's a MessageBox before, after, or not at all.
So I tried adding the PaintEventArg for the button and moved the code into it. I also added a bool called focus since I only want the button to have the rectangle when it's in focus.
private void focusPaint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
if (focus == true)<br />
{<br />
int x = toggleLength.ClientRectangle.Location.X + 3;<br />
int y = toggleLength.ClientRectangle.Location.Y + 3;<br />
int w = toggleLength.ClientRectangle.Width - 6;<br />
int h = toggleLength.ClientRectangle.Height - 6;<br />
Rectangle r = new Rectangle(x,y,w,h); <br />
ControlPaint.DrawFocusRectangle(e.Graphics, r, Color.Red, Color.Red);<br />
focus = false;<br />
} <br />
}
This results in me never being able to move to another control (using the up/down arrow keys - only with the mouse). When I returned control to the system (by adding a Messagebox above the if (focus == true) ), I could move without problem.
I also noticed that if I replace the e.Graphics with my original Graphics.FromHwnd(toggleLength.Handle) , it wouldn't draw with or without system control, which I don't understand. (Maybe if I get that working I wouldn't need to add a Paint event?)
I'm not sure what else to try.
Thanks so much for any thoughts!!!!!!
Mel
-- modified at 15:59 Friday 28th April, 2006
|
|
|
|
|
Does anyone have tips or hard-earned wisdom with regards to writing a .NET Web Service which is intended to be used by a Java application? Are there any things that I should keep in mind about things such as:
1) SOAP formats
2) ref or out parameters
3) SOAP deserialization quirks found in the Java platform
4) Things I have not thought to list...
I've given this topic some due diligence (a.k.a. Google) but am hoping someone has nuggets of wisdom that I didn't find yet.
Thanks for any help,
Josh
|
|
|
|
|
Hi,
if I have a function that uses an object, for example: an SqlDataAdapter; what would be the correct way to clean up memory resources once finished with it?
myAdapter = null;
Is the above acceptable?
Or this?
myAdapter.Dispose();
Andy
|
|
|
|
|
An SqlDataAdapter has a Dispose method, you should therefore use it.
An easy way to ensure that the object is cleaned up is to use:
using (SqlDataAdapter da = new SqlDataAdapter())
{
}
This will ensure that the SqlDataAdapter (or any disposable object supplied in the using() part) is cleaned up, even if an exception is thrown.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I am inputting RTF data from a database into a RichTextBox in my C# program. The problem is, if there is a table in the original data that contains more data than will fit on a single line in the table, the RichTextBox wraps the line under the table instead of expanding the number of lines in the table so the text will fit. Has anyone else experienced this and, if so, is there a solution?
I have been living with this problem for quite a while and would like to solve it. I have not been able to find anything on the Web dispite many searches.
Thanks much for any help you might provide.
Ed Coburn
|
|
|
|
|
I am looking for information on writing Web Control Libraries, and using that control inside a windows application (using .NET 1.1 not 2.0). I am trying to determine the do's and don't's for the HTML controls, data passing, JavaScript. Are there any white papers or good examples. Information like the HTML/windows/frames are accessed by C# by using the ID attribute field. Changing the ID in the HTML will effect the C# back-end. I know this is trivial, but my knowledge on this subject is limited.
Thank you in advance for any assistance
-- modified at 14:53 Thursday 27th April, 2006
I am not running IIS on this computer
|
|
|
|
|
thompson_38 wrote: I am looking for information on writing Web Control Libraries, and using that control inside a windows application
If I understand your objective correctly, then what you want to do is impossible. A Windows app cannot use Web controls. Web controls generate HTML and JavaScript, which a web browser then renders into a graphical representation. WinForms controls do not use HTML or JavaScript at all, rather, they draw the controls directly to the screen. It's two separate worlds.
Josh
|
|
|
|
|
Is there an expander control for C# windows app?
|
|
|
|
|
|
I have two windows forms, FormPurchaseHistory and FormCustomer. FormPurchaseHistory opens up FormCustomer which displays a list of Customers in a DataGridView control. User clicks on a cell to select a customer and FormCustomer passes the CustomerID to FormPurchaseHistory and FormCustomer closes. There is a method in FormPurchaseHistoy I need to call after FormCustomer passes CustomerID to FormPurchaseHistory to retrieve purchase history by the customer. How do I fire that method?
I am using a static variable in a Module to pass value from FormCustomer to FormPurchaseHistory.
|
|
|
|
|
|
I have seen lots of good articles on owner-drawn ComboBox controls that can display multi-column data. What I need to do is to override the Paint of the TextBox portion of the ComboBox so that I can display one or more of the columns of the selected item.
I've made multiple attempts at this and always failed. Somehow the MS ComboBox control gets flaky when you try to override the paint event for the TextBox portion of the control. I suspect its going to require some fancy API coding to get it to work.
Anybody know where to start?
Thanks,
Sean
|
|
|
|
|
secovel wrote: Anybody know where to start?
From scratch.
Seriously: Its good to extend given controls but only to a certain extend. I had more than once made the experience that it is sometimes more work to bend the .Net framework controls to my needs instead of just writing my own.
Think about your case: You are painting the combobox items yourself. Now you also want to paint the textbox yourself. What is left of the original control? Probably not more than the dropdown button...
|
|
|
|
|
Hi All
How can I rotate the world in Managed DirectX using mouse drag and zooming using Scroll, like DirectX Viewer did
Thx All
|
|
|
|
|
Text Graphics has the facility to rotate the text by using RotateTransform.
Change its corrdinate in mouse move and Zoom in .
If you can think then I Can.
|
|
|
|
|
I want to buid my custom DVD graph and then get all the DVD interface.
I know how to build the graph but I don't know how to get the DVD interface.
I am using the DirectShowLib library.
Of course, I cannot use the code below which is for graph created using the
DvdGraphBuilder
Guid riid = typeof( IDvdInfo2 ).GUID;
hr = dvdGraph.GetDvdInterface( riid, out comobj );
Marshal.ThrowExceptionForHR( hr );
My code for creating the graph is:
m_graphBuilder = (IFilterGraph2) new FilterGraph();
idvdnav = new DVDNavigator() as IBaseFilter;
hr = m_graphBuilder.AddFilter(idvdnav,"DVD Navigator");
Marshal.ThrowExceptionForHR(hr);
IPin nav_video = GetPinByName(idvdnav,"Video");
hr = m_graphBuilder.Render(nav_video);
Marshal.ThrowExceptionForHR(hr);
IPin nav_AC3 = GetPinByName(idvdnav,"AC3");
hr = m_graphBuilder.Render(nav_AC3);
Marshal.ThrowExceptionForHR(hr);
IPin nav_SP = GetPinByName(idvdnav,"SubPicture");
hr = m_graphBuilder.Render(nav_SP);
Marshal.ThrowExceptionForHR(hr);
I think I must get IDvdInfo2 and IDvdControl2 interfaces of the DVD Navigator somewhere but I
am lost.
I tried to add the code below but I don't think it is working:
comType = Type.GetTypeFromCLSID(typeof( DVDNavigator ).GUID, true);
if (comType == null)
throw new NotImplementedException(@"DVD Navigator not installed/registered?");
comobj = Activator.CreateInstance(comType);
dvdInfo = (IDvdInfo2) comobj;
dvdCtrl = (IDvdControl2) comobj;
comobj = null;
Any idea?
Thanks in advance for you help.
PS: I wanted to post this question of SF forum but it seems it's impossible to start new threads there.
Manusse
-- modified at 16:05 Sunday 30th April, 2006
|
|
|
|
|
Hi,
I have also posted this question in SF forum after it started working again.
I got an answer and posted my comments.
I copy it also here for those interested:
The answer I got:
I believe you get those off the DvdNavigator, don't you?
IDvdInfo2 dvdInfo = idvdnav as IDvdInfo2;
My answer:
Thanks for your reply.
In the meantime I had found it also.
In my case as dvdInfo is already defined, a simple cast will do the job. It is easier than what I thought:
dvdInfo = (IDvdInfo2) idvdnav;
I am a beginner in C# but I am impressed by its apparent ease of use.
The answer was there:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkCOMInteropPart1CClientTutorial.asp
See: Using Casts Instead of QueryInterface
I think this also means that the DVDPlay sample could be a bit simplified.
For example instead of:
hr = dvdGraph.GetDvdInterface( typeof( IVideoWindow ).GUID, out comobj );
DsError.ThrowExceptionForHR( hr );
videoWin = (IVideoWindow) comobj;
comobj = null;
Simply writing:
videoWin = (IVideoWindow) graphBuilder;
Does the same job
Manusse
-- modified at 16:06 Sunday 30th April, 2006
|
|
|
|
|
Hi all,
I have a Datalist with dynamicly created CheckbosLists in it, a little like this:
protected void lstDashboardOptions_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
CheckBoxList cbxDashboardGroup = new CheckBoxList();
DataListItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
cbxDashboardGroup = (CheckBoxList)item.FindControl("cbxDashboardGroup");
DataRowView drv = (DataRowView)item.DataItem;
int intReportId = Convert.ToInt32(drv.Row["rep_id"]);
cbxDashboardGroup.DataSource = ccoDalReport.ReportGetTabs(intReportId);
cbxDashboardGroup.DataTextField = "rta_Name";
cbxDashboardGroup.DataValueField = "rta_Id";
cbxDashboardGroup.DataBind();
}
}
The code works fine. The problem comes when I want to check wich items has been selected. I do this in a foreach loop a little like this:
protected void btnDashboardSave_Click(object sender, EventArgs e)
{
foreach (DataListItem item in lstDashboardOptions.Items)
{
foreach (Control ctrl in item.Controls)
{
if (ctrl is CheckBoxList)
{
foreach (ListItem lstItem in (ctrl as CheckBoxList).Items)
{
Response.Write(lstItem.Text +"["+ lstItem.Selected) + "]<br>";
}
}
}
}
}
The item text comes out right, but the item selected always return false i.e. not checked.
The whole thing is sitting in a usercontrol, but that shouldn't be the reason for it not to work. Any one knows what I'm doing wrong here.
Mike
|
|
|
|
|
Here is how I detemine if a CheckedListBox item is checked:
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if (checkedListBox1.GetItemChecked(i)==true)
{
}
else
{
}
}
|
|
|
|