|
The ToString(); method isn't doing it, is there another way?
Nick Parker
|
|
|
|
|
|
I believe you can also use BitConverter.ToString(), I don't have the documentation to hand, but I'm pretty sure thats it. The only parameter to ToString is the array AFAIK.
--
Paul
"I need the secure packaging of Jockeys. My boys need a house!"
- Kramer, in "The Chinese Woman" episode of Seinfeld
MS Messenger: paul@oobaloo.co.uk
Sonork: 100.22446
|
|
|
|
|
|
|
I guess the signatures are wrong, produce an exception in CLR, but are trapped in /dev/null so you don't see a sh*t.
In other words, your SomeFunc doesn't even have a return value. Was the code snippet a real code ?
This should be :
[DllImport("SomeLib.dll"), CharSet=CharSet.Auto)]
public static extern <something> SomeFunc(MyCallback callback);
public delegate int MyCallback(int bla, string foo);
And I swallow a small raisin.
|
|
|
|
|
|
From what I see in EnumFontFamiliesEx , you've got to marshall structures as well, thus redefine using C# all that NEWTEXTMETRIC and stuff. leppie has posted a lot about marshalling structures in this forum.
And I swallow a small raisin.
|
|
|
|
|
i dont need any of the text metric stuff, so ive just swapped that for object. ill have a look at what i may need to do with marshalling. but i have remade the LOGFONT and ENUMLOGFONT structures.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
you need to keep a reference to the delegate live while the Enum is in progress.
MyCallback foo = new MyCallback(DoSomething);<br />
<br />
SomeFunc(foo);<br />
<br />
foo = null
Otherwise the delegate becomes eligable for collection immediately (as it is passed into unmanaged code) and that could be what you are seeing.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
Otherwise the delegate becomes eligable for collection immediately (as it is passed into unmanaged code) and that could be what you are seeing.
Does the delegate NOT get collected if it is passed into managed code?
I thought I saw something about HandleRef, but I'm not sure if it applicable in this case.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
how can i tell C# to fill remaining space with '0'?
when writing:
string.Format("0x{0,4:X}",256);
i get
0x 100 but i want
0x0100
the msdn-documentaition just says "...is padded with spaces" - no word on changing the fill-character. is this possible at all?
:wq
|
|
|
|
|
String.PadLeft Method
Right-aligns the characters in this instance, padding on the left with a specified Unicode character for a specified total length.
public string PadLeft(int, char);
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
ah. not the way i thought, but an option.
thx
:wq
|
|
|
|
|
current workaround (input is a Int16, so 4 chars are always enough)
Int16 id =
string.Format("0x{0}{1}{2}{3:X}",(id<4096)?"0":"",(id<256)?"0":"",(id<16)?"0":"",id);
but thats kind of
:wq
|
|
|
|
|
int f = 256;
string s = f.ToString("0000");
And I swallow a small raisin.
|
|
|
|
|
I have a form with a menubar and a tab control. Each tab has a set of buttons which inlcude Close and Detach. Once I hit either of these buttons, the code works as expected. However after that my application refuses to exit.
The button I've played with the most, Close, has relatively simple code. It iterates through the COntrols on th emain form, finds the tab page it's looking for and then removes it.
I've traced my code and I know that Application.Exit() is being called but it's not forcing Application.Run to return. What could be going wrong?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
There is a bug in the WinForms code that causes forms to refuse to close if their ActiveControl (ie the control that has focus) is removed. I would expect that this is what you are experiencing.
There are a number of workarounds available on the web and newsgroups (time for google[^]!). The easiest I've found is to manually shift focus to an off-screen, permanent control before you remove the other control.
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
Ouch. Well the control that I am removing is just a tab page in the tab control. I'll just switch focus to another tab page and then remove the one I want.
Sh*tty bug. Hope they will fix it soon.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
I have an Explorer extension that implements the IContextMenu interface. It all compiles fine in vc6 but if I open and hence convert it in vc7 (.net) it tells me that interface hasn't been defined. In my class file I can right click on the word IContextMenu and go to definition and life is good. all win32 defines are correct. Would there be a problem with the SDK if it was installed before .Net. Maybe I'll check the SDK update...
|
|
|
|
|
From what I read, you are not using C# (C# forum).
-IContextMenu is defined in ShlObj.h which is not a default header automatically included by vc.
-IID_IContextMenu is defined in ShlGuid.h
-You must link with either uuid.lib or shell32.lib
And I swallow a small raisin.
|
|
|
|
|
hi,
i'm designing an exception for my program and have the following problem. i want an additional constructor, which gets an int as paramter, builds a string out of it and calls the base-classes constructor with a string.
something like
class MyException : ApplicationExcpetion
{
...
public MyException(int errorCode)
{
string message;
switch(errorCode)
{
case
default: message="unkown errorcode"; break;
}
base(message);
}
}
but C# tells me: "Use of keyword base is not valid in this context"
i'm stuck. anyone any idea?
thx!
:wq
|
|
|
|
|
You can only call the base constructor like the following.
<br />
class MyException: ApplicationException<br />
{<br />
pubilc MyException(int errorcode) : base ( MyException.GetErrorString(errorcode) ) {<br />
}<br />
}<br />
The base constructor can only be called in that location.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
yeah, with GetErrorString being a static function is does work - thanks a lot!
sometimes it's like a blocking in your head, when you're coding all day long...
:wq
|
|
|
|
|
I would also prefer to be able to delay the base construction. Look at my case.
class MyException: ApplicationException
{
int errorcode;
pubilc MyException() {
errorcode = GetErrorCode();
base ( MyException.GetErrorString(errorcode) );
}
}
Now I wouldnt have to call the GetErrorCode() function everytime when i need to throw it
Maybe there is a way to pre-initialise some variables...
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|