Skip to content

Commit

Permalink
Created empty shell Windowed application refresh_file_explorer.exe.
Browse files Browse the repository at this point in the history
  • Loading branch information
end2endzone committed Jan 7, 2024
1 parent fc092bf commit f8f632a
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ add_subdirectory(shellextension)
add_subdirectory(api)
add_subdirectory(logger/glog)
add_subdirectory(windows)
add_subdirectory(refresh_file_explorer)

if(SHELLANYTHING_BUILD_PLUGINS)
add_subdirectory(plugins/sa_plugin_process)
Expand Down
37 changes: 37 additions & 0 deletions src/refresh_file_explorer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
find_package(rapidassist REQUIRED)

add_executable(refresh_file_explorer WIN32
${SHELLANYTHING_EXPORT_HEADER}
${SHELLANYTHING_VERSION_HEADER}
${SHELLANYTHING_CONFIG_HEADER}
main.cpp
)

# Force UNICODE for target
target_compile_definitions(refresh_file_explorer PRIVATE -D_UNICODE -DUNICODE)

# Force CMAKE_DEBUG_POSTFIX for executables
set_target_properties(refresh_file_explorer PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

# Define include directories for the executable.
target_include_directories(refresh_file_explorer
PRIVATE
${GTEST_INCLUDE_DIR}
rapidassist
${CMAKE_SOURCE_DIR}/src/shared
)

# Define linking dependencies.
add_dependencies(refresh_file_explorer sa.shared)
target_link_libraries(refresh_file_explorer
PRIVATE
sa.shared
rapidassist
)

install(TARGETS refresh_file_explorer
EXPORT shellanything-targets
ARCHIVE DESTINATION ${SHELLANYTHING_INSTALL_LIB_DIR}
LIBRARY DESTINATION ${SHELLANYTHING_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${SHELLANYTHING_INSTALL_BIN_DIR}
)
74 changes: 74 additions & 0 deletions src/refresh_file_explorer/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#include <windows.h>

const TCHAR g_szClassName[] = L"myWindowClass";

// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG msg;

//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if (!RegisterClassEx(&wc))
{
MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}

// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
L"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
NULL, NULL, hInstance, NULL);

if (hwnd == NULL)
{
MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);

// Step 3: The Message Loop
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}

0 comments on commit f8f632a

Please sign in to comment.