|
Bhangorix wrote:
the class show only flashes on the first load, but normal after that
I don't understand what you mean? If you mean you want it to be loaded initially, then instantiate it and add it to the controls collection in your constructor (or, like the VS.NET designer does it, in InitializeComponent ).
If this isn't what you mean, please elaborate.
-----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 mean... when this proc
if (aLOV == null)
aLOV = new MyDataGrid();
if (aForm.Controls.Contains(aLOV))
aForm.Controls.Remove(aLOV);
else
aForm.Controls.Add(aLOV);
call for the the first time, it just flashes.
but never mind, i've work something else that is different but a litle like that one. THANKS anyway
|
|
|
|
|
Basically, i want to know if there is a way to convert an Image to an Icon in C#. I tried the Icon constructor which accepts a Stream object and a Memory stream accepts a byte[], but i wasnt sure how to convert an Image to a byte[].
I am loading a .png file into memory to show a status, but i also have to show the same image in the form's icon and i dont want to have a .ico and a .png file for every status.
Thanks for the help.
|
|
|
|
|
Why don't you load an icon and convert it to a bitmap? Icon.ToBitmap does it.
(Don't know how to do it the other way round...)
|
|
|
|
|
Mybe Im just stupid, but I cant work out how to insert a new line in the text I wish to enter into a textBox (multiline = true) on the COMPACT FRAMEWORK.
\r \n, nope , I need some help.
tia
|
|
|
|
|
Greets,
You should be able to insert a newline as a CR/LF pair, but I would use the System.Environment.Newline static member to add the newline based on the environment.
If you're referring to adding a newline while entering text into one, perhaps Ctrl-Enter may help.
Regards,
Joe
|
|
|
|
|
When a Windows app starts, it typically calls WinMain where it passes the desired window state as the 4th parameter (nCmdShow).
How is this value retrieved in .NET? I've searched the Application object and it doesn't seem to be there.
Thanks!
Alvaro
Can I ask you a question?
|
|
|
|
|
Check the Form.WindowState property of your application form (main form). If you read the documentation for the property, however, it'll tell you that the initial value is always FormWindowState.Normal until the Window is shown.
-----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-----
|
|
|
|
|
Heath Stewart wrote:
If you read the documentation for the property, however, it'll tell you that the initial value is always FormWindowState.Normal until the Window is shown.
So then how can I retrieve it before the window is shown? Surely the runtime must keep it somewhere so it can change the WindowState property right before showing the form. Perhaps there's a Win32 API that holds this information about a process, but I can't find it.
Thanks,
Alvaro
Can I ask you a question?
|
|
|
|
|
The runtime doesn't expose near as much as what Win32 would. Otherwise ListViews would support grouping, working areas, multiple column sorting, and filter columns. It doesn't. Forms would support drop-shadows. They don't. In these and many other cases, you have to P/Invoke code and often defines structs and enums/consts. These are wrapper classes - and early ones at that.
If you need the window state before the application window (main form) is shown in a purely .NET manner, you're sunk.
You could P/Invoke GetWindowPlacement and redefine the WINDOWPLACEMENT struct in the Windows Manager functions (see MSDN Library for this function for more information). It requires an HWND , which you can easily get from Form.Handle (inherited from Control ). Something like this:
[DllImport("user32.dll")]
private static extern bool GetWindowPlacement(IntPtr hWnd, ref WindowPlacement placement);
internal struct WindowPlacement
{
public int length;
public int flags;
public int showCmd;
public POINT ptMinPosition;
public POINT ptMaxPosition;
public RECT rcNormalPosition;
}
internal POINT
{
public long x;
public long y;
}
internal RECT
{
public long left;
public long top;
public long right;
public long buttom;
}
WindowPlacement placement = new WindowPlacement();
placement.cbSize = Marshal.SizeOf(placement);
if (GetWindowPlacement(this.Handle, ref placement))
{
int nCmdShow = placement.showCmd;
}
-----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-----
|
|
|
|
|
Heath Stewart wrote:
The runtime doesn't expose near as much as what Win32 would. Otherwise ListViews would support grouping, working areas, multiple column sorting, and filter columns. It doesn't. Forms would support drop-shadows. They don't. In these and many other cases, you have to P/Invoke code and often defines structs and enums/consts. These are wrapper classes - and early ones at that.
What's the explanation for all these things lacking? I mean, on one hand you'd think it's because they didn't have sufficient time to include everything. While on the other, it looks like a ploy to keep our apps tied to the OS, diminishing the possibility of one day running them on other platforms.
I guess the important question is, is Microsoft planning on filling the missing pieces in future releases?
Heath Stewart wrote:
You could P/Invoke GetWindowPlacement and redefine the WINDOWPLACEMENT struct in the Windows Manager functions (see MSDN Library for this function for more information). It requires an HWND, which you can easily get from Form.Handle (inherited from Control).
That did it! Thanks for taking the time to answer Heath.
Regards,
Alvaro
He who laughs last, thinks slowest.
|
|
|
|
|
Alvaro Mendez wrote:
What's the explanation for all these things lacking?
Perhaps the fact that they could never wrap everything. Look at MFC - it doesn't wrap everything either. There are practically limitless possibilities and they couldn't possibly provide support for everything because there's always different ways of doing things and different reasons for using different code.
Alvaro Mendez wrote:
I guess the important question is, is Microsoft planning on filling the missing pieces in future releases?
I don't know. Probably not. WinFX in Longhorn will wrap a lot of other functionality but, once again, probably not everything because it would be almost impossible to do such as I mentioned before.
The BCL includes stuff that most applications need. When you start worrying about things like Windows position or drawing a Window frame title, you're already typing an application to a particular OS because that stuff is handled different in different Windows managers like Windows, KDE, Gnome, Aqua, etc.
-----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 am looking to change the newly imaged computer's name and add that computer to domain. Can any one help me to do this?
Thanks
CJ
|
|
|
|
|
What, with C#? This definitely is not worth it. It requires redefining a lot of structures already defined for C++ in the Platform SDK and P/Invoking a lot of function calls. And for what? Something that's done very rarely? If nothing else, doing this in VC++ would be much faster and easier to do. Use the right tools for the right job. Now when Longhorn comes around, many of these functions and structures should already be wrapped - but for right now, you'd have to do it all and it's definitely not easy!
Just do it the old fashion way. Right-click on "My Computer", go to "Computer Name" and read the directions. In most cases, your domain administrator doesn't allow you to do this yourself so talk to your IT department.
If you're not looking to do this programmatically, you're in the wrong forum big time! This is for C# programming questions.
-----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 add new computers to a domain. Can any one help to get this task done.
Thanks
CJ
|
|
|
|
|
Does anybody Know a way to use arrays with negative pointers?
I mean something like A[-2], B[-7], C[-3,1,-12], ...
I don't want to lose speed.
|
|
|
|
|
You could create your own class that wraps a regular array and then use the indexing property to translate your negative indexes into positive indexes in the array that you are wrapping. Something like this:
public class NegativeArray
{
private Array myArray;
private int indexOffset;
public object this[int i]
{
get
{
return myArray[i+indexOffset];
}
set
{
myArray[i+indexOffset] = value;
}
}
}
Where indexOffset is the amount you'd have to add to your negative index to get a positive index, or to put it another way, an indexOffset of 10 would let you have an index down to -10, which would translate into the index 0 of the array you're wrapping.
You might also think about inheriting from the Array class instead of wrapping. That might actually be better.
Can't imagine why you'd need to do this though.....
|
|
|
|
|
Thanks Wjousts.
It's simple and clear, I like it.
|
|
|
|
|
Convert a STRING!!!! to a CLASS!!! I hear you scream. Pull up a pew and let me explain the problem I have.
I am creating an application that pulls various values from an XML file and then uses these values to create various pieces of text within a PDF document. Now using iTextSharp (http://itextsharp.sourceforge.net/index.html[^]) this is fairly easy.
The problem is that I want/need everything to be driven by XML parameters, as an example to set the font of a particular piece of text you would use the following code :
basefont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
CreateFont takes 3 parameters, and I want to be able to specify these parameters in the XML.
When the data comes out of the XML file it is in string format. So the desired effect can easily (ish) be achived, by using a massive multiple if/switch statement.
The problem is that using if's everything is hardcoded, so if I decided to use an uncoded font I would have to recompile and re-release code, which is a pain.
What I would like to do is set the follow parameters in XML :
<basefont_string>BaseFont.HELVETICA</basefont_string>
<basefont_encoding>BaseFont.CP1252</basefont_encoding>
<basefont_embedding>BaseFont.NOT_EMBEDDED</basefont_embedding>
Then use these as class values, rather than have to mess around with if's and switch's, so if I pulled the values using their XML tag names I would have the following line of code
basefont = BaseFont.createFont(basefont_string, basefont_encoding, basefont_embedding)
Did that make sense?
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Using reflection I believe you can use the Type.InvokeMember method to invoke the constructor and create an object of the type specified by your string. So, you'd do something like this:
<br />
Type t = Type.GetType(MyObjectName);<br />
Object myobj = t.InvokeMember(...
Something like that ought to work.
|
|
|
|
|
I will try that out tomorrow, looks like a distinct possibility
While I am here I found another possible solution here on CP :
http://www.codeproject.com/csharp/commandlineincsharp.asp[^]
Even if it doesnt work for my intend purpose, it is a brilliant article.
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
The Font class is also serializable, so don't forget that you can give it a serialization context and let it serialize itself (and you can bet that Microsoft will serializable about any non-default property available).
-----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 have a picture box displaying an image. I want to be able to use 4 trackbars (one on each side) in order to draw 4 lines across the image. The end result will be to divide the image up into 9 regions graphically. I've got the image displaying, and I've got the 4 trackbars drawing the lines I want. The problem I'm running into is twofold.
1. How do I get the line to draw on top of the picture box image? Right now, the lines only appear beneath the picture box.
2. Whenever I move a trackbar slider, the line left from another trackbar is wiped out before the new one is drawn. The end result is that only one line can be displayed at a time, when I want all four to be displayed all at once.
Any suggestions?
Also... does anybody know if there's a way to change the color of the slider on the trackbar, and not just the backcolor?
Thanks.
|
|
|
|
|
as for painting the lines i think you have to override the paint event and as for drawing all at once you should use SetStyle function to the user control and modify the parameter DoubleBuffer to true and you will get good results
|
|
|
|
|
How can i set the printer before print something?
i guess i must use Printdialog but i dont know how
|
|
|
|