/*---------------------------------------
POPPAD.C -- Popup Editor
(c) Charles Petzold, 1998
---------------------------------------*/
#include <windows.h>
#include <commdlg.h>
#include "resource.h"
#define EDITID 1
#define UNTITLED TEXT ("(untitled)")
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ;
// Functions in POPFILE.C
void PopFileInitialize (HWND) ;
BOOL PopFileOpenDlg (HWND, PTSTR, PTSTR) ;
BOOL PopFileSaveDlg (HWND, PTSTR, PTSTR) ;
BOOL PopFileRead (HWND, PTSTR) ;
BOOL PopFileWrite (HWND, PTSTR) ;
// Functions in POPFIND.C
HWND PopFindFindDlg (HWND) ;
HWND PopFindReplaceDlg (HWND) ;
BOOL PopFindFindText (HWND, int *, LPFINDREPLACE) ;
BOOL PopFindReplaceText (HWND, int *, LPFINDREPLACE) ;
BOOL PopFindNextText (HWND, int *) ;
BOOL PopFindValidFind (void) ;
// Functions in POPFONT.C
void PopFontInitialize (HWND) ;
BOOL PopFontChooseFont (HWND) ;
void PopFontSetFont (HWND) ;
void PopFontDeinitialize (void) ;
// Functions in POPPRNT.C
BOOL PopPrntPrintFile (HINSTANCE, HWND, HWND, PTSTR) ;
// Global variables
static HWND hDlgModeless ;
static TCHAR szAppName[] = TEXT ("PopPad") ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
MSG msg ;
HWND hwnd ;
HACCEL hAccel ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, szAppName) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = szAppName ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, NULL,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, szCmdLine) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
hAccel = LoadAccelerators (hInstance, szAppName) ;
while (GetMessage (&msg, NULL, 0, 0))
{
if (hDlgModeless == NULL || !IsDialogMessage (hDlgModeless, &msg))
{
if (!TranslateAccelerator (hwnd, hAccel, &msg))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
}
return msg.wParam ;
}
void DoCaption (HWND hwnd, TCHAR * szTitleName)
{
TCHAR szCaption[64 + MAX_PATH] ;
wsprintf (szCaption, TEXT ("%s - %s"), szAppName,
szTitleName[0] ? szTitleName : UNTITLED) ;
SetWindowText (hwnd, szCaption) ;
}
void OkMessage (HWND hwnd, TCHAR * szMessage, TCHAR * szTitleName)
{
TCHAR szBuffer[64 + MAX_PATH] ;
wsprintf (szBuffer, szMessage, szTitleName[0] ? szTitleName : UNTITLED) ;
MessageBox (hwnd, szBuffer, szAppName, MB_OK | MB_ICONEXCLAMATION) ;
}
short AskAboutSave (HWND hwnd, TCHAR * szTitleName)
{
TCHAR szBuffer[64 + MAX_PATH] ;
int iReturn ;
wsprintf (szBuffer, TEXT ("Save current changes in %s?"),
szTitleName[0] ? szTitleName : UNTITLED) ;
iReturn = MessageBox (hwnd, szBuffer, szAppName,
MB_YESNOCANCEL | MB_ICONQUESTION) ;
if (iReturn == IDYES)
if (!SendMessage (hwnd, WM_COMMAND, IDM_FILE_SAVE, 0))
iReturn = IDCANCEL ;
return iReturn ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static BOOL bNeedSave = FALSE ;
static HINSTANCE hInst ;
static HWND hwndEdit ;
static int iOffset ;
static TCHAR szFileName[MAX_PATH], szTitleName[MAX_PATH] ;
static UINT messageFindReplace ;
int iSelBeg, iSelEnd, iEnable ;
LPFINDREPLACE pfr ;
switch (message)
{
case WM_CREATE:
hInst = ((LPCREATESTRUCT) lParam) -> hInstance ;
// Create the edit control child window
hwndEdit = CreateWindow (TEXT ("edit"), NULL,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
WS_BORDER | ES_LEFT | ES_MULTILINE |
ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
0, 0, 0, 0,
hwnd, (HMENU) EDITID, hInst, NULL) ;
SendMessage (hwndEdit, EM_LIMITTEXT, 32000, 0L) ;
// Initialize common dialog box stuff
PopFileInitialize (hwnd) ;
PopFontInitialize (hwndEdit) ;
messageFindReplace = RegisterWindowMessage (FINDMSGSTRING) ;
DoCaption (hwnd, szTitleName) ;
return 0 ;
case WM_SETFOCUS:
SetFocus (hwndEdit) ;
return 0 ;
case WM_SIZE:
MoveWindow (hwndEdit, 0, 0, LOWORD (lParam), HIWORD (lParam), TRUE) ;
return 0 ;
case WM_INITMENUPOPUP:
switch (lParam)
{
case 1: // Edit menu
// Enable Undo if edit control can do it
EnableMenuItem ((HMENU) wParam, IDM_EDIT_UNDO,
SendMessage (hwndEdit, EM_CANUNDO, 0, 0L) ?
MF_ENABLED : MF_GRAYED) ;
// Enable Paste if text is in the clipboard
EnableMenuItem ((HMENU) wParam, IDM_EDIT_PASTE,
IsClipboardFormatAvailable (CF_TEXT) ?
MF_ENABLED : MF_GRAYED) ;
// Enable Cut, Copy, and Del if text is selected
SendMessage (hwndEdit, EM_GETSEL, (WPARAM) &iSelBeg,
(LPARAM) &iSelEnd) ;
iEnable = iSelBeg != iSelEnd ? MF_ENABLED : MF_GRAYED ;
EnableMenuItem ((HMENU) wParam, IDM_EDIT_CUT, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_EDIT_COPY, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_EDIT_CLEAR, iEnable) ;
break ;
case 2: // Search menu
// Enable Find, Next, and Replace if modeless
// dialogs are not already active
iEnable = hDlgModeless == NULL ?
MF_ENABLED : MF_GRAYED ;
EnableMenuItem ((HMENU) wParam, IDM_SEARCH_FIND, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_SEARCH_NEXT, iEnable) ;
EnableMenuItem ((HMENU) wParam, IDM_SEARCH_REPLACE, iEnable) ;
break ;
}
return 0 ;
case WM_COMMAND:
// Messages from edit control
if (lParam && LOWORD (wParam) == EDITID)
{
switch (HIWORD (wParam))
{
case EN_UPDATE :
bNee
没有合适的资源?快使用搜索试试~ 我知道了~
Windows程序设计的记事本源码
共14个文件
c:5个
exe:2个
dsp:1个
5星 · 超过95%的资源 需积分: 9 40 下载量 82 浏览量
2008-10-15
15:23:04
上传
评论
收藏 65KB RAR 举报
温馨提示
Windows程序设计的记事本源码,有需要的就下吧~~~嘿嘿
资源推荐
资源详情
资源评论
收起资源包目录
PopPad3.rar (14个子文件)
PopPad3
PopPad3.dep 121B
PopFile.c 6KB
PopPad3.dsp 4KB
PopPrnt0.c 367B
POPPAD.ICO 1KB
PopFont.c 2KB
PopPad3.mak 5KB
Debug
PopPad3.exe 160KB
Release
PopPad3.exe 32KB
PopPad.c 15KB
RESOURCE.H 1KB
PopFind.c 3KB
POPPAD.RC 6KB
PopPad3.dsw 537B
共 14 条
- 1
资源评论
- xuhaowangji2011-12-14下来看了一下,看到不懂代码,有点乱,但是运行出来了,谢谢
- wwx22014-04-21还好吧,有点乱 没用到
- 345D2015-06-28看不太懂,。
- 暖晴2013-05-08很实用,但是我是新手,不会搭建整个工程
bysdy
- 粉丝: 30
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功