|
how can I copy a file to a server?
is it using file.copy???
Nisrine
|
|
|
|
|
Yes.
Using System.IO;
...
File.Copy(SOURCE,TARGET);
or
File.Copy(SOURCE,TARGET,OVERWRITE); where overwrite is true/false
|
|
|
|
|
Is there a way to trap a mouse click on your taskbar window button.
My application does not have the title bar. So am facing two problems.
1. I cannot restore my application by clicking on the taskbar window button, if it is minimized.
2. On Windows 2000 if I choose Minimize All, my app is not minimized along with the other apps.
Help wanted badly!!!
Thanks,
Blade
|
|
|
|
|
I have a ContextMenu with about a dozen MenuItems in it. I've assigned the ContextMenu property of several NumericUpDown controls. When the user right-clicks one of the NumericUpDown controls and then selects a MenuItem from the ContextMenu. This triggers the MenuItem's Click event.
Within the MenuItem's event handler, I need to determine which NumericUpDown control called the MenuItem so I can set the Value property of the NumericUpDown to the appropriate value.
The problem is, I cannot seem to make this happen. The SourceControl of the ContextMenu has a type of "UpDownBase+UpDownEdit". I've found UpDownBase in the docs, but I get casting errors whenever I try to get to the value of the NumericUpDown. Such as...
private void miProg010_Click(object sender, System.EventArgs e)<br />
{<br />
MenuItem mi = (MenuItem) sender;<br />
ContextMenu cm = mi.GetContextMenu();<br />
Control c = (Control) cm.SourceControl;<br />
UpDownBase udb = (UpDownBase) c;<br />
}
Any ideas?
-- James --
|
|
|
|
|
So I kept working on it and discovered the following: The NumericUpDown is a contol composed of other controls. If the user pulls up the context menu by right-clicking the TextBox area of the NumericUpDown, the the ContextMenu's SourceControl can be cast to a TextBox, or you can get the parent of the TextBox which will be the NumericUpDown I was originally seeking. If the user right-clicks the spinner portion, the ContextMenu's SourceContol is the NumericUpDown directly.
So the code that does what I was asking is here:
private void miProg010_Click(object sender, System.EventArgs e)<br />
{<br />
MenuItem mi = (MenuItem) sender;<br />
ContextMenu cm = mi.GetContextMenu();<br />
NumericUpDown nud = null;<br />
<br />
if (cm.SourceControl.GetType() != typeof(System.Windows.Forms.NumericUpDown))<br />
nud = (NumericUpDown) cm.SourceControl.Parent;<br />
else<br />
nud = (NumericUpDown) cm.SourceControl;<br />
<br />
nud.Value = 10;<br />
}
Hopefully this saves someone out there some grief.
-- James --
|
|
|
|
|
Is it possable to grab the Printer settings dialog and postion it where ever I want? I notice that when calling the printer settings dialog, it always goes to the centre of the screen, where I want it to go to the centre of my program
|
|
|
|
|
Since you can't derive PrintDialog , you're going to have to rely on owner messages, which hopefully should work (does in Win32, which the CommonDialog /PrintDialog classes use, but this is untested).
Override the WndProc method of your form (or add a message filter to the Application object, but this can be more difficult to implement). Assuming that the PrintDialog passes messages up the chain, you can access the dialog from the Message.HWnd property. You could run a little test to see if you're getting messages (like mouse messages, just insert a Debug.WriteLine in a test handler to see). If you are, you can handle the WM_INITDIALOG (0x0110) message and P/Invoke a call to SetWindowsPos , passing the HWND of the dialog along wit new site and position information.
See the PSDK docs for more details on SetWindowPos and messaging.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I can get my toolbar to work when clciking a button, but I want to be able to tell - is what button I right clicked on.
Has anyone any idea how to do this?
|
|
|
|
|
Other than overriding the Toolbar class and using Win32 messages to do some of this, or using a pre-canned and much-better toolbar out there (like from Magic controls), there is a completely managed way of doing this.
Hook-up an event handler for either the Click event, or the MouseUp or MouseDown events. Using the Click event does warrant some extra code, but gives you some things for free (like detecting if the user escaped and message before you handle the "up" event). You can get the screen coordinates using the Click event, then use Control.MousePosition to get the screen coordinates, then use Control.PointToClient to get the form coordinates. If you use one of the Mouse* events, you are given the form coordinates.
Then, pass the Point to a function like so:
private ToolbarButton GetButtonFromPoint(Point p)
{
foreach (ToolbarButton btn in myToolbar.Buttons)
{
Rectangle r = myToolbar.RectangleToClient(btn.Rectangle);
if (r.Contains(myToolbar.PointToClient(p)))
return btn;
}
return null;
} You might have to fiddle with the coordinate conversion a little to make sure it works. This code is untested but should give you the basic idea.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Does anyone know how I can draw a dashed or dotted line. I dont seem to be able to get amywhere using System.Drawing.Graphics short of drawing lots of little line. This can be right.
tia
gadget
www.FUXUP.com[^]
|
|
|
|
|
You set it in the Pen that you use to draw (the first parameter in all overloaded Graphics.DrawLine methods). There are many properties (mostly, DashStyle ) that you can set to do dashed lines, and dictate the frequency, length, etc. of those lines.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
If you still have any questions about what all the options are you can check the following article out on the MSDN.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingpenclasstopic.asp
|
|
|
|
|
Thanks, I new there was a way - I just couldnt find it.
|
|
|
|
|
am trying to load JPEG2000 (J2k) image and make use of the scalability features provided by J2k
by showing the image while loading. The tutorials clearly show that there are two possible “modes”:
- Progressive by resolution (You load the picture and it becomes sharper while loading, something
like interlaced GIF)
- Progressive by accuracy (ROI – region of interest)
I am interested in the first: “Progressive by resolution”. So I want to show the image while loading
for example if you download a 2 MB image through Modem connection.
I am looking for a exemplary implementation - does not matter in which language or platform it is running.
I would be grateful for any help.
Regards,
gicio
|
|
|
|
|
Hello, Everyone!
This is my very first post here, and I'm hoping someone can help me out.
I'm not even a novice C# programmer (DBA by trade) but I have a small app I'm working on and need to import a CSV text file into an MS Access Database table using C#.
If anyone can help me out with some sample code I would be very grateful. (I'll even help ya out with SQL code if you need! =)
~Best Regards!
Ray Sotkiewicz
T-Mobile USA
raymond.sotkiewicz@t-mobile.com
|
|
|
|
|
The first thing you want to do is import that CSV file into a Dataset... Best shown here: http://www.codeproject.com/cs/database/asc2xxx.asp[^]
Then you can use that data set to create a table in the access database. Do you need help on that end also?
// Steve McLenithan
Family Guy: Season 2 - Episode 8
|
|
|
|
|
I'm trying to read the StandardOutput of a process while it is running, but I'm unable to read anything from the StandardOutput before the process actually finishes. Here's what I currently have. I was trying to multithread it in the hope that that would solve the problem but it still doesn't, although it doesn't hang up my whole application anymore The method PutFiles is called first:
<br />
public void PutFiles(string FilePath)<br />
{<br />
string args = "-r -pw " + m_Password + " " + FilePath + " " + m_UserID + "@" + m_Address + ":" + m_CalcPath;<br />
m_ProcessArgs = args;<br />
m_ProcessApp = "pscp.exe";<br />
Thread myThread = new Thread(new ThreadStart(TransferProcess));<br />
myThread.Start();<br />
}<br />
<br />
private void TransferProcess()<br />
{<br />
ProcessStartInfo pInfo = new ProcessStartInfo(m_ProcessApp,m_ProcessArgs);<br />
pInfo.UseShellExecute = false;<br />
pInfo.RedirectStandardOutput = true;<br />
pInfo.RedirectStandardError = true;<br />
pInfo.CreateNoWindow = true;<br />
m_Running = Process.Start(pInfo);<br />
m_StdOut = m_Running.StandardOutput;<br />
Thread InfoThread = new Thread(new ThreadStart(ProcessInfo));<br />
InfoThread.Start();<br />
m_Running.WaitForExit();<br />
MessageBox.Show("Transfer Thread Done");<br />
}<br />
<br />
private void ProcessInfo()<br />
{<br />
MessageBox.Show(m_StdOut.Read().ToString());<br />
}<br />
The MessageBox in the ProcessInfo thread will not be displayed until the process is actually finished. If I don't try reading the stream in the ProcessInfo method then it'll display a textbox immediately. I've tried Read, ReadLine and ReadToEnd, but they all do the same thing. What I'm trying to do is grab the StandardOutput while it is being produced so that I can echo it to the user and they'd know whats going on.
Anybody got any ideas on this one?
|
|
|
|
|
You have to grab the stdout before you start the process. This is even in the docs. Since it's a reference, the reference will be non-null when the loader allocates resources for the new process.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
What exactly do you mean? I tried this:
<br />
ProcessStartInfo pInfo = new ProcessStartInfo(m_ProcessApp,m_ProcessArgs);<br />
pInfo.UseShellExecute = false;<br />
pInfo.RedirectStandardOutput = true;<br />
pInfo.RedirectStandardError = true;<br />
pInfo.CreateNoWindow = true;<br />
m_Running = new Process();<br />
m_Running.StartInfo = pInfo;<br />
m_StdOut = m_Running.StandardOutput;<br />
m_Running.Start();<br />
But I get an exception saying that StandardOutput has not been redirected. What docs are you looking at? The only ones that I've found only mention that you should read the StandardOutput before you wait for the process to finish because otherwise the pipe can fill up and hang both processes (the one you started and the parent). I haven't seen any suggesting that you should try and read it before starting the process!
|
|
|
|
|
The docs I'm talking about are the .NET Framework SDK docs, specifically for Process.StandardOutput ; however, when I looked here at my newest MSDN Library at home, you're right - you can't read it until after the call to Process.Start . The documentation I have at work is an older version - looks like it's time to update!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Okay, thats what I was looking at too. Thanks for trying to help.
I've looked everywhere I can think of, but I can't find any examples of doing this. I'm wondering if it might be the case that the process that I'm running has to fill the pipe before anything can be read out of the StandardOutput? Maybe it's the case that my process just isn't writting enough for the pipe to be flushed into the StandardOutput stream? Therefore, I have to wait until the process is complete before anything gets written to the stream. The process that I'm running can take a while to run, but it doesn't write all that much to the console while it's running. Does anybody know if this is likely and if there is a way around it?
|
|
|
|
|
I have looked High and low to get this resolved, but still no luck .
I am trying to get some VB6 forms to show from within my C# windows app.
I have created a VB6 COM component (ActiveX dll) that has a method that is able to display the VB6 forms I need. This works fine in a VB6 test harness. but if I fire it off from a button in my C# windows form i get an ActiveX error:
Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property Page
The only way the VB6 forms will show up in my C# app is if I have the forms in VB6 show as Modal, BUT I absolutely need to show them as modeless.
please help. I'm tearing whats left of my hair out!
|
|
|
|
|
I have a multilie textbox and I only want it to contain HEX characters. I can stop non-hex characters being typed in as I check what keys are being pressed, however I am having problems with pasting text into the textbox.
There are 2 ways to paste : via the context menu or pressing ctrl+v
I can detect a right click (which brings up the context menu) but I can't detect what menu item is selected from the context menu. I want to find out if paste has been selected and then validate the text and reject the paste if it contains non-hex characters.
I want to do the same for the keyboard shortcut for paste i.e. ctrl+v
Any help appreciated
Eco
|
|
|
|
|
Could you not hook the TextChanged event of your text box? I think that event should be fired when text is pasted into you text box regardless of how it was pasted. I'm not sure if you're going to be able to restore the old text if you decide to reject the new text though? Perhaps you could copy the text to a member varible in the TextChanged event (if the new text is valid) then if the new text is invalid you'd be able to restore it from the last time it was changed to something valid.
Yeah, I think that should work?
|
|
|
|
|
Hi,
I'm trying to catch an event fired by a radio button in a html page.
for this reason I created a console application in c#.
Until now, I managed to open an internet explorer instance,
and got a connection to the document via the mshtml.IHTMLDocument2 function.
After receiving the documentcomplete event my eventhandler mthlEvents.onmousedown
reacts if I click in the Internet Explorer with the mouse.
But my Radio Button is not marked and I see no way, to catogorize between different
Radiobuttons (i.e. No.1 and No.2).
I tried the example by Nikhil Dabas: Handling Document Events, too.
But the axshdocvw.dll is not available in a console application.
The shdocvw.dll which I'm using does not know the
DWebBrowserEvents2_DocumentCompleteEvent.
So I can't run this sample.
If somebody is more specialisted than me, please contact me.
Thanks Sonja
|
|
|
|