Solved

How do i show Run dialog from C code?

Posted on 2009-03-30
8
357 Views
Last Modified: 2013-12-14
How do i show Run dialog from cpp code? I couldn't find a solution on internet :(
0
Comment
Question by:Shershen
8 Comments
 
LVL 45

Expert Comment

by:Kdo
Comment Utility
Hi Shershen,

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
0
 

Author Comment

by:Shershen
Comment Utility
Yes, I'm using c++ builder, but I need to show Run dialog from Start menu.
0
 
LVL 45

Expert Comment

by:Kdo
Comment Utility
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
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
Comment Utility
>>>> 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 ();


0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Shershen
Comment Utility
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.
0
 
LVL 45

Expert Comment

by:Kdo
Comment Utility
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



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;

  }

}

Open in new window

0
 

Accepted Solution

by:
Shershen earned 0 total points
Comment Utility
Solved by this code:

Variant V;
V = CreateOleObject("Shell.Application");
V.Exec(Procedure("FileRun"));
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Shershen, Good job, You have solved this yourself!  Click the "Accept As Solution" button in your above answer.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now