Skip to content

Commit 3db04cb

Browse files
committed
Improvements
1 parent fa74b7c commit 3db04cb

File tree

4 files changed

+155
-2
lines changed

4 files changed

+155
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ pause;
7070
* void: Can be used with commands or functions if you want to dismiss the result value.
7171

7272
## Helper commands:
73-
* getscriptpath (result) # Stores the full path of the current executed script in the result var
74-
* getscriptname (result) # Stores the full file name of the current executed script in the result var
73+
* getscriptpath (result var) # Stores the full path of the current executed script in the result var
74+
* getscriptname (result var) # Stores the full file name of the current executed script in the result var
7575
* debug (text content) # Prints a system debug message
7676
* textview (file) # Prints the text contents of the file to the standard output
7777
* random (start) (end) (result var) # Generates a random number within the range and stores it to the result var

defplugins/forms/forms/dnyWinForms.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,16 @@ namespace dnyWinForms {
354354

355355
return false;
356356
}
357+
virtual LONG_PTR SetStyle(LONG_PTR lStyle, bool refresh = false)
358+
{
359+
LONG_PTR result = SetWindowLongPtr(this->GetHandle(), GWL_STYLE, lStyle);
360+
361+
if (refresh) {
362+
SetWindowPos(this->GetHandle(), NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
363+
}
364+
365+
return result;
366+
}
357367
virtual bool StartGroup()
358368
{
359369
//Set component group
@@ -819,6 +829,8 @@ namespace dnyWinForms {
819829
};
820830

821831
class CTextbox : public IBaseComponent {
832+
private:
833+
bool m_bMultiLine;
822834
public:
823835
CTextbox() {}
824836
CTextbox(HWND hParentWnd, const std::wstring& wszName, const WFDimension& dimPosition, const WFDimension& dimResolution) { this->Instantiate(hParentWnd, wszName, dimPosition, dimResolution); }
@@ -838,6 +850,9 @@ namespace dnyWinForms {
838850
//Create textbox control
839851
this->m_hWindow = CreateWindowEx(WS_EX_CLIENTEDGE, L"Edit", NULL, WS_CHILD | WS_VISIBLE | ES_MULTILINE, dimPosition[0], dimPosition[1], dimResolution[0], dimResolution[1], this->GetParent(), (HMENU)this->m_usMenuId, (HINSTANCE)GetCurrentProcess(), NULL);
840852

853+
//Set initially to false
854+
this->m_bMultiLine = false;
855+
841856
return this->m_hWindow != NULL;
842857
}
843858

@@ -851,6 +866,19 @@ namespace dnyWinForms {
851866
return IBaseComponent::SetText(wszText);
852867
}
853868

869+
virtual bool AppendText(const std::wstring& wszText)
870+
{
871+
//Append control text
872+
873+
if (!this->SetText(this->GetText() + L"\r\n" + wszText))
874+
return false;
875+
876+
if (!SendMessage(this->m_hWindow, EM_LINESCROLL, 0, INT_MAX))
877+
return false;
878+
879+
return true;
880+
}
881+
854882
virtual std::wstring GetText(void)
855883
{
856884
//Get control text
@@ -877,6 +905,19 @@ namespace dnyWinForms {
877905
return wszResult;
878906
}
879907

908+
virtual void SetMultiline(void)
909+
{
910+
//Set textbox to multiline
911+
912+
this->m_bMultiLine = true;
913+
914+
SetWindowLongPtr(this->GetHandle(), GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL);
915+
916+
SendMessage(this->GetHandle(), EM_SETLIMITTEXT, 0, 0);
917+
918+
SetWindowPos(this->GetHandle(), NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
919+
}
920+
880921
//Handlers
881922
virtual bool Process(void) { return true; }
882923
virtual bool Draw(void) { return true; }

defplugins/forms/forms/interface.cpp

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,35 @@ class IGetCompTextCommandInterface : public IResultCommandInterface<dnyString> {
220220

221221
} g_oGetCompTextCommandInterface;
222222

223+
class IGetCompHandleCommandInterface : public IResultCommandInterface<dnyInteger> {
224+
public:
225+
IGetCompHandleCommandInterface() {}
226+
227+
virtual bool CommandCallback(void* pCodeContext, void* pInterfaceObject)
228+
{
229+
ICodeContext* pContext = (ICodeContext*)pCodeContext;
230+
231+
pContext->ReplaceAllVariables(pInterfaceObject);
232+
233+
dnyWinForms::CForm* pForm = dnyWinForms::FindForm(pContext->GetPartString(1));
234+
if (!pForm)
235+
return false;
236+
237+
if (pContext->GetPartCount() > 3) {
238+
dnyWinForms::IBaseComponent* pBaseComp = pForm->FindComponent(pContext->GetPartString(2), pContext->GetPartString(3));
239+
if (!pBaseComp)
240+
return false;
241+
242+
IResultCommandInterface<dnyInteger>::SetResult((dnyInteger)pBaseComp->GetHandle());
243+
} else {
244+
IResultCommandInterface<dnyInteger>::SetResult((dnyInteger)pForm->GetHandle());
245+
}
246+
247+
return true;
248+
}
249+
250+
} g_oGetCompHandleCommandInterface;
251+
223252
class ISetCompFontCommandInterface : public IVoidCommandInterface {
224253
public:
225254
ISetCompFontCommandInterface() {}
@@ -243,6 +272,33 @@ class ISetCompFontCommandInterface : public IVoidCommandInterface {
243272

244273
} g_oSetCompFontCommandInterface;
245274

275+
class ISetCompStyleCommandInterface : public IResultCommandInterface<dnyInteger> {
276+
public:
277+
ISetCompStyleCommandInterface() {}
278+
279+
virtual bool CommandCallback(void* pCodeContext, void* pInterfaceObject)
280+
{
281+
ICodeContext* pContext = (ICodeContext*)pCodeContext;
282+
283+
pContext->ReplaceAllVariables(pInterfaceObject);
284+
285+
dnyWinForms::CForm* pForm = dnyWinForms::FindForm(pContext->GetPartString(1));
286+
if (!pForm)
287+
return false;
288+
289+
dnyWinForms::IBaseComponent* pBaseComp = pForm->FindComponent(pContext->GetPartString(2), pContext->GetPartString(3));
290+
if (!pBaseComp)
291+
return false;
292+
293+
dnyInteger iOldStyle = (dnyInteger)pBaseComp->SetStyle(pContext->GetPartInt(4), true);
294+
295+
this->SetResult(iOldStyle);
296+
297+
return true;
298+
}
299+
300+
} g_oSetCompStyleCommandInterface;
301+
246302
class IStartCompGroupCommandInterface : public IVoidCommandInterface {
247303
public:
248304
IStartCompGroupCommandInterface() {}
@@ -374,6 +430,31 @@ class ISpawnTextboxCommandInterface : public IVoidCommandInterface {
374430

375431
} g_oSpawnTextboxCommandInterface;
376432

433+
class ISetTextboxMultilineCommandInterface : public IVoidCommandInterface {
434+
public:
435+
ISetTextboxMultilineCommandInterface() {}
436+
437+
virtual bool CommandCallback(void* pCodeContext, void* pInterfaceObject)
438+
{
439+
ICodeContext* pContext = (ICodeContext*)pCodeContext;
440+
441+
pContext->ReplaceAllVariables(pInterfaceObject);
442+
443+
dnyWinForms::CForm* pForm = dnyWinForms::FindForm(pContext->GetPartString(1));
444+
if (!pForm)
445+
return false;
446+
447+
dnyWinForms::CTextbox* pTextbox = (dnyWinForms::CTextbox*)pForm->FindComponent(L"CTextbox", pContext->GetPartString(2));
448+
if (!pTextbox)
449+
return false;
450+
451+
pTextbox->SetMultiline();
452+
453+
return true;
454+
}
455+
456+
} g_oSetTextboxMultilineCommandInterface;
457+
377458
class IGetTextboxTextCommandInterface : public IResultCommandInterface<dnyString> {
378459
public:
379460
IGetTextboxTextCommandInterface() {}
@@ -422,6 +503,29 @@ class ISetTextboxTextCommandInterface : public IVoidCommandInterface {
422503

423504
} g_oSetTextboxTextCommandInterface;
424505

506+
class IAppendTextboxTextCommandInterface : public IVoidCommandInterface {
507+
public:
508+
IAppendTextboxTextCommandInterface() {}
509+
510+
virtual bool CommandCallback(void* pCodeContext, void* pInterfaceObject)
511+
{
512+
ICodeContext* pContext = (ICodeContext*)pCodeContext;
513+
514+
pContext->ReplaceAllVariables(pInterfaceObject);
515+
516+
dnyWinForms::CForm* pForm = dnyWinForms::FindForm(pContext->GetPartString(1));
517+
if (!pForm)
518+
return false;
519+
520+
dnyWinForms::CTextbox* pTextbox = (dnyWinForms::CTextbox*)pForm->FindComponent(L"CTextbox", pContext->GetPartString(2));
521+
if (!pTextbox)
522+
return false;
523+
524+
return pTextbox->AppendText(pContext->GetPartString(3));
525+
}
526+
527+
} g_oAppendTextboxTextCommandInterface;
528+
425529
class ISpawnCheckboxCommandInterface : public IVoidCommandInterface {
426530
public:
427531
ISpawnCheckboxCommandInterface() {}
@@ -1441,14 +1545,18 @@ bool dnyAS_PluginLoad(dnyVersionInfo version, IShellPluginAPI* pInterfaceData, p
14411545
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_setcomptext", &g_oSetCompTextCommandInterface, CT_VOID);
14421546
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_setcompfont", &g_oSetCompFontCommandInterface, CT_VOID);
14431547
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_getcomptext", &g_oGetCompTextCommandInterface, CT_STRING);
1548+
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_getcomphandle", &g_oGetCompHandleCommandInterface, CT_INT);
1549+
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_setcompstyle", &g_oSetCompStyleCommandInterface, CT_INT);
14441550
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_startcompgroup", &g_oStartCompGroupCommandInterface, CT_VOID);
14451551
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_setcompgroup", &g_oSetCompGroupCommandInterface, CT_VOID);
14461552
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_clearcompgroup", &g_oClearCompGroupCommandInterface, CT_VOID);
14471553
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_spawnlabel", &g_oSpawnLabelCommandInterface, CT_VOID);
14481554
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_spawnbutton", &g_oSpawnButtonCommandInterface, CT_VOID);
14491555
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_spawntextbox", &g_oSpawnTextboxCommandInterface, CT_VOID);
1556+
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_settextboxmultiline", &g_oSetTextboxMultilineCommandInterface, CT_VOID);
14501557
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_gettextboxtext", &g_oGetTextboxTextCommandInterface, CT_STRING);
14511558
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_settextboxtext", &g_oSetTextboxTextCommandInterface, CT_VOID);
1559+
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_appendtextboxtext", &g_oAppendTextboxTextCommandInterface, CT_VOID);
14521560
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_spawncheckbox", &g_oSpawnCheckboxCommandInterface, CT_VOID);
14531561
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_cbischecked", &g_oCbGetValueCommandInterface, CT_BOOL);
14541562
g_pShellPluginAPI->Cmd_RegisterCommand(L"wnd_cbsetvalue", &g_oCbSetValueCommandInterface, CT_VOID);
@@ -1525,14 +1633,18 @@ void dnyAS_PluginUnload(void)
15251633
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_setcomptext");
15261634
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_setcompfont");
15271635
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_getcomptext");
1636+
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_getcomphandle");
1637+
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_setcompstyle");
15281638
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_startcompgroup");
15291639
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_setcompgroup");
15301640
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_clearcompgroup");
15311641
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_spawnlabel");
15321642
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_spawnbutton");
15331643
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_spawntextbox");
1644+
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_settextboxmultiline");
15341645
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_gettextboxtext");
15351646
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_settextboxtext");
1647+
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_appendtextboxtext");
15361648
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_spawncheckbox");
15371649
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_cbischecked");
15381650
g_pShellPluginAPI->Cmd_UnregisterCommand(L"wnd_cbsetvalue");

0 commit comments

Comments
 (0)