Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C++ fuction to minimize or close console window

Options
  • 27-11-2006 2:54pm
    #1
    Registered Users Posts: 4,037 ✭✭✭


    I have a DOS Window open that displays a list of images, you select one and a new window opens with the image on it, along with a menu that displays a set of image processsing functions you can perform on the image (ie rotate,change colour etc.)
    The trouble is the original window with the list of images on it remains on the screen. I want it to close or minimize once an image has been selected.
    The window that displays the list of images is a console window so functions like setcurrentwindow won't work.
    Any help would be appreciated.


Comments

  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    What is your code that launches the second window?
    Why doesn't the process in the first window simple end? (that should close the window)
    Why do you open a second window? Why not reuse the original window?

    To minimise the first window you'd probably be looking at the SendMessage function, with the WM_MINIMIZE message. The hard part might be to find the window handle of the first function.


  • Registered Users Posts: 4,037 ✭✭✭lukin


    I've attached the code (I cut some functions out that you don't need to know about).

    initwindow(1200,800); (about 110 lines down) is the code that opens the window.


  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    If your 'DOS' program used Win32 functions I'm sure you'd be able to get the window handle for that DOS window. Then you'd be able to send a message to tell it to minimise itself after the initwindow call.

    Since you are using outtextxy() after you try to chdir into the imgsdir, it seems to me that your original window is a BGI graphics window. I wonder would getcurrentwindow() return a handle to this window? Maybe you could call closegraph( handle ) after initwindow():
    handle = getcurrentwindow();
    initwindow(1200,800);      /*initialise graphics mode and set window size*/
    closegraph( handle );      /* Close the original window. */
    
    BTW, I made the above guesses by reading some online BGI docs. I've never used BGI so my comments could be waaay off the mark.


  • Registered Users Posts: 4,037 ✭✭✭lukin


    daymobrew wrote:
    If your 'DOS' program used Win32 functions I'm sure you'd be able to get the window handle for that DOS window. Then you'd be able to send a message to tell it to minimise itself after the initwindow call.

    Since you are using outtextxy() after you try to chdir into the imgsdir, it seems to me that your original window is a BGI graphics window. I wonder would getcurrentwindow() return a handle to this window? Maybe you could call closegraph( handle ) after initwindow():
    handle = getcurrentwindow();
    initwindow(1200,800);      /*initialise graphics mode and set window size*/
    closegraph( handle );      /* Close the original window. */
    
    BTW, I made the above guesses by reading some online BGI docs. I've never used BGI so my comments could be waaay off the mark.

    Yeah the first window that opens up displaying the list of images is a BGI graphics window.
    I tried your code but the compiler doesn't seem to know WTF getcurrentwindow(); is (see the attachment).
    (I have imported graphics.h).


  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    lukin wrote:
    Yeah the first window that opens up displaying the list of images is a BGI graphics window.
    I tried your code but the compiler doesn't seem to know WTF getcurrentwindow(); is (see the attachment).
    (I have imported graphics.h).
    Strange - it's listed in the docs that I was reading. There is a tiny chance that it has to be enabled e.g. with something like '#define BCI_GET_FUNCS' before you #include "graphics.h", though I doubt it. Have a look through graphics.h to see if there are any '#ifdef' lines that may prevent the getcurrentwindow() function from being declared.
    As I said earlier, I don't know the BGI API at all and I am just approaching this with normal debugging techniques.

    BTW, I found it very difficult to read the screenshot you took. Please paste it into a image file and save as a jpeg e.g. with Microsoft Paint or GIMP.


  • Advertisement
  • Registered Users Posts: 4,037 ✭✭✭lukin


    daymobrew wrote:
    BTW, I found it very difficult to read the screenshot you took. Please paste it into a image file and save as a jpeg e.g. with Microsoft Paint or GIMP.

    If you click on the pic in MSWord,then increase the zoom on the toolbar from 100% to 200% it should be bigger.


Advertisement