public partial class frmBackground : Form
{
frmMain main = new frmMain();
[DllImport("user32.dll")]
private static extern int FindWindow(string className, string
windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);
private const int SW_HIDE = 0;
private const int SW_SHOW = 1;
public frmBackground()
{
InitializeComponent();
}
private void frmBackground_Load(object sender, EventArgs e)
{
int hwnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(hwnd, SW_HIDE);
main.Show();
}
> I think I just need to know how a use can click a button in
> frmMain, make frmMain unload itself AND load a new form.
private void ShowFormXButton_Click(object sender, EventArgs e)
{
FormX newForm = new FormX();
newForm.Show();
this.Close();
}
Am I missing something...?
When the main form closes, the app closes. You can use this.Hide(). I
think there is a setting to close the app when the main form closes, or
when all forms close. I'm using express at home and cannot find the
setting that the moment.
--
Mike
There's no setting, but it can be accomplished by showing the initial
form explicitly and using the parameterless Application.Run() overload
(requires editing the Program.cs file).
Not that that appears to be the problem the OP is concerned about. His
post (admittedly vague) seems to be suggesting that he has some problem
with his full-screen window NOT being closed.
Unfortunately, he didn't post a concise-but-complete code example, nor
explain why he's using p/invoked functions to manipulate his window. I
think it will be difficult to know exactly what the expected and useful
answer is without some elaboration of the question.
Pete
Ah, I found the setting, but it is in the VB application properties.
> Not that that appears to be the problem the OP is concerned about. His
> post (admittedly vague) seems to be suggesting that he has some problem
> with his full-screen window NOT being closed.
>
> Unfortunately, he didn't post a concise-but-complete code example, nor
> explain why he's using p/invoked functions to manipulate his window. I
> think it will be difficult to know exactly what the expected and useful
> answer is without some elaboration of the question.
>
> Pete
I was actually answering Jeff's post, but you are right on about the
original post.
--
Mike
Sorry...my C# projects don't have that setting.
;)
> Not that that appears to be the problem the OP is concerned about. His
> post (admittedly vague) seems to be suggesting that he has some problem
> with his full-screen window NOT being closed.
I didn't get that at all from what the poster said:
> The user from there can make a selection via a button and when that
> selection
> is made, frmMain needs to close and the new form which the user selected
> needs to pop up. The problem is that I can get the new form to pop up but
> frmMain won't go away.
He WANTS frmMain to close and does NOT want the background to close.
(Although if the child-child form opened by frmMain is closed and the user
is left with only the background form, I'm not sure how he's supposed to
proceed outside of hitting Alt+F4....)
But yes, the post is quite vague, with perhaps the most confusing piece
being this one:
> I've programmed it to full truescreen mode.
"Truescreen" mode? Damned kids and their newfangled technology....
>>> I think I just need to know how a use can click a button in
>>> frmMain, make frmMain unload itself AND load a new form.
>>
>> private void ShowFormXButton_Click(object sender, EventArgs e)
>> {
>> FormX newForm = new FormX();
>>
>> newForm.Show();
>>
>> this.Close();
>> }
>>
>> Am I missing something...?
>
> When the main form closes, the app closes.
But frmMain is NOT the main form, according to the initial post:
"Jeff Johnson" wrote:
> .
>
Jeff,
Yep, you are right. I saw the frmMain and a button click, and assumed
frmMain was "the main form"...
Mike
> Yep, you are right. I saw the frmMain and a button click, and assumed
> frmMain was "the main form"...
Yeah, in addition to vagueness the naming convention is horrible.
(Starting with the classic VB "frm..." naming! I'm a convert: bastardized
Hungarian must die.)