|
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
|
|
|
|
|
Use:
::WinExec("cmd /k \"tracert X.X.X.X\"", SW_SHOWNORMAL);
|
|
|
|
|
We're implementing context-sensitive help into our application and I have a few questions I'm hoping someone could help me out with.
We currently use ROBOHELP to generate our .HLP documents, no problem. I've been successfull in implementing they're DLL to call help files, from behind buttons, and even with the context-sensitive stuff when the user presses F1 on a control, or right clicks and selects the "What's This" menu item.
I want to be able to envoke the control-selection help mode when the user does a Help->What's This help selection from a menu. This is quite easy to do in C++/MFC, (CFrameWnd:OnContextHelp), but in Win32, How would I envoke the same "mode"? I dont see anything in RoboHelps documentation that will allow me to do that... Anyone have any experience here?
Mike.
doner@obtain.com
|
|
|
|
|
I assume the "What's This" option in the menu item activates a similar mode to the standard "What's This" event. That is, the pointer changes into a question pointer (combined question mark & arrow) and the user can click on any object on the GUI to get help with.
In this approach, I would suggest that you use the same handler as in the normal What's This calls.. Is this possible in your code ? Or is the "What's This" mode different when selected from the Help menu as it is when selected from the right-click menu ?
Just use the same handler for "a click with the question cursor" as you use when the user selects "What's This" from the context (right-click) menu of an item. If you use pure Win32, just go to the Window procedure handler, detect a left click of mouse, check the cursor type, and if it is the question cursor, invoke the target item's "What's This" feature.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I think you may need to add an extra level to your WM_COMMAND handlers, such that when a WM_COMMAND message comes through, you check the value of m_bContextHelpActive. If its true you display the help, else you pass the WM_COMMAND on to the correct message handler.
This would work for toolbar and menu items.
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
I want to display a JPEG file at the picture control.
I created a memory variable m_hBitmap at the CDialog class and have the interface to process the following code when the Open button is clicked. But line #2 always returns NULL.
CString file_name = "c:\\gis\\aspjpeg\\root.jpeg"; //line #1
m_hBitmap = (HBITMAP)::LoadBitmap(NULL, file_name); //line #2
m_thumbnail.SetBitmap(m_hBitmap); //line #3
Elizabeth
|
|
|
|
|
are you sure LoadBitmap can load jpg files ?
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Are you sure that the first parameter to LoadBitmap() can be NULL? The docs do not indicate such. Have you checked the return value of GetLastError() ? That might tell you exactly what is happening! I suspect Max's comment is more in line with what is happening.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I tried openning a bitmap file, but still getting a NULl return. Here is the updated code:
CString file_name = "c:\\gis\\aspjpeg\\new_file.bmp"; //line #1
m_hBitmap = (HBITMAP)::LoadBitmap(NULL, file_name); //line #2
DWORD error = GetLastError();
The error code is 1814 which is resource file not found.
Elizabeth
|
|
|
|