Virtual Developer Workshop: Containerized Development with Docker

Environment: eg VC6 WIN9x/WINNT/WIN2K

By using Visual C++ you can easily communicate with other application running on your desktop computer. You can easily do work on them. For example you can place text in a textbox, click a button and much more. In the Windows OS every object you see is a window and if you get the handle of a window, you can do many different things with it.

The key is to get the handle of the window and then make it into a CWnd Object. You can then play around with all the basic window APIs. You can even get the handle of your desktop, your Start button, and the system tray.

I will show you an example of how to get the handle of the windows Start button and enable and disable it. In the same way, you can capture any window running on the desktop.

  1. Create an MFC Dialog based Application
  2. Place two buttons in it and name them "enable" and "disable"
  3. In the "disable" button click event write the following code segment (say I call a function disable in it):

    // make them either global or class variables.
    HWND starthandle;
    CWnd StartButton;
    void disable(void)
      // Since there is only one button on the desktop, you
      // will automatically get the handle of it, otherwise
      // you will give its caption name.
      // Button is the class name of the (Button) in windows.
      // You can see the description of (FindWindowEx) in MSDN
      // for more details. 
      starthandle = FindWindowEx(NULL,NULL,"Button","");
      // Now you have the button in the window form.
      // You can type cast it in either CButton or do whatever
      // you like. I will only make it invisible, so...
    void enable(void)




  • how about the start menu ?

    Posted by Legacy on 02/14/2003 08:00am

    Originally posted by: soul

    anyone knows how to access the start menu ?
    i would need to count items, find position and get strings from the start menu ...

    thx in advance for any tips/code

  • doesn't work

    Posted by Legacy on 11/15/2002 08:00am

    Originally posted by: Qian


  • click a button and much more...You think much more? slow down

    Posted by Legacy on 10/23/2002 07:00am

    Originally posted by: sasha

    It looks an impressive from first glance, but in fact, you can do very little with that HWND you get. To be more presize only those things which are passed through stack without addressing memory. e.g. you can't read a content of list/tree control, all this because this assumes getting into address space of another process, which is a bit more complicated.
    That is all for now

  • Killing open applications on the desktop

    Posted by Legacy on 10/17/2002 07:00am

    Originally posted by: Ato Koomson

    Hi, I really need help on this.

    I am writing an application within which I have to close all other open applications on the desktop when it is exiting.

    Can anyone help me out here. I am developing in VC++.

    Thanks in advance.

  • Accessing Accelerators

    Posted by Legacy on 04/13/2002 07:00am

    Originally posted by: Graham Child

    I needed to access the accelerators for mspaint and came up with this:-

    57642 = select all for mspaint ctrl a
    57634 = copy
    Numbers obtained from spy Wid57642 etc


    starthandle = FindWindowEx(0,0,"MSPaintApp",NULL);


    Regards Graham

  • can't Click on Test Page OK Button

    Posted by Legacy on 03/11/2002 08:00am

    Originally posted by: Naveen Maheshwari

    I found the Idea given as very interesting...and helpful ...but stuck up in a problem ..what I am trying to do is to write a application that opens up properties of any printer and fire test page on Windows 2000 machine.
    Using the given Technique I could fire the test page but I am unable to click on OK button on the confirmayion dialog box which comes up just after Print Test Page "test page printed Properly"...
    To open printer properties I am using

    CreateProcess() with command line as
    rundll32 printui.dll,PrintUIEntry /p /n printername

    This opens up propertypage and I am able to print test page but after that my application is set as not responding till manually click on OK button.
    code written for firing test page is

    TestPage = FindWindowEx(NULL,NULL,"#32770",NULL);
    TestPage = FindWindowEx(TestPage,NULL,NULL,"General");
    TestPage = FindWindowEx(TestPage,NULL,"Button","Print &Test Page");
    if (TestPage)


    pls Help.

  • Inter-process

    Posted by Legacy on 02/01/2002 08:00am

    Originally posted by: Maha

    when i try to run the code the assertion error is coming. it seems like we've to give the start button caption in the last argument. mine is NT Workstation.Is it a problem with N? I want this in a different way like.. I want to send text from my application to a text box which is appeared in the browser. How do i do it? Plz help me if u know

    Thanx in advance


  • Posted by Legacy on 11/28/2001 08:00am

    Originally posted by: leo

    Useful tips to me. Thanks a lot!

  • Useful tips to me. Thanks a lot!

    Posted by Legacy on 11/28/2001 08:00am

    Originally posted by: leo

  • Good Work

    Posted by Legacy on 11/27/2001 08:00am

    Originally posted by: AZEEM SAJJAD

    I am a Software Engineer in ILM and I am novice user of Visual C. I check your work. It was a good effort and may Allah bless u and give u determination to do more and more.

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date