From f48685ca01327ec66e355d72e2ca6df1eb833d77 Mon Sep 17 00:00:00 2001 From: Martin Frederic Date: Fri, 27 May 2022 17:14:53 +0200 Subject: [PATCH] Initial commit --- .gitignore | 7 ++ Nanowiggle.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++++ Nanowiggle.dsp | 131 +++++++++++++++++++++++++++++++++++ Nanowiggle.dsw | 29 ++++++++ Nanowiggle.h | 12 ++++ Nanowiggle.ico | Bin 0 -> 1078 bytes Nanowiggle.rc | 141 +++++++++++++++++++++++++++++++++++++ resource.h | 28 ++++++++ small.ico | Bin 0 -> 318 bytes 9 files changed, 532 insertions(+) create mode 100644 .gitignore create mode 100644 Nanowiggle.c create mode 100644 Nanowiggle.dsp create mode 100644 Nanowiggle.dsw create mode 100644 Nanowiggle.h create mode 100644 Nanowiggle.ico create mode 100644 Nanowiggle.rc create mode 100644 resource.h create mode 100644 small.ico diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bce8e02 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +Debug/ +Release/ + +*.aps +*.ncb +*.opt +*.plg diff --git a/Nanowiggle.c b/Nanowiggle.c new file mode 100644 index 0000000..c791f21 --- /dev/null +++ b/Nanowiggle.c @@ -0,0 +1,184 @@ +#define WIN32_LEAN_AND_MEAN +#include + +#include "resource.h" + +#define WIGGLE_INTERVAL_MS 2000 +#define WIGGLE_OFFSET 5 + +#define MAX_LOADSTRING 100 + +/* Globals */ +HINSTANCE hInst; /* current instance */ +TCHAR szTitle[MAX_LOADSTRING]; /* title bar text */ +TCHAR szWindowClass[MAX_LOADSTRING]; /* title bar text */ + +/* Foward declarations */ +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); +void WiggleTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + MSG msg; + HACCEL hAccelTable; + WNDCLASSEX wcex; + + /* Initialize global strings */ + LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadString(hInstance, IDC_NANOWIGGLE, szWindowClass, MAX_LOADSTRING); + + /* Register Window class */ + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_NANOWIGGLE); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = (LPCSTR)IDC_NANOWIGGLE; + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); + + RegisterClassEx(&wcex); + + /* Initialize application */ + if (!InitInstance (hInstance, nCmdShow)) { + return FALSE; + } + + hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_NANOWIGGLE); + + /* Main Loop */ + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + return msg.wParam; +} + +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + HWND hWnd; + RECT windowRect; + + hInst = hInstance; + + hWnd = CreateWindow( + szWindowClass, + szTitle, + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + 0, + 320, /* width */ + 240, /* height */ + NULL, + NULL, + hInstance, + NULL + ); + + if (!hWnd) { + return FALSE; + } + + /* Create wiggle timer */ + SetTimer(hWnd, 1337, WIGGLE_INTERVAL_MS, (TIMERPROC)WiggleTimerProc); + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + /* Place mouse in window. + On Windows 2000, it sometimes takes a couple of seconds before + this actually happens and the program moves on. Why? */ + GetWindowRect(hWnd, &windowRect); + SetCursorPos(windowRect.left + 35, windowRect.top + 70); + + return TRUE; +} + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + int wmId, wmEvent; + PAINTSTRUCT ps; + HDC hdc; + TCHAR szText[MAX_LOADSTRING]; + LoadString(hInst, IDS_RUNNING, szText, MAX_LOADSTRING); + + switch (message) { + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + + switch (wmId) { + case IDM_ABOUT: + DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); + break; + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_PAINT: { + RECT rt; + + hdc = BeginPaint(hWnd, &ps); + GetClientRect(hWnd, &rt); + DrawText(hdc, szText, strlen(szText), &rt, DT_CENTER); + EndPaint(hWnd, &ps); + break; + } + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + +static int sign = -1; +void WiggleTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + POINT pt; + + sign = sign * (-1); + + if (GetCursorPos(&pt)) { + if (!SetCursorPos( + pt.x + (WIGGLE_OFFSET * sign), + pt.y + (WIGGLE_OFFSET * sign))) { + MessageBox(hWnd, "Could not set cursor position.", "Oh, no!", MB_OK | MB_ICONEXCLAMATION); + }; + } +} + +/* About box */ +LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_INITDIALOG: + return TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + } + break; + } + return FALSE; +} diff --git a/Nanowiggle.dsp b/Nanowiggle.dsp new file mode 100644 index 0000000..e3e9a5f --- /dev/null +++ b/Nanowiggle.dsp @@ -0,0 +1,131 @@ +# Microsoft Developer Studio Project File - Name="Nanowiggle" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=Nanowiggle - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Nanowiggle.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Nanowiggle.mak" CFG="Nanowiggle - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Nanowiggle - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "Nanowiggle - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Nanowiggle - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "Nanowiggle - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Nanowiggle - Win32 Release" +# Name "Nanowiggle - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Nanowiggle.c +# End Source File +# Begin Source File + +SOURCE=.\Nanowiggle.rc +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\Nanowiggle.h +# End Source File +# Begin Source File + +SOURCE=.\resource.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\Nanowiggle.ico +# End Source File +# Begin Source File + +SOURCE=.\small.ico +# End Source File +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/Nanowiggle.dsw b/Nanowiggle.dsw new file mode 100644 index 0000000..1106e6b --- /dev/null +++ b/Nanowiggle.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Nanowiggle"=".\Nanowiggle.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Nanowiggle.h b/Nanowiggle.h new file mode 100644 index 0000000..96a0652 --- /dev/null +++ b/Nanowiggle.h @@ -0,0 +1,12 @@ + +#if !defined(AFX_NANOWIGGLE_H__F82BC221_262B_4829_9596_2EE5DA504EBF__INCLUDED_) +#define AFX_NANOWIGGLE_H__F82BC221_262B_4829_9596_2EE5DA504EBF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + + +#endif // !defined(AFX_NANOWIGGLE_H__F82BC221_262B_4829_9596_2EE5DA504EBF__INCLUDED_) diff --git a/Nanowiggle.ico b/Nanowiggle.ico new file mode 100644 index 0000000000000000000000000000000000000000..386883523bcc032db77b69b047cbc5c15ae3b7fe GIT binary patch literal 1078 zcmeH_K@!3s3`IZHwe$$AoF2oYaWszOk{jR)NR>_(PRDWOZgV)&%Zp6VccBVa2?uQ&sh9LW;!?J w2dwKn!S@jnH5GJS10MR3&V{nkc?%F^XS#jrb=7ItXV>BJ*yg?&H~)SR4}%AClK=n! literal 0 HcmV?d00001 diff --git a/Nanowiggle.rc b/Nanowiggle.rc new file mode 100644 index 0000000..9f49cff --- /dev/null +++ b/Nanowiggle.rc @@ -0,0 +1,141 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_NANOWIGGLE ICON DISCARDABLE "Nanowiggle.ICO" +IDI_SMALL ICON DISCARDABLE "SMALL.ICO" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_NANOWIGGLE MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDM_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", IDM_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_NANOWIGGLE ACCELERATORS MOVEABLE PURE +BEGIN + "?", IDM_ABOUT, ASCII, ALT + "/", IDM_ABOUT, ASCII, ALT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "System" +BEGIN + ICON IDI_NANOWIGGLE,IDC_MYICON,14,9,20,20 + LTEXT "Nanowiggle Version 1.0",IDC_STATIC,49,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2022 Martin Frederic",IDC_STATIC,49,20, + 119,8 + DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""resource.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE "Nanowiggle" + IDC_NANOWIGGLE "NANOWIGGLE" + IDS_RUNNING "Nanowiggle is running." +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..31a2893 --- /dev/null +++ b/resource.h @@ -0,0 +1,28 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Nanowiggle.rc +// +#define IDC_MYICON 2 +#define IDD_NANOWIGGLE_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDS_APP_TITLE 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDS_HELLO 106 +#define IDI_NANOWIGGLE 107 +#define IDI_SMALL 108 +#define IDC_NANOWIGGLE 109 +#define IDS_RUNNING 110 +#define IDR_MAINFRAME 128 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/small.ico b/small.ico new file mode 100644 index 0000000000000000000000000000000000000000..8f94d9aa8285725af1920f17fa4ba90a7dad97fc GIT binary patch literal 318 zcmbu1u@S&92m|H2^tei$GGj6tBe4N_?3C#ONWzj2Y0z^{b=^ZcTR}S)7&>4n7JrdT ujNG@ttiTl!1hqz0y#czdCNotgVrj}ml}kwpjQ>