Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by �ϵ�
Sun, 19 Apr 1998 00:00
vc���ָ��68ƪ(5)
Author: �ϵ�
Date: Sun, 19 Apr 1998 00:00
Date: Sun, 19 Apr 1998 00:00
208 lines
9595 bytes
9595 bytes
2m������:m TINA (�ռ�����)
2m�� ��:m RAD
2m�� ��:m VC��̼���68ƪ(5)
2m����վ:m '3m�Ͻ�ɺ�m' (Mon Apr 6 08:35:33 1998) , 5mվ���ż�m
[������ҳ] [����������] [ȫ��������]
������: Zeemon (������), ����: Visual
�� ��: vc���ָ��68ƪ(5)
����վ: BBS ˮľ�廪վ (Thu Oct 23 12:40:34 1997)
26����δ���һ����������״�Ĵ���
����ʹ���µ�SDK����SetWindowRgn���ú���滭�������Ϣ���ڴ��ڵ�һ
��ָ��������ʵ����ʹ���ڳ�Ϊָ���IJ�������״��
ʹ��AppWizard����һ�����ڶԵ�Ӧ�ó���ʹ����Դ�༭�������Ի���Դ��ɾ
�����ڵ�ȱʡ�ؼ��������Լ��߽硣
��Ի�������һ��CRgn��ݳ�Ա���Ժ�Ҫʹ�ø���ݳ�Ա������������
Class CRoundDlg : public CDialog
{
��
private :
Crgn m_rgn : // window region
��
} ;
��OnInitDialog������һ����Բ������SetWindowRgn������������
���ڣ�
BOOL CRoundDlg : : OnInitDialog ( )
{
CDialog : : OnInitDialog ( ) ;
//Get size of dialog .
CRect rcDialog ;
GetClientRect (rcDialog );
// Create region and assign to window .
m_rgn . CreateEllipticRgn (0 , 0 , rcDialog.Width ( ) , rcDialog
.Height ( ) );
SetWindowRgn (GetSafeHwnd ( ) , (HRGN) m_ rgn , TRUE );
return TRUE ;
}
ͨ��������͵���SetWindowRgn���Ѿ�����һ����������״�Ĵ��ڣ��������
�ӳ�������OnPaint����ʹ������״��������һ�������塣
voik CRoundDlg : : OnPaint ( )
{
CPaintDC de (this) ; // device context for painting .
//draw ellipse with out any border
dc. SelecStockObject (NULL_PEN);
//get the RGB colour components of the sphere color
COLORREF color= RGB( 0 , 0 , 255);
BYTE byRed =GetRValue (color);
BYTE byGreen = GetGValue (color);
BYTE byBlue = GetBValue (color);
// get the size of the view window
Crect rect ;
GetClientRect (rect);
// get minimun number of units
int nUnits =min (rect.right , rect.bottom );
//calculate he horiaontal and vertical step size
float fltStepHorz = (float) rect.right /nUnits ;
float fltStepVert = (float) rect.bottom /nUnits ;
int nEllipse = nUnits/3; // calculate how many to draw
int nIndex ; // current ellipse that is being draw
CBrush brush ; // bursh used for ellipse fill color
CBrush *pBrushOld; // previous brush that was selected into dc
//draw ellipse , gradually moving towards upper-right corner
for (nIndex = 0 ; nIndes < + nEllipse ; nIndes ++)
{
//creat solid brush
brush . CreatSolidBrush (RGB ( ( (nIndex *byRed ) /nEllipse ).
( ( nIndex * byGreen ) /nEllipse ), ( (nIndex * byBlue)
/nEllipse ) ) );
//select brush into dc
pBrushOld= dc .SelectObject (&brhsh);
//draw ellipse
dc .Ellipse ( (int) fltStepHorz * 2, (int) fltStepVert * nIndex ,
rect. right -( (int) fltStepHorz * nIndex )+ 1,
rect . bottom -( (int) fltStepVert * (nIndex *2) ) +1) ;
//delete the brush
brush.DelecteObject ( );
}
}
�����WM_NCHITTEST��Ϣ��ʹ�����ڵ��κ�λ��ʱ���ƶ����ڡ�
UINT CRoundDlg : : OnNchitTest (Cpoint point )
{
//Let user move window by clickign anywhere on the window .
UINT nHitTest = CDialog : : OnNcHitTest (point) ;
rerurn (nHitTest = = HTCLIENT)? HTCAPTION: nHitTest ;
}
27������ڴ����л�ȡ��������״̬����ָ��
ȱʡʱ�� ������״̬��������ʱ��������Ϊ���ڵ��Ӵ��ڣ�״̬��
��һ��AFX_IDW_STATUS_BAR��ʶ��������һ��AFX_IDW_TOOLBAR��ʶ������˵
�������ͨ��һ�����CWnd: : GetDescendantWindow��AfxGetMainWnd����ȡ��Щ
�Ӵ��ڵ�ָ�룺
//Get pointer to status bar .
CStatusBar * pStatusBar =
(CStatusBar *) AfxGetMainWnd ( ) ��> GetDescendantWindow
(AFX_IDW_STUTUS_BAR);
//Get pointer to toolbar .
CToolBar * pToolBar =
(CToolBar * ) AfxGetMainWnd ( ) ��> GetDescendantWindow
(AFX_IDW_TOOLBAR);
28�����ʹ�ܺͽ�ֹ�������Ĺ�����ʾ
���������CBRS_TOOLTIPS���λ������������ʾ������ʾ��Ҫʹ�ܻ��߽�ֹ
������ʾ����Ҫ���û������÷��λ������ͨ�����CControlBar : : GetBarStyle
��CControlBar : : SetBarStyle����һ����ɴ˹��ܵij�Ա����
void CMainFrame : : EnableToolTips ( BOOL bDisplayTips )
{
ASSERT_VALID (m_wndToolBar);
DWORD dwStyle = m _wndToolBar.GetBarStyle ( ) ;
if (bDisplayTips)
dwStyle ��=CBRS_TOOLTIPS ;
else
dwStyle & = ~ CBRS_TOOLTIPS ;
m_wndToolBar.SetBarStyle (dwStyle );
}
29��������ù���������
��������һ�����ڣ����Կ����ڵ���CWnd : : SetWindowText�����ñ��⣬
�������£�
int CMainFrame : : OnCreate (LPCREATESTRUCT lpCreateStruct )
{
��
// Set the caption of the toolbar .
m_wndToolBar.SetWindowText (_T "Standdard");
30����δ�����ʹ����ģʽ�Ի���
MFC��ģʽ����ģʽ�Ի���װ��ͬһ�����У�����ʹ����ģʽ�Ի���Ҫ��
���Ի���Ҫ������IJ��衣���ȣ�ʹ����Դ�༭�������Ի���Դ��ʹ��
ClassWizard����һ��CDialog�������ࡣģʽ����ģʽ�Ի�����ֹ�Dz�һ��ģ�
ģʽ�Ի�ͨ�����CDialog : : EndDialog ����ֹ����ģʽ�Ի����ǵ���
CWnd: : DestroyWindow����ֹ�ģ�����CDialog : : OnOK��CDialog : : OnCancel
����EndDialog ,������Ҫ����DestroyWindow��������ģʽ�Ի��ĺ���
void CSampleDialog : : OnOK ( )
{
// Retrieve and validate dialog data .
if (! UpdateData (TRUE) )
{
// the UpdateData rountine will set focus to correct item
TRACEO (" UpdateData failed during dialog termination .\n") ;
return ;
}
//Call DestroyWindow instead of EndDialog .
DestroyWindow ( ) ;
}
void CSampleDialog : : OnCancel ( )
{
//Call DestroyWindow instead of EndDialog .
DestroyWindow ( ) ;
}
��Σ���Ҫ��ȷɾ���ʾ�Ի���C++������ģʽ����˵��������ף���Ҫ��
������غ�ɾ��C++������ģʽ�Ի�����ͬ���ģ�����������ú��������أ�
����û���֪����ʱɾ��C++�������ʱ���������CWnd : : PostNcDestroy��
�������øú���ִ��������������ɾ��thisָ�롣
void CSampleDialog : : PostNcDestroy ( )
{
// Declete the C++ object that represents this dialog .
delete this ;
}
���Ҫ������ģʽ�Ի������Ե���CDialog : : DoModal����һ��ģʽ�Էţ�
Ҫ����һ����ģʽ�Ի���Ҫ����CDialog: : Create�����������˵�� ��Ӧ�ó���
����δ�����ģʽ�Ի��ģ�
void CMainFrame : : OnSampleDialog ( )
{
//Allocate a modeless dialog object .
CSampleDilog * pDialog =new CSampleDialog ;
ASSERT_VALID (pDialog) ;
//Create the modeless dialog .
BOOL bResult = pDialog ��> Creste (IDD_IDALOG) ;
ASSERT (bResult ) ;
}
--
�� ��Դ:��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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads