Thread View: cn.bbs.comp.program
1 messages
1 total messages
Started by �ϵ�
Sun, 19 Apr 1998 00:00
vc���ָ��68ƪ(1)
Author: �ϵ�
Date: Sun, 19 Apr 1998 00:00
Date: Sun, 19 Apr 1998 00:00
163 lines
9070 bytes
9070 bytes
2m������:m TINA (�ռ�����)
2m�� ��:m RAD
2m�� ��:m VC��̼���68ƪ(1)
2m����վ:m '3m�Ͻ�ɺ�m' (Mon Apr 6 08:32:59 1998) , 5mվ���ż�m
������: Zeemon (������), ����: Visual
�� ��: vc���ָ��68ƪ(1)
����վ: BBS ˮľ�廪վ (Thu Oct 23 12:31:48 1997)
������: knofler (Break Heart), ����: Programming
�� ��: vc���ָ��68ƪ(1)
����վ: BBS ˮľ�廪վ (Sat Oct 18 19:09:52 1997)
Ŀ�ģ� Ϊ���Visual C++��ѧ�ߺͳ���Ա�ṩһЩ����Ҳ�����Ѿ��� vc���֣�
���Բ�����Щ����.
˵��:��������� "�ö�ý��ѧ Visual C++" ����,һ������ż�� ������.
���Ѿ�����Щ���ӷŵ� 166.111.72.52/incoming/knofler/vc/vckit.zip.
��Ҫ�� ���ѿ���ȥȡ������� CRC Error,����������ϵ. ��� �Ǵ���������
Post�� ���⣬����ּ�ʱָ��.
���°���: �������ߴ� Post.
������� ��: ������Щ�����뾫�����ڵĶ����ظ������½�.
����:
1. ��λ�ȡӦ�ó���� ʵ����?
Ӧ�ó���� ʵ�������CWinAppIm_hInstance ��,������ô����
AfxGetInstancdHandle��þ��.
Example: HANDLE hInstance=AfxGetInstanceHandle();
2. ���ͨ�������Ӧ�ó��������ڵ� ָ��?
�����ڵ� ָ�뱣����CWinThread::m_pMainWnd��,���� AfxGetMainWndʵ�֡�
AfxGetMainWnd() ->ShowWindow(SW_SHOWMAXMIZED); //ʹ�������.
3.����ڳ����л���������� ͼ��?
���ַ���:
(1) SDK���� SHGetFileInfo ��ʹ�� ExtractIcon���ͼ����Դ�� handle,
(2) SDK���� SHGetFileInfo����й��ļ��� �ܶ���Ϣ,���Сͼ��,����,
���͵�.
Example(1): �ڳ������Ͻ���ʾ NotePadͼ��.
void CSampleView: OnDraw(CDC * pDC)
{
if( :: SHGetFileInfo(_T("c:\\pwin95\\notepad.exe"),0,
&stFileInfo,sizeof(stFileInfo),SHGFI_ICON))
{
pDC ->DrawIcon(10,10,stFileInfo.hIcon);
}
}
Example(2):ͬ����,Use ExtractIcon Function
void CSampleView:: OnDraw(CDC *pDC)
{
HICON hIcon=:: ExtractIcon(AfxGetInstanceHandle(),_T
("NotePad.exe"),0);
if (hIcon &&hIcon!=(HICON)-1)
pDC->DrawIcon(10,10,hIcon);
}
˵��: ���notepad.exe��·���������˵��GetWindowsDirectory ����õ�,
����ǵ��� win95�µĻ��ʣ�Ӧ���÷���ע���ķ��������·����Ҫ����һ
��
�ȽϿ����ij�����Ӧ��ȫ���.
4.��α�̽���Ӧ�ó���?��α�̿���windows��������?
���Ǹ��ܼ����DZ���о���Ҫ����������.
��һ��,�ڷ��� WM_CLOSE��Ϣ,���� CWnd::OnClose��Ա����.������û���
ʾ
�Ƿ��Ĺ�����.
Example: AfxGetMainWindow()->SendMessage(WM_CLOSE);
�����Դ���һ���Զ���ĺ��� Terminate Window
void Terminate Window(LPCSTR pCaption)
{
CWnd *pWnd=Cwnd::FindWindow(NULL,pCaption);
if (pWnd)
pWnd ->SendMessage(WM_CLOSE);
}
˵��: FindWindow�������ᳫ����������Ϊ��������������Զ��ı䣬����
����Ҫ��� Notepad�Dz��������ж����Ȳ�֪��Notepad�ı�����,��ʱ
FindWindow��
����Ϊ���ˣ�����ͨ��ö�� windows�����б�İ취��ʵ�֡� �� ��е������
"Windows 95 API������Աָ��"һ���бȽ���ϸ�Ľ���,����Ͳ��ٶ�˵�֡�
�ڶ���,Use ExitWindowsEx Function�������ϵͳ���������������
windows.
ǰ���Ѿ����˽����֣��Ͳ������ˡ�
5.������������Ӧ�ó���?
�Ҽǵ�������dz���Ƶ�Ⱥܸߵ����⡣
���SDK���� winexec, shellexecute,createprocess����ʹ�á�
WinExec�����������ǰһ��ָ��·������һ��ָ����ʾ��ʽ.��һ������
ֵ��˵һ�£��������� SW_SHOWMAXMIZED��ʽȥ����һ�������ť�� ����
��
����Neterm,calc�ȵȣ��Ͳ��������� ���壬�����Ѿ����ӵ������б����ˡ�
ShellExecute�� WinExex���һ�㣬����ָ������Ŀ¼,����� Example����ֱ��
�� c:\temp\1.txt,���ü����� txt�ļ�������Ӧ�ó���,�ܶలװ������ɺ�
�����һ�����ڣ�����ʾReadme or Faq,ż�¾�����ô������.
ShellExecute(NULL,NULL,_T("1.txt"),NULL,_T("c:\\temp"),SW_SHOWMAXMIZED);
CreateProcess��ӣ�һ����ʮ�������ֶ�������NULL���棬�����
ָ����̵İ�ȫ���ԣ��̳���Ϣ��������ȼ��ȵ�.�������ܼ� Example:
STARTUPINFO stinfo; //�������ڵ���Ϣ
PROCESSINFO procinfo; //��̵���Ϣ
CreateProcess(NULL,_T("notepad.exe"),NULL,NULL.FALSE, NORMAL_PRIORITY_
CLASS,NULL,NULL, &stinfo,&procinfo);
6. ȷ��Ӧ�ó���� ·��
ǰЩ����������ʹ��������.
Use GetModuleFileName ���Ӧ�ó����·����Ȼ��ȥ����ִ���ļ���
Example:
TCHAR exeFullPath[MAX_PATH]; // MAX_PATH��API�ж����˰ɣ�������
128
GetModuleFileName(NULL,exeFullPath,MAX_PATH)
7. ��ø���Ŀ¼��Ϣ
WindowsĿ¼: Use "GetWindowsDirectory��
Windows�µ�systemĿ¼: Use "GetSystemDirectory"
tempĿ¼: Use "GetTempPath "
��ǰĿ¼: Use "GetCurrentDirectory"
��ע��ǰ��������ĵ�һ������Ϊ Ŀ¼�������һ��Ϊ������; ��������
��.
8. ����Զ�����Ϣ
Ҳ�����ʹ�ģ���ʵ���ѡ�
(1) �ֹ�������Ϣ��������ôд #define WM_MY_MESSAGE(WM_USER+100),
MS �Ƽ��������� WM_USER+100;
(2)д��Ϣ���?��,�� WPARAM,LPARAM����LRESULT.
LRESULT CMainFrame::OnMyMessage(WPARAM wparam,LPARAM lParam)
{
//������Ĵ��?��
}
(3) ����� AFX_MSG������������Ҳ���dz�˵��"��ӳ��"
��ƪ����д����.
����...
�е���㯣��е�ʧ��
�������������?
--
�� ��Դ:��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