Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by �ϵ�
Sun, 19 Apr 1998 00:00
vc���ָ��68ƪ(8)
Author: �ϵ�
Date: Sun, 19 Apr 1998 00:00
Date: Sun, 19 Apr 1998 00:00
266 lines
11823 bytes
11823 bytes
2m������:m TINA (�ռ�����)
2m�� ��:m RAD
2m�� ��:m VC��̼���68ƪ(8)
2m����վ:m '3m�Ͻ�ɺ�m' (Mon Apr 6 08:38:20 1998) , 5mվ���ż�m
[������ҳ] [����������] [ȫ��������]
������: Zeemon (������), ����: Visual
�� ��: vc���ָ��68ƪ(8)
����վ: BBS ˮľ�廪վ (Thu Oct 23 12:55:20 1997)
51����δ���һ�������ض����С������
����ָ����������λ�Ĵ�С������ʱָ������ĵ�Ĵ�С���ܻ���һ
Щ���������½�����ĵ�ת��Ϊ����ĸ߶ȣ�
int nHeigth=mulDiv (nPointSize, -dc.GetDeviceCaps (LOGPIXELSY), 72);
������һ��8���Apial���壺
��
CClientDC dc (AqfxGetMainWnd ());
m_font. CreateFont (MulDiv (8, -dc.GetDeviceCaps (LOGPIXELSY),
72),0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,
OUT_STROKE_PRECIS,CLIP_STROKE_PRECIS,DRAFT_QUALITY,
VARIABLE_PITCH | FF-SWISS,_T ("Arial"));
..
52����μ���һ�����Ĵ�С
����CDC:: Det text Extent ��ݵ�ǰѡ����������һ�����ĸ߶ȺͿ�
�ȡ����ʹ�õIJ���ϵͳ��������������壬���ڵ���GetTextExtent֮ǰ����
��ѡ���豸���������Ǻ���Ҫ�ģ��������߶ȺͿ��ʱ������ϵͳ���壬�ɴ�
�ó��Ľ��Ȼ�Dz���ȷ�ġ����������ı���ѹ��ť�ı���ʱ��̬����
ť�Ĵ�С����ť�Ĵ�С�ɰ�ť������ͱ���Ĵ�С����Ӧ��ϢWM_SETTEXTʱ
����OnSetText������Ϣʹ��ON_MESSAE��ָ�����û��Զ�����Ϣ��
LRESULT CMyButton:: OnSettext (WPARAM wParam, LPARAM lParam)
{
//Pass message to window procedure.
LRESULT bResult=CallWindowProc (*GetSuperWndProcAddr (),
m_hWnd, GetCurrentMessage () ->message,wParam,lParam);
//Get title of push button.
CString strTitle;
GetWindowText (strTitle);
//Select current font into device context.
CDC* pDC=GetDc ();
CFont*pFont=GetFont ();
CFont*pOldFont=pDC->SelectObject (pFont);
//Calculate size of title.
CSize size=pDC->GetTextExent (strTitle,strTitle.GetLength ());
//Adjust the button's size based on its title.
//Add a 5-pixel border around the button.
SetWindowPos (NULL, 0, 0, size.cx+10, size.cy+10,
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
//Clean up.
pDC->SelectFont (pOldFont);
ReleaseDC (pDC);
return bResult;
}
53�������ʾ��ת�ı�
ֻҪ�û�ʹ��TrueType����GDI�ʻ�����Ϳ�����ʾ��ת�ı�(��ЩӲ���豸Ҳ
֧����ת��դ���壩��LOGFONT�ṹ�е�ifEscapement��Աָ�����ı��к�x��Ľ�
�ȣ��Ƕȵĵ�λ��ʮ��֮һ�ȶ��Ƕȣ����磬ifEscapementΪ450��ʾ������ת
45�ȡ�Ϊȷ�����е����������ϵͳ��ͬһ������ת��һ��Ҫ����ifEscapement��
Ա��CLIP_LH_ANGLESλ��������Щ������ܷ�����ת������ʹ����14��Arial����
ÿ���15�Ȼ�һ������
void CSampleView:: OnDraw (CDC* pDC)
{
//Determine the size of the window.
CRect rcClient;
GetClientRect (rcClient);
//Create sample string.
CString str (_T ("Wheeee������I am rotating!"));
//Draw transparent, red text.
pDC->SetBkMode (TRANSPARENT);
pDC->SetTextColor (RGB (255,0,0));
CFont font; //font object
LOGFONT stFont; //font definition
//Set font attributes that will not change.
memset (&stFont, 0, sizeof (LOGFONT));
stFont.ifheight=MulDiv (14, -pDC->GetDeviceCaps (LOGPIXELSY), 72);
stFont.ifWeight=FW_NORMAL;
stFont.ifClipPrecision=LCIP_LH_ANGLES;
strcpy (stFont.lfFaceName, "Arial");
//Draw text at 15degree intervals.
for (int nAngle=0; nAngle<3600; nAngle+=150)
{
//Specify new angle.
stFont.lfEscapement=nAngle;
//Create and select font into dc.
font.CreateFontIndirect (&stfont);
CFont* pOldFont=pDC->SelectObject (&font);
//Draw the text.
pDC->SelectObject (pOldFont);
font.DelectObjext ();
}
}
54�������ȷ��ʾ���ǩ�ַ�Ĵ�
����GDI�ı��滭����ʱ��Ҫչ����ǩ�ַ������ͨ�����
CDC:: TabbedTextOut����CDC:: DrawText��ָ��DT_EXPANDTABS��־����
�ɡ�TabbedTextOut��������ָ����ǩλ�����飬����ָ��ÿ20�豸��λչ
��һ����ǩ��
void CSampleView:: OnDraw (CDC* pDC)
{
CTestDoc* pDoc=GetDocument ();
ASSERT_VALID (pDoC);
CString str;
str.Format (_T ("Cathy\tNorman\tOliver"));
int nTabStop=20; //tabs are every 20 pixels
pDC->TabbedtextOut (10, 10, str, 1, &nTabStop, 10);
}
55����̫��ʱ�������ĩβ��ʾһ��ʡ�Ժ�
����CDC:: DrawText��ָ��DT_END_ELLIPSIS��־������Ϳ�����С�Ժ�ȡ
��ĩβ���ַ�ʹ���ʺ���ָ���ı߽���Ρ����Ҫ��ʾ·����Ϣ��ָ��
DT_END_ELLIPSIS��־��ʡ�Ժ�ȡ���м���ַ�
void CSampleView:: OnDraw (CDC* pDC)
{
CTestDoc* pDoc=GetDocument ();
ASSERT_VALID (pDoc);
//Add ellpsis to end of string if it does not fit
pDC->Drawtext (CString ("This is a long string"),
CRect (10, 10, 80, 30), DT_LEFT | DT_END_ELLIPSIS);
//Add ellpsis to middle of string if it does not fit
pDC->DrawText (AfxgetApp () ->m_pszhelpfilePath,
CRect (10, 40, 200, 60), DT_LEFT | DT_PATH_ELLIPSIS);
}
56����ο��ٵظ�ʽ��һ��CString����
����CString:: Format���ú����printf���������ͬ�IJ�������˵����
���ʹ��Format����
//Get size of window.
CRect rcWindow;
GetWindowRect (rcWindow);
//Format message string.
CString strMessage;
strMessage.Format (_T ("Window Size (%d, %d)"),
rcWindow.Width (), rcWindow.Height ());
//Display the message.
MessageBox (strmessage);
57��Ϊʲô��ʹ����EnableMenuItem�˵���˵�����ڽ�ֹ״̬
��Ҫ��CFrameWnd:: m_bAutomenuEnable����ΪFALSE��������ݳ�Ա
ΪTRUE��ȱʡֵ�����������Զ��ؽ�ֹû��ON_UPDATE_COMMAND_UI����
ON_COMMAND�IJ˵��
//Disable MFC from automatically disabling menu items.
m_bAuoMenuEnable=FALSE;
//Now enable the menu item.
CMenu* pMenu=GetMenu ();
ASSERT_VALID (pMenu);
pMenu->EnableMenuItem (ID_MENU_ITEM,MF_BYCOMMAND | MF_ENABLED);
58����θ�ϵͳ�˵����һ���˵���
��ϵͳ�˵����һ���˵�����Ҫ��������������裺
���ȣ�ʹ��Resource Symbols�Ի�����View�˵���ѡ��Resource Symbols������
������ʾ�öԻ�������˵���ID����IDӦ����0x0F��С��0xF000��
��Σ�����CWnd::GetSystemMenu��ȡϵͳ�˵���ָ�벢����
CWnd:: Appendmenu���˵�����ӵ��˵��С������ϵͳ�˵���������µ�
�˵��
int CMainFrame:: OnCreate (LPCREATESTRUCT lpCreateStruct)
{
��
//Make sure system menu item is in the right range.
ASSERT (IDM_MYSYSITEM &0xFFF0)==IDM_MYSYSITEM);
ASSERT (IDM-MYSYSITEM<0xF000);
//Get pointer to system menu.
CMenu* pSysmenu=GetSystemmenu (FALSE);
ASSERT_VALID (pSysMenu);
//Add a separator and our menu item to system menu.
CString StrMenuItem (_T ("New menu item"));
pSysMenu->Appendmenu (MF_SEPARATOR);
pSysMenu->AppendMenu (MF_STRING, IDM_MYSYSITEM, strMenuitem);
��
}
���ڣ�ѡ��ϵͳ�˵���ʱ�û�Ӧ���м�⡣ʹ��ClassWizard����
WM_SYSCOMMAND��Ϣ������û��˵���nID����
void CMainFrame:: OnSysCommand (UINT nID,LPARAM lParam)
{
//Determine if our system menu item was selected.
if ( (nID & 0xFFF0)==IDM_MYSYSITEM)
{
//TODO-process system menu item
}
else
CMDIFrameWnd:: OnSysCommand (nID, lParam);
}
���һ��������õ�UIӦ�ó���Ӧ����ϵͳ�˵������ʱ��״̬����ʾ
һ��������Ϣ�������ͨ������һ����ϵͳ�˵���ID�Ĵ���������ʵ�֡�
59�����ȷ������˵���ռ�ݵIJ˵�����
�����ͨ��ļ����ͳ���ʵ�֡����ȣ��û���Ҫ�������ڵĸ�
�ȺͿͻ�����Σ������ڵĸ߶��м�ȥ�ͻ����߽��Լ�����ĸ߶ȣ�
����Բ˵����ĸ߶ȡ������Ա������һ����������˵���ռ�ݵ�����Ĵ�
��ʵ�֡�
int CMainFrame:: GetMenuRows ()
{
CRect rcFrame,rcClient;
GetWindowRect (rcFrame);
GetClientRect (rcClient);
return (rcFrame.Height () -rcClient.Height ()-
:: GetSystemMetrics (SM_CYCAPTION) -
(:: getSystemMetrics (SM_CYFRAME) *2)) /
:: GetSystemMetrics (SM_CYMENU);
}
60�����û����������ȷ��ϵͳ��ʾԪ�ص���ɫ
����SDK����GetSysColor���Ի�ȡһ���ض���ʾԪ�ص���ɫ������˵�������
��MFC����CMainFrameWnd:: OnNcPaint�е��øú������ô��ڱ�����ɫ��
void CMiniFrameWnd:: OnNcPaint ()
{
��
dc.SetTextColor (:: GetSysColor (m_bActive ?
COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT));
��
}
--
�� ��Դ:��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