12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The <strong>C++</strong>Builder IDE Explored: Projects and Forms<br />

Handle<br />

The Handle property returns the w<strong>in</strong>dow handle (HWND) of the form. Use this property when<br />

you need the w<strong>in</strong>dow handle to pass to a W<strong>in</strong>dows API function.<br />

ModalResult<br />

The ModalResult property is used to close a modal w<strong>in</strong>dow. If you have a dialog box that has<br />

OK and Cancel buttons, you can set ModalResult to mrOK when the user clicks the OK button,<br />

and to mrCancel when the user clicks the Cancel button. The call<strong>in</strong>g form can then read<br />

ModalResult to see which button was clicked to close the form. Other possibilities <strong>in</strong>clude<br />

mrYes, mrNo, and mrAbort.<br />

Owner<br />

The Owner property is a po<strong>in</strong>ter to the owner of the form. The owner of the form is the object<br />

that is responsible for delet<strong>in</strong>g the form when the form is no longer needed. The parent of<br />

a component, on the other hand, is the w<strong>in</strong>dow (a form or another component) that acts as<br />

the conta<strong>in</strong>er for the component. In the case of a ma<strong>in</strong> form, the application object is both<br />

the owner of the form and the parent of the form. In the case of components, the owner would<br />

be the form, but the parent could be another component, such as a panel.<br />

Parent<br />

The Parent property is a po<strong>in</strong>ter to the parent of the form. See the previous section about<br />

Owner for an explanation of Owner versus Parent.<br />

Form Methods<br />

Forms are components, too. As such, forms have many methods <strong>in</strong> common with components.<br />

Common methods <strong>in</strong>clude Show(), ShowModal(), and Invalidate(), to name just a<br />

few. There are some methods, however, that are specific to forms. As before, I’ll discuss only<br />

the most commonly used methods.<br />

Br<strong>in</strong>gToFront()<br />

The Br<strong>in</strong>gToFront() method causes the form to be brought to the top of all other forms <strong>in</strong><br />

the application.<br />

Close() and CloseQuery()<br />

The Close() method closes a form after first call<strong>in</strong>g CloseQuery() to be sure that it’s okay to<br />

close the form. The CloseQuery() function, <strong>in</strong> turn, calls the OnCloseQuery event handler. If<br />

197<br />

6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!