Copy the .h, .cpp and .resx files into the project directory.
Right click the project name in the solution explorer and use ‘Add Existing Item’ to add them to the project.
Select the .h file and then in the properties change the file type from “C++ Class” to “C++ Form”
Select category to view:
Add a form from another project
Calling A Form Control Event
When you need to pass sender and e to the function (e.g. a form control event)
frmMain_Load(this, gcnew EventArgs());
(more...)
Child Forms / Multiple Document Interface
Int Note: Kin Lib uses child forms
Applications that have a main window which contain one or more child windows are called Multiple Document Interface (MDI)
Create New Form
Creating The Form
Project > Add New Item > Windows Form. Name it using ‘frm’ at the start (my convention)
Set the ‘Form Border Style’
Set ‘MaximiseBox’ and ‘MinimizeBox’ properties
Set StartPostion
Set ‘Text’
Set ‘icon’ (or turn off ShowIcon)
Cursor
Show and hide the cursor
Cursor->Show();
Cursor->Hide();
Events For Multiple Form Objects – What Object Called An Event?
You can assign the same event to multiple controls. When called the “object sender” portion will be a reference to whatever one of the controls was clicked.
The EventArgs portion is a way to pass extra information to the event handler. Some events use a derivative of EventArgs which contain extra information.
Focus
Detecting Form Has Got Focus
Use the ‘Activated’ event
Bring Form To Front
this->BringToFront();
Form Controls and Objects
Indexing Controls (refer to them by index number)
Use a group box
Stopping Refresh Of A Control
General Form Usage
Opening a form
#include "FormName.h" //Add this at top of file
frmConfiguration ^ConfigForm = gcnew frmConfiguration();
ConfigForm->PassedValue1 = "This is a string I'm passing";
(more...)
Link two forms
Set the secondary form owner to the main form. For instance, if you have created another form you do this: (more…)
Passing values between forms
To Use A Global Variable
Add it to our ap-main.h file – this is automatically included in all files (see creating a project if this file is not in your project)
You can’t make strings global – only normal variable types
However you can just pass a handle to a string or come other object so the form can read/write it. (more…)
Re-sizable Forms
Making Form Re-Sizable
AutoScroll
Set to true, to enable scroll bars when needed.
You can then just add controls outside of the forms size and the scroll bars will appear to allow then to be seen.
Right Click Menus
Create a ContextMenuStrip from the toolbox
Transparency
Transparency is actually simulated by drawing the pixels of the Parent, which is the form. Therefore you only see the form pixels, stacking effects don’t work. One approach is to just draw the images in the form’s Paint event, or consider WPF which has a very different rendering model that easily supports transparency.
Z Order
Force Label To Front
MyLabel->BringToFront();



