|
I call my dialogs a little different, but i don't really see why that would make much of a difference.
As a fix, before you hide the child form, make the parent always on top, then turn off always on top once its hidden. Unless once you turn it off it goes straight to the back again anyways.
Incase you want to try i call my dialogs thusly:
Form2 whatev = new Form2();
whatev.ShowDialog();
Its pretty much the same thing of course but, who knows.
Computers secretly laugh at us y'know
|
|
|
|
|
First thanks for you reply, I have implemented the TopMost Property as a result. I used to call my dialogs this way
Dialogs.dlg dialog = new Dialogs.dlg
dlg.ShowDialog(this);
if(!dlg.IsDisposed)
dlg.Dispose();
dlg = null;
Either way I still have this problem. I am testing the TopMost trick and see if it works. Again Thanks for your reply.
Sautin.
"All of us who served in one war or another know very well that all wars are the glory and the agony of the young."
Gerald Ford
|
|
|
|
|
Hi everyone
I have generated a 2D array (like a matrix) which is rather large and I want to find som simple way to display it in e.g a datagrid. Is there anyone how can tell me how this is done. I have seen the examples on the net, but they only show how you can do this for a simple array...
Thanks in advance
AL
|
|
|
|
|
|
hi
i have a table in my sqlServer 2005 database that it's type is nvarchar, and when i insert a record to table with persian language (Farsi), it show them like "???????"
i insert a record directly to my sql table and show it's content correctly but when i insert to it from code, it show as "??????".
how to solve my problem ?
thanks.
|
|
|
|
|
Is it possible to assign a range to a case statement? If not, is there a different way to accomplish the same thing?
For example:
Switch (int x)<br />
{<br />
Case 0 to 5:<br />
Case 6 to 10:<br />
Case 11 to 15:<br />
Default:<br />
}
Thanks!
David Wilkes
|
|
|
|
|
Unfortunately not. your only option is an if/else structure.
if ((0 <= x) && (x <=5))<br />
else ...
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
You can accomplish the same using this,
<br />
Switch (int x)<br />
{<br />
Case 0:<br />
Case 1:<br />
Case 2:<br />
Case 3:<br />
Case 4:<br />
Case 5:<br />
break;<br />
...<br />
Default:<br />
}<br />
<br />
|
|
|
|
|
Thats good thinking, I should have remembered that since I have used similar structures in the past. However, I only see that as workable within a limited range. I am looking at ranges like 0-512, 513-1024, 1025-2048... Sadly there is not a consistent step size, or I would simply divide the value by the step size.
Thanks for the response! This is a helpful & responsive group!
David Wilkes
|
|
|
|
|
|
You can use an abstract class instead of an interface:
abstract class AsyncCallback
{
public void Receive(bool echo)
{
if(!echo) { ... erase ... };
}
}
Now in the class that overrides this class:
class MyCallback : AsyncCallback
{
public override void Receive(bool echo)
{
base.Receive(echo);
}
}
I'm not sure if this is the best technique, but I'm using something similiar in my own application.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
That's what I would do, but MyCallback is supposed to be used by either another programmer or myself in another program, and I want AsyncCallback and my overall "library" to be fully usable without the following coder having to do anything (calling base ) in order to use it... Any other approach? Thanks very much!
Windows Calculator told me I will die at 28.
|
|
|
|
|
If the receive function is a callback, why not create an event for it?
This will too work with an abstract class, but will not require the programmer to call base.Function at all.
Something like this:
public delegate void ReceiveHandler(bool echo);
abstract class AsyncCallback
{
public event ReceiveHandler Received;
void IReceivedSomething(bool echo)
{
if(!echo) { ... clear ... }
if(Received != null)
Received(echo);
}
}
Now the class that overrides AsyncCallback will just have to register the callback function:
class MyHandler : AsyncCallback
{
public MyHandler
{
this.Received += new ReceiveHandler(OnReceive);
}
public void OnReceive(bool echo)
{
}
}
Hope this helps
modified 12-Sep-18 21:01pm.
|
|
|
|
|
In C#, how does one make a thread live indefinitely?
MyObject obj = new MyObject();
Thread t = new Thread(new ThreadStart(obj.MyMethod));
t.Start();
Because MyMethod has code in it that kicks off an asynchronous process in it, I want that thread to live forever (or at least until the application is terminated). Any ideas on how that might be accomplished?
Thank you,
Dan
C#, King of languages
|
|
|
|
|
Just don't return from the method.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Guffa had the right answer. But just to clarify, the thread won't end until the method obj.MyMethod() returns. You're allowed to return from the method that creates the Thread object and calls t.Start().
In fact, you don't even have to keep a reference to the Thread object that you created. You can simply write this as one line:
new Thread(new ThreadStart(obj.MyMethod)).Start();
|
|
|
|
|
This may seem like a dumb question, but I haven't been able to find the answer out there.
I have a 32 bit application with several 32 bit COM controls that can interact with it. I also have a .NET app that uses these COM controls. When I run the .NET app on a 32 bit machine, it runs just fine, no problems.
When I install the 32 bit application and its COM controls to an x64 system, the .NET application crashes. If I look at the exception thrown when I compile the .NET app on the x64 system, it says "COM Exception was unhandled". Then the rest of the message is: Retrieving the COM class factory for component with CLSID {B87F44E3-191A-4655-B582-D2E176A09BCF} failed due to the following error: 80040154.
When I look on the web at that error all that is mentioned is that the COM control is not registered properly.
On the x64 machine, if I run an old VB6 program that uses those same COM controls, it works just fine, so obviously my COM controls are registered so that the VB6 app can see them.
Is it possible that I need to recompile all the 32 bit code (32 bit app and COM controls) as 64 bit to get it to work on the x64 machine?
Are there any other ideas?
Thanks!
David
|
|
|
|
|
I have form1 and form2.
But form2 is not a child of form1.
How to fix this.
Because when i want to close one form, the two forms are closing.
Vasildb
|
|
|
|
|
It is not clear what you are asking for. I assume that form1 is your main form and form2 another form initialized in form2. So if you close (by closing I do not mean just changing the Visible property to false, I mean exit) form1 the application will exit. This will also happen if form2 was the child of form1...
Here is a snippet keeping the application running by changing the application thread, when the main form is disposed :
<br />
private void onExitEvent(object sender, EventArgs e)<br />
{<br />
Application.ExitThread();
<br />
Thread mainThread = new Thread(new ThreadStart(startRun));
mainThread.SetApartmentState(ApartmentState.STA);
mainThread.Start();
<br />
}<br />
public void startRun()<br />
{<br />
Application.Run(new NewForm());
}<br />
I am not sure if it has performance overheads or any side effects, but I am using this pattern and everything is working fine.
Best regards..
.:: Something is Wrong ::.
|
|
|
|
|
Is there something easy i can use? That doesn't involve the Windows Media Player? Or anything really. Thats the point of this app, that it doesn't need anything else installed.
Or do you think i'll have to yoink the stuff straight from the files by reading them byte by byte?
|
|
|
|
|
If you are talking about mp3 files, look up the id3 tag . Reading the id3 tag is done by yoinking bytes from the file.
I believe that there is an article here on the cp with an id3 class that works for id3 version 1 at least.
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Yeah, after peering into an MP3 with a hex editor, each piece of info has its own little 4 letter tag, like TIT1, or TRCK.
So i'll probably just do it all myself.
|
|
|
|
|
The Undefeated wrote: Yeah, after peering into an MP3 with a hex editor, each piece of info has its own little 4 letter tag, like TIT1, or TRCK.
This is the ID3 Version 2 tag. It's very complicated and pretty complex to parse. You might want to check the much easier ID3 Version 1 tag. It's typically at the end of the MP3 file, starting 128bytes from the end to then end. If there is an ID3v1 tag, then the last 128bytes start with 'TAG'.
It's very easy to read and write.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hmm. I don't have much choice of what tags i get to use in the first instance.
I file could come in with any version of an ID3 tag so im gonna have to check 'em all out i guess.
I've also got to accomodate for the tags in WMA files, which are much clearly labled it seems. For example, a tag might contain this: O r i g i n a l A r t i s t Bob
Incase you couldn't tell, the original artist is Bob
|
|
|
|
|
I am trying to get and R, G, and B value and make the form that color, but the BackColor. R, G, and B values are all read-only. how should i go about doing this? is there a way to convert RGB values into hex-colors(or whatever they're called - 000000 is black and ffffff is white)and then assign the hex to the form?
thanks in advance
|
|
|
|