|
See Mazdak's answer that he(/she?) copied from MSDN. I was just answering why you couldn't change the paper size with the code you were using. I thought it seemed weird that the original reply was doing this in PrintDocument.PrintPage .
-----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 try that as well and it didnt work. Am i doing somehting wrong?
thanks.
Carlos Eduardo Hernandez P.
|
|
|
|
|
Are you sure the printer supports that size of paper? Use the other technique I mentioned where you get the sizes that it supports and see if that paper size is in the collection.
-----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 try using the enumeration of papersize and it didnt work. But I really need to define a custom size, not one defined on the printer. Before using .Net, I was using VB6, and in Windows 98, Windows 95, it was very easy to print in any paper size in the printer. But after windows NT, or windows 2000, my vb6 applications could not print on any sizes on those windows. I found out that after windows nt, it has to be creted a form and then attach it to the printer and print. Could it be that I have to do the same thing.
Thanks.
Carlos Eduardo Hernandez P.
|
|
|
|
|
Why didn't enumerating work? That's supported by the Framework plus some Windows function that are P/Invoked and has more to do with the print server and the printer driver than the printer itself.
As far as forms, A3 is already supported so long as you use the dimensions that I gave in a previous example - no rounding! You could try it, though. After all, all the print classes and methods in the Framework are just wrappers for all the functionality in Windows anyway.
-----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-----
|
|
|
|
|
THis is sample code from MSDN:
private void MyButtonPrint_Click(object sender, System.EventArgs e)
{
if (comboPaperSize.SelectedIndex != -1) {
printDoc.DefaultPageSettings.PaperSize =
printDoc.PrinterSettings.PaperSizes[comboPaperSize.SelectedIndex];
}
if (comboPaperSource.SelectedIndex != -1) {
printDoc.DefaultPageSettings.PaperSource =
printDoc.PrinterSettings.PaperSources[comboPaperSource.SelectedIndex];
}
if (comboPrintResolution.SelectedIndex != -1)
{
printDoc.DefaultPageSettings.PrinterResolution=
printDoc.PrinterSettings.PrinterResolutions[comboPrintResolution.SelectedIndex];
}
printDoc.Print();
}
Mazy
No sig. available now.
|
|
|
|
|
Hi all
In one of my vc dlls, following structure and function have been declared:
struct mystruct
{
uint u1;
TCHAR arr1[30];
TCHAR arr2[15];
uint u2;
}
int testfunc(mystruct** arrptr)
i have declared c# equivalent of structure as
public class mystruct
{
public uint u1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string arr1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 15)]
public string arr2;
public uint u2;
}
Internally testfunc is implementing arrptr as pointer to array of structures.
My query is what should be declaration of this function. Should i pass class variable by ref, or IntPtr or ???
Thanks in advance
lsb
|
|
|
|
|
Both, actually. This is a pointer to a pointer to a struct (why in the world they would do that, I don't know). So your method should be P/Invoked like so:
[DllImport("whatever.dll")]
private int testfunc(ref IntPtr struct); Then, take a look at the docs for information on the Marshal.StructureToPtr and Marshal.PtrToStructure methods. You'll need to allow for unsafe code using the /unsafe command-line switch, or turning on the Allow Unsafe Code option in your project to use StructureToPtr .
Also, you should add [StructLayout(LayoutKind.Sequential)] to your mystruct definition.
-----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-----
|
|
|
|
|
1. How do you access the serial port on a c# project, using windows forms?
2. How do you do access the serial port on an asp.net project? The port is on the client side, not the server. Does it has to be done with activex, if so, how?
Thanx,
Pedro
|
|
|
|
|
pedropj wrote:
1. How do you access the serial port on a c# project, using windows forms?
A simple search here on the CP site revealed several results: http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=serial+port[^]
pedropj wrote:
2. How do you do access the serial port on an asp.net project? The port is on the client side, not the server. Does it has to be done with activex, if so, how?
ASP.NET is stricly server-side technology (though some client-side javascripts and hidden form fields are used). You can host ActiveX controls in any HTML served from any web server, be it IIS, Apache, etc.
You don't have to use ActiveX, though. If you want to stick with .NET, you can use smart clients. See an article I wrote a long time back on another site (that's being transcribed and updated for this site) here: User Controls for Windows and the Web[^].
Even smart clients can be hosted in pages delivered by any web browser - even local pages served-up in your browser right off your hard drive. It's just that Internet Explorer (Mozilla doesn't do this...yet) is hosting the control. There is some documentation about this in the MSDN Library as well (under the .NET Framework SDK Documentation - see "Deployment").
-----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-----
|
|
|
|
|
Hello experts
I am new to c# and i need your help
I want to create three forms in c# project and then nevigate through these forms by clicking the next and back buttons.
I have created a c# proj and then added two more forms i have created two buttons next and back on each form.Form3 also contains a Finish Button.
Now i want that when i click on the next button of firm1 it should load the Form2 and by clicking the next button of Form2 it should load Form3.
By clicking the back button of Form3 it should load the form2 and so on as we have seen during installation a s/w.
Any idea. Thanks in advance
|
|
|
|
|
I'm not sure if it's the best way. But I do it like this.
In form1 (which you raise form2) pass form1 as a constructor parameter or as a public variable to it. then you can access form1 in form2 thruogh this. something like
form2 f2 = new form2(form1); // in form1
system.Windows.Form f1;
public form2(system.Windows.Form f) // form 2 constructor
{
f1 = f;
}
form2.Hide(); f1.Show(); // Whenever you wanna go back
hope this helps !
|
|
|
|
|
Perhaps a better way is to take a lesson from the way property pages work within a property sheet in Windows (and a lot of other implementations I've seen): instead of using multiple forms, use one form with the Previous and Next buttons (or whatever you want to call them), along with a collection of user controls that represent the property pages. You can code the logic in the form to add and remove the controls when you click the Previous or Next buttons by adding and removing them from the container (perhaps use a Panel above the buttons). The buttons could also be disabled or hidden when you reach the beginning or the end of the collection of pages.
There's many ways to evolve this method, but it's pretty much done the same way in Windows. If you've done any Win32 programming, take a look at the documentation for the IPropertyPage interface. There's links to other helpful documentation in there. You could use a similar mechanism where the controls you will host must implement a similar interface in order for them to communicate with the property sheet (same goes for a Wizard, actually, like you're doing), or for the property sheet to abstractly communicate with them (through this IPropertyPage -like interface) without knowing specific types.
There should be several articles here on CP that outline this approach. Just search for "wizard" or "property pages" or something like that. You could also try google to find some examples.
-----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-----
|
|
|
|
|
Thanks
It worked to some extend but i still want to some thing
Suppose that currently i am on form2 which u call f2 and i press the back button it should move to the currently running form1 but how to refer to the
currentl running form1.
Because in Main method
Application.run(new Form1);
creates an object but has no name to refer to
Any idea .
Thanks for u r help.
|
|
|
|
|
you can use:
Form1 form1 = new Form1();
Application.Run(f1);
and pass the form1 to form2 constructor.
Good Luck!
|
|
|
|
|
but is there a way to convert a byte array into int ?
[Edit]
Never mind, I found it. There goes the 5 minute rule again.
Anyway for those interested, use BitConverter.ToInt32
[/Edit]
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
I am trying to implement cut copy and paste in my application. I have the cut,copy and paste buttons on a toolbar and they are always visible. I have tried hooking the Controls Enter event but this solves only half the problem. I also need to be able to tell if text is being highlighted.
This is not on a menu so I cannot just hook the menu_click event
Thanks in Advance
Forever Developing
|
|
|
|
|
I ran into this and solved it in a funny way...
Instead of using the TextBox control, I subclassed the RichTextBox to mimic an "Enhanced" TextBox.
In the subclass set the Multiline property to false, and the height to 20. This essentialy makes the RichTextBox look like TextBox.
Now you can hook into the SelectionChanged event and check the Can<xxx> properties to enable/disable your buttons. Call the SelectionChanged handler from the Enter event for the object to handle the initial setup.
|
|
|
|
|
A good way is to take advantage that WM_COMMAND messages are passed to a control's parent (keep in mind that all controls in System.Windows.Forms are just wrapper classes for Windows Common Controls). If you override WndProc in your main form, all child controls - as well as their children, and so forth - will send you a WM_COMMAND message that you can mask for the EN_SETFOCUS or EN_SELCHANGE notification message. You then use the Message.HWnd property to get the Window handle (HWND ) and use Control.FromChildHandle to get the control. You can then cast it to a TextBoxBase (base class for both TextBox and RichTextBox ) and call the Cut , Copy , or Paste methods on it.
-----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 got a great idea. It is a little bit cheesy, but it appears that Microshnizzle does it this way alot, so if they can do it, so can we! Make ONE function for each of the following handlers and subscribe all of your text boxes to it.
1. Mouse UP
2. Key press (interested in the left and right arrows)
When either of these events is fired, check the Selection for the Textbox (Textbox.SelectionLength). If the selection Length is NOT zero, then Enable your cut and copy buttons, if the length is 0, nothing to copy, so Disable the cut and copy buttons!
|
|
|
|
|
Hi, I would like to know how is it possible to see:
1. if a specific application is being installed, and
2. how could i get the path to the executable.
Edit: i found out, i will have to read the machine's registry, in order to be able to get the path to an application. Could someone post an example of how i can reach the application's directory by accessing the registry?
thank you.
|
|
|
|
|
It depends on the installer technology. If the app installer is a Windows Installer package, you can use WMI to not only list the apps installed, but to watch when new ones are installed (add an event and hookup code to it). See the System.Mananagement namespace for information. There are also a few articles that talk about the WMI integration with VS.NET on this site, too, though nothing specific to your problem.
Also with Windows installer, each component SHOULD (and often does) have a key path that represents the executable. If you know the component ID (a GUID) you can get its key path.
For other installer technologies, it's specific to the implementation and often times will not be possible. You could also use a FileSystemWatcher but this could be expensive as you'd have to watch a lot of files, or take a snapshot of the system before and after (a system diff), but that's even more expensive.
-----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 want to make a Modeless Dialog box that will pop up and allow processing to continue in the main window. The dialog box is only displaying some information and just needs an OK button that will destroy it. If I use .Show() instead of .ShowDialog() to make it modeless, processing continues, however, the dialog does not redraw and it goes permamently not responding with an hourglass.
What is the proper way to do a modeless dialog box?
Thanks
|
|
|
|
|
|
Before going thru the effort of making a new thread.. Try .Refresh() right after the .Show() call.
|
|
|
|