Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Can a Windows Forms 'button' link to ShellExecute? (http://www.go4expert.com/forums/windows-forms-button-link-shellexecute-t17901/)

Panarchy 8Jun2009 07:30

Can a Windows Forms 'button' link to ShellExecute?
 
Greetings

I've created a Windows Forms [Visual C++] project within Microsoft Visual Studio 2008.

I've been able to create a button.

Now how do I make that button correspond to a ShellExecute command, eg;

Code:

ShellExecute(NULL, TEXT("open"), TEXT("diskmgmt.msc"), NULL, NULL, SW_HIDE);
Thanks in advance for any suggestions,

Panarchy

PS: In case you need it, here's the code: http://www.mediafire.com/?lj2ma33kwmw

shabbir 8Jun2009 08:15

Re: Can a Windows Forms 'button' link to ShellExecute?
 
Moved to MFC forum and what do you meant by correspond ?

Panarchy 9Jun2009 04:47

Re: Can a Windows Forms 'button' link to ShellExecute?
 
So you click the button and it does the ShellExecute() call...

shabbir 9Jun2009 12:53

Re: Can a Windows Forms 'button' link to ShellExecute?
 
Add the Button Click Event Handler ( Either using the IDE or manually using Message Map Macros ) and then add the needed code for the handler into it.

Panarchy 10Jun2009 09:05

Re: Can a Windows Forms 'button' link to ShellExecute?
 
Thanks, however I can't find that option within the IDE.

Can you give me an example of the code for it?

Thanks in advance,

Panarchy

shabbir 10Jun2009 12:55

Re: Can a Windows Forms 'button' link to ShellExecute?
 
No. they would link to functions which has a predefined signatures and not to any other function

Panarchy 10Jun2009 13:18

Re: Can a Windows Forms 'button' link to ShellExecute?
 
Would you please be so kind as to give me an example of a GUI program, written in C++, with a button, which can launch an 'outside' program?

e.g.: Disk Management

Thanks in advance,

Panarchy

shabbir 11Jun2009 09:45

Re: Can a Windows Forms 'button' link to ShellExecute?
 
I guess you need to get the basics of MFC handling as its very simple a button click to get the button handler

Panarchy 12Jun2009 06:18

Re: Can a Windows Forms 'button' link to ShellExecute?
 
I worked it out. Here is the bottom of my code;
Code:

}
#pragma endregion
        private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {System::Diagnostics::Process::Start("C:\\Windows\\System32\\diskmgmt.msc");
                        }
};
}

Any ideas on how I can put if & else types onto the above type of command?

I'd really appreciate it if you could help me work that out.

Thanks in advance,

Panarchy

PS: Some links;
http://msdn.microsoft.com/en-us/libr...rol.click.aspx
http://msdn.microsoft.com/en-us/libr...ess.start.aspx

Panarchy 12Jun2009 06:25

Re: Can a Windows Forms 'button' link to ShellExecute?
 
I worked it out. Here is the bottom of my code;
Code:

}
#pragma endregion
        private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {System::Diagnostics::Process::Start("C:\\Windows\\System32\\diskmgmt.msc");
                        }
};
}

Any ideas on how I can put if & else types onto the above type of command?

I'd really appreciate it if you could help me work that out.

Thanks in advance,

Panarchy

PS: Some links;
http://msdn.microsoft.com/en-us/libr...rol.click.aspx
http://msdn.microsoft.com/en-us/libr...ess.start.aspx


All times are GMT +5.5. The time now is 01:09.