Skip to content
Permalink
Browse files

Release SafeEditor source code into public domain

  • Loading branch information...
magole committed Feb 25, 2019
1 parent 0476d8d commit 26c1fd73a4af5f0d2867e98689e0f7d049538ea0
@@ -0,0 +1,158 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf


#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac desktop service store files
.DS_Store
/.vs
/src/.vs/SafeEditor/v15
@@ -0,0 +1,138 @@
//
// This is free and unencumbered software released into the public domain.
//

#include "AboutWindow.h"
#include "Resources.h"


typedef struct ABOUTDLGINFO
{
HMSGLOOP hMsgLoop;
DWORD wndId;

} ABOUTDLGINFO;


static INT_PTR WINAPI AboutWmInitDialog(HWND hWnd, const ABOUTDLGINFO *lParam)
{
SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)lParam->hMsgLoop);
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)lParam->wndId);

HWND hParent = GetParent(hWnd);

if (hParent)
{
SendMessage(hParent, WM_APP_WINDOWCREATED, MAKEWPARAM(lParam->wndId, TRUE), (LPARAM)hWnd);
}

HWND hEditWndAbout = GetDlgItem(hWnd, IDC_EDIT_ABOUT);

if (hEditWndAbout)
{
LPCWSTR lpAbout;

if (GetString(IDS_ABOUT_APP, &lpAbout))
{
SendMessage(hEditWndAbout, WM_SETTEXT, 0, (LPARAM)lpAbout);
}

ReplaceWndProc(hEditWndAbout, MultilineEditWndProc);
}

return TRUE;
}

static void WINAPI AboutMwDestroy(HWND hWnd)
{
HWND hParent = GetParent(hWnd);

if (hParent)
{
LONG_PTR wndId = GetWindowLongPtr(hWnd, GWLP_USERDATA);

SendMessage(hParent, WM_APP_WINDOWCREATED, MAKEWPARAM(wndId, FALSE), (LPARAM)hWnd);
}
}

static void WINAPI AboutMwActivate(HWND hWnd, WPARAM wParam)
{
HMSGLOOP hMsgLoop = (HMSGLOOP)GetWindowLongPtr(hWnd, DWLP_USER);

DWORD fActive = LOWORD(wParam);
BOOL fMinimized = HIWORD(wParam);

if (fActive != WA_INACTIVE) // The window is being activated
{
if (!fMinimized)
{
SetMsgLoop(hMsgLoop, hWnd, NULL);
}
}
else if (fActive == WA_INACTIVE) // The window is being deactivated
{
RestoreMsgLoop(hMsgLoop);
}
}

/*
static INT_PTR CALLBACK AboutMwCtlColorDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return (INT_PTR)GetSysColorBrush(COLOR_3DLIGHT);
}
*/

static INT_PTR CALLBACK ModelessAboutDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
// http://msdn.microsoft.com/en-us/library/bb432504(v=vs.85).aspx

/* case WM_CTLCOLORDLG:
case WM_CTLCOLORBTN:
case WM_CTLCOLORSTATIC:
WM_CTLCOLOREDIT:
WM_CTLCOLORSCROLLBAR
return AboutMwCtlColorDlg(hWnd, msg, wParam, lParam); */

case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDCANCEL:
DestroyWindow(hWnd);
break;
}

break;
case WM_ACTIVATE:
AboutMwActivate(hWnd, wParam);

break;
case WM_DESTROY:
AboutMwDestroy(hWnd);

break;
case WM_INITDIALOG:
return AboutWmInitDialog(hWnd, (ABOUTDLGINFO*)lParam);
}

return FALSE;
}

HWND WINAPI ShowAbout(HWND hWndAbout, DWORD wndAboutId, HWND hWndParent, HMSGLOOP hMsgLoop)
{
ABOUTDLGINFO info;

if (hWndAbout)
{
SendMessage(hWndAbout, DM_REPOSITION, 0, 0);
SetActiveWindow(hWndAbout);

return hWndAbout;
}

info.hMsgLoop = hMsgLoop;
info.wndId = wndAboutId;

return CreateDialogParam(GetCurrentModuleHandle(), MAKEINTRESOURCE(IDD_ABOUT), hWndParent, ModelessAboutDlgProc, (LPARAM)&info);
}
@@ -0,0 +1,22 @@
//
// This is free and unencumbered software released into the public domain.
//

#ifndef __ABOUTWINDOW_H__
#define __ABOUTWINDOW_H__

#include "UICommon.h"

#ifdef __cplusplus
extern "C" {
#endif


HWND WINAPI ShowAbout(HWND hWndAbout, DWORD wndAboutId, HWND hWndParent, HMSGLOOP hMsgLoop);


#ifdef __cplusplus
}
#endif

#endif // __ABOUTWINDOW_H__
Oops, something went wrong.

0 comments on commit 26c1fd7

Please sign in to comment.
You can’t perform that action at this time.