mirror of
https://github.com/brain-hackers/brain-tools.git
synced 2025-10-15 12:48:42 +09:00
Initial commit.
This commit is contained in:
256
edcloser/edcloser.cpp
Normal file
256
edcloser/edcloser.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef UNICODE
|
||||
namespace std { typedef wstring tstring; }
|
||||
#else
|
||||
namespace std { typedef string tstring; }
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum {
|
||||
IDM_POPUP_CLOSE_ED = 101,
|
||||
IDM_POPUP_RUN = 102,
|
||||
IDM_POPUP_EXIT = 111,
|
||||
IDM_POPUP_CANCEL = 121,
|
||||
AREA_MARGIN = 1,
|
||||
AREA_WIDTH = 24,
|
||||
AREA_HEIGHT = 24,
|
||||
WINDOW_WIDTH = AREA_WIDTH + AREA_MARGIN * 2,
|
||||
WINDOW_HEIGHT = AREA_HEIGHT + AREA_MARGIN * 2
|
||||
};
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
|
||||
static LRESULT CALLBACK editAreaProc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
static BOOL WINAPI findStringDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
static void onCreate(HWND hWnd);
|
||||
static void onDestroy(HWND hWnd);
|
||||
static void onClose(HWND hWnd);
|
||||
static void onLButtonUp(HWND hWnd, int x, int y);
|
||||
static void onActivate(HWND hWnd, int active);
|
||||
static void onEraseBkgnd(HWND hWnd, HDC hDC);
|
||||
static void onCloseEd(HWND hWnd);
|
||||
static void onRun(HWND hWnd);
|
||||
static void changeWindowLayout(HWND hWnd);
|
||||
|
||||
HINSTANCE g_hInstance = NULL;
|
||||
HFONT g_hMainFont = NULL;
|
||||
|
||||
struct EdCloserData {
|
||||
HBITMAP hBitmap;
|
||||
HMENU hPopupMenu;
|
||||
};
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
|
||||
switch (msg) {
|
||||
case WM_CREATE:
|
||||
onCreate(hWnd);
|
||||
return 0;
|
||||
case WM_DESTROY:
|
||||
onDestroy(hWnd);
|
||||
return 0;
|
||||
case WM_CLOSE:
|
||||
onClose(hWnd);
|
||||
return 0;
|
||||
case WM_LBUTTONUP:
|
||||
onLButtonUp(hWnd, LOWORD(lParam), HIWORD(lParam));
|
||||
return 0;
|
||||
case WM_COMMAND:
|
||||
{
|
||||
int id = LOWORD(wParam);
|
||||
int event = HIWORD(wParam);
|
||||
|
||||
switch (id) {
|
||||
case IDM_POPUP_CLOSE_ED:
|
||||
onCloseEd(hWnd);
|
||||
break;
|
||||
case IDM_POPUP_RUN:
|
||||
onRun(hWnd);
|
||||
break;
|
||||
case IDM_POPUP_EXIT:
|
||||
SendMessage(hWnd, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
case IDM_POPUP_CANCEL:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_ACTIVATE:
|
||||
onActivate(hWnd, wParam & 0xFFFF);
|
||||
return 0;
|
||||
case WM_ERASEBKGND:
|
||||
onEraseBkgnd(hWnd, (HDC)wParam);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
static void onCreate(HWND hWnd) {
|
||||
EdCloserData *data = new EdCloserData();
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (long)data);
|
||||
|
||||
data->hBitmap = (HBITMAP)LoadImage(g_hInstance, _T("MAIN"), IMAGE_BITMAP,
|
||||
0, 0, 0);
|
||||
|
||||
HMENU hMenu = LoadMenu(g_hInstance, _T("MENU"));
|
||||
data->hPopupMenu = GetSubMenu(hMenu, 0);
|
||||
|
||||
changeWindowLayout(hWnd);
|
||||
}
|
||||
|
||||
static void onDestroy(HWND hWnd) {
|
||||
EdCloserData *data = (EdCloserData *)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
PostQuitMessage(0);
|
||||
|
||||
delete data;
|
||||
}
|
||||
|
||||
static void onClose(HWND hWnd) {
|
||||
if (MessageBox(hWnd, _T("Do you really want to exit?"), _T("Confirm"),
|
||||
MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2 | MB_SETFOREGROUND) ==
|
||||
IDNO) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
DestroyWindow(hWnd);
|
||||
}
|
||||
|
||||
static void onLButtonUp(HWND hWnd, int x, int y) {
|
||||
EdCloserData *data = (EdCloserData *)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
MENUITEMINFO item = {0};
|
||||
item.cbSize = sizeof(MENUITEMINFO);
|
||||
item.fMask = MIIM_TYPE;
|
||||
item.fType = MFT_STRING;
|
||||
|
||||
HWND hEdWindow = FindWindow(_T("SHARP SIM"), NULL);
|
||||
if (hEdWindow == NULL)
|
||||
item.dwTypeData = _T("Open Dictionary App");
|
||||
else
|
||||
item.dwTypeData = _T("Close Dictionary App");
|
||||
|
||||
SetMenuItemInfo(data->hPopupMenu, IDM_POPUP_CLOSE_ED, false, &item);
|
||||
|
||||
POINT pt = {x, y};
|
||||
ClientToScreen(hWnd, &pt);
|
||||
|
||||
TrackPopupMenu(data->hPopupMenu, TPM_LEFTALIGN | TPM_BOTTOMALIGN,
|
||||
pt.x, pt.y, 0, hWnd, NULL);
|
||||
}
|
||||
|
||||
static void onActivate(HWND hWnd, int active) {
|
||||
ShowWindow(hWnd, SW_HIDE);
|
||||
ShowWindow(hWnd, SW_SHOWNA);
|
||||
}
|
||||
|
||||
static void onEraseBkgnd(HWND hWnd, HDC hDC) {
|
||||
EdCloserData *data = (EdCloserData *)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
RECT clientRect;
|
||||
GetClientRect(hWnd, &clientRect);
|
||||
|
||||
HPEN hPen = CreatePen(PS_SOLID, 1, RGB(77, 109, 243));
|
||||
HPEN hPrevPen = (HPEN)SelectObject(hDC, hPen);
|
||||
|
||||
MoveToEx(hDC, clientRect.right - 1, 0, NULL);
|
||||
LineTo(hDC, 0, 0);
|
||||
LineTo(hDC, 0, clientRect.bottom - 1);
|
||||
LineTo(hDC, clientRect.right - 1, clientRect.bottom - 1);
|
||||
LineTo(hDC, clientRect.right - 1, 0);
|
||||
|
||||
SelectObject(hDC, hPrevPen);
|
||||
DeleteObject(hPen);
|
||||
|
||||
HDC hOffscrDC = CreateCompatibleDC(hDC);
|
||||
HANDLE hPrevBmp = SelectObject(hOffscrDC, data->hBitmap);
|
||||
|
||||
BitBlt(hDC, AREA_MARGIN, AREA_MARGIN, AREA_WIDTH, AREA_HEIGHT, hOffscrDC,
|
||||
0, 0, SRCCOPY);
|
||||
|
||||
SelectObject(hOffscrDC, hPrevBmp);
|
||||
|
||||
DeleteObject(hOffscrDC);
|
||||
}
|
||||
|
||||
static void onCloseEd(HWND hWnd) {
|
||||
HWND hOpenerWindow = FindWindow(_T("ceOpener"), NULL);
|
||||
if (hOpenerWindow != NULL) {
|
||||
MessageBox(hWnd, _T("ceOpener is running."), _T("Warning"),
|
||||
MB_ICONEXCLAMATION | MB_SETFOREGROUND);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
HWND hEdWindow = FindWindow(_T("SHARP SIM"), NULL);
|
||||
if (hEdWindow == NULL) {
|
||||
CreateProcess(_T("\\Windows\\wceprj.exe"), _T("1"), NULL, NULL,
|
||||
false, 0, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
PostMessage(hEdWindow, WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
static void onRun(HWND hWnd) {
|
||||
HWND hTaskbar = FindWindow(_T("HHTaskBar"), NULL);
|
||||
if (hTaskbar != NULL)
|
||||
EnableWindow(hTaskbar, true);
|
||||
|
||||
keybd_event(VK_LWIN, 0, 0, NULL);
|
||||
keybd_event('R', 0, 0, NULL);
|
||||
keybd_event('R', 0, KEYEVENTF_KEYUP, NULL);
|
||||
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, NULL);
|
||||
}
|
||||
|
||||
static void changeWindowLayout(HWND hWnd) {
|
||||
RECT workAreaRect;
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0);
|
||||
|
||||
MoveWindow(hWnd, 0, workAreaRect.bottom - WINDOW_HEIGHT, WINDOW_WIDTH,
|
||||
WINDOW_HEIGHT, false);
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR lpCmd, int nShow)
|
||||
{
|
||||
const TCHAR *className = _T("EdCloser");
|
||||
|
||||
g_hInstance = hInst;
|
||||
|
||||
WNDCLASS windowClass;
|
||||
memset(&windowClass, 0, sizeof(WNDCLASS));
|
||||
windowClass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
windowClass.lpfnWndProc = WndProc;
|
||||
windowClass.hInstance = hInst;
|
||||
windowClass.hbrBackground = NULL;
|
||||
windowClass.lpszClassName = className;
|
||||
RegisterClass(&windowClass);
|
||||
|
||||
HWND hWnd = CreateWindowEx(
|
||||
WS_EX_TOPMOST,
|
||||
className, _T("EdCloser"),
|
||||
WS_POPUP,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, NULL, hInst, NULL);
|
||||
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
UnregisterClass(className, hInst);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
18
edcloser/edcloser.mk
Normal file
18
edcloser/edcloser.mk
Normal file
@@ -0,0 +1,18 @@
|
||||
TARGET=edcloser.exe
|
||||
CPP=clarm
|
||||
CPPFLAGS=/nologo /W3 /O2 /EHsc /QRarch4T /QRinterwork-return \
|
||||
/D "ARM" /D "_ARM_" /D "ARMV4I" /D UNDER_CE=400 /D _WIN32_WCE=400 \
|
||||
/D "UNICODE" /D "_UNICODE"
|
||||
LDFLAGS=/NOLOGO /SUBSYSTEM:WINDOWSCE
|
||||
LIBS=
|
||||
OBJS=\
|
||||
edcloser.obj
|
||||
RESOURCE=edcloser.res
|
||||
|
||||
all : $(TARGET)
|
||||
|
||||
$(TARGET) : $(OBJS) $(RESOURCE)
|
||||
link $(LDFLAGS) /OUT:$@ $(OBJS) $(RESOURCE) $(LIBS)
|
||||
|
||||
clean :
|
||||
-del $(TARGET) $(OBJS)
|
BIN
edcloser/edcloser.res
Normal file
BIN
edcloser/edcloser.res
Normal file
Binary file not shown.
35
edcloser/edcloser_spawn.cpp
Normal file
35
edcloser/edcloser_spawn.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef UNICODE
|
||||
namespace std { typedef wstring tstring; }
|
||||
#else
|
||||
namespace std { typedef string tstring; }
|
||||
#endif
|
||||
|
||||
tstring getCurrentDirectory() {
|
||||
TCHAR path[MAX_PATH];
|
||||
GetModuleFileName(NULL, path, MAX_PATH);
|
||||
|
||||
TCHAR *p = _tcschr(path, _T('\0'));
|
||||
for ( ; p >= path; p--) {
|
||||
if (*p == _T('\\')) {
|
||||
*p = _T('\0');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR lpCmd, int nShow)
|
||||
{
|
||||
tstring mainProcPath = getCurrentDirectory() + _T("\\edcloser.exe");
|
||||
|
||||
CreateProcess(mainProcPath.c_str(), mainProcPath.c_str(), NULL, NULL,
|
||||
false, 0, NULL, NULL, NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
18
edcloser/edcloser_spawn.mk
Normal file
18
edcloser/edcloser_spawn.mk
Normal file
@@ -0,0 +1,18 @@
|
||||
TARGET=AppMain.exe
|
||||
CPP=clarm
|
||||
CPPFLAGS=/nologo /W3 /O2 /EHsc /QRarch4T /QRinterwork-return \
|
||||
/D "ARM" /D "_ARM_" /D "ARMV4I" /D UNDER_CE=400 /D _WIN32_WCE=400 \
|
||||
/D "UNICODE" /D "_UNICODE"
|
||||
LDFLAGS=/NOLOGO /SUBSYSTEM:WINDOWSCE
|
||||
LIBS=
|
||||
OBJS=\
|
||||
edcloser_spawn.obj
|
||||
RESOURCE=
|
||||
|
||||
all : $(TARGET)
|
||||
|
||||
$(TARGET) : $(OBJS) $(RESOURCE)
|
||||
link $(LDFLAGS) /OUT:$@ $(OBJS) $(RESOURCE) $(LIBS)
|
||||
|
||||
clean :
|
||||
-del $(TARGET) $(OBJS)
|
BIN
edcloser/images/door.png
Normal file
BIN
edcloser/images/door.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
27
edcloser/images/door.svg
Normal file
27
edcloser/images/door.svg
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="300" height="300" id="svg2" sodipodi:version="0.32" inkscape:version="0.47 r22583" version="1.0" sodipodi:docname="door.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs id="defs4">
|
||||
<inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 150 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="300 : 150 : 1" inkscape:persp3d-origin="150 : 100 : 1" id="perspective17"/>
|
||||
</defs>
|
||||
<sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.0866631" inkscape:cx="134.35726" inkscape:cy="170.91772" inkscape:document-units="px" inkscape:current-layer="layer1" width="300px" height="300px" inkscape:window-width="1152" inkscape:window-height="746" inkscape:window-x="-4" inkscape:window-y="-4" showgrid="false" inkscape:window-maximized="0"/>
|
||||
<metadata id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title/>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1">
|
||||
<rect style="opacity: 1; fill: rgb(143, 89, 2); fill-opacity: 1; fill-rule: nonzero; stroke: rgb(0, 0, 0); stroke-width: 0pt; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 1.4; stroke-opacity: 1;" id="rect2162" width="201.3158" height="268.42105" x="47.861843" y="19.243422"/>
|
||||
<rect style="opacity: 1; fill: rgb(204, 204, 204); fill-opacity: 1; fill-rule: nonzero; stroke: rgb(0, 0, 0); stroke-width: 0pt; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 1.4; stroke-opacity: 1;" id="rect3134" width="162.82895" height="234.375" x="67.105263" y="37.006577"/>
|
||||
<path style="fill: rgb(143, 89, 2); fill-rule: evenodd; stroke: rgb(0, 0, 0); stroke-width: 1px; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1;" d="M 68.092105,270.39474 L 183.55263,245.23026 L 183.55263,48.407895 L 66.611845,38.019737 L 66.611842,64.019737 L 68.092105,270.39474 z " id="path3138" sodipodi:nodetypes="cccccc"/>
|
||||
<path style="fill: rgb(206, 92, 0); fill-rule: evenodd; stroke: rgb(0, 0, 0); stroke-width: 0pt; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1; stroke-miterlimit: 4; stroke-dasharray: none;" d="M 230.92105,271.38158 L 184.04605,218.09211 L 183.55263,37.5 L 230.42763,36.019737 L 230.92105,271.38158 z " id="path3141"/>
|
||||
<path style="fill: rgb(244, 215, 215); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(0, 0, 0); stroke-width: 0pt; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1; stroke-miterlimit: 4; stroke-dasharray: none;" d="M 183.05921,47.368421 L 78.453947,37.5 L 185.52632,37.5 L 183.05921,47.368421 z " id="path3143"/>
|
||||
<path sodipodi:nodetypes="cccccc" id="path3164" d="M 80.786621,245.54363 L 171.61188,225.74837 L 171.61188,70.921078 L 79.622198,61.176123 L 79.622195,61.176123 L 80.786621,245.54363 z " style="fill: rgb(193, 125, 17); fill-rule: evenodd; stroke: rgb(0, 0, 0); stroke-width: 0.786635px; stroke-linecap: butt; stroke-linejoin: miter; stroke-opacity: 1;"/>
|
||||
<rect style="opacity: 1; fill: rgb(80, 22, 22); fill-opacity: 1; fill-rule: nonzero; stroke: rgb(0, 0, 0); stroke-width: 0pt; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 1.4; stroke-opacity: 1;" id="rect3166" width="6.6222301" height="18.983727" x="64.456367" y="79.259003"/>
|
||||
<rect y="223.259" x="64.456367" height="18.983727" width="6.6222301" id="rect3168" style="opacity: 1; fill: rgb(80, 22, 22); fill-opacity: 1; fill-rule: nonzero; stroke: rgb(0, 0, 0); stroke-width: 0pt; stroke-miterlimit: 4; stroke-dasharray: none; stroke-dashoffset: 1.4; stroke-opacity: 1;"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.3 KiB |
BIN
edcloser/images/main.bmp
Normal file
BIN
edcloser/images/main.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Reference in New Issue
Block a user