Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions PowerEditor/src/ScintillaComponent/UserDefineDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ intptr_t CALLBACK FolderStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, LP
return SharedParametersDialog::run_dlgProc(Message, wParam, lParam);
}

case WM_DPICHANGED_AFTERPARENT:
{
_pageLink.destroy();
return TRUE;
}

case WM_COMMAND:
{
switch (wParam)
Expand Down Expand Up @@ -200,11 +194,7 @@ intptr_t CALLBACK FolderStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, LP
return SharedParametersDialog::run_dlgProc(Message, wParam, lParam);
}
}
case WM_DESTROY:
{
_pageLink.destroy();
return TRUE;
}

default :
return SharedParametersDialog::run_dlgProc(Message, wParam, lParam);
}
Expand Down
1 change: 0 additions & 1 deletion PowerEditor/src/WinControls/AboutDlg/AboutDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public :

void destroy() override {
//_emailLink.destroy();
_pageLink.destroy();
if (_hIcon != nullptr)
{
::DestroyIcon(_hIcon);
Expand Down
147 changes: 88 additions & 59 deletions PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@


#include "URLCtrl.h"

#include <commctrl.h>

#include "Common.h"
#include "NppConstants.h"
#include "NppDarkMode.h"
#include "Parameters.h"
#include "dpiManagerV2.h"


void URLCtrl::create(HWND itemHandle, const wchar_t * link, COLORREF linkColor)
Expand All @@ -36,10 +41,7 @@ void URLCtrl::create(HWND itemHandle, const wchar_t * link, COLORREF linkColor)
_visitedColor = RGB(128,0,128);

// subclass the static control
_oldproc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(itemHandle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(URLCtrlProc)));

// associate the URL structure with the static control
::SetWindowLongPtr(itemHandle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
::SetWindowSubclass(itemHandle, URLCtrlProc, static_cast<UINT_PTR>(SubclassID::first), reinterpret_cast<DWORD_PTR>(this));

// save hwnd
_hSelf = itemHandle;
Expand All @@ -58,10 +60,7 @@ void URLCtrl::create(HWND itemHandle, int cmd, HWND msgDest)
_linkColor = RGB(0,0,255);

// subclass the static control
_oldproc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(itemHandle, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(URLCtrlProc)));

// associate the URL structure with the static control
::SetWindowLongPtr(itemHandle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
::SetWindowSubclass(itemHandle, URLCtrlProc, static_cast<UINT_PTR>(SubclassID::first), reinterpret_cast<DWORD_PTR>(this));

// save hwnd
_hSelf = itemHandle;
Expand Down Expand Up @@ -115,14 +114,24 @@ void URLCtrl::action()
}
}

LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK URLCtrl::URLCtrlProc(
HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam,
UINT_PTR uIdSubclass,
DWORD_PTR dwRefData
)
{
switch(Message)
{
// Free up the structure we allocated
case WM_NCDESTROY:
//HeapFree(GetProcessHeap(), 0, url);
break;
auto* pRefData = reinterpret_cast<URLCtrl*>(dwRefData);

switch (Message)
{
case WM_NCDESTROY:
{
::RemoveWindowSubclass(hwnd, URLCtrlProc, uIdSubclass);
break;
}

// Paint the static control using our custom
// colours, and with an underline text style
Expand All @@ -142,34 +151,34 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
PAINTSTRUCT ps{};
HDC hdc = ::BeginPaint(hwnd, &ps);

if ((_linkColor == _visitedColor) || (_linkColor == NppDarkMode::getDarkerTextColor()))
if ((pRefData->_linkColor == pRefData->_visitedColor) || (pRefData->_linkColor == NppDarkMode::getDarkerTextColor()))
{
_linkColor = NppDarkMode::isEnabled() ? NppDarkMode::getDarkerTextColor() : _visitedColor;
::SetTextColor(hdc, _linkColor);
pRefData->_linkColor = NppDarkMode::isEnabled() ? NppDarkMode::getDarkerTextColor() : pRefData->_visitedColor;
::SetTextColor(hdc, pRefData->_linkColor);
}
else if (NppDarkMode::isEnabled())
{
::SetTextColor(hdc, NppDarkMode::getLinkTextColor());
}
else
{
::SetTextColor(hdc, _linkColor);
::SetTextColor(hdc, pRefData->_linkColor);
}

::SetBkColor(hdc, getCtrlBgColor(GetParent(hwnd))); ///*::GetSysColor(COLOR_3DFACE)*/);

// Create an underline font
if (_hfUnderlined == nullptr)
if (pRefData->_hfUnderlined == nullptr)
{
// Get the default GUI font
LOGFONT lf{ DPIManagerV2::getDefaultGUIFontForDpi(::GetParent(hwnd)) };
lf.lfUnderline = TRUE;

// Create a new font
_hfUnderlined = ::CreateFontIndirect(&lf);
pRefData->_hfUnderlined = ::CreateFontIndirect(&lf);
}

HANDLE hOld = SelectObject(hdc, _hfUnderlined);
auto hOld = static_cast<HFONT>(::SelectObject(hdc, pRefData->_hfUnderlined));

// Draw the text!
wchar_t szWinText[MAX_PATH] = { '\0' };
Expand All @@ -183,54 +192,74 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
return 0;
}

case WM_SETTEXT:
{
LRESULT ret = ::CallWindowProc(_oldproc, hwnd, Message, wParam, lParam);
::InvalidateRect(hwnd, 0, 0);
return ret;
}
// Provide a hand cursor when the mouse moves over us
//case WM_SETCURSOR:
case WM_MOUSEMOVE:
{
::SetCursor(loadHandCursor());
return TRUE;
}

case WM_LBUTTONDOWN:
_clicking = true;
break;
case WM_DPICHANGED_AFTERPARENT:
{
pRefData->destroy();
return 0;
}

case WM_LBUTTONUP:
if (_clicking)
{
_clicking = false;
case WM_SETTEXT:
{
const LRESULT ret = ::DefSubclassProc(hwnd, Message, wParam, lParam);
::InvalidateRect(hwnd, 0, 0);
return ret;
}
// Provide a hand cursor when the mouse moves over us
//case WM_SETCURSOR:
case WM_MOUSEMOVE:
{
::SetCursor(pRefData->loadHandCursor());
return 0;
}

action();
}
case WM_LBUTTONDOWN:
{
pRefData->_clicking = true;
break;
}

break;
case WM_LBUTTONUP:
{
if (pRefData->_clicking)
{
pRefData->_clicking = false;
pRefData->action();
}
break;
}

//Support using space to activate this object
case WM_KEYDOWN:
{
if (wParam == VK_SPACE)
_clicking = true;
pRefData->_clicking = true;

break;
}

case WM_KEYUP:
if (wParam == VK_SPACE && _clicking)
{
if (wParam == VK_SPACE && pRefData->_clicking)
{
_clicking = false;

action();
pRefData->_clicking = false;
pRefData->action();
}
break;
}

// A standard static control returns HTTRANSPARENT here, which
// prevents us from receiving any mouse messages. So, return
// HTCLIENT instead.
case WM_NCHITTEST:
{
return HTCLIENT;
}

// A standard static control returns HTTRANSPARENT here, which
// prevents us from receiving any mouse messages. So, return
// HTCLIENT instead.
case WM_NCHITTEST:
return HTCLIENT;
}
return ::CallWindowProc(_oldproc, hwnd, Message, wParam, lParam);
case WM_DESTROY:
{
pRefData->destroy();
break;
}
}
return ::DefSubclassProc(hwnd, Message, wParam, lParam);
}
10 changes: 3 additions & 7 deletions PowerEditor/src/WinControls/AboutDlg/URLCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#pragma once

#include "Window.h"
#include "Common.h"
#include <string>

class URLCtrl : public Window {
public:
Expand All @@ -36,14 +36,10 @@ protected :
HWND _msgDest = nullptr;
unsigned long _cmdID = 0;

WNDPROC _oldproc = nullptr;
COLORREF _linkColor = RGB(0xFF, 0xFF, 0xFF);
COLORREF _visitedColor = RGB(0xFF, 0xFF, 0xFF);
bool _clicking = false;

static LRESULT CALLBACK URLCtrlProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){
return ((URLCtrl *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)))->runProc(hwnd, Message, wParam, lParam);
}
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK URLCtrlProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
};

4 changes: 0 additions & 4 deletions PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
{
_dpiManager.setDpiWP(wParam);

_goToSettings.destroy();

const int cpDynamicalSize = _dpiManager.scale(25);
move2CtrlRight(IDC_FG_STATIC, _pFgColour->getHSelf(), cpDynamicalSize, cpDynamicalSize);
move2CtrlRight(IDC_BG_STATIC, _pBgColour->getHSelf(), cpDynamicalSize, cpDynamicalSize);
Expand Down Expand Up @@ -1399,8 +1397,6 @@ void WordStyleDlg::doDialog(bool isRTL)

void WordStyleDlg::destroy()
{
_goToSettings.destroy();

if (_pFgColour != nullptr)
{
_pFgColour->destroy();
Expand Down
3 changes: 0 additions & 3 deletions PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ class WordStyleDlg : public StaticDialog
public :
WordStyleDlg() = default;
~WordStyleDlg() override {
_goToSettings.destroy();
_globalOverrideLinkTip.destroy();

if (_globalOverrideTip)
::DestroyWindow(_globalOverrideTip);
}
Expand Down
7 changes: 0 additions & 7 deletions PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,6 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
case WM_DPICHANGED:
{
_dpiManager.setDpiWP(wParam);
_repoLink.destroy();

const size_t szColVer = _dpiManager.scale(100);
const size_t szColName = szColVer * 2;
Expand Down Expand Up @@ -1330,12 +1329,6 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR

return TRUE;
}

case WM_DESTROY:
{
_repoLink.destroy();
return TRUE;
}
}
return FALSE;
}
Loading