vc下简单的notepad

注意读入数据的文件路径必须正确不然出现乱码:

代码如下

View Code
 1 #include "stdafx.h"
 2 #include <windows.h>
 3 #include <windowsx.h>
 4 #include "resource.h"
 5 #include "MainDlg.h"
 6 
 7 
 8 BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 9 {
10     switch(uMsg)
11     {
12         HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);
13         HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);
14         HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);
15     }
16 
17     return FALSE;
18 }
19 
20 BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
21 {
22     return TRUE;
23 }
24 
25 void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
26 {
27     switch(id)
28     {
29         
30         case IDC_OPEN:
31         {
32             char str[256];
33             FILE *fp;
34             fp = fopen("E:\\test.txt","r");
35             fgets(str,sizeof(str),fp);
36             fclose(fp);
37             SetDlgItemText(hwnd,IDC_EDIT1,TEXT(str));
38         }
39         break;
40         default:
41         break;
42     }
43 }
44 
45 void Main_OnClose(HWND hwnd)
46 {
47     EndDialog(hwnd, 0);
48 }

运行结果:

转载于:https://www.cnblogs.com/liuweilinlin/archive/2012/06/24/2560415.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值