 |

|
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|

|
Well, I'm plum out of ideas. I've got a listbox with a List<> for its DataSource. When I init it - before the form is displayed, it works. But not after that. I am modifying the List<> contents and then I run:
public void RefreshLbx()
{
lbxQuotes.DataSource = null;
lbxQuotes.DataSource = _quotes;
}
where _quotes is the List<>
Now here is where it gets weird. I put a button on the form - here's its handler:
private void btnRefresh_Click(object sender, EventArgs e)
{
RefreshLbx();
}
So that when I click on the button then the lbxQuotes listbox is properly updated. But in the modification code - where I call RefreshLbx() directly, nothing happens.
I even tried invoking btnRefresh_Click() in the code, but alas could not find the magic.
Oh one other thought - the modification code is in a timer event handler - could this be a problem of trying to modify a control from a different thread? All I am doing is changing the List<> contents and then reseting the DataSource.
I must be missing something to kick the listbox to redisplay, or something... HELP!
|
|
|
|

|
Wow but this is weird. Okay, I found the solution because I tried the recommendation given below:
lbxQuotes.DataSource = null;
lbxQuotes.DataSource = _quotes;
lbxQuotes.SelectionMode = SelectionMode.None;
lbxQuotes.SelectionMode = SelectionMode.One;
That is, I added the SelectionMode two lines... and this caused (only once) a "from different thread" exception. Weird, I'm NOT running a method - I'm changing data... hmmm... I wonder if the DataSource is instead a Property (which secretly runs a method). D'oh!
Okay, so the solution was to create a delegate in the main form, for the RefreshLbx method, and have the RefreshLbx method recursively call this, as below:
public void RefreshLbx()
{
if (lbxQuotes.InvokeRequired)
{
lbxQuotes.Invoke(_refreshLbx);
}
else
{
lbxQuotes.DataSource = null;
lbxQuotes.DataSource = _quotes;
}
}
with the _refreshLbx delegate defined in the form's class as:
private delegate void RefreshLbxDg8();
private RefreshLbxDg8 _refreshLbx;
Then just init the delegate in the form constructor (after the InitializeComponent() call):
_refreshLbx = RefreshLbx;
Now I am able to update the listbox contents from a timer handler.
|
|
|
|

|
I have two objects, PriceRule and WeekDay, and PriceRule has a DayId column I have bound to a ComboBox column in a DataGridView. When I load the grid, if DayId is null, the combo is blank, but as soon as I drop the combo down, I have to select a day. No problem, I can inject an extra empty string day into the combo's data source, but the Id property of WeekDay is not nullable, so I need to do something as clumsy and stupid as insert a false day with Id of -1.
How do I catch this -1 and make it null before saving, and vice versa, catch a null DayId and make it -1 when loading?
Is there no other way to do what is a bloody common task that MS clearly isn't capable of handling themselves?
|
|
|
|

|
I'm creating an user control like treeView, in this control, I want to put a button to let my user control hide/show in Owner form.
how could I do?
thanks
|
|
|
|
|

|
Just delete it in C# forum
|
|
|
|
|

|
kenmaMoon wrote: how could I do?
Toggle the Visible property?
The problem is a logical one; if you hide the control containing the button to toggle visibility, the user will not be able to make it visible again, as the button that toggles it is invisible too.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|

|
thanks for your reply.
yes, but the button is in the userControl, next time I want the user control shown by click the button.
|
|
|
|

|
kenmaMoon wrote: yes, but the button is in the userControl, next time I want the user control shown by click the button.
Re-read what I wrote; the button will be invisible if you hide the container it's in. You cannot click an invisible button.
Either put the button somewhere else and have it toggle the Visible property, or put the button somewhere on location (0,0) and resize the control to shrink to the size of the button.
Third, best option; throw the button and the control you wish to show/hide on a new usercontrol.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|

|
I am working on a heavily used winform C# application.
I have a user control, that has 3 textboxes and it can contain another user control. user can add n number of main user control on the form. due to this, if the user adds more than 20 controls, after the 20th control, the UI doesnt show anything. It is not giving any exception, its simply not drawing the controls? My application is not exceeding GDI objects
Also the textbox is using WPF textbox.
All suggestions welcome. Thanks.
|
|
|
|

|
Member 7834460 wrote: after the 20th control, the UI doesnt show anything.
Does that mean that "20 items" is the maximum that "fit" on your form? It might be creating the rest of them on the non-visible area.
Does it have a ScrollViewer where you put the children in? Any scrollbars set?
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|

|
Hello!
Gray BackColor is not suitable for my application GUI. Tell me how it is possible to change the background color of the control.
|
|
|
|

|
So what happens when you change the value of the BackColor property?
|
|
|
|

|
Nothing ... )) msdn: "This member is not meaningful for this control"
|
|
|
|

|
Did you read this[^]?
You'll have to custom draw the tab control yourself to change the color.
|
|
|
|

|
I'm using Visual C# 2010 Express.
I've written code to display Provider maps on my form.
I can draw lines on the maps, and capture the latitude / longitude from the map.
My problem is that when I pan or zoom the map, my drawn line stays in one place; it doesn't move or resize with the map.
I'm using a gMap control to load the provider maps as below:
private void Form1_Load(object sender, EventArgs e)
{
gMapControl1.MapProvider = GMap.NET.MapProviders.ArcGIS_Topo_US_2D_MapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
gMapControl1.Position = new GMap.NET.PointLatLng(39.401389, -077.986111); gMapControl1.Zoom = 10;
I've created an Overlay for my form, and I'm drawing on the overlay as below:
private void graphicalOverlay1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen fl = new Pen(Color.Red, 3.0f);
e.Graphics.DrawLine(fl, x_start, y_start, xx, yy);
}
Perhaps I shouldn't be drawing on the Overlay. But I don't know how to just draw on the providers image.
Any direction to "lock" my drawn lines with the map would be appreciated.
Thanks
AW
|
|
|
|

|
e.Graphics.DrawLine(fl, x_start, y_start, xx, yy); uses pixel values, not geo coordinates. You have to get the latitude/longitude values for your lines, the transform them into pixels using the zoom and offset values of the underlying map.
|
|
|
|

|
Bernhard;
Thank you for reading my post question and replying.
I'm getting the lat/long coordinates with this:
private void gMapControl1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
double lat = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lat;
double lng = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lng;
This returns decimal degrees which I then convert to dd-mm-ss.sss.
I was using the following to paint my lines on the provider map, which does work to paint the lines;
private void gMapControl1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen fl = new Pen(Color.Red, 3.0f);
e.Graphics.DrawLine(fl, x_start, y_start, xx, yy);
But x_start, y_start, xx, yy are nothing more than screen coordinates; just like with the overlay code. And when I pan or zoom, the map moves but my drawn lines stay in the same place relative to the screen.
x_start = e.X;
y_start = e.Y
Are you saying that I need to pass the geo coordinates to xx, yy to draw the lines on the providers map?
I don't understand your statement; "then transform them into pixels using the zoom and offset values of the underlying map".
|
|
|
|

|
Oh, I think I understand what you meant!
I need to do something like
Double map_x equals gMapControl1.FromMapLatLngToLocal(PiontLatLng Point);
Then when I pan or zoom, just redraw my lines.
Can you provide the proper syntax for MapLatToLocal ?
|
|
|
|

|
That's the way to go. But I do not know the functions provided by the control. Why don't you ask the author - there is a section below his article for taht purposes, isn't it?
|
|
|
|

|
people often develop chat apps and they display chat conversion between two people in simple text box or rich text box. i want to develop a chat apps where i want to design chat conversion UI area look like Skype.
1) Skype chat conversion area show the conversion where other user name show as with different color
2) user can copy text from chat conversion area by mouse selection
3) chat conversion area is capable of showing emoticons.
4) chat conversion area can show progress bar when one user send file to other then progress bar is show at two end.
so here i am uploading few screen shot of Skype chat conversion area as a result you guys can visualize and can understand what kind of UI i want to develop. please click on the two link to better understand what i am talking about.
http://social.msdn.microsoft.com/Forums/getfile/262465[^]
http://social.msdn.microsoft.com/Forums/getfile/262468[^]
the problem is i am not being able to take decision how to develop chat conversion window where i need to show chat conversion data between two user and user name too. also that area must have capability of showing emoticon and progress bar and images.
so just suggest me which control i should use to develop chat conversion windows.
1) should i use rich text box ?
2) should i use datagridview ?
2) should i use web browser control ?
i need something which can show user name and user chat data and also emoticon and progress bar.
please guide me how to develop. if possible give me some c# code. thanks
tbhattacharjee
|
|
|
|

|
Tridip Bhattacharjee wrote: please guide me how to develop Use a rich-text box. Hardest part in a chat-application will be the server. After that, it's doing the messaging on a background-thread in the client, to keep the UI nicely responsive. The UI itself is hardly relevant at that point.
I'd start with a plain textbox; once it works, make a backup. Then yank out that textbox, plugin a RTB. Or a WebBrowser. Or something more complex. (FWIW, example seems like a list of a custom-control, consisting of 2 labels and a HTML-capable label in the middle)
The datagridview would be the fastest of those controls. The browser would be ideal, given that you can simply embed emotes as pictures in the text.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|

|
u said :- FWIW, example seems like a list of a custom-control, consisting of 2 labels and a HTML-capable label in the middle
what is the meaning of FWIW? where to download it.
tbhattacharjee
|
|
|
|

|
Tridip Bhattacharjee wrote: what is the meaning of FWIW?
FWIW is "For What It's Worth". You can build a UserControl, drop two labels and a browser on there, and you'd have something similar.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|

|
I have a WinForms application that moves a group of points around with the mouse. The code has worked fine on Win 98, XP and Vista. It was slow under Win7, until I disabled the Aero stuff and then it was fine there, too. Now under Win8 it's acting just like on Win7 with Aero activated.
I've checked to make sure the graphics drivers are updated, and even gone to Control Panel and set things for Optimum Performance rather that Optimum Appearance. No difference at all.
Does anyone know what might be done? This is a show stopper! The program uses plain GDI and is in C#.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|

|
Disable Aero for Win8
modified 19 Apr '13 - 15:36.
|
|
|
|

|
If you figured out how to disable Aero in Win 8, I'd love to hear about it. I thought about that first.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|

|
Joke is joke, but come back to reality...
The transparent borders/glass effect as Aero themes are gone in Windows 8. Many useful information you'll find here: http://superuser.com/questions/445971/disable-aero-on-windows-8[^]
Although, above information isn't friendly much, there is a possibility to disable some visual options, which can help to improve performance:
1) Go to Control Panel-> (in Icon View) click Easy Of Access Center
2) Find Explore All Setting section
3) Go to Make things on the screen easier to see section and find Turn off all unnecessary animation (when it possible) and Remove background images (when available)
4) Check both options
That's all. I hope it helps.
|
|
|
|

|
I tried all of that months ago before posting the message, even talked to Microsoft. I also investigated graphics card issues - no change.
It appears they have changed something inside the Win8 graphics kernel so that part of Aero is built-in and cannot be disabled conventionally.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|

|
below is my routine which works fine but the routine is not generating the image of sdi form with proper height & width. here is my routine and i think there is flaw but i am not being able to capture & fix the flaw. so here is my code. please have a look and guide me what i need to change in this code to fix this flaw.
protected virtual void OnMinimize(EventArgs e)
{
Rectangle r = this.RectangleToScreen(this.ClientRectangle);
int titleHeight = r.Top - this.Top;
_lastSnapshot = new Bitmap(r.Width, r.Height);
using (Image windowImage = new Bitmap(r.Width, r.Height + titleHeight))
using (Graphics windowGraphics = Graphics.FromImage(windowImage))
using (Graphics tipGraphics = Graphics.FromImage(_lastSnapshot))
{
windowGraphics.CopyFromScreen(new Point(r.Left, r.Top - titleHeight),
new Point(0, 0), new Size(r.Width, r.Height + titleHeight));
windowGraphics.Flush();
tipGraphics.DrawImage(windowImage, 0, 0, r.Width, r.Height + titleHeight);
_lastSnapshot.Save(@".\tmp.bmp", ImageFormat.Bmp);
}
}
with the help of above routine i could generate form image and just click on the link to check.
http://i.stack.imgur.com/wCvUl.png[^]
tbhattacharjee
|
|
|
|

|
Unfortunately the ClientRectangle does not include the form borders so that is not useful for capturing the complete window. However the actual location and size is kept in the form's properties and can be used to capture the window as below. And in this case, the title bar size is not needed.
Rectangle r = new Rectangle(this.Left, this.Top, this.Width, this.Height);
Bitmap _lastSnapshot = new Bitmap(r.Width, r.Height);
using (Image windowImage = new Bitmap(r.Width, r.Height))
using (Graphics windowGraphics = Graphics.FromImage(windowImage))
using (Graphics tipGraphics = Graphics.FromImage(_lastSnapshot))
{
windowGraphics.CopyFromScreen(new Point(r.Left, r.Top), new Point(0, 0), new Size(r.Width, r.Height));
windowGraphics.Flush();
tipGraphics.DrawImage(windowImage, 0, 0, r.Width, r.Height);
_lastSnapshot.Save(@".\tmp.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
}
Use the best guess
|
|
|
|

|
thanks for your answer. i got another trick that is bit small and works well
Bitmap bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size));
bmp.Save(@"d:\Zapps.bmp", ImageFormat.Bmp);
tbhattacharjee
|
|
|
|

|
Good catch.
Use the best guess
|
|
|
|

|
i want to detect mouse over on title bar or mouse out from title bar in my c# winform apps. i got a code sample which works but the problem is when i place the mouse on any area of win form then mouse leave occur and when i put mouse on title bar then right event call. actually i want that if i place my mouse on any area of form except title bar then nothing should happen.only when i will place mouse on title bar then a notification should come to me and when i will remove mouse from title to out of my form then label should display mouse out message but if remove mouse from title bar to form body then label should be blank.
here is code. just run this code and tell me what modification i should do to get my expected result. thanks
using System.Runtime.InteropServices;
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0xA0) // WM_NCMOUSEMOVE
{
TrackNcMouseLeave(this);
//ShowClientArea();
label1.Text = "mouse move on title bar";
}
else if (m.Msg == 0x2A2) // WM_NCMOUSELEAVE
{
//HideClientAreaIfPointerIsOut();
label1.Text = "mouse leave from title bar";
}
base.WndProc(ref m);
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
//HideClientAreaIfPointerIsOut();
}
private int previouseHeight;
private void ShowClientArea()
{
if (this.ClientSize.Height == 0)
this.ClientSize = new Size(this.ClientSize.Width, previouseHeight);
}
private void HideClientAreaIfPointerIsOut()
{
if (this.Bounds.Contains(Cursor.Position))
return;
previouseHeight = this.ClientSize.Height;
this.ClientSize = new Size(this.ClientSize.Width, 0);
}
public static void TrackNcMouseLeave(Control control)
{
TRACKMOUSEEVENT tme = new TRACKMOUSEEVENT();
tme.cbSize = (uint)Marshal.SizeOf(tme);
tme.dwFlags = 2 | 0x10; // TME_LEAVE | TME_NONCLIENT
tme.hwndTrack = control.Handle;
TrackMouseEvent(tme);
}
[DllImport("user32")]
public static extern bool TrackMouseEvent([In, Out] TRACKMOUSEEVENT lpEventTrack);
[StructLayout(LayoutKind.Sequential)]
public class TRACKMOUSEEVENT
{
public uint cbSize;
public uint dwFlags;
public IntPtr hwndTrack;
public uint dwHoverTime;
}
}
tbhattacharjee
|
|
|
|

|
HI,
I Have Created a Desktop Winforms Application On The Basis of Wix.com Means a user can create Html templates in the Application and then Publish Them.now when a user Clicks on the Menu On Right side( Which Contains Menu For Adding Buttons and Other General Controls),The Control is Drawn on The Webbrowser control ( Setting its Editmode true).
But Whenever we add a Control is Alighned to left By Default and There is No Mean To Reorder them .
Can we implement a Functionality Which Lets Users Place Controls on Document where ever they want instead of Having Each control Autoalighned to Left.
Thanx
Tarjeet
Tarjeet
|
|
|
|

|
First, get your finger off the Shift key. You're not using correctly and it makes your post a little difficult to read.
Second, what controls are you talking about?? HTML controls?? Like INPUT tags? If so, you've got a lot to learn about writing HTML and why everything is "left aligned" by default.
|
|
|
|

|
ok but can i break this behaviour of html ??
|
|
|
|

|
You have two choices if you want to continue to use HTML.
1) Use the nightmare that is CSS positioning.
2) Rewrite the HTML spec yourself and write a parsing and rendering engine to use your new spec.
Other than that, we have no idea what you're using HTML for and what your app does, so it's pretty much impossible to suggest any other methods.
|
|
|
|

|
I am finding a new kind of memory link. Maybe not new but new to me. I have an application that generates 50 to 70 threads. I am using a vision library by a third part which generates many of them. My program is a C#/WPF. I think the library was done in C++.
I capture and analyze an image every 60 msec. After 3 to 4 hours I see the thread count for the application rise. This is well over 100,000 images. Every image creates a few threads and then closes them when finished. This spreads the load out over several core. I am watching it in Resource Monitor. Of course as thread count raises so does memory.
Has anyone seen a similar leak?
So many years of programming I have forgotten more languages than I know.
|
|
|
|

|
Do not know for sure. But you could try to call Garbage Collection manually after processing an image. Use GC.WaitForPendingFinalizers() and GC.Collect(). Maybe that helps.
|
|
|
|

|
Even if the system is not used for 5 minutes the extra threads still persists. That should be plenty of time for automatic garbage collection to get rid of old threads.
So many years of programming I have forgotten more languages than I know.
|
|
|
|

|
It's hard to say. The issue could be inside this external library, or it could be in your code. What I would do is, rather than trying to manage the threading by yourself, make use of the Task Parallel Library (TPL). This is a great way to have your code do threading without burdening you with thread lifetime issues. It's incredibly simple to use.
|
|
|
|

|
I am fairly sure it is inside the external library. It processes the images and create all the threads. I only provide an operator interface and process the results.
So many years of programming I have forgotten more languages than I know.
|
|
|
|

|
If it's in that library then you have no recourse but to notify the vendor that their library is leaking memory.
|
|
|
|

|
I have gone to the vendor. Since it takes hours and several 100,000 images they cannot reproduce it and cannot deal with it. It is kind of an exponential failure. Once you get one then there is a higher probability of getting the second, etc.
I do not expect a fix at this point but still hope. It is just a very different kind of bug than I have ever seen and in so many different ways. I was kind of hoping that someone else had seen something like this and might have some clues because it would be really nice to fix.
So many years of programming I have forgotten more languages than I know.
|
|
|
|

|
The only way to fix it is to get the source for the component you're using (yeah, right) and rework the component or scrap the component you're using and use a different library that does the same job, or work up a component from scratch yourself.
|
|
|
|

|
There's no magic bullet to fix threading issues. You can't try and arbitrarily kill threads because you have no idea as to whether or not they are busy. The problem is, doing threading right is hard - very, very hard. I wouldn't accept their answer that they can't reproduce it - if necessary, you could send them a slimmed down version of your code that triggers the leak and let them use that with their debuggers.
|
|
|
|

|
I have an usercontrol that contains a toolstrip. The toolstrip is exposed through the usercontrol by a readonly property 'HostStrip' with DesignerSerializationVisibility.Content attribute. In this way we can handle the toolstrip and its contents from the usercontrol.
While using the usercontrol in an application, after adding the elements of the toolstrip, if I copy the whole usercontrol and paste it somewhere else, the elements of the toolstrip get deleted. I need to add them all over again. Why is this happening and can it be solved?
Regards!
|
|
|
|
 |