📄 regstr.c
字号:
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "windows.h"
#include "regstr.h"
#include "mad.h"
#include <string.h>
#include "drwatcom.h"
#include "mem.h"
#include "regcmbo.h"
#include "jdlg.h"
#include "malloc.h"
#include "string.h"
#include "bitman.h"
#include "madcli.h"
#include "regedit.h"
#include "reglist.h"
#include <errno.h>
#include "strcnv.h"
HWND CreateRegString( HWND parent, int x, int y, int width, int height, char *text, int id )
{
HWND ret;
ret = CreateWindow( "REG_STRING",
text,
WS_VISIBLE|WS_CHILD,
x,
y,
width,
height,
parent,
(HMENU)id,
Instance,
NULL );
MoveWindow( ret, x, y, width, height, FALSE );
SetWindowLong( ret, 0, 0 );
return( ret );
}
void UpdateRegString( HWND string, HWND list, int x, int y, int width, int height, char *text )
{
int len;
char *cmp;
LONG flags;
len = GetWindowTextLength( string ) + 1;
cmp = alloca( len + 1 );
GetWindowText( string, cmp, len );
if( strcmp( text, cmp ) != 0 ) {
SetWindowText( string, text );
InvalidateRect( string, NULL, FALSE );
}
MoveWindow( string, x, y, width, height, TRUE );
flags = GetWindowLong( string, 0 );
flags &= ~REG_DESTROY;
SetWindowLong( string, 0, flags );
}
void SetRegStringDestroyFlag(HWND hwnd)
{
LONG flags;
flags = GetWindowLong( hwnd, 0 );
flags |= REG_DESTROY;
SetWindowLong( hwnd, 0, flags );
}
BOOL GetRegStringDestroyFlag(HWND hwnd)
{
LONG flags;
flags = GetWindowLong( hwnd, 0 );
if( flags & REG_DESTROY ) {
return( TRUE );
}
return( FALSE );
}
static void RegStrPaint(HWND hwnd)
{
PAINTSTRUCT ps;
HDC hdc;
RECT r;
char buff[255];
int len;
SIZE size;
int top;
COLORREF fground;
COLORREF bground;
LONG flags;
flags = GetWindowLong( hwnd, 0);
hdc = BeginPaint( hwnd, &ps );
SelectObject( hdc, GetMonoFont() );
GetClientRect( hwnd, &r );
GetWindowText( hwnd, buff, 255 );
len = strlen( buff );
GetTextExtentPoint32( hdc, buff, len, &size );
if( flags & REG_SELECTED ){
fground = GetSysColor( COLOR_HIGHLIGHTTEXT );
bground = GetSysColor( COLOR_HIGHLIGHT );
}
else{
fground = GetSysColor( COLOR_WINDOWTEXT );
bground = GetSysColor( COLOR_WINDOW );
}
SetTextColor( hdc, fground );
SetBkColor( hdc, bground );
top = ( r.bottom - r.top - size.cy ) / 2;
ExtTextOut( hdc, 0, top, ETO_OPAQUE, &r, buff, len, NULL );
EndPaint( hwnd, &ps );
}
static BOOL SetRegSelectFlag(HWND hwnd,BOOL setting)
{
LONG flags;
flags = GetWindowLong( hwnd, 0 );
if( ( setting == TRUE ) && !( flags & REG_SELECTED ) ) {
flags |= REG_SELECTED;
InvalidateRect( hwnd, NULL, FALSE );
SetWindowLong( hwnd, 0, flags );
return ( TRUE );
}
if( ( setting == FALSE ) && ( flags & REG_SELECTED ) ) {
flags &= ~REG_SELECTED;
InvalidateRect( hwnd, NULL, FALSE );
SetWindowLong( hwnd, 0, flags );
return ( TRUE );
}
return ( FALSE );
}
void GetChildPos( HWND parent, HWND child, RECT *c_rect )
{
LONG style;
LONG ex_style;
RECT p_rect;
GetWindowRect( parent, &p_rect );
GetClientRect( parent, c_rect );
style = GetWindowLong( parent, GWL_STYLE );
ex_style = GetWindowLong( parent, GWL_EXSTYLE );
AdjustWindowRectEx( c_rect, style, FALSE, ex_style );
p_rect.left -= c_rect->left;
p_rect.top -= c_rect->top;
GetWindowRect( child, c_rect );
c_rect->right -= c_rect->left;
c_rect->left -= p_rect.left;
c_rect->bottom -= c_rect->top;
c_rect->top -= p_rect.top;
}
static void InitChangeRegisterDialog(HWND hwnd,LPARAM lparam)
{
RegModifyData *data;
char *name;
unsigned len;
unsigned new;
mad_type_info mti;
mad_type_info cmp;
char s[255];
RECT p_rect;
RECT c_rect;
HWND field;
int i;
unsigned max_len;
HDC dc;
TEXTMETRIC tm;
HWND cancel;
SetWindowLong( hwnd, DWL_USER, (LONG)lparam);
data = (RegModifyData *)lparam;
len = MADRegFullName( data->curr_info, ".", 0, NULL );
if( len > 0 ) {
name = alloca( ( len + 1 ) * sizeof( char ) );
MADRegFullName( data->curr_info, ".", len, name );
SetWindowText( hwnd, name );
} else {
SetWindowText( hwnd, "" );
}
if( data->num_possible == 1) {
field = GetDlgItem( hwnd, REG_EDIT_FIELD );
} else {
field = GetDlgItem( hwnd, CH_REG_COMBO_LIST );
}
SetMonoFont( field );
GetChildPos( hwnd, field, &c_rect);
dc = GetDC( field );
GetTextMetrics( dc, &tm );
MADTypeInfo( data->th, &mti );
new = MADTypePreferredRadix( data->th );
if( data->num_possible == 1 ) {
if( data->maxv == 0 ) {
len = 255;
} else {
len = data->maxv;
}
MADTypeToString( new, &mti, data->curr_value, &len, s );
if( data->maxv == 0 ) {
max_len = strlen( s );
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -