Shershen
asked on
How do i show Run dialog from C code?
How do i show Run dialog from cpp code? I couldn't find a solution on internet :(
ASKER
Yes, I'm using c++ builder, but I need to show Run dialog from Start menu.
It sounds like a communications issue.
By "Start menu" do you mean the "file" menu or something else?
For most any place that you want to show the dialog box, the code is the same. You simply need to execute it.
Note that dialog boxes are modal, meaning that the user can not access other parts of the application until the dialog box closes. If you put the dialog box as part of the application's startup code, the user will always have to complete the dialog box before the application can resume.
Kent
By "Start menu" do you mean the "file" menu or something else?
For most any place that you want to show the dialog box, the code is the same. You simply need to execute it.
Note that dialog boxes are modal, meaning that the user can not access other parts of the application until the dialog box closes. If you put the dialog box as part of the application's startup code, the user will always have to complete the dialog box before the application can resume.
Kent
>>>> By "Start menu" do you mean the "file" menu or something else?
Probably the Windows Start menu.
I don't know whether there is an Active-X available for Run Dialog, but you easily could make your own using the resource editor, create a dialog instance and call execute member function. and invoke the command entered by the user via ShellExecute.
TDialog * ptrRunDialog = new MyRunDialog();
ptrRunDialog->Execute ();
Probably the Windows Start menu.
I don't know whether there is an Active-X available for Run Dialog, but you easily could make your own using the resource editor, create a dialog instance and call execute member function. and invoke the command entered by the user via ShellExecute.
TDialog * ptrRunDialog = new MyRunDialog();
ptrRunDialog->Execute ();
ASKER
Seems my english is quite bad :)
Press Win+R - I need to show this dialog from my program, using some API function or interface or rundll32 or something else.
Press Win+R - I need to show this dialog from my program, using some API function or interface or rundll32 or something else.
Ok. If I get this correct...
The application's main form (just like any other form) traps a bunch of events that you can process.
Create an OnKeyPress event handler for the main form. (In the "Object Inspector", click the "Events" tab, then double click OnKeyPress. The IDE will create the method and put you into the editor within the new method.
Within the handler, check to see if the value of Key is what you want. (I have no idea what the Win+R key combination is.) If it is your key, open the dialog box as shown above and set the value of Key to 0 (zero) before the method exits. If the value of Key is not a keypress that you want to handle, simply leave it alone
Good Luck,
Kent
The application's main form (just like any other form) traps a bunch of events that you can process.
Create an OnKeyPress event handler for the main form. (In the "Object Inspector", click the "Events" tab, then double click OnKeyPress. The IDE will create the method and put you into the editor within the new method.
Within the handler, check to see if the value of Key is what you want. (I have no idea what the Win+R key combination is.) If it is your key, open the dialog box as shown above and set the value of Key to 0 (zero) before the method exits. If the value of Key is not a keypress that you want to handle, simply leave it alone
Good Luck,
Kent
void fastcall TMainForm::FormKeyPress (TObject *Sender, char &Key)
{
if (Key == 'R') // Key on 'R' (as an example)
{
TDiaglogBox *Dialog = new TDialogBox (this);
if (Dialog->Execute ())
// Do Something
Key = 0;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Shershen, Good job, You have solved this yourself! Click the "Accept As Solution" button in your above answer.
If you really are using C++ Builder, simply drop any of the dialog box controls onto your form. Then from within the C code, execute that box.
TDiaglog *MyDialog = new ....;
MyDialog->Execute ()
Kent