|
No, there isn't. You can only rough-guess if you've got enough free memory. Because if you have the amount you need, there's no way to tell that if, in that moment, it's all continguous.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey.. I'm very new to this but I'll try explaining the best I can.
Say I have a function in a "class library" project which gets imported by my "ASP.NET Web Application".
Now in my ASP.NET project I got:
private void Button1_Click(object sender, System.EventArgs e)
{
TestClass test = new TestClass();
test.TestFunction();
}
and my TestFunction looks like this:
public void TestFunction()
{
Console.WriteLine( "testing.." );
}
How would I go about writing the output of my TestFunction() to the actual page in my ASP.NET project? Do I need to set the message from TestFunction() to a public string and then use that string to display what I need on the web page?
Another example..
public void TestFunction()
{
try
{
Console.WriteLine( "testing.." );
}
catch( Exception E )
{
Console.WriteLine( "Ex: {0}", E.Message );
}
}
if TestFunction() should error now, it'll print out the Exception message to the console.. but I need it to print to the web page instead. I guess setting a string to the text now is not going to work.
Hope you understand and thanks for the help!
|
|
|
|
|
Make your function return the output as a string:
public string TestFunction() {<br />
return "Testing...";<br />
}
From the page, you can put the text in a control:
private void Button1_Click(object sender, System.EventArgs e) {
TestClass test = new TestClass();
MyControl.Text = test.TestFunction();
}
For the error handling, you can store the error text in a local variable, and supply a property for fetching the value. You can return a null value from the function to signal that an error occured:
private string lastError;
public string LastError { get { return lastError; } }
public string TextFunction() {
try {
return "Testing...";
} catch (Exception E) {
lastError = E.Message;
return null;
}
}
---
b { font-weight: normal; }
|
|
|
|
|
I see. Thanks alot for your reply!
|
|
|
|
|
hi all.
I have some problems in programming rich text box i succeeded to draw an image inside text box as emoticons by using dataformats and clipboard but the problems are:
1- the emoticons entered inside the rtb unanimated even if it is animated how can i implement that emoticons animated ?????????????
2- when the emoticons entered the richtext box if you point with your mouse pointer on it in rtb you can resize it how can i make it fixed ?????????
3- when i press my send button to send emoticons to the other user in chat the previous emoticons in my rich text box disappears and even the previous one transfered disappears in the private chat of the other user.
how can i make the emoticons don't disappears and make my rtb contains all the emoticons ?
Any help with this please .
i used the following code.
<br />
<br />
Bitmap myemot = new Bitmap(dialog.filename);<br />
ClipBoard.setDataObject(myemot);<br />
DataFormats.Format chm = DataFormats.GetFormat(DataFormats.Bitmap);<br />
rtb.text +=myusername + " \r\n";<br />
if(rtb.canpaste(chm))<br />
{<br />
rtb.paste(chm);<br />
}<br />
The Above Code makes the bitmap enter the rtb but with the previous problems any help with that please
Mess With The Best And Die Like The Rest
Miss With The Best And Die Like The Rest
|
|
|
|
|
is there a way to give basic windows controls a better look, like a skin ect.. or do you have to create a custom control?
if I have to make a custom control anyone know of a good sample?
thanks
j
|
|
|
|
|
There are heaps of samples on this very site. I think XP has some options for controls, but overall, if you want to change how they look, you need to draw them yourself.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello all,
After reading almost all tutorials on splash screen for C# I'm quite confused which aproach to take. So I want to ask you what would be the best way. Personally, what I've been thinking is doing something like this:
1. In Main() start the splash thread
2. Run the Main form thread
3. main form thread sends signals to the splash thread about the progress
4. main form sends a signal to the splash thread that it has finished and the splash thread closes itself
The thing is that I've done some threading recently but I haven't actually encountered how to call object methods on different threads. Another thing which I'm not sure about is, should the function which is to be called for the start point of the thread call Application.Run(SplashThread) for the splash thread and Application.Run(MainForm) ? Any advice is greatly appreciated.
|
|
|
|
|
I don't see the need for another thread. Your main thread can just open a window which shows the splash screen, then close it using either a timer, or at a specific point during initialisation ( i.e. just before the main app is ready to show itself ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
But if I show the splash using Application.Run(Splash); the function will return when the splash is closed, am I right? If it's that way, then I'm in a deadlock. That's why I resort the threads.
|
|
|
|
|
1nsp1r3d wrote:
Application.Run(Splash);
Why would you do this ? I'm talking about a modeless form being shown by your application, during startup. Sure, you can use a thread, it just seems like overkill to me.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Because using the same message pump for both the splash screen and the main application window might cause the splash screen to freeze if there is some heavy duty initialization involved.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
How does a splash screen 'freeze' ? I guess if you move something in front of it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes. And if you intend to show some dynamic text in the splash screen window.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
You could do all your initializing in the Main() function.
Something like as follows:
static void Main()
{
// Create splash
fclsSpash splash = new fclsSplash();
splash.Show();
// Create main form
fclsMain main = new fclsMain();
// Initialize this
splash.SetMessage("Initializing this.");
main.InitializeThis();
// Initialize that
splash.SetMessage("Initializing that.");
main.InitializeThat();
// Close splash
splash.Dispose();
// Show main
main.Show();
// Start application
Application.Run();
}
-Chris
|
|
|
|
|
Hello,
I did solve my problem with the initial structure. So this is what I'm doing in Main():
1. Create Splash thread
2. Start Splash thread
3. Create Main Window Thread
4. Start Main Window Thread
5. Hide Main Window
The thing which I'm working now is to implement an event which will signalize the splash screen that main is ready and it should close itself and Main form should appear.
|
|
|
|
|
How do I check id MDI Form is activate?
|
|
|
|
|
//
// code in your MDI parent form (not tested)
//
public MDIParent() {
...
mdi = new Form()
mdi.OnActivated += new EventHandler(MdiOnActivated);
// ...or similar name of this event, I'm not sure
}
void MdiOnActivated(object o, EventArgs e) {
Form activeMdi = (Form)this.ActiveMdiChild;
...
}
|
|
|
|
|
oh - and if you want to check if MDI is active, just compare:
if (mdi == this.ActiveMdiChild)
// mdi is active
else
// mdi is inactive
|
|
|
|
|
This snippet activates the paper feed but does not result in any printed text.
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Drawing.Printing;<br />
<br />
namespace _316CH11<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.TextBox txtText;<br />
private System.Windows.Forms.Button btnPrint;<br />
private System.Drawing.Printing.PrintDocument printDocument1;<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.txtText = new System.Windows.Forms.TextBox();<br />
this.btnPrint = new System.Windows.Forms.Button();<br />
this.printDocument1 = new System.Drawing.Printing.PrintDocument();<br />
this.SuspendLayout();<br />
this.txtText.Location = new System.Drawing.Point(0, 0);<br />
this.txtText.Multiline = true;<br />
this.txtText.Name = "txtText";<br />
this.txtText.Size = new System.Drawing.Size(176, 125);<br />
this.txtText.TabIndex = 0;<br />
this.txtText.Text = "";<br />
this.btnPrint.Location = new System.Drawing.Point(0, 136);<br />
this.btnPrint.Name = "btnPrint";<br />
this.btnPrint.Size = new System.Drawing.Size(176, 23);<br />
this.btnPrint.TabIndex = 1;<br />
this.btnPrint.Text = "&Print";<br />
this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click);<br />
this.printDocument1.DocumentName = "NetDocument11-1";<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(292, 262);<br />
this.Controls.Add(this.btnPrint);<br />
this.Controls.Add(this.txtText);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.Load += new System.EventHandler(this.Form1_Load);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
private void btnPrint_Click(object sender, System.EventArgs e)<br />
{<br />
printDocument1.Print();<br />
}<br />
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)<br />
{<br />
Font fnt = new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel);<br />
e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, 0, 0);<br />
e.HasMorePages=false;<br />
}<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
<br />
}<br />
}<br />
}<br />
Any suggestion on what might wrong here?
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
Maybe it is printing outside the margins of the page.
Try: e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, e.MarginBounds.Location);
-Chris
|
|
|
|
|
cmaissan wrote:
Try: e.Graphics.DrawString(txtText.Text, fnt, Brushes.Black, e.MarginBounds.Location);
No joy. Tried it and get the same behavior. Thank you for the suggestion.
Jerry
Most people are willing to pay more to be amused than to be educated--Robert C. Savage, Life Lessons
Toasty0.com
Ladder League (beta)
My Grandkids
|
|
|
|
|
I m not finding solution to this problem. Can anybody please help me regarding this problem?
I need to obtain ip address and computer names of all machines of a LAN, which are ACTIVE in the network. The problem has to be solved in C#.
Aakash
|
|
|
|
|
Hey buddy, I did post a reply to your original post. You could have asked for more information instead of posting it again
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
sorry, i didnt mean to hurt you mr. senthil kumar. But i am trying from past 2 weeks on that context. Suggestions from this forum always helps me. Thanks to everyone.
Aakash
|
|
|
|