diff --git a/notepad_clone.c b/ClasicNotepad.c similarity index 95% rename from notepad_clone.c rename to ClasicNotepad.c index 8544479..2196cdf 100644 --- a/notepad_clone.c +++ b/ClasicNotepad.c @@ -11,6 +11,8 @@ int swprintf_s(wchar_t *buffer, size_t sizeOfBuffer, const wchar_t *format, ...); #endif +#define IDI_APP 101 + #define IDM_FILE_NEW 1001 #define IDM_FILE_OPEN 1002 #define IDM_FILE_SAVE 1003 @@ -74,7 +76,7 @@ static void UpdateTitle(HWND hwnd) } WCHAR title[512]; - swprintf_s(title, ARRAYSIZE(title), L"%s - Notepad Clone", name); + swprintf_s(title, ARRAYSIZE(title), L"%s - ClasicNotepad", name); SetWindowTextW(hwnd, title); } @@ -156,7 +158,7 @@ static HMENU BuildMenu(void) AppendMenuW(hFormat, MF_STRING, IDM_FORMAT_FONT, L"&Font..."); HMENU hHelp = CreatePopupMenu(); - AppendMenuW(hHelp, MF_STRING, IDM_HELP_ABOUT, L"&About Notepad Clone"); + AppendMenuW(hHelp, MF_STRING, IDM_HELP_ABOUT, L"&About ClasicNotepad"); AppendMenuW(hMenu, MF_POPUP, (UINT_PTR)hFile, L"&File"); AppendMenuW(hMenu, MF_POPUP, (UINT_PTR)hEdit, L"&Edit"); @@ -426,7 +428,7 @@ static void ChooseFontAndApply(HWND hwnd) static void ShowAbout(HWND hwnd) { - MessageBoxW(hwnd, L"Notepad Clone\nBuilt with Win32 API in C.", L"About", MB_OK | MB_ICONINFORMATION); + MessageBoxW(hwnd, L"ClasicNotepad\nBuilt with Win32 API in C.", L"About", MB_OK | MB_ICONINFORMATION); } static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -536,11 +538,22 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd wc.cbSize = sizeof(wc); wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + HICON hIconLarge = LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDI_APP)); + HICON hIconSmall = LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDI_APP)); + if (!hIconLarge) + { + hIconLarge = LoadIcon(NULL, IDI_APPLICATION); + } + if (!hIconSmall) + { + hIconSmall = LoadIcon(NULL, IDI_APPLICATION); + } + + wc.hIcon = hIconLarge; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wc.lpszClassName = L"NotepadCloneClass"; - wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + wc.lpszClassName = L"ClasicNotepadClass"; + wc.hIconSm = hIconSmall; if (!RegisterClassExW(&wc)) { @@ -548,7 +561,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd return -1; } - HWND hwnd = CreateWindowExW(0, wc.lpszClassName, L"Notepad Clone", WS_OVERLAPPEDWINDOW, + HWND hwnd = CreateWindowExW(0, wc.lpszClassName, L"ClasicNotepad", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); if (!hwnd) diff --git a/Makefile b/Makefile index 564b110..95cf6b3 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,18 @@ CC = gcc -TARGET = notepad_clone.exe -SRC = notepad_clone.c +WINDRES = windres +TARGET = ClasicNotepad.exe +SRC = ClasicNotepad.c +RES = ClasicNotepad.res CFLAGS = -Wall -Wextra -std=c11 -mwindows LDLIBS = -luser32 -lgdi32 -lcomdlg32 -$(TARGET): $(SRC) - $(CC) $(CFLAGS) -o $@ $< $(LDLIBS) +$(TARGET): $(SRC) $(RES) + $(CC) $(CFLAGS) -o $@ $(SRC) $(RES) $(LDLIBS) + +$(RES): ClasicNotepad.rc app.ico + $(WINDRES) -O coff ClasicNotepad.rc $(RES) .PHONY: clean clean: - del /f /q $(TARGET) 2>NUL || true + del /f /q $(TARGET) $(RES) 2>NUL || true diff --git a/app.ico b/app.ico new file mode 100644 index 0000000..79ba57b Binary files /dev/null and b/app.ico differ