|
Hello,
Instead, you should use:
Text.Split(System.Environment.NewLine);
All the best,
Martin
|
|
|
|
|
I do not agree.
First of all, System.Environment.NewLine results in a string, but String.Split requires
a char or char array.
Second, the logic you follow is correct only if the system that generates the file,
and the system that processes the file, both have the same opinion on how to
terminate lines.
e.g. if you generate the file on Linux, and want to process it on WinXP, it would
not work.
Luc Pattyn
|
|
|
|
|
I do agree with you in every point.
Luc Pattyn wrote: First of all, System.Environment.NewLine results in a string, but String.Split requires
a char or char array.
I shout test before I post!
Luc Pattyn wrote: Second, the logic you follow is correct only if the system that generates the file,
and the system that processes the file, both have the same opinion on how to
terminate lines.
It's not important in the application I'm working on, but it's good to inform about that it's possibility!
Thanks
All the best,
Martin
|
|
|
|
|
Is there a way of doing this? so i could have different registry on my memory stick.
|
|
|
|
|
A different registry on your memory stick? What are you trying to do here? circumvent the existing one?
|
|
|
|
|
I mean have a program, which loads up and then it takes over the regdistry tempoarly, then it sets it back to how it was.
(Have a app like mojopac)
|
|
|
|
|
I am creating custom control.I am hiding all base class properties and displaying only custom properties.But one property ->"(Name)" under design category is getting displayed .
Design category has 2 properties :(Name) & Locked
I am able to hide "Locked" property but not "(Name)" property.By hiding Name property it doesnt work.
CAn anyone suggest the solution...
|
|
|
|
|
How are you attempting to hide Name? By deriving from the type and hiding it from there? If you use the new keyword and create a Name property with that keyword on your derived type, then make that property non-public, it should be hidden.
|
|
|
|
|
snoby wrote: CAn anyone suggest the solution...
Yes, you can't, (Name) refers to the name which the variable is declared in code with. E.g. if you have a textbox called txtUsername then if you look in the code generated by the designer you get:
private System.Windows.Forms.TextBox txtUsername;
So you can't get rid of the (Name) property because if defines how the code is generated.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
I've made custom shell for purposes of one application. However I have problems with slow printing. I've found solution on:
link to post
but still can't make C# equivalent of code on that location. Can someone help me on making this hidden "PrintTray_Notify_WndClass" window?
Thanks in advance.
|
|
|
|
|
I have created the following, based on PInvoke and unmanaged code in Windows dlls.
It always gives the error "ALREADY_EXISTS", probably since I am run Windows Explorer...
private void mniCodeProject_Click(object sender, System.EventArgs e) {
int handle=CreateWindowEx(
0,
"PrintTray_Notify_WndClass",
"",
0x80000000,
0,0,10,10,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero);
log("handle="+handle.ToString("X8"));
if (handle==0) {
int i=GetLastError();
string s="";
if (i==183) s=" ERROR_ALREADY_EXISTS";
log("last error="+i.ToString("X8")+s);
}
}
[DllImport("kernel32.dll", CallingConvention=CallingConvention.StdCall)]
private static extern int GetLastError();
[DllImport("user32.dll", EntryPoint="CreateWindowEx", CallingConvention=CallingConvention.StdCall)]
public static extern int CreateWindowEx(uint style2, string className,
string windowName, uint style, int x, int y, int w, int h, IntPtr parent,
IntPtr menu, IntPtr instance, IntPtr lpParam);
You will have to add some #using statements, and to replace my log function by yours
(could be Console.WriteLine).
I am not sure how long the Window will live, and/or whether you should delete it
when it is no longer needed...
Good luck with it.
Luc Pattyn
|
|
|
|
|
First of all thanks for your code.
Now, I'm having trouble using it, as I always get error code: 1400 ("Invalid window handle") exception. I tried on three computers and it's happens on all of them. Any idea how I can solve this problem?
Thanks in advance!
|
|
|
|
|
I need more info to form an opinion on this.
Is 1400 hex or decimal ?
is it exactly my code that reports "handle=00000000" and "last error=00001400" ??
Please provide exact code and output.
What is your OS (winXP ? any service pack ?) and .NET version (1.1, 2.0 ? any
service pack?)
Furthermore, I have some ideas.
Idea 1:
I am not sure, maybe it is necessary to prefix my code by the following:
SetLastError(0);
together with the declaration:
[DllImport("kernel32.dll", CallingConvention=CallingConvention.StdCall)]
private static extern int SetLastError(int err);
Rationale: a lot of system calls change the "last error" value only when something
goes wrong, but don't clear it beforehand. This is what SetLastError(0) is about.
(So it may have been set by CreateWindow or any call executed earlier).
Idea 2:
there might be a problem with the className/windowName arguments (ASCII/Unicode
confusion). If so, this could be fixed by specifying CharSet=CharSet.ASCII or Unicode
inside the DllImport line of CreateWindowEx declaration, and/or by changing
the EntryPoint to either CreateWindowExA or CreateWindowExW.
Luc Pattyn
|
|
|
|
|
Here is more info:
-1400 is decimal, it gives 00000578 when I put i.ToString("X8").
-my OS i WinXP and .NET is 2.0
Here is complete code:
<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
SetLastError(0);<br />
int handle = CreateWindowEx(<br />
0,
"PrintTray_Notify_WndClass",
"",
0x80000000,
0, 0, 10, 10,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero);
<br />
MessageBox.Show("Handle: "+ handle.ToString("X8"));<br />
if (handle == 0)<br />
{<br />
int i = GetLastError();<br />
<br />
if (i == 183)<br />
MessageBox.Show("ERROR_ALREADY_EXISTS");<br />
else<br />
MessageBox.Show("error code:"+ i.ToString("X8"));<br />
<br />
}<br />
}<br />
<br />
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)]<br />
private static extern int GetLastError();<br />
<br />
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)]<br />
private static extern int SetLastError(int err);<br />
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "CreateWindowEx", CallingConvention = CallingConvention.StdCall)]<br />
public static extern int CreateWindowEx(uint style2, string className,<br />
string windowName, uint style, int x, int y, int w, int h, IntPtr parent,<br />
IntPtr menu, IntPtr instance, IntPtr lpParam);<br />
}<br />
And it always gets to: MessageBox.Show("error code:"+ i.ToString("X8")); giving 00000573.
I tried your two ideas and nothing happens. Can you give me any more help?
Thanks!
|
|
|
|
|
One or more of the arguments to CreateWindowEx seems to be wrong.
If we assume Windows did report an accurate error code (ERROR_INVALID_WINDOW_HANDLE),
then the problem must be with one of the handles
(i.e. parent/menu/instance/lpParam) but then MSDN says:
- parent: "This parameter is optional for pop-up windows"
- menu: more complex text, but then there also exists ERROR_INVALID_MENU_HANDLE
which is not what you are getting
- instance: "Windows NT/2000/XP: This value is ignored"
but your reference article did supply hInstance here (I replaced it by null because
of MSDN's "is ignored")
- lpParam: is explained as a pointer, not really a handler.
So maybe MSDN is wrong and it just needs an hInstance.
Getting hInstance is somewhat tricky; my best guess is:
IntPtr hInstance=Marshal.GetHINSTANCE(GetType().Module);
which only works inside an instance (= non-static) method.
Once again good luck !
BTW, you are not running on a 64-bit OS by any chance ?
Luc Pattyn
|
|
|
|
|
Funny thing about this is that when using NativeWindow (.NET wrapper class over CreateWindowEx), I get same error...
<br />
NativeWindow nw = new NativeWindow();<br />
CreateParams cp = new CreateParams();<br />
cp.ExStyle = 0;<br />
cp.ClassName = "PrintTray_Notify_WndClass";<br />
cp.Caption = "";<br />
<br />
nw.CreateHandle(cp);<br />
I wish I'm using 64-bit OS... I'm getting desperate this way - can't create one window for two days .
|
|
|
|
|
Hi Mikker,
I wasnt aware of NativeWindow and CreateParams classes.
These make my code unnecessary (but it seems to confirm it was correct...)
So there must be a deeper problem somewhere. Did you Google it ?
Or try Microsoft Connect ?
BTW, dit you try the same on .NET 1.1 ?
Luc Pattyn
|
|
|
|
|
Dear Luc.
I found your answer on problem at slow printing when custom shell is used. I tried to use PrintTray_notify_WndClass class to create window, but I get error 1407=cannot find wnd class. What is wrong?
Tnx,
Matjaž
|
|
|
|
|
Like the title says.
I have no idea what to do, i'll keep on looking but...
-- modified at 10:50 Tuesday 2nd January, 2007
This always happens when i post a message in places... anyways, FileStream inherits Stream, and Stream i can inherit so.. yeah. Just means i need one extra line of code (NOOO >_<)
|
|
|
|
|
FileStream is not sealed, meaning you can inherit from it if you want.
class Class1 : FileStream
{
public Class1()
: base("c:\\foo.txt", FileMode.Open)
{
}
}
|
|
|
|
|
I am designing my print form but im having a small problem, some strings that I am wanting to print are longer than the print bounds and I would like to know if there is a way to make the string print within the bounds and wrap to the next line when it hits those bounds?
|
|
|
|
|
Hi,
the application that shows stuff on the screen is also responsible for formatting it
while printing. It could use the same PaintEvent handler for doing so.
Amongst others this means the application itself must do any word wrapping that is required.
Printing may vary from simple to complex depending on functionality:
- if the screen also shows pages (as in MS Word when viewing "Print layout", then
nothing much has to change for printing (except some border settings, and scaling
that is)
- if the screen only shows continuous data (as in Word's "Normal view", or in
a simple text editor) then new code is required to figure out page boundaries etc.
- furthermore there are issues around printer selection, page settings (per document?
per page?), duplex printing, etc.
So my advice is to separate all these concerns as much as possible.
For one this implies providing a "page mode" or "print layout" view capability to your
app (at least during the development phase, but then why not keep it?),
in order to separate the different problem domains.
Good luck !
Luc Pattyn
|
|
|
|
|
Hi,
I am trying to find a way to customize the color of the check mark that appears in the CheckedListBox. I want to alter the color of the check mark of certains items (not all) in the list based on some criteria.
Is there is any way of doing it?
Thanks in advance
|
|
|
|
|
How can i hide the row indicator column. Its the first column that as the user moves up and down the grid a black triangle shows in the first column to show the user the current row. I want to hide this column?
|
|
|
|
|
DataGridView1.RowHeadersVisible = false;
thanks
|
|
|
|
|