|
David Stone wrote:
So you're trying to add one form to another? You can't do that unless the parent form
Yes you can
Two forms, Parent and Child:
Child.TopLevel = false;<br />
<br />
Parent.Controls.Add(Child);<br />
<br />
Child.Show();
James
Sig code stolen from David Wulff
|
|
|
|
|
Two forms, Parent and Child:
Child.TopLevel = false;<br />
<br />
Parent.Controls.Add(Child);<br />
<br />
Child.Show();
That should do it
James
Sig code stolen from David Wulff
|
|
|
|
|
I ran the producer/consumer threading lock example, and set the breakpoints right after the cell locked. From my understanding, anything within a lock block should by synchronized, and only one thread can enter into a locked block at a time. However, when the program is run, the breakpoints are hit on both of the producer and consumer threads. How can this be?
The code used:
<br />
using System;<br />
using System.Threading;<br />
<br />
public class MonitorSample<br />
{<br />
public static void Main(String[] args)<br />
{<br />
int result = 0;
Cell cell = new Cell( );<br />
<br />
CellProd prod = new CellProd(cell, 20);
CellCons cons = new CellCons(cell, 20);
<br />
Thread producer = new Thread(new ThreadStart(prod.ThreadRun));<br />
Thread consumer = new Thread(new ThreadStart(cons.ThreadRun));<br />
<br />
try<br />
{<br />
producer.Start( );<br />
consumer.Start( );<br />
<br />
producer.Join( );
consumer.Join( ); <br />
}<br />
catch (ThreadStateException e)<br />
{<br />
Console.WriteLine(e);
result = 1;
}<br />
catch (ThreadInterruptedException e)<br />
{<br />
Console.WriteLine(e);
result = 1;
}<br />
Environment.ExitCode = result;<br />
<br />
Console.WriteLine("Finished");<br />
Console.ReadLine();<br />
}<br />
}<br />
<br />
public class CellProd<br />
{<br />
Cell cell;
int quantity = 1;
<br />
public CellProd(Cell box, int request)<br />
{<br />
cell = box;
quantity = request;
}<br />
public void ThreadRun( )<br />
{<br />
for(int looper=1; looper<=quantity; looper++)<br />
cell.WriteToCell(looper);
}<br />
}<br />
<br />
public class CellCons<br />
{<br />
Cell cell;
int quantity = 1;
<br />
public CellCons(Cell box, int request)<br />
{<br />
cell = box;
quantity = request;
}<br />
public void ThreadRun( )<br />
{<br />
int valReturned;<br />
for(int looper=1; looper<=quantity; looper++)<br />
valReturned=cell.ReadFromCell( );<br />
}<br />
}<br />
<br />
public class Cell<br />
{<br />
int cellContents;
bool readerFlag = false;
public int ReadFromCell( )<br />
{<br />
lock(this)
{<br />
Console.WriteLine("Enter ReadFromCell()");<br />
if (!readerFlag)<br />
{
try<br />
{<br />
Monitor.Wait(this);<br />
}<br />
catch (SynchronizationLockException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
catch (ThreadInterruptedException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
}<br />
Console.WriteLine("Consume: {0}",cellContents);<br />
readerFlag = false;
Monitor.Pulse(this);
Console.WriteLine("Exit ReadFromCell()");<br />
}
return cellContents;<br />
}<br />
<br />
public void WriteToCell(int n)<br />
{<br />
lock(this)
{<br />
Console.WriteLine("Enter WriteToCell()");<br />
if (readerFlag)<br />
{
try<br />
{<br />
Monitor.Wait(this);
}<br />
catch (SynchronizationLockException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
catch (ThreadInterruptedException e)<br />
{<br />
Console.WriteLine(e);<br />
}<br />
}<br />
cellContents = n;<br />
Console.WriteLine("Produce: {0}",cellContents);<br />
readerFlag = true;
Monitor.Pulse(this);
Console.WriteLine("Exit WriteToCell()");<br />
}
}<br />
}<br />
|
|
|
|
|
When you call Monitor.Wait() from within the lock, the lock is released and that thread waits for another thread to call Pulse. When that happens, the lock will be re-acquired and the process will continue.
|
|
|
|
|
Ah, I see now. I knew I was missing something, but couldn't quite put my finger on it. Thanks for the tip!
|
|
|
|
|
Hi,
I don't see that crappy setup tool that comes w/ Visual Studio anywhere ? Did I not install it? Am I missing something here ? I have a simple C# app I need to distrubute.
Can someone explain what is involved ? Will it work on WIN98?WIN95?
Thks in advance .
jon
Jon ...
|
|
|
|
|
In my VS.NET (Pro edition) I can find the setup tool under New Project -> Setup and Deployment Projects
Deploying a C# app doesn't require much. Install the .NET framework if it isn't installed and copy the .exe's and .dlls you need to the same directory.
If you use any 3rd party tools/controls refer to their documentation for how you need to deploy their stuff.
Jon E wrote:
Will it work on WIN98?WIN95?
It will work in Win98, .NET isn't supported on Win95
James
Sig code stolen from David Wulff
|
|
|
|
|
What's the equivalent of VB's CreateObject or MFC's CreateDispatch in C#?
Don't want to use references but instead create object by progID.
|
|
|
|
|
Have a look at System.Activator .
Paul
|
|
|
|
|
Paul Riley wrote:
Have a look at System.Activator
And combine with Type.GetTypeFromCLSID or Type.GetTypeFromProgID .
object CreateObject(string progID)
{
Type T = Type.GetTypeFromProgID(progID, true);
return Activator.CreateInstance(T);
}
object CreateObject(string progID, string server)
{
Type T = Type.GetTypeFromProgID(progID, server, true);
return Activator.CreateInstance(T);
}
|
|
|
|
|
I only want to display a tooltip if it is within a certain area of a specific control, but the current Tooltip class needs you to specify a control, and doesnt disappear until the mouse moves away from that item.
so far, my only solution is to create a new tooltip class, which i will start work on now, but do any of you know an easier way?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Add an empty label control with a size fitting this area, and attach a tooltip. Not even one line of code!
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
but this will cover the area so u cant see it [its a custom control] and when i set the backcolor to Color.Transparent, the tooltip doesnt appear.
[edit]
and this area also has to be clicked on.
[/edit]
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Hi,
I have created a Deployment Project for which I would like to get the data from the Customer Details dialog box.
Does anyone know how to get the serial number or the Organization field from this dialog ... there must be a way !!!!
Thanks,
Nic
|
|
|
|
|
Nic Oughton wrote:
Does anyone know how to get the serial number or the Organization field from this dialog ... there must be a way !!!!
The registry
Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
|
|
|
|
|
That's what I thought ... but it seems stupid to me that I then have to go to the registry to get the values, when if I use a text box dialog I can get directly at the values....
Thanks anyway for your help - you have confirmed my fear !
Nic
|
|
|
|
|
Nic Oughton wrote:
... but it seems stupid to me that I then have to go to the registry to get the values, when if I use a text box dialog I can get directly at the values....
Thats what the dialog box does in the 1st place
Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
|
|
|
|
|
I am trying to implement a blinking listbox that can display individual items in different colors. I have worked out the different colors due to existing samples on this site. However, I am stumped regarding the blink.
I know I will utilize a timer, but I can't figure out how to redraw the individual items that need to blink every time the timer expires.
I am working off the DrawItem event currently to draw the items in the color I want. Is there a way to force this event for a given item (i.e. listbox.item[0].redraw)?
Any help would be greatly appreciated.
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
You could force OnDrawItem by creating a new event :
this.OnDrawItem(new DrawItemEventArgs(local3, this.Font, local4, local0.itemID, local0.itemState, this.ForeColor, this.BackColor));
(however, because OnDrawItem is protected, you'll have to derive the class).
Or you may go the softer way, by invalidating a region with a Control.Invalidate(...) + Control.Update() (by analogy with WIN32).
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Thank you for taking the time to reply. I'll try your suggestion!
dpb
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
I tried the easier of the two methods (invalidate control) and it works great - thanks!.
Is there a way to get the bounds of a specified item in the list box? I am invalidating the whole control, but I would rather not have to redraw everything - just the items that need to blink.
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Returns the bounding rectangle for an item in the ListBox.
Rectangle rect = myListBox.GetItemRectangle( nItemIndex );
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Hi,
I have a Image object as a private member of a class. I then have a tree view file browser which enables the user to browse for an image. I then use Image.FromFile to load the selected image into the member Image class. Once this has completed I have many refresh problems with the rest of the app. The tree view doesn't display correctly, slider bars dont show, etc...
If i change the code to load the Image.FromFile into a local variable then the app works fine.
Anybody seen this before
|
|
|
|
|
Can anyone suggest?
I have C# Standard edition, which under new projects does not provide the ability to start an assembly project. Can it be done without? That is the compiler must be capable of generating the Assembly?
If the answer is yes what I am trying to do is just add some forms to an assembly. Then I want to load that assembly into my application and display the forms the assembly contains. Can anyone point me to a good article on how to do this??
I have the Wrox press Pro C# book but the Assembly section doesn't make it clear how to achieve this.
TIA
Luke
|
|
|
|
|
I can't figure out why you couldn't do things such like :
csc /out:myAssembly.exe myCode.cs
csc /out:myCodeLibrary.dll /t:library myCode.cs
Using such assembly in your code depends on the environment :
- from the IDE, you just add a reference
- from code, you dynamically load the assembly thanks to the *.Assembly namespace
- from configuration, you may create either a manifest file (versioning), or a config file (targetting specific outside assemblies), depending on what you intend to do.
I would suggest these two links : appdomain[^], assemblies[^].
if you start putting in too manay features, it no longer remains useful for beginners
quote in a CP article comment, shiraz baig
|
|
|
|