Today, you learned how you can use standard windows controls in a Visual C++ application.
You learned how to declare and attach variables to each of these controls and how
Q When I specified the object IDs of the controls on the window, three controls
had the same ID, ID C_STATIC. These controls were the text at the top of the
window and the two group boxes. The other two static text controls started
out with this same ID until I changed them. How can these controls have the
same ID, and why did I have to change the ID on the two static texts where I
did change them?
A All controls that don’t normally have any user interaction, such as static text and
group boxes, are by default given the same object ID. This works fine as long as
your application doesn’t need to perform any actions on any of these controls. If
you do need to interact with one of these controls, as you did with the static text
prompts for the edit box and combo box, then you need to give that control a
unique ID. In this case, you needed the unique ID to be able to retrieve the control
object so that you could enable or disable and show or hide the control. You also
44 Day 2
The Win Exec function is an obsolete Windows function. You really should use
the Create Process function instead. However, the Create Process function
has a number of arguments that are difficult to understand this early in programming
using Visual C++. The Win Exec function is still available and is
implemented as a macro that calls the Create Process function. This allows
you to use the much simpler Win Exec function to run another application
while still using the function that Windows wants you to use.
Another API function that can be used to run another application is the
Shell Execute function. This function was originally intended for opening or
printing files, but can also be used to run other programs.
Note