Article View: cn.bbs.comp.program
Article #1185vc���ָ��68ƪ(6)
From: �ϵ�
Date: Sun, 19 Apr 1998 00:00
Date: Sun, 19 Apr 1998 00:00
213 lines
10328 bytes
10328 bytes
2m������:m TINA (�ռ�����)
2m�� ��:m RAD
2m�� ��:m VC��̼���68ƪ(6)
2m����վ:m '3m�Ͻ�ɺ�m' (Mon Apr 6 08:36:12 1998) , 5mվ���ż�m
[������ҳ] [����������] [ȫ��������]
������: Zeemon (������), ����: Visual
�� ��: vc���ָ��68ƪ(6)
����վ: BBS ˮľ�廪վ (Thu Oct 23 12:45:54 1997)
31������ڶԻ�������ʾһ��λͼ
��Ҫ�鹦��Win 32�Ƚ�ľ�̬�ؼ���Microsoft����Դ�༭���� �ڶԻ�����
��ʾλͼ�Ǻ����ģ� ֻ�轫ͼ�οؼ��ϵ��Ի��в�ѡ���ʵ����Լ��ɣ��û�Ҳ
������ʾͼ�ꡢλͼ�Լ���ǿ��Ԫ�ļ���
32����θı�Ի������Ӵ��ı�����ɫ
����CWinApp : : SetDialogBkColor���Ըı�����Ӧ�ó���ı�����ɫ����
һ������ָ���˱�����ɫ���ڶ�������ָ�����ı���ɫ������Ӧ�ó���Ի�����
Ϊ��ɫ�����ͻ�ɫ�ı���
BOOL CSampleApp : : InitInstance ( )
{
��
//use blue dialog with yellow text .
SetDialogBkColor (RGB (0, 0, 255 ), RGB ( 255 , 255 , 0 ) ) ;
��
}
��Ҫ�ػ��Ի�����Ի����ӿؼ���ʱ��Windows��Ի�������ϢWM_CTLCOLOR��
ͨ���û�������Windowsѡ��滭������ˢ�ӣ�Ҳ�����ø���Ϣָ��ˢ�ӡ�����˵
���˴���һ����ɫ�����Ի��IJ��衣
���ȣ���Ի���������һ�˳�Ա����CBursh :
class CMyFormView : public CFormView
{
��
private :
CBrush m_ brush ; // background brush
��
} ;
��Σ� ����Ĺ��캯���н�ˢ�ӳ�ʼ��Ϊ����Ҫ�ı�����ɫ��
CMyFormView : : CMyFormView ( )
{
// Initialize background brush .
m_brush .CreateSolidBrush (RGB ( 0, 0, 255 ) )
}
���ʹ��ClassWizard����WM_CTLCOLOR��Ϣ������һ�������滭�Ի�������
ˢ�Ӿ��ע�⣺���ڵ��ػ��Ի��ؼ�ʱҲҪ���øú�������Ҫ���nCtlColor
������
HBRUSH CMyFormView : : OnCtlColor (CDC* pDC , CWnd*pWnd , UINT nCtlColor )
{
// Determine if drawing a dialog box . If we are , return +handle to
//our own background brush . Otherwise let windows handle it .
if (nCtlColor = = CTLCOLOR _ DLG )
return (HBRUSH) m_brush .GetSafeHandle ( ) ;
return CFormView : : OnCtlColor (pDC, pWnd , nCtlColor );
}
33����λ�ȡһ���Ի��ؼ���ָ��
�����ַ�������һ������CWnd: : GetDlgItem����ȡһ��CWnd*ָ����ó�
Ա�����������GetDlgItem��������ֵ����һ��CSpinButtonCtrl*�Ա����
CSpinButtonCtrl : : SetPos ����
BOOL CSampleDialog : : OnInitDialog ( )
{
CDialog : : OnInitDialog ( ) ;
//Get pointer to spin button .
CSpinButtonCtrl * pSpin - ( CSpinButtonCtrl *) GetDlgItem (IDC_SPIN) ;
ASSERT _ VALID (pSpin) ;
//Set spin button's default position .
pSpin ��> SetPos (10) ;
return TRUE ;
}
����� ����ʹ��ClassWizard���ؼ��ͳ�Ա������ϵ��������ClassWizard�м�
����ѡ��Member Variables��ǩ��Ȼ��ѡ��Add Variable ����ť������ڶԻ���Դ
�༭���У�����Ctrl��˫���ؼ�����ת��Add Member Variable�Ի���
34����ν�ֹ��ʹ�ܿؼ�
�ؼ�Ҳ�Ǵ��ڣ����Կ��Ե���CWnd : : EnableWindowʹ�ܺͽ�ֹ�ؼ���
//Disable button controls .
m_wndOK.EnableWindow (FALSE ) ;
m_wndApply.EnableWindow (FALSE ) ;
35����θı�ؼ�������
���ڿؼ���Ҳ�Ǵ��ڣ��û����Ե���CWnd: : SetFontָ�������塣�ú�����
һ��Cfontָ�룬Ҫ��֤�ڿؼ�����֮ǰ���ܳ����������������ѹ��ť����
���Ϊ8��Arial���壺
//Declare font object in class declaration (.H file ).
private :
Cfont m_font ;
// Set font in class implementation (.Cpp file ). Note m_wndButton is a
//member variable added by ClassWizard.DDX routines hook the member
//variable to a dialog button contrlo.
BOOL CSampleDialog : : OnInitDialog ( )
{
��
//Create an 8-point Arial font
m_font . CreateFont (MulDiv (8 , -pDC��> GetDeviceCaps (LOGPIXELSY) ,
72).
0 , 0 , 0 , FW_NORMAL , 0 , 0, 0, ANSI_CHARSER, OUT_STROKE_PRECIS ,
CLIP_STROKE _PRECIS , DRAFT _QUALITY
VARIABLE_PITCH ��FF_SWISS, _T ("Arial") );
//Set font for push button .
m_wndButton . SetFont (&m _font );
��
}
36�������OLE�ؼ���ʹ��OLE_COLOR�������
����COleControl : : GetFortColor��COleControl : : GetBackColor�Ⱥ���
����OLE _COLOR������͵���ɫ����GDI��������ʺ�ˢ��ʹ�õ���COLORREF�����
�ͣ�����COleControl : : TranslateColor���Ժ����ؽ�OLE_COLOR����Ϊ
COLORREF���͡�������һ����ǰ������ɫ��ˢ�ӣ�
void CSampleControl : : OnDraw (CDC* pdc
const Crect& rcBounds , const Crect& rcInvalid )
{
//Create a brush of the cuttent background color .
CBrush brushBack (TranslateColor (GetBackColor ( ) ) );
//Paint the background using the current background color .
pdc��> FilllRect (rcBounds , &brushBack) ;
//other drawign commands
��
}
37���ڲ�ʹ��ͨ���ļ��Ի�������������ʾһ���ļ��б�
����CWnd: : DlgDirList����CWnd: : DlgDirListComboBox�� Windows ���Զ�
�����б�����Ͽ������õ����������ָ��Ŀ¼�е��ļ�������WindowsĿ
¼�е��ļ��������Ͽ��У�
BOOL CSampleDig : : OnInitDialog ( )
{
CDialog : : OnInitDialog ( )
TCHAR szPath [MAX_PATH] = {"c:\\windows"} ;
int nReslt = DlgDirListComboBox (szPath , IDC_COMBO , IDC_CURIDIR,
DDL_READWRITE ��DDL_READONLY��DDL_HIDDEN��
DDL_SYSTEM��DDL_ARCHIVE ) ;
return TRUE ;
}
38��Ϊʲô��ת��ť�ؼ���������ת
��Ҫ����CSpinCtrl : : SetRange ������ת��ť�ؼ��ķ�Χ����ת��ť�ؼ�
��ȱʡ����Ϊ0��ȱʡ����Ϊ100������ζ������ʱ��ת���ؼ���ֵ��100��Ϊ0��
������ת��ť�ؼ��ķ�Χ����Ϊ0��100��
BOOL CAboutDlg : : OnInitDialog ( )
{
CDialog : : OnInitDialog ( )
//set the lower and upper limit of the spin button
m_wndSpin . SetRange ( 0 ,100 ) ;
return TRUE ;
}
Visual C++ 4.0 Print�Ի��е�Copise��ת��ť�ؼ�Ҳ��ͬ������⣺����Up
��ťʱ��������Ŀ���٣�����Down ��ťʱ��������Ŀ���ӡ�
39Ϊʲô��ת��ť�ؼ������Զ��ظ���������ı༭�ؼ�
���ʹ����ת��ť��autu buddy���ԣ� ����뱣֤�ڶԻ��ı��˳����
buddy������������ת��ť�ؼ�����Layout�˵���ѡ��Tab Order�˵�����߰�
��Crtl+D���������öԻ��ı�ǩ˳��
40�������λͼ��ʾ��ѹ��ť
Windows 95��ť�м����µĴ������������BS_BITMAP��BS_ICON��Ҫ���
��λͼ��ť��������ť�͵���CButton : : SetBitmap��CButton : : SetIconʱ
Ҫָ��BS_BITMAP��BS_ICON���
���ȣ����ð�ť��ͼ�����ԡ�
Ȼ���Ի���ʼ��ʱ����CButton: : SetIcon��ע�⣺������ͼ�����λ
ͼ��ʹ��λͼʱҪС�ģ���Ϊ��֪���������е���ɫ��������ÿ���˶�ʹ��dz��
ɫ��
BOOL CSampleDlg : : OnInitDialog ( )
{
CDialog : : OnInitDialog ( ) ;
//set the images for the push buttons .
m_wndButton1.SetIcon (AfxGetApp ( ) ��> LoadIcon (IDI _ IPTION1) )
m_wndButton2.SetIcon (AfxGetApp ( ) ��> LoadIcon (IDI _ IPTION2) )
m_wndButton3.SetIcon (AfxGetApp ( ) ��> LoadIcon (IDI _ IPTION3) )
return TRUE ;
}
--
�� ��Դ:��BBS ˮľ�廪վ bbs.net.tsinghua.edu.cn��[FROM: sapphire.ncic.a]
[������ҳ] [����������] [ȫ��������]
--
m;37m�� ��Դ:���Ͻ�ɺ� bbs.njupt.edu.cn��[FROM: pc05.info.njupt]m
--
[m[1;33m�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: a507yjh.nju.edu][m
Technical Details
Message-ID:
<3OAiOe$tDB@bbs.nju.edu.cn>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB X-Google-Thread: fc86e,41f38cb48d4de63f,start X-Google-Attributes: gidfc86e,public From: mendy.bbs@bbs.nju.edu.cn (�ϵ�) Subject: vc���ָ��68ƪ(6) Date: 1998/04/19 Message-ID: <3OAiOe$tDB@bbs.nju.edu.cn> X-Deja-AN: 345948184 X-Filename: Programming/M.893022376.A Organization: nju_bbs Newsgroups: cn.bbs.comp.program