Solved

How do i show Run dialog from C code?

Posted on 2009-03-30
8
369 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
ID: 24020603
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
ID: 24020648
Yes, I'm using c++ builder, but I need to show Run dialog from Start menu.
0
 
LVL 45

Expert Comment

by:Kdo
ID: 24020696
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 24021982
>>>> 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
 

Author Comment

by:Shershen
ID: 24023030
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
ID: 24023655
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
ID: 24023695
Solved by this code:

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

Expert Comment

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

785 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