Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
112 lines (98 loc) · 3.02 KB

File metadata and controls

112 lines (98 loc) · 3.02 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "stdafx.h"
#include "PromptDialog.h"
#include "resource.h"
#include "Notepad_Plus_msgs.h"
PromptDialog::PromptDialog(HINSTANCE hInst, HWND hNotepad)
: m_hInst(hInst),
m_hNotepad(hNotepad),
m_result(RESULT_CANCEL),
m_hSelf(NULL)
{
}
PromptDialog::~PromptDialog()
{
m_hInst = NULL;
m_hNotepad = NULL;
// m_hSelf is handed down to us and not created by us. Therefore, let's just NULL the variable.
m_hSelf = NULL;
}
PromptDialog::PROMPT_RESULT PromptDialog::showPrompt(const char *prompt, const char *title, const char *initial)
{
m_result = RESULT_CANCEL;
m_prompt = prompt;
m_title = title;
if (initial)
m_initial = initial;
DialogBoxParam(m_hInst, MAKEINTRESOURCE(IDD_PROMPTDIALOG), m_hNotepad, PromptDialog::dlgProc, reinterpret_cast<LPARAM>(this));
return m_result;
}
INT_PTR CALLBACK PromptDialog::dlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
{
::SetWindowLongPtr(hWnd, GWLP_USERDATA, static_cast<LONG_PTR>(lParam));
PromptDialog* dlg = reinterpret_cast<PromptDialog*>(lParam);
return dlg->runDlgProc(hWnd, message, wParam, lParam);
}
default:
{
PromptDialog* dlg = reinterpret_cast<PromptDialog*>(::GetWindowLongPtr(hWnd, GWLP_USERDATA));
if (dlg)
return dlg->runDlgProc(hWnd, message, wParam, lParam);
else
return TRUE;
}
}
}
INT_PTR CALLBACK PromptDialog::runDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM /* lParam */)
{
switch(message)
{
case WM_INITDIALOG:
{
SendMessage(m_hNotepad, NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast<LPARAM>(hWnd));
m_hSelf = hWnd;
::SetWindowTextA(::GetDlgItem(m_hSelf, IDC_PROMPT), m_prompt.c_str());
::SetWindowTextA(m_hSelf, m_title.c_str());
::SetWindowTextA(::GetDlgItem(m_hSelf, IDC_USERTEXT), m_initial.c_str());
::SendMessage(::GetDlgItem(m_hSelf, IDC_USERTEXT), EM_SETSEL, 0, -1);
SetFocus(::GetDlgItem(m_hSelf, IDC_USERTEXT));
RECT rc;
::GetClientRect(m_hNotepad, &rc);
POINT center;
center.x = rc.left + (rc.right - rc.left)/2;
center.y = rc.top + (rc.bottom - rc.top)/2;
::ClientToScreen(m_hNotepad, &center);
RECT promptRC;
::GetWindowRect(m_hSelf, &promptRC);
int x = center.x - (promptRC.right - promptRC.left)/2;
int y = center.y - (promptRC.bottom - promptRC.top)/2;
::SetWindowPos(m_hSelf, HWND_TOP, x, y, promptRC.right - promptRC.left, promptRC.bottom - promptRC.top, 0);
return FALSE;
}
case WM_COMMAND:
{
switch(wParam)
{
case IDOK:
{
char buffer[1000];
::GetWindowTextA(::GetDlgItem(m_hSelf, IDC_USERTEXT), buffer, 1000);
m_value = buffer;
m_result = RESULT_OK;
}
//lint -fallthrough
case IDCANCEL:
::EndDialog(m_hSelf, 0);
SendMessage(m_hNotepad, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast<LPARAM>(hWnd));
return TRUE;
default:
return FALSE;
}
}
default:
return FALSE;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.