diff --git a/Contrib/ShowWin/ShowWin.c b/Contrib/ShowWin/ShowWin.c new file mode 100644 index 00000000..0e4d3fab --- /dev/null +++ b/Contrib/ShowWin/ShowWin.c @@ -0,0 +1,222 @@ +#include + +typedef struct _stack_t { + struct _stack_t *next; + char text[1]; // this should be the length of string_size +} stack_t; + +int popstring(char *str); // 0 on success, 1 on empty stack +void pushstring(char *str); +int my_atoi(char *s); + +enum +{ +INST_0, // $0 +INST_1, // $1 +INST_2, // $2 +INST_3, // $3 +INST_4, // $4 +INST_5, // $5 +INST_6, // $6 +INST_7, // $7 +INST_8, // $8 +INST_9, // $9 +INST_R0, // $R0 +INST_R1, // $R1 +INST_R2, // $R2 +INST_R3, // $R3 +INST_R4, // $R4 +INST_R5, // $R5 +INST_R6, // $R6 +INST_R7, // $R7 +INST_R8, // $R8 +INST_R9, // $R9 +INST_CMDLINE, // $CMDLINE +INST_INSTDIR, // $INSTDIR +INST_OUTDIR, // $OUTDIR +INST_EXEDIR, // $EXEDIR +INST_LANG, // $LANGUAGE +__INST_LAST +}; + +char *getuservariable(int varnum); + + +HINSTANCE g_hInstance; +HWND g_hwndParent; +int g_stringsize; +stack_t **g_stacktop; +char *g_variables; + +void __declspec(dllexport) Show(HWND hwndParent, int string_size, + char *variables, stack_t **stacktop) +{ + g_hwndParent=hwndParent; + g_stringsize=string_size; + g_stacktop=stacktop; + g_variables=variables; + + // do your stuff here + { + HWND hwnd_ctrl; + char* str_var; + str_var = (char *)GlobalAlloc(GPTR, sizeof(char)*string_size+1); + if (!popstring(str_var)) { + hwnd_ctrl = (HWND)my_atoi(str_var); + if (IsWindow(hwnd_ctrl)) { + ShowWindow(hwnd_ctrl,1); + } else { + pushstring("error"); + } + } else { + pushstring("error"); + } + } +} + +void __declspec(dllexport) Hide(HWND hwndParent, int string_size, char *variables, stack_t **stacktop){ + g_hwndParent=hwndParent; + g_stringsize=string_size; + g_stacktop=stacktop; + g_variables=variables; + { + HWND hwnd_ctrl; + char* str_var; + str_var = (char *)GlobalAlloc(GPTR, sizeof(char)*string_size+1); + if (!popstring(str_var)) { + hwnd_ctrl = (HWND)my_atoi(str_var); + if (IsWindow(hwnd_ctrl)) { + ShowWindow(hwnd_ctrl,0); + } else { + pushstring("error"); + } + } else { + pushstring("error"); + } + } +} + +void __declspec(dllexport) Enable(HWND hwndParent, int string_size, char *variables, stack_t **stacktop){ + g_hwndParent=hwndParent; + g_stringsize=string_size; + g_stacktop=stacktop; + g_variables=variables; + { + HWND hwnd_ctrl; + char* str_var; + str_var = (char *)GlobalAlloc(GPTR, sizeof(char)*string_size+1); + if (!popstring(str_var)) { + hwnd_ctrl = (HWND)my_atoi(str_var); + if (IsWindow(hwnd_ctrl)) { + EnableWindow(hwnd_ctrl,TRUE); + } else { + pushstring("error"); + } + } else { + pushstring("error"); + } + } +} + +void __declspec(dllexport) Disable(HWND hwndParent, int string_size, char *variables, stack_t **stacktop){ + g_hwndParent=hwndParent; + g_stringsize=string_size; + g_stacktop=stacktop; + g_variables=variables; + { + HWND hwnd_ctrl; + char* str_var; + str_var = (char *)GlobalAlloc(GPTR, sizeof(char)*string_size+1); + if (!popstring(str_var)) { + hwnd_ctrl = (HWND)my_atoi(str_var); + if (IsWindow(hwnd_ctrl)) { + EnableWindow(hwnd_ctrl,FALSE); + } else { + pushstring("error"); + } + } else { + pushstring("error"); + } + } +} + +BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) +{ + g_hInstance=hInst; + return TRUE; +} + +// utility functions (not required but often useful) +int popstring(char *str) +{ + stack_t *th; + if (!g_stacktop || !*g_stacktop) return 1; + th=(*g_stacktop); + lstrcpy(str,th->text); + *g_stacktop = th->next; + GlobalFree((HGLOBAL)th); + return 0; +} + +void pushstring(char *str) +{ + stack_t *th; + if (!g_stacktop) return; + th=(stack_t*)GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize); + lstrcpyn(th->text,str,g_stringsize); + th->next=*g_stacktop; + *g_stacktop=th; +} + +char *getuservariable(int varnum) +{ + if (varnum < 0 || varnum >= __INST_LAST) return NULL; + return g_variables+varnum*g_stringsize; +} + +int my_atoi(char *s) +{ + unsigned int v=0; + if (*s == '0' && (s[1] == 'x' || s[1] == 'X')) + { + s+=2; + for (;;) + { + int c=*s++; + if (c >= '0' && c <= '9') c-='0'; + else if (c >= 'a' && c <= 'f') c-='a'-10; + else if (c >= 'A' && c <= 'F') c-='A'-10; + else break; + v<<=4; + v+=c; + } + } + else if (*s == '0' && s[1] <= '7' && s[1] >= '0') + { + s++; + for (;;) + { + int c=*s++; + if (c >= '0' && c <= '7') c-='0'; + else break; + v<<=3; + v+=c; + } + } + else + { + int sign=0; + if (*s == '-') { s++; sign++; } + for (;;) + { + int c=*s++ - '0'; + if (c < 0 || c > 9) break; + v*=10; + v+=c; + } + if (sign) return -(int) v; + } + return (int)v; +} + + diff --git a/Contrib/ShowWin/ShowWin.dpr b/Contrib/ShowWin/ShowWin.dpr new file mode 100644 index 00000000..2fccf576 --- /dev/null +++ b/Contrib/ShowWin/ShowWin.dpr @@ -0,0 +1,123 @@ +{ + NSIS ExDLL example + (C) 2001 - Peter Windridge + + Fixed and formatted by Alexander Tereschenko + http://futuris.plastiqueweb.com/ + + Tested in Delphi 6.01 +} + +library exdll; + +uses Windows; + +type + VarConstants = ( + INST_0, + INST_1, // $1 + INST_2, // $2 + INST_3, // $3 + INST_4, // $4 + INST_5, // $5 + INST_6, // $6 + INST_7, // $7 + INST_8, // $8 + INST_9, // $9 + INST_R0, // $R0 + INST_R1, // $R1 + INST_R2, // $R2 + INST_R3, // $R3 + INST_R4, // $R4 + INST_R5, // $R5 + INST_R6, // $R6 + INST_R7, // $R7 + INST_R8, // $R8 + INST_R9, // $R9 + INST_CMDLINE, // $CMDLINE + INST_INSTDIR, // $INSTDIR + INST_OUTDIR, // $OUTDIR + INST_EXEDIR, // $EXEDIR + INST_LANG, // $LANGUAGE + __INST_LAST + ); + TVariableList = INST_0..__INST_LAST; + pstack_t = ^stack_t; + stack_t = record + next: pstack_t; + text: PChar; + end; + +var + g_stringsize: integer; + g_stacktop: ^pstack_t; + g_variables: PChar; + g_hwndParent: HWND; + +function PopString(str: PChar):integer; +var + th: pstack_t; +begin + if integer(g_stacktop^) = 0 then + begin + Result:=1; + Exit; + end; + th:=g_stacktop^; + lstrcpy(str,@th.text); + g_stacktop^ := th.next; + GlobalFree(HGLOBAL(th)); + Result:=0; +end; + +function PushString(str: PChar):integer; +var + th: pstack_t; +begin + if integer(g_stacktop) = 0 then + begin + Result:=1; + Exit; + end; + th:=pstack_t(GlobalAlloc(GPTR,sizeof(stack_t)+g_stringsize)); + lstrcpyn(@th.text,str,g_stringsize); + th.next:=g_stacktop^; + g_stacktop^:=th; + Result:=0; +end; + +function GetUserVariable(varnum: TVariableList):PChar; +begin + if (integer(varnum) < 0) or (integer(varnum) >= integer(__INST_LAST)) then + begin + Result:=''; + Exit; + end; + Result:=g_variables+integer(varnum)*g_stringsize; +end; + +function ex_dll(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer):integer; cdecl; +var + c: PChar; + buf: array[0..1024] of char; +begin + // set up global variables + g_stringsize:=string_size; + g_hwndParent:=hwndParent; + g_stringsize:=string_size; + g_stacktop:=stacktop; + g_variables:=variables; + + c:=GetUserVariable(INST_0); + MessageBox(g_hwndParent,c,'The value of $0',MB_OK); + PopString(@buf); + MessageBox(g_hwndParent,@buf,'pop',MB_OK); + PushString(PChar('Hello, this is a push')); + + Result:=1; +end; + +exports ex_dll; + +begin +end. diff --git a/Contrib/ShowWin/ShowWin.dsp b/Contrib/ShowWin/ShowWin.dsp new file mode 100644 index 00000000..9ff57e02 --- /dev/null +++ b/Contrib/ShowWin/ShowWin.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="ShowWin" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=ShowWin - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ShowWin.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ShowWin.mak" CFG="ShowWin - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ShowWin - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "ShowWin - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "ShowWin - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShowWin_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShowWin_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"_DllMainCRTStartup" /dll /machine:I386 /nodefaultlib /opt:nowin98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "ShowWin - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShowWin_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ShowWin_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "ShowWin - Win32 Release" +# Name "ShowWin - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\ShowWin.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/Contrib/ShowWin/ShowWin.dsw b/Contrib/ShowWin/ShowWin.dsw new file mode 100644 index 00000000..510e35ac --- /dev/null +++ b/Contrib/ShowWin/ShowWin.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "ShowWin"=.\ShowWin.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/Contrib/ShowWin/ShowWin.nsi b/Contrib/ShowWin/ShowWin.nsi new file mode 100644 index 00000000..e87c3023 --- /dev/null +++ b/Contrib/ShowWin/ShowWin.nsi @@ -0,0 +1,21 @@ +;ShowWin Example + +Name "ShowWin Example" +OutFile "ShowWin.exe" + +LicenseText "Hide Richedit Control and disable the cancel button." +LicenseData "ShowWin.txt" + +Section "" +SectionEnd + +Function .onInitDialog + ;hide richedit control + FindWindow $R1 "#32770" "" $HWNDPARENT + GetDlgItem $R1 $R1 1000 + ShowWin::Hide $R1 + + ;disable the 'I Agree' button + GetDlgItem $R1 $HWNDPARENT 1 + ShowWin::Disable $R1 +FunctionEnd \ No newline at end of file diff --git a/Contrib/ShowWin/ShowWin.txt b/Contrib/ShowWin/ShowWin.txt new file mode 100644 index 00000000..5190702a --- /dev/null +++ b/Contrib/ShowWin/ShowWin.txt @@ -0,0 +1,23 @@ +ShowWin Plugin +---------------------------------------------------------------------- + +Description: + ShowWin is a small plugin which will allow you to hide, show, enable + and disable controls. + +Usage: + ShowWin::Show hwnd + ShowWin::Hide hwnd + ShowWin::Enable hwnd + ShowWin::Disable hwnd + +Example: + Hide the version label + + GetDlgItem $R1 $HWNDPARENT 1028 + ShowWin::Hide $R1 + + Also see ShowWin.nsi. + +---------------------------------------------------------------------- +Copyright (c) 2002 Don Selkirk \ No newline at end of file diff --git a/Plugins/ShowWin.dll b/Plugins/ShowWin.dll index 9ae89fa5..b5ecf648 100644 Binary files a/Plugins/ShowWin.dll and b/Plugins/ShowWin.dll differ