Skip to content

Commit

Permalink
merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jsg2021 committed Dec 17, 2023
1 parent 70ece6e commit 8d4e4d4
Show file tree
Hide file tree
Showing 213 changed files with 12,239 additions and 0 deletions.
Binary file removed 7/Bin/SimplyTransparent.exe
Binary file not shown.
Binary file removed 7/Bin/res_x86.dll
Binary file not shown.
Binary file removed 7/Bin/tool_x86.dll
Binary file not shown.
Binary file removed 7/Help/ST7 Help src files.zip
Binary file not shown.
File renamed without changes.
0 7/CfgFuncs.h → App/CfgFuncs.h
100644 → 100755
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
0 7/Options.cpp → App/Options.cpp
100644 → 100755
File renamed without changes.
0 7/Options.h → App/Options.h
100644 → 100755
File renamed without changes.
150 changes: 150 additions & 0 deletions App/Simply Transparent/CfgFuncs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
///////////////////////////////////////////////////////////////////////////////
//// Configuration Functions
//
#include "stdafx.h"
#include "SimplyTransparent.h"
#include "CfgFuncs.h"



COLORREF rgb_from_text( string txt_rgb )
{

int R,G,B;
char color[15];
char * buf;

txt_rgb.copy( color, 15 );

buf = strtok( color, "," );
R = atoi( buf );

buf = strtok( 0, "," );
G = atoi( buf );

buf = strtok( 0, "," );
B = atoi( buf );

return RGB(R,G,B);
}












string rgb_to_text( COLORREF c )//char[15]
{
char color_rgb[15];
sprintf( color_rgb, "%d,%d,%d", GetRValue(c), GetGValue(c), GetBValue(c) );

string color = color_rgb;

return color;
}










DWORD ReadIntSetting( string section, string lable, DWORD def )
{
DWORD x = 0;

try{

DWORD *n = NULL;
bool bAlloced = false;

n = (DWORD *)ReadSetting( (char *)section.c_str(), (char *)lable.c_str(), &def, &x, bAlloced );

x = *n;


}
catch(...){
__ErrorMessage( "ReadIntSetting( )" );
}

return x;
}









void WriteIntSetting( string section, string lable, int data )
{
WriteSetting( (char *)section.c_str(), (char *)lable.c_str(), &data );
}











DWORD ReadRGBSetting( string section, string lable, string def )
{
COLORREF x;

try{

char *n = NULL;
bool bAlloced = false;

n = ReadSetting( (char *)section.c_str(), (char *)lable.c_str(), (char *)def.c_str(), n, bAlloced );


x = rgb_from_text( n );


if(bAlloced)
delete n;

}
catch(...){
__ErrorMessage( "ReadRGBSetting( )" );
}

return x;
}








void WriteRGBSetting( string section, string lable, COLORREF data )
{
try{
string rgb = rgb_to_text( data );

WriteSetting( (char *)section.c_str(), (char *)lable.c_str(), rgb.c_str( ) );

}
catch(...){
__ErrorMessage( "ReadRGBSetting( )" );
}
}
158 changes: 158 additions & 0 deletions App/Simply Transparent/CfgFuncs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
///////////////////////////////////////////////////////////////////////////////
//// Configuration Functions header file (CfgFuncs.h)
//

#ifndef ____CFG_FUNCS_H___
#define ____CFG_FUNCS_H___

#include "resource.h"
#include <winreg.h>

COLORREF rgb_from_text( string txt_rgb );
string rgb_to_text( COLORREF c );

DWORD ReadIntSetting( string section, string lable, DWORD def );
void WriteIntSetting( string section, string lable, int data );

DWORD ReadRGBSetting( string section, string lable, string def );
void WriteRGBSetting( string section, string lable, COLORREF data );

template <class T>
inline int WriteSetting( char section[], char lable[], T *data )
{
int ret = 1;

try{

const unsigned int string_size = 50;

DWORD disposition;
LONG res = 0;
HKEY softkey = NULL, key = NULL;
char subkey[MAX_PATH];
char appname[string_size];
char author[string_size];

LoadString( GetMyInstanceHandle( ), IDS_APP_TITLE,
appname, string_size );

LoadString( GetMyInstanceHandle( ), IDS_REGISTRY_KEY,
author, string_size );

sprintf( subkey, "%s\\%s\\%s", author, appname, section );

res = RegOpenKeyEx( HKEY_CURRENT_USER, "software", 0, KEY_WRITE,
&softkey );
if( ERROR_SUCCESS == res )
{
res = RegCreateKeyEx( softkey, subkey, 0, "key",
REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &key, &disposition );
if( ERROR_SUCCESS == res )
{
res = RegSetValueEx(key, lable, 0,
( sizeof( *data ) == sizeof( char ) ) ? REG_SZ : REG_DWORD,
(BYTE*)data, ( sizeof( *data ) == sizeof( char ) ) ? strlen( (const char *) data ) : sizeof( data ) );
if( ERROR_SUCCESS == res )
{
ret = 0;
}
}
}

RegCloseKey( softkey );
RegCloseKey( key );

}catch(...){

__ErrorMessage( "WriteSetting( )" );

}

return ret;
}













template <class T>
inline T * ReadSetting( char section[], char lable[], T *def, T *data, bool &alloced )
{
LONG res = 0;

try {

const unsigned int string_size = 50;

DWORD disposition, size, type = ( sizeof( *def ) == sizeof( char ) ) ? REG_SZ : REG_DWORD;

HKEY softkey = NULL, key = NULL;
char subkey[MAX_PATH];
char appname[string_size];
char author[string_size];

LoadString( GetMyInstanceHandle( ), IDS_APP_TITLE,
appname, string_size );

LoadString( GetMyInstanceHandle( ), IDS_REGISTRY_KEY,
author, string_size );

sprintf( subkey, "%s\\%s\\%s", author, appname, section );

res = RegOpenKeyEx( HKEY_CURRENT_USER, "software", 0, KEY_WRITE,
&softkey );
if( ERROR_SUCCESS == res )
{
res = RegCreateKeyEx( softkey, subkey, 0, "key",
REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, 0, &key, &disposition );
if( ERROR_SUCCESS == res )
{
res = RegQueryValueEx(key, lable, 0, &type, 0, &size );
if( ERROR_SUCCESS == res )
{
if( type == REG_SZ )
{
alloced = true;
data = new T[size/sizeof(T)];
}

res = RegQueryValueEx(key, lable, 0, &type, (BYTE*)data,
&size );

res = ( ERROR_SUCCESS == res ) ? 1 : 0;

if(res != 1)
{
if(type == REG_SZ)
delete data;

data = def;
}
}
else data = def;
}
else data = def;
}
else data = def;

RegCloseKey( softkey );
RegCloseKey( key );

}catch(...){

__ErrorMessage( "T * ReadSetting( )" );

}

return (res == 1) ? data : def;
}

#endif //____CFG_FUNCS_H___
Loading

0 comments on commit 8d4e4d4

Please sign in to comment.