|
you should use command line parameters and read them in Program.cs as below
static void Main()
{
string[] arguments = Environment.GetCommandLineArgs();
if (arguments.Length > 0)
{
foreach (string argument in arguments)
{
if (argument == "something")
{
call options;
}
else
{
call program;
}
}
}
}
next thing you have to create two application shortcuts in setup project and pass respective parameters to them. these are the same parameters which will read by program.cs.
based on this you can toggle start up object on you application.
Hope this helps..
pls reply if you need something else
|
|
|
|
|
how are charts resized in windows form the same way charts in excel. I think charts in excel convert to an image and then resized.
|
|
|
|
|
Member 9811332 wrote: I think charts in excel convert to an image and then resized. Why would you think that? Resizing is merely repainting the frame and its contents according to the new position and dimensions set by the user.
Use the best guess
|
|
|
|
|
i have some problem in handling mdi windows form
in my application i want that when open a child form after the clicking of menuitem in mdiparent form, then after that mdiparent form will be disabled and when i will close the child form the mdiparent form will be enabled again.
during the disability uer can not close the parent form , user must hav to close the child form firt thn after user may can close the parent form.
can any help me in it how to do it in c#...........
|
|
|
|
|
Arun kumar Gautam wrote: can any help me in it how to do it in c#. You just need to keep some state flags to tell you whether the form can be closed or not.
Use the best guess
|
|
|
|
|
It is very hard to understand the issue that you are facing using mdi windows form. Can you please rewrite your problem using proper language without any spelling errors?
|
|
|
|
|
The behaviour you describe is default for a modal dialog. A MDI-document is exactly that, a document-interface - not a dialog.
Use a normal form, call the ShowDialog method.
Done.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'm testing the software. Database functions are connected using BackgroundWorker or not load any data into the control, only assign backgroundimage but at load user control on the user control the control it still blinks for 5 seconds. who have there a way to fix that for load control in the user control that does not flicker? Thank you everyone
|
|
|
|
|
Lương Tuấn Anh wrote: who have there a way to fix that for load control in the user control that does not flicker? Pause the painting[^] while updating the property and set your form to DoubleBuffered. You can post the code here if you want specific tips.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i will set property for form is DoubleBuffered = true . but it did not improve much. >.<
|
|
|
|
|
DoubleBuffering the form will speed up drawing "a bit". Disabling drawing as suggested will improve it "a bit" too. Without your code, I can only give these options. If you only need to assign the image to a control, then there would be not much of a "flickering", albeit the screen will show the update.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have one form and one panel. my Panel set background image are .png. form set DoubleBuffered = true. One user control have more than 10 controls (combobox, textbox...) when User control add to this panel, it flicker
< ====== My Code> http://www.mediafire.com/?1mgh5qjcly1auq2[^]
UC 1 : have DoubleBuffered = true.
But I don't want form flickered when load. I want form load the same when form don't set background image.
|
|
|
|
|
Lương Tuấn Anh wrote: But I don't want form flickered when load.
Then read the link provided to stop it drawing while running the InitializeComponents-method. How long does it take to show that form? Contains many controls?
--edit;
The idea would be for you to post the relevant code, surrounded with pre-tags, not a binary package.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i don't knows. you can said more details or help me code in this project. Thank
|
|
|
|
|
Lương Tuấn Anh wrote: you can said more details or help me code in this project. That's what I'm trying. Let's try it another way; copy the method below (comes from here[^])
public static class SuspendUpdate
{
private const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(control.Handle, WM_SETREDRAW, IntPtr.Zero,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(control.Handle, WM_SETREDRAW, wparam,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
Call it in the InitializeComponents , or whereever you put the image in the control.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
can you give me one example for it .. i'm newbie ... thank you very much
|
|
|
|
|
Ehr, no; read the article, it contains the example.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
ok , thank you . i will ask you if i dont know thank you verry much. Do you have Yahoo or mail ?
|
|
|
|
|
Lương Tuấn Anh wrote: i will ask you if i dont know Please do so - wrote the example in a few spare moments, based on a new project;
using System;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
SuspendUpdate.Resume(this);
}
public void button1_Click(object sender, EventArgs e)
{
SuspendUpdate.Suspend(this.pictureBox1);
this.pictureBox1.Image =
SuspendUpdate.Resume(this.pictureBox1);
}
}
public static class SuspendUpdate
{
const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(
control.Handle, WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(
control.Handle, WM_SETREDRAW, wparam, IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
} Here we add in some help-routines in a new class; they should be in a separate file. Before updating something, call "Suspend" to stop the drawing temporarily and "Resume" to active it again. It'll speed up things on the UI-thread if it doesn't have to paint every change. I've also surrounded the "InitializeComponents" routine with those calls, to speed up the load-time. Again, it helps "a bit", it's not a miracle-worker. If your image is very large (>5 Mb), then it might be wiser to change the image.Lương Tuấn Anh wrote: Do you have Yahoo or mail ? I'm every day available on CodeProject; whenever I open GMail, I also open CodeProjects' forum. I'd also get an email if you reply to one of my messages
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
i will set SuspendUpdate for UC and panel but controls add in UC disappeared at load. when mouse move to controls, it will show. Do you see for me will set SuspendUpdate ok?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testForm
{
public partial class Form1 : Form
{
public Form1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
loadUC1();
SuspendUpdate.Resume(this);
}
public void loadUC1()
{
panel1.Controls.Clear();
UserControl1 test = new UserControl1();
SuspendUpdate.Suspend(this.panel1);
panel1.Controls.Add(test);
SuspendUpdate.Resume(this.panel1);
}
public void loadUC2()
{
panel1.Controls.Clear();
UserControl2 test2 = new UserControl2();
SuspendUpdate.Suspend(test2);
panel1.Controls.Add(test2);
SuspendUpdate.Resume(test2);
}
private void button1_Click(object sender, EventArgs e)
{
loadUC1();
}
private void button2_Click(object sender, EventArgs e)
{
loadUC2();
}
}
public static class SuspendUpdate
{
private const int WM_SETREDRAW = 0x000B;
public static void Suspend(Control control)
{
Message msgSuspendUpdate = Message.Create(control.Handle, WM_SETREDRAW, IntPtr.Zero,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgSuspendUpdate);
}
public static void Resume(Control control)
{
IntPtr wparam = new IntPtr(1);
Message msgResumeUpdate = Message.Create(control.Handle, WM_SETREDRAW, wparam,
IntPtr.Zero);
NativeWindow window = NativeWindow.FromHandle(control.Handle);
window.DefWndProc(ref msgResumeUpdate);
control.Invalidate();
}
}
}
and code in UC
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace testForm
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
SuspendUpdate.Suspend(this);
InitializeComponent();
this.DoubleBuffered = true;
SuspendUpdate.Resume(this);
}
}
}
all with the same result.
|
|
|
|
|
Only one control can be suspended at a time; remove the suspend-methods in the UserControls and it should work
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
In a C# 2008/2010 desktop application, I need to be able to allow users the ability
to select a file they need to work with. There needs to be a default directory path. However I need to be able to allow users the ability to select files from whatever directory path they have access to.
Thus can you tell me. show me code, and/or point me to a url I can use as a reference to accomplish my goal?
|
|
|
|
|
use OpenFileDialog Control. this will allow you to choose any file.
You can get file name using OpenFileDialog.FileName
|
|
|
|
|
OpenFileDialog control seems to be the only option for you as it can allow users to choose any file from whatever directory path they want to access.
|
|
|
|