|
Which is the simplest way to terminate a dialog-based application?
|
|
|
|
|
1.The simplest is: clicking on the close button on the right upper corner with the mouse.
2.Second simplest: DestroyWindow() (from your app);
Peter Molnar
|
|
|
|
|
)Sorry, I missed some words in my question - I meant how one application can terminate another one...
|
|
|
|
|
|
Click the the X???
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
O, really? Thanks! It's my mistake I didn't ask the right question - what I meant was how one application can terminate another one.
|
|
|
|
|
I figured so...but the answer is fairly trivial, so I figured I'd just be a smart a$$ and let someone else tell you.
Cheers
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
if you know the title of that window, use this:
LPSTR name="the_window_title";
HWND hWnd = ::FindWindow(NULL,name);
::SendMessage(hWnd, WM_CLOSE, 0, 0);
|
|
|
|
|
The best way is to send WM_CLOSE message at any time
|
|
|
|
|
AfxGetMainWnd()->PostMessage(WM_CLOSE, 0, 0);
Fast.
Riccardo.
|
|
|
|
|
Is it possible to restart my dialog application from within or should I create an outside object to close it and then to start it again?
|
|
|
|
|
If your application lives just in an *.exe there isn't a possibility, but if in a *.dll there is.
You load your own .dll from an *.exe, when the *.dll attaches to the *.exe the reason for call in DllMain is DLL_PROCESS_ATTACH. Depending upon value of dwReason you can start your code.
If your process starts, your *.exe is shown in the task manager (with the *.dll linked to it), and it can be killed from there. In this case your DllMain gets called again with reason DLL_PROCESS_DETACH. From here you have to do a ShellExecute on your *.exe, and your process with the linked *.dll starts again.
Peter Molnar
|
|
|
|
|
You basically need two exe files, say, A and B. Now you want to restart A "within" A, you simply let A do the following:
1, Launch B via a call to ::ShellExecute .
2, Terminate itself.
At this point B has been launched and A has been terminated. Now, what B does are the following:
1, Wait a few seconds by using a timer. This is usually necessary because A may need some time to cleanup, i.e., de-allocate resources, clean files, whatever, etc.
2, Launch A via a call to ::ShellExecute .
3, Terminate itself.
So now your A is "restarted".
|
|
|
|
|
Yes, few solutions awailable:
1) External executable, when given control restarts app.
2) Create batch file that restarts application with flag delete on close,
execute it, and exit application.
3) Same executable, or new version of exec or exe making copy of itself, with when started with "reboot" command option, waits for executer to close, places itself into original directory, and re-starts itself.
I used to use (1), now I use (3) for self-update.
|
|
|
|
|
If I want to round my float so that automatically
3.45 ---- > 3.0 and 3.55---------->4.0 do I have to test (> 3.5 or < 3.5)and use a combination of ceil and floor? I couldnt find anything like a round() which might be able to decide automatically.
Thanks,
ns
|
|
|
|
|
Just put that comparison you mentioned in a function and name it round!
|
|
|
|
|
double d = 3.45;
int x = (int) (d + 0.5); // x is 3
...
d = 3.55;
x = (int) (d + 0.5); // x is 4
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
pretty tricky. Thank you!
|
|
|
|
|
|
hi,
my program displays up to 120.000 or more items in a ctreectrl. no problems, but it uses nearly ten megabytes of the ram, i've calculated a value of around 70 bytes per entry. how can i reduce this?
|
|
|
|
|
perhaps don't put 120,000 or more items in a ctreectrl?
|
|
|
|
|
Rather than populate the tree control all at once, populate each branch as it is expanded. You may be doing this already. If so, my bad.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
is it the same when you create all items just with one letter texts?
maybe try LPSTR_TEXTCALLBACK if you have texts stored at another memory place
t!
|
|
|
|
|
I would like to popup a new dos prompt and execute tracert command when
the user clicks a button. I am using WinExec for this. e.g.
::WinExec ("tracert X.X.X.X", SHOW_NORMAL);
However, after tracert executes the console window disappears. How can I keep the console window from disappearing ?
Thank you
Orcun Colak
|
|
|
|
|
::WinExec ("cmd.exe /c tracert X.X.X.X & pause", SW_SHOWNORMAL/* not SHOW_NORMAL */);
on win95/98/me I think you need to use command.com
instead of cmd.exe
|
|
|
|