61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
#include <windows.h>
|
|
#include <commctrl.h>
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <string_view>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include "files_text_window.h"
|
|
|
|
namespace
|
|
{
|
|
#include "files_dialog_input.inl"
|
|
|
|
bool cancelled(HWND dialog)
|
|
{
|
|
MSG message{};
|
|
return PeekMessageW(&message,dialog,WM_COMMAND,WM_COMMAND,PM_REMOVE) &&
|
|
LOWORD(message.wParam)==IDCANCEL;
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
const auto instance=GetModuleHandleW(nullptr);
|
|
const auto owner=CreateWindowW(L"STATIC",L"Files",WS_OVERLAPPEDWINDOW,
|
|
0,0,300,200,nullptr,nullptr,instance,nullptr);
|
|
const auto dialog=CreateWindowW(L"STATIC",L"Search",WS_POPUP,
|
|
0,0,200,100,owner,nullptr,instance,nullptr);
|
|
const auto external=CreateWindowW(L"STATIC",L"Other",WS_OVERLAPPEDWINDOW,
|
|
0,0,300,200,nullptr,nullptr,instance,nullptr);
|
|
if(!owner || !dialog || !external)
|
|
{
|
|
std::cerr << "Could not create modal test windows.\n";
|
|
return 1;
|
|
}
|
|
|
|
POINT client{10,10},frame{10,-1};
|
|
ClientToScreen(owner,&client);
|
|
ClientToScreen(owner,&frame);
|
|
if(handleFilesDialogClick(dialog,external,client) ||
|
|
handleFilesDialogClick(dialog,GetDesktopWindow(),client) ||
|
|
handleFilesDialogClick(dialog,nullptr,client) || cancelled(dialog))
|
|
{
|
|
std::cerr << "A click outside Files cancelled the dialog.\n";
|
|
return 1;
|
|
}
|
|
if(handleFilesDialogClick(dialog,owner,frame) || cancelled(dialog))
|
|
{
|
|
std::cerr << "A click on the owner's frame cancelled the dialog.\n";
|
|
return 1;
|
|
}
|
|
if(!handleFilesDialogClick(dialog,owner,client) || !cancelled(dialog))
|
|
{
|
|
std::cerr << "A click in the Files client area did not cancel the dialog.\n";
|
|
return 1;
|
|
}
|
|
DestroyWindow(owner);
|
|
DestroyWindow(external);
|
|
std::cout << "Verified Files modal handling of external, frame, and client-area clicks.\n";
|
|
}
|