|
|
At last I found the way to compile manifest into C# exe file. Download program called PE Explorer (http://www.heaventools.com). This program can insert manifest resource into the final exe file. It's a little odd, but it works very well
|
|
|
|
|
I want to use this property for Button.Is that possible?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Not with the current set of .NET controls. Its easy after you figure out how to get the parent to draw itself on a Graphics object you give it, but so far I've hit a dead end there.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
James T. Johnson wrote:
Its easy after you figure out how to get the parent to draw itself on a Graphics object you give it, but so far I've hit a dead end there.
What does this means James?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
|
Thanks you,I'll do that.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
In my aged c code, there is tons of "%.1f" in source.
How can i transfer it to c#?
i read the document of Console.Write.
the format is describe by {a,b:s}.
How can i get the same result as c format string like "%.1f"?
|
|
|
|
|
Are you asking how you can use "%.1f" in C# or for the format string that produces an equivilant to "%.1f"?
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
You can use the Math.Round static function or the String.Format method (called implicitly below).
double d = 136.7835;
Console.WriteLine(Math.Round(d, 1));
Console.WriteLine("{0:.#}", d);
Both of these result in 136.8 which is what the C/C++ format specifier %.1f would provide.
Cheers,
Tom Archer
Author, Inside C#
|
|
|
|
|
Console.WriteLine("Test: {0:f1}", 765.7689);
The result will be 765.8 instead of 765.7, but usually that is the preferred output...
/moliate (just started learning C#)
|
|
|
|
|
I have written a C# windows application. However, when the program is running, and I want to shut down windows, every program closes except my C# program; and windows does not shut down. It just waits. When I close my program manually, windows shuts down without a problem. The cause is that I have overriden the Closing event of the main form like this:
private void WindowsCloserForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
OpenDialog(false);
}
I wanted this behaviour however: closing the form should not end the program, but just hide it. (Via an icon in the system tray you can close the program) If I do not override the Closing event, this problem does not occur. Can this be a bug in the framework, or am I forgetting something?
Ludwig
|
|
|
|
|
This thread should have an answer: Click here
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
I'm sorry, I didn't remember I already asked this question in this place. I'll try it out...
|
|
|
|
|
Well, I tried:
override protected void WndProc(ref Message m)
{
int message = m.Msg;
if ( message == 0x0012 ) //WM_QUIT
{
}
else
if ( message == 0x0010 ) //WM_CLOSE
{
// Who closed the form?
}
base.WndProc(ref m);
}
but is seems that quitting windows does not raise the WM_QUIT event. It raises the WM_CLOSE event, though. But how can I check who closed the form? I don't know how to use LParam of WParam?
|
|
|
|
|
I am truly at a loss... It appears that every single event that is raised to ask if the program/form should close just asks not providing any information as to why its asking.
I've even fiddled with using reflection to get at some internal members, but all I get is "member not found" errors
Here's what I've found if you want to investigate it further
Inside of the Application class is a nested type called ThreadContext.
You can get the Type for this with this bit of code.
public Type GetThreadContextType() {
MemberInfo[] typesInApp = typeof(Application).FindMembers(
MemberTypes.NestedType,
BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public,
new MemberFilter(memFilter), null
);
return MemberInfo[0].DeclaringType;
}
private bool memFilter(MemberInfo m, object filterCriteria)
{
if( m.Name.IndexOf("ThreadContext") != -1 )
return true;
else
return false;
} Now that class has a static method called "FromCurrent" which takes no arguments and returns the ThreadContext for the current application. This is retrieved by looking up a LocalDataStore on the Thread, the LocalDataStoreSlot is stored in a static field named tlsSlot , this slot corresponds to the thread's ThreadContext object.
Once you have an instance of ThreadContext you can call the GetState method passing in the value 0x10 to see if the Thread has an AppQuit message posted or pass in 0x08 to see if the Thread has a Quit message posted.
Here is the code I've been pounding out since you posted your message, if anyone can get it to work I'll buy you a beer the next time you are in the area
Type app = typeof(Application);
MemberInfo[] typesInApp = app.FindMembers(
MemberTypes.NestedType,
BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public,
new MemberFilter(memFilter), null
);
Type typeThreadContext = typesInApp[0].DeclaringType;
object threadContext = Thread.GetData(
(LocalDataStoreSlot) typeThreadContext.InvokeMember(
"tlsSlot",
BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Static,
null, null, new object [] { }
)
);
bool StatePostedAppQuit = (bool) typeThreadContext.InvokeMember(
"threadState",
BindingFlags.GetField | BindingFlags.NonPublic,
null, threadContext, new object[] { 0x10 }
);
bool StatePostedQuit = (bool) typeThreadContext.InvokeMember(
"threadState",
BindingFlags.GetField | BindingFlags.NonPublic,
null, threadContext, new object[] { 0x08 }
); You'll need the memFilter method from the first chunk of code above.
Feel free to completely destroy that bit of code, I'm getting an exception on the line that retrieves the threadContext. I've tried by using the FromCurrent method and the method above (which basically does what FromCurrent() does).
Now I get to go take my car in to get a flat tire fixed
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
Found another (rather simple solution ), like this:
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
if (m.Msg == WM_SYSCOMMAND && (int) m.WParam == SC_CLOSE)
{
// User clicked close button
OpenDialog(false);
return;
}
base.WndProc(ref m);
}
Kind regards,
Ludwig
|
|
|
|
|
Doh!
I like your version much better
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
Well, thanks anyway for the answer! Meanwhile I've joined this forum, because it's one of the best I've seen.
Ludwig
|
|
|
|
|
Gday All,
I have a performance /design question regarding whether it
is better to implement helper functions for a class as
static members or as global/namespace functions.
For example:
namespace MyObjCtrl {
class MyObject {
public:
//static member that uses a MyObject ( option 'A' )
static HelperStyleA( MyObject* pObj );
};
//namespace helper function of option 'B'
HelperStyleB( MyObject* pObj );
};
//implementation of option 'B'
MyObjCtrl::HelperStyleB( MyObject* pObj )
{
}
If anyone could give me a run down on the pros and cons of
these two methods or of any website or tutorial that might
help, it would be much appreciated
|
|
|
|
|
This is actually a C++ question, but I'll answer it.
There is not performance issue here just a stylistic one. I personally prefer static functions over global functions as they imply a link to a given context.
Cheers,
Tom Archer
Author, Inside C#
|
|
|
|
|
I created a collection class using the .NET help files, but when I add objects to the collection, it appears as though the each new object copies itself throughout the collection--all objects in the collection become equal to the new added object. Anyone run into this before?
Here's a snip of code to give you a idea of what I'm doing...
namespace NatesKentuckyRook.Classes
{
public class RookCards : System.Collections.CollectionBase
{
// Constructors
public RookCards()
{
}
// Functions
public void Reset()
{
List.Clear();
}
public void AddCard(RookCard Card)
{
List.Add(Card);
}
}
}
|
|
|
|
|
Take a look at CollGen2 on GotDotNet. It will create a collection for you using the type you specify.
As to your problem I've not seen it before.
James
Sonork: Hasaki
"I left there in the morning
with their God tucked underneath my arm
their half-assed smiles and the book of rules.
So I asked this God a question
and by way of firm reply,
He said - I'm not the kind you have to wind up on Sundays."
"Wind Up" from Aqualung, Jethro Tull 1971
|
|
|
|
|
There's nothing in the code you posted that would cause the problem you're describing. Can you post a sample app - especially the client code?
Cheers,
Tom Archer
Author, Inside C#
|
|
|
|
|
I want to know how can I send command via socket to another computer on my LAN like take a screenshot, send a message, Controls the computer, something with the same concept as Netbus but for my LAN monitoring ?
Thanks
P.S Source code will be very appreciated
|
|
|
|