diff --git a/Scylla/DonateGui.cpp b/Scylla/DonateGui.cpp new file mode 100644 index 0000000..c472200 --- /dev/null +++ b/Scylla/DonateGui.cpp @@ -0,0 +1,50 @@ +#include "DonateGui.h" + +#include "Scylla.h" +#include "Architecture.h" + +const WCHAR DonateGui::TEXT_DONATE[] = L"If you like this tool, please feel free to donate some Bitcoins to support this project.\n\n\nBTC Address:\n\n" TEXT(DONATE_BTC_ADDRESS); + + +BOOL DonateGui::OnInitDialog(CWindow wndFocus, LPARAM lInitParam) +{ + DoDataExchange(); // attach controls + + DonateInfo.SetWindowText(TEXT_DONATE); + + CenterWindow(); + + // Set focus to button + GotoDlgCtrl(GetDlgItem(IDC_BUTTON_COPYBTC)); + return FALSE; +} + +void DonateGui::OnClose() +{ + EndDialog(0); +} + +void DonateGui::OnExit(UINT uNotifyCode, int nID, CWindow wndCtl) +{ + SendMessage(WM_CLOSE); +} + +void DonateGui::CopyBtcAddress(UINT uNotifyCode, int nID, CWindow wndCtl) +{ + if(OpenClipboard()) + { + EmptyClipboard(); + size_t len = strlen(DONATE_BTC_ADDRESS); + HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(CHAR)); + if(hMem) + { + strcpy_s(static_cast(GlobalLock(hMem)), len + 1, DONATE_BTC_ADDRESS); + GlobalUnlock(hMem); + if(!SetClipboardData(CF_TEXT, hMem)) + { + GlobalFree(hMem); + } + } + CloseClipboard(); + } +} \ No newline at end of file diff --git a/Scylla/DonateGui.h b/Scylla/DonateGui.h new file mode 100644 index 0000000..26534ed --- /dev/null +++ b/Scylla/DonateGui.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include "resource.h" + +// WTL +#include // base ATL classes +#include // base WTL classes +#include // ATL GUI classes +#include // WTL enhanced msg map macros +#include // WTL controls +#include // WTL dialog data exchange + +class DonateGui : public CDialogImpl, public CWinDataExchange +{ +public: + enum { IDD = IDD_DLG_DONATE }; + + BEGIN_DDX_MAP(DonateGui) + DDX_CONTROL_HANDLE(IDC_STATIC_DONATEINFO, DonateInfo) + END_DDX_MAP() + + BEGIN_MSG_MAP(DonateGui) + MSG_WM_INITDIALOG(OnInitDialog) + MSG_WM_CLOSE(OnClose) + COMMAND_ID_HANDLER_EX(IDC_BUTTON_COPYBTC, CopyBtcAddress) + + COMMAND_ID_HANDLER_EX(IDOK, OnExit) + COMMAND_ID_HANDLER_EX(IDCANCEL, OnExit) + END_MSG_MAP() + +protected: + + // Controls + + CStatic DonateInfo; + + // Texts + static const WCHAR TEXT_DONATE[]; + +protected: + + // Message handlers + void CopyBtcAddress(UINT uNotifyCode, int nID, CWindow wndCtl); + BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam); + void OnClose(); + void OnExit(UINT uNotifyCode, int nID, CWindow wndCtl); + +}; \ No newline at end of file