Aimp Demo Form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "aimpDemoForm.h" | |
#include "dllmain.h" | |
#include <aimpString.h> | |
namespace AIMP::UI | |
{ | |
DemoForm::DemoForm(IAIMPServiceUI* Service) | |
: _skipMouseEvents{ true } | |
, _service{ Service } | |
, _form{ nullptr } | |
, _images{ nullptr } | |
, _log{ nullptr } | |
, _treeList{ nullptr } | |
{ | |
RECT bounds{}; | |
auto handler = static_cast<Base*>(this); | |
CheckResult(_service->CreateForm(0, 0, String(L"DemoForm"), handler, & _form)); | |
CheckResult(_form->SetValueAsInt32(AIMPUI_FORM_PROPID_CLOSEBYESCAPE, 1)); | |
// Center the Form on screen | |
SystemParametersInfo(SPI_GETWORKAREA, 0, &bounds, 0); | |
CheckResult(_form->SetPlacement(Place(CenterRect(bounds, 1024, 600)))); | |
// Create ImageList for children controls | |
CheckResult(_service->CreateObject(_form, nullptr, IID_IAIMPUIImageList, r_cast(_images))); | |
CheckResult(_images->LoadFromResource(HInstance, L"IMAGES", L"PNG")); | |
// Create children controls | |
CreateControls(_form); | |
} | |
DemoForm::~DemoForm() | |
{ | |
if (_form) | |
{ | |
_form->Release(0); | |
} | |
} | |
int DemoForm::ShowModal() | |
{ | |
return _form->ShowModal(); | |
} | |
void DemoForm::AddPathToTreeList( | |
std::wstring_view Name, | |
std::wstring_view ParentFolder, | |
std::wstring_view Notes, | |
int ImageIndex) | |
{ | |
} | |
void DemoForm::Log(IUnknown* Sender, std::wstring_view S) | |
{ | |
} | |
void DemoForm::CreateControls(IAIMPUIWinControl* Parent) | |
{ | |
CreateBottomBar(Parent); | |
//CreateLog(Parent); | |
CreatePageControl(Parent); | |
} | |
void DemoForm::CreateBottomBar(IAIMPUIWinControl* Parent) | |
{ | |
IAIMPUIButton* button = nullptr; | |
IAIMPUIWinControl* panel = nullptr; | |
// Create the panel for Bar | |
CheckResult(_service->CreateControl(_form, Parent, nullptr, nullptr, IID_IAIMPUIPanel, r_cast(panel))); | |
CheckResult(panel->SetPlacement(Place(ualBottom, { 0, SHRT_MAX, 0, 28 }))); | |
CheckResult(panel->SetValueAsInt32(AIMPUI_PANEL_PROPID_BORDERS, 0)); | |
//auto closeBtn = new NotifyEventAdapter([this](IUnknown*) { _form->Close(); }); | |
//auto event = static_cast<NotifyEventAdapter::Base*>(closeBtn); | |
auto event = nullptr; | |
// Create the Button | |
CheckResult(_service->CreateControl(_form, panel, String(L"B1"), event, IID_IAIMPUIButton, r_cast(button))); | |
CheckResult(button->SetPlacement(Place(ualRight, 0))); | |
CheckResult(button->SetPlacementConstraints(PlaceConst(100, 25))); | |
} | |
void DemoForm::CreateLog(IAIMPUIWinControl* Parent) | |
{ | |
IAIMPUITreeListColumn* column = nullptr; | |
IAIMPUIControl* control = nullptr; | |
IAIMPUIWinControl* panel = nullptr; | |
CheckResult(_service->CreateControl(_form, Parent, nullptr, nullptr, IID_IAIMPUIPanel, r_cast(panel))); | |
CheckResult(panel->SetPlacement(Place(ualLeft, 400, { 6, 6, 0, 0 }))); | |
CheckResult(panel->SetValueAsInt32(AIMPUI_PANEL_PROPID_BORDERS, 0)); | |
auto handler = static_cast<Base*>(this); | |
// The Treelist control will be used for loging all events | |
CheckResult(_service->CreateControl(_form, panel, String(L"Log"), handler, IID_IAIMPUITreeList, r_cast(_log))); | |
CheckResult(_log->SetPlacement(Place(ualClient, 0))); | |
CheckResult(_log->SetValueAsInt32(AIMPUI_TL_PROPID_COLUMN_AUTOWIDTH, 1)); | |
CheckResult(_log->AddColumn(IID_IAIMPUITreeListColumn, r_cast(column))); // Create the Sender column | |
CheckResult(column->SetValueAsInt32(AIMPUI_TL_COLUMN_PROPID_CAN_RESIZE, 0)); | |
CheckResult(_log->AddColumn(IID_IAIMPUITreeListColumn, r_cast(column))); // Create the Action column | |
auto skipMouseEvents = new NotifyEventAdapter([](IUnknown*) {}); | |
auto event = static_cast<NotifyEventAdapter::Base*>(skipMouseEvents); | |
// Create the SkipMouseEvents option | |
CheckResult(_service->CreateControl(_form, panel, String(L"cbSkipMouseEvents"), | |
event, IID_IAIMPUICheckBox, r_cast(control))); | |
CheckResult(control->SetPlacement(Place(ualBottom, 0, { 0, 6, 0, 0 }))); | |
CheckResult(control->SetValueAsInt32(AIMPUI_CHECKBOX_PROPID_STATE, _skipMouseEvents)); | |
// Create the splitter | |
CheckResult(_service->CreateControl(_form, Parent, nullptr, handler , IID_IAIMPUISplitter, r_cast(control))); | |
CheckResult(control->SetPlacement(Place(ualLeft, 3))); | |
CheckResult(control->SetValueAsObject(AIMPUI_SPLITTER_PROPID_CONTROL, panel)); | |
} | |
void DemoForm::CreatePageControl(IAIMPUIWinControl* Parent) | |
{ | |
} | |
void DemoForm::CreateBBCBox(IAIMPUIWinControl* Parent) | |
{ | |
} | |
void DemoForm::CreateEditors(IAIMPUIWinControl* Parent) | |
{ | |
} | |
void DemoForm::CreateGraphics(IAIMPUIWinControl* Parent) | |
{ | |
} | |
void DemoForm::CreateGroups(IAIMPUIWinControl* Parent) | |
{ | |
} | |
void DemoForm::CreateIndicators(IAIMPUIWinControl* Parent) | |
{ | |
} | |
void DemoForm::CreateTreeList(IAIMPUIWinControl* Parent) | |
{ | |
} | |
void DemoForm::HandlerAddCustom(IUnknown* Sender) | |
{ | |
} | |
void DemoForm::HandlerAddFiles(IUnknown* Sender) | |
{ | |
} | |
void DemoForm::HandlerAddFolders(IUnknown* Sender) | |
{ | |
} | |
void DemoForm::HandlerCloseButton(IUnknown* Sender) | |
{ | |
} | |
void DemoForm::HandlerCustomDrawSlider(IUnknown* Sender, HDC DC, const RECT R) | |
{ | |
} | |
void DemoForm::HandlerEditButton(IUnknown* Sender) | |
{ | |
} | |
void DemoForm::HandlerSkipMouseEvents(IUnknown* Sender) | |
{ | |
} | |
HRESULT WINAPI DemoForm::QueryInterface(REFIID riid, LPVOID* ppvObj) | |
{ | |
auto result = Base::QueryInterface(riid, ppvObj); | |
if (SUCCEEDED(result)) | |
{ | |
return result; | |
} | |
if (riid == IID_IAIMPUIChangeEvents) | |
{ | |
*ppvObj = static_cast<IAIMPUIChangeEvents*>(this); | |
AddRef(); | |
return S_OK; | |
} | |
if (riid == IID_IAIMPUIKeyboardEvents) | |
{ | |
*ppvObj = static_cast<IAIMPUIKeyboardEvents*>(this); | |
AddRef(); | |
return S_OK; | |
} | |
/*if (riid == IID_IAIMPUIMouseEvents) | |
{ | |
*ppvObj = static_cast<IAIMPUIMouseEvents*>(this); | |
AddRef(); | |
return S_OK; | |
}*/ | |
if (riid == IID_IAIMPUIMouseWheelEvents) | |
{ | |
*ppvObj = static_cast<IAIMPUIMouseWheelEvents*>(this); | |
AddRef(); | |
return S_OK; | |
} | |
if (riid == IID_IAIMPUIPageControlEvents) | |
{ | |
*ppvObj = static_cast<IAIMPUIPageControlEvents*>(this); | |
AddRef(); | |
return S_OK; | |
} | |
if (riid == IID_IAIMPUIFormEvents) | |
{ | |
*ppvObj = static_cast<IAIMPUIFormEvents*>(this); | |
AddRef(); | |
return S_OK; | |
} | |
return result; | |
} | |
ULONG WINAPI DemoForm::AddRef(void) | |
{ | |
return Base::AddRef(); | |
} | |
ULONG WINAPI DemoForm::Release(void) | |
{ | |
return Base::Release(); | |
} | |
void WINAPI DemoForm::OnChanged(IUnknown* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnEnter(IUnknown* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnExit(IUnknown* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnKeyDown(IUnknown* Sender, WORD* Key, WORD Modifiers) | |
{ | |
} | |
void WINAPI DemoForm::OnKeyPress(IUnknown* Sender, WCHAR* Key) | |
{ | |
} | |
void WINAPI DemoForm::OnKeyUp(IUnknown* Sender, WORD* Key, WORD Modifiers) | |
{ | |
} | |
void WINAPI DemoForm::OnMouseDoubleClick(IUnknown* Sender, TAIMPUIMouseButton Button, int X, int Y, WORD Modifiers) | |
{ | |
} | |
void WINAPI DemoForm::OnMouseDown(IUnknown* Sender, TAIMPUIMouseButton Button, int X, int Y, WORD Modifiers) | |
{ | |
} | |
void WINAPI DemoForm::OnMouseLeave(IUnknown* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnMouseMove(IUnknown* Sender, int X, int Y, WORD Modifiers) | |
{ | |
} | |
void WINAPI DemoForm::OnMouseUp(IUnknown* Sender, TAIMPUIMouseButton Button, int X, int Y, WORD Modifiers) | |
{ | |
} | |
BOOL WINAPI DemoForm::OnMouseWheel(IUnknown* Sender, int WheelDelta, int X, int Y, WORD Modifiers) | |
{ | |
return 0; | |
} | |
void WINAPI DemoForm::OnActivating(IAIMPUIPageControl* Sender, IAIMPUITabSheet* Page, BOOL* Allow) | |
{ | |
} | |
void WINAPI DemoForm::OnActivated(IAIMPUIPageControl* Sender, IAIMPUITabSheet* Page) | |
{ | |
} | |
void WINAPI DemoForm::OnActivated(IAIMPUIForm* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnDeactivated(IAIMPUIForm* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnCreated(IAIMPUIForm* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnDestroyed(IAIMPUIForm* Sender) | |
{ | |
_images = nullptr; | |
_log = nullptr; | |
_treeList = nullptr; | |
_form = nullptr; | |
} | |
void WINAPI DemoForm::OnCloseQuery(IAIMPUIForm* Sender, BOOL* CanClose) | |
{ | |
*CanClose = true; | |
} | |
void WINAPI DemoForm::OnLocalize(IAIMPUIForm* Sender) | |
{ | |
} | |
void WINAPI DemoForm::OnShortCut(IAIMPUIForm* Sender, WORD Key, WORD Modifiers, BOOL* Handled) | |
{ | |
} | |
RECT DemoForm::CenterRect(const RECT& Bounds, int Width, int Height) | |
{ | |
RECT result{}; | |
result.left = (Bounds.left + Bounds.right - Width) / 2; | |
result.top = (Bounds.top + Bounds.bottom - Height) / 2; | |
result.right = result.left + Width; | |
result.bottom = result.top + Height; | |
return result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <apiWrappersGUI.h> | |
namespace AIMP::UI | |
{ | |
class DemoForm final | |
: public UnknownII<IAIMPUIChangeEvents> | |
, public IAIMPUIKeyboardEvents | |
, public IAIMPUIMouseEvents | |
, public IAIMPUIMouseWheelEvents | |
, public IAIMPUIPageControlEvents | |
, public IAIMPUIFormEvents | |
{ | |
using Base = UnknownII<IAIMPUIChangeEvents>; | |
public: | |
DemoForm(IAIMPServiceUI* Service); | |
~DemoForm(); | |
int ShowModal(); | |
private: | |
void AddPathToTreeList( | |
std::wstring_view Name, | |
std::wstring_view ParentFolder, | |
std::wstring_view Notes, | |
int ImageIndex); | |
void Log(IUnknown* Sender, std::wstring_view S); | |
void CreateControls(IAIMPUIWinControl* Parent); | |
void CreateBottomBar(IAIMPUIWinControl* Parent); | |
void CreateLog(IAIMPUIWinControl* Parent); | |
void CreatePageControl(IAIMPUIWinControl* Parent); | |
void CreateBBCBox(IAIMPUIWinControl* Parent); | |
void CreateEditors(IAIMPUIWinControl* Parent); | |
void CreateGraphics(IAIMPUIWinControl* Parent); | |
void CreateGroups(IAIMPUIWinControl* Parent); | |
void CreateIndicators(IAIMPUIWinControl* Parent); | |
void CreateTreeList(IAIMPUIWinControl* Parent); | |
// Custom Handlers | |
void HandlerAddCustom(IUnknown* Sender); | |
void HandlerAddFiles(IUnknown* Sender); | |
void HandlerAddFolders(IUnknown* Sender); | |
void HandlerCloseButton(IUnknown* Sender); | |
void HandlerCustomDrawSlider(IUnknown* Sender, HDC DC, const RECT R); | |
void HandlerEditButton(IUnknown* Sender); | |
void HandlerSkipMouseEvents(IUnknown* Sender); | |
// IUnknown | |
HRESULT WINAPI QueryInterface(REFIID riid, LPVOID* ppvObj) override; | |
ULONG WINAPI AddRef(void) override; | |
ULONG WINAPI Release(void) override; | |
// IAIMPUIChangeEvents | |
void WINAPI OnChanged(IUnknown* Sender) override; | |
// IAIMPUIKeyboardEvents | |
void WINAPI OnEnter(IUnknown* Sender) override; | |
void WINAPI OnExit(IUnknown* Sender) override; | |
void WINAPI OnKeyDown(IUnknown* Sender, WORD* Key, WORD Modifiers) override; | |
void WINAPI OnKeyPress(IUnknown* Sender, WCHAR* Key) override; | |
void WINAPI OnKeyUp(IUnknown* Sender, WORD* Key, WORD Modifiers) override; | |
// IAIMPUIMouseEvents | |
void WINAPI OnMouseDoubleClick(IUnknown* Sender, TAIMPUIMouseButton Button, int X, int Y, WORD Modifiers) override; | |
void WINAPI OnMouseDown(IUnknown* Sender, TAIMPUIMouseButton Button, int X, int Y, WORD Modifiers) override; | |
void WINAPI OnMouseLeave(IUnknown* Sender) override; | |
void WINAPI OnMouseMove(IUnknown* Sender, int X, int Y, WORD Modifiers) override; | |
void WINAPI OnMouseUp(IUnknown* Sender, TAIMPUIMouseButton Button, int X, int Y, WORD Modifiers) override; | |
// IAIMPUIMouseWheelEvents | |
BOOL WINAPI OnMouseWheel(IUnknown* Sender, int WheelDelta, int X, int Y, WORD Modifiers) override; | |
// IAIMPUIPageControlEvents | |
void WINAPI OnActivating(IAIMPUIPageControl* Sender, IAIMPUITabSheet* Page, BOOL* Allow) override; | |
void WINAPI OnActivated(IAIMPUIPageControl* Sender, IAIMPUITabSheet* Page) override; | |
// IAIMPUIFormEvents | |
void WINAPI OnActivated(IAIMPUIForm* Sender) override; | |
void WINAPI OnDeactivated(IAIMPUIForm* Sender) override; | |
void WINAPI OnCreated(IAIMPUIForm* Sender) override; | |
void WINAPI OnDestroyed(IAIMPUIForm* Sender) override; | |
void WINAPI OnCloseQuery(IAIMPUIForm* Sender, BOOL* CanClose) override; | |
void WINAPI OnLocalize(IAIMPUIForm* Sender) override; | |
void WINAPI OnShortCut(IAIMPUIForm* Sender, WORD Key, WORD Modifiers, BOOL* Handled) override; | |
static RECT CenterRect(const RECT& Bounds, int Width, int Height); | |
bool _skipMouseEvents; | |
IAIMPServiceUI* _service; | |
IAIMPUIForm* _form; | |
IAIMPUIImageList* _images; | |
IAIMPUITreeList* _log; | |
IAIMPUITreeList* _treeList; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment