|
IDD_BIOGTAPHY
dialog, the design
Add Picture Files
- From the
CD-Rom - Teach_VNet, copy the
bmp files butterfly1.bmp and
butterfly2.bmp
(\\C_Col_VC++Net\KJV_VCNet\res\ingraphic1.bmp)
to the folder - c:\KJV_VCNet\res
- On the
Projet menu , click Add Resource, Add
Resource dialog box
appears, select Bitmap, click Import,
Import dialog box appears, select the file
butterfly1.bmp of the folder c:\KJV_VCNet\res,
and then click Open. New
item - IDB_BITMAP6 added to the Bitmap folder
of Resource View
- On the
Projet menu , click Add Resource, Add
Resource dialog box
appears, select Bitmap, click Import,
Import dialog box appears, select the file
butterfly2.bmp of the folder c:\KJV_VCNet\res,
and then click Open. New
item - IDB_BITMAP7 added to the Bitmap folder
of Resource View
|
| |
|
IDD_BIOGRAPHY
1. |
The Dialog
design
|
2. |
The Dialog
Properties
Caption: Center: ID: Menu: Maximize
Box: |
Biography True IDD_BIOGRAPHY
False | |
Delete
the Button
control - IDCANCEL
|
3. |
From the Toolbox/Dialog Editor add
the following control to
IDD_BIOGRAPHY
Six
Text controls and one Picture
control
The controls
Properties
- Picture control
ID: Image: Type: |
IDC_STBITMAP IDB_BITMAP6 Bitmap | |
IDB_BITMAP6 = bmp file - butterfly1.bmp
- Text
controls
1. |
Align
Text: Caption: ID: |
Left Name: ... IDC_STATIC |
|
|
2. |
Align Text:
Caption:
ID: |
Left
Address: ....
IDC_STATIC |
|
|
3. |
Align Text:
Caption:
ID: |
Left
Signification: ...
IDC_STATIC |
|
|
4. |
Align Text:
Caption:
ID: |
Left
Tel: ...
IDC_STATIC |
|
|
5. |
Align Text:
Caption:
ID: |
Left
Web: ...
IDC_STATIC |
|
|
6. |
Align Text:
Caption:
ID: |
Left
E-mail: ..
IDC_STATIC |
|
|
|
|
4. |
Add Variable
...
- On the View menu , click
Resource View, in the Resource View - KJV_VCNet dialog
box appears, expand KJV_VCNet , expand Dialog
folder and click
IDD_BIOGRAPHY
- Select
and right click the Picture control - IDC_STBITMAP,
select Add variable ... on the
shortcut menu, the Add Member Variable Wizard - KJV_VCNet dialog box
appears.
-
In this
dialog ...
- In the Control ID
box , display IDC_STBITMAP
- In the
Control type box , display
ICON
- In the
Category box, select
Control
-
Click Finish. new
text codes to be added to the files:
- In the
Biograhy.h
CStatic m_bitmap; -
In the Biography.cpp
DDX_Control(pDX, IDC_STBITMAP, m_bitmap);
|
|
|
5. |
Add Events
- On the View menu , click
Resource View, in the Resource View - KJV_VCNet dialog
box appears, expand KJV_VCNet , expand Dialog
folder and click
IDD_BIOGRAPHY
- Select
and right click the
IDD_BIOGRAPHY dialog,
select Properties on the shortcut
menu, in the Properties dialog box appears, click
Messages
- From
the new dialog box appears add 2 events :
- Select WM_DESTROY
and add the event OnDestroy. New text codes to be added to the
files
- In the
Biograhy.h
afx_msg
void
OnDestroy(); -
In the Biography.cpp
void
CBiography::OnDestroy()
{
CDialog::OnDestroy();
//
TODO: Add your message handler code here
}
|
- Select
WM_TIMER and add the event OnTimer. New text
codes to be added to the
files
- In the
Biograhy.h
afx_msg
void
OnTimer(UINT nIDEvent); -
In the Biography.cpp
void
CBiography::OnTimer(UINT nIDEvent)
{
//
TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);}
|
|
|
|
|
1.
|
Biography.h
The color of the new text codes
added is Red
#pragma
once #include
"afxwin.h"
// CBiography dialog
class CBiography :
public
CDialog
{
DECLARE_DYNAMIC(CBiography)
public :
CBiography(CWnd* pParent = NULL);
// standard constructor
virtual
~CBiography();
// Dialog Data
enum
{ IDD = IDD_BIOGRAPHY };
protected :
UINT m_Timer;
CBitmap m_bitmapbutterfly1,
m_bitmapbutterfly2;
virtual
void
DoDataExchange(CDataExchange* pDX);
// DDX/DDV support
DECLARE_MESSAGE_MAP()
public :
CStatic m_bitmap;
virtual
BOOL OnInitDialog();
afx_msg
void
OnDestroy();
afx_msg
void
OnTimer(UINT nIDEvent);
}; |
|
2. |
Biography.cpp
The color of the new text codes
added is Red
//
Biography.cpp : implementation file //
#include "stdafx.h"
#include "KJV_VCNet.h"
#include "Biography.h"
#include ".\biography.h"
// CBiography dialog
IMPLEMENT_DYNAMIC(CBiography, CDialog)
CBiography::CBiography(CWnd* pParent
/*=NULL*/)
: CDialog(CBiography::IDD, pParent)
{
}
CBiography::~CBiography()
{
}
void
CBiography::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_STBITMAP,
m_bitmap);
}
BEGIN_MESSAGE_MAP(CBiography, CDialog)
ON_WM_DESTROY()
ON_WM_TIMER()
END_MESSAGE_MAP()
// CBiography message handlers
BOOL CBiography::OnInitDialog()
{
CDialog::OnInitDialog();
m_bitmapbutterfly1.LoadBitmap(IDB_BITMAP6);
m_bitmapbutterfly2.LoadBitmap(IDB_BITMAP7);
m_Timer =
SetTimer(IDD_BIOGRAPHY,1,NULL);
// TODO: Add
extra initialization here
return TRUE; //
return TRUE unless you set the focus to a control
// EXCEPTION:
OCX Property Pages should return FALSE
}
void
CBiography::OnDestroy()
{
CDialog::OnDestroy();
KillTimer(m_Timer);
// TODO: Add
your message handler code here
}
void
CBiography::OnTimer(UINT nIDEvent)
{
tm *vtma;
time_t vtime_ta;
time(&vtime_ta);
vtma = localtime(&vtime_ta);
if
((vtma->tm_sec % 2) == 0)
m_bitmap.SetBitmap(m_bitmapbutterfly1);
else
m_bitmap.SetBitmap(m_bitmapbutterfly2);
// TODO: Add
your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
} |
| |
|
|