📄 ddeproc.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 <string.h>
#include <math.h>
#include "wddespy.h"
#include "aboutdlg.h"
#include "wwinhelp.h"
#include "jdlg.h"
static FARPROC DDEMsgFp;
static const MenuItemHint menuHints[] = {
DDEMENU_SAVE, STR_HINT_SAVE,
DDEMENU_SAVE_AS, STR_HINT_SAVE_AS,
DDEMENU_LOG_FILE, STR_HINT_LOG_FILE,
DDEMENU_LOG_PAUSE, STR_HINT_LOG_PAUSE,
DDEMENU_LOG_CONFIG, STR_HINT_LOG_CONFIG,
DDEMENU_FONT, STR_HINT_FONT,
DDEMENU_TOOLBAR, STR_HINT_TOOLBAR,
DDEMENU_HINTBAR, STR_HINT_HINTBAR,
DDEMENU_EXIT, STR_HINT_EXIT,
DDEMENU_CLEAR, STR_HINT_CLEAR,
DDEMENU_MARK, STR_HINT_MARK,
DDEMENU_SCREEN_OUT, STR_HINT_SCREEN_OUT,
DDEMENU_SCROLL, STR_HINT_SCROLL,
DDEMENU_MON_POST, STR_HINT_MON_POST,
DDEMENU_MON_SENT, STR_HINT_MON_SENT,
DDEMENU_MON_STR, STR_HINT_MON_STR,
DDEMENU_MON_CB, STR_HINT_MON_CB,
DDEMENU_MON_ERR, STR_HINT_MON_ERR,
DDEMENU_MON_CONV, STR_HINT_MON_CONV,
DDEMENU_MON_LNK, STR_HINT_MON_LNK,
DDEMENU_MSG_FILTER, STR_HINT_MSG_FILTER,
DDEMENU_CB_FILTER, STR_HINT_CB_FILTER,
DDEMENU_TRK_STR, STR_HINT_TRK_STR,
DDEMENU_TRK_CONV, STR_HINT_TRK_CONV,
DDEMENU_TRK_LINK, STR_HINT_TRK_LINK,
DDEMENU_TRK_SERVER, STR_HINT_TRK_SERVER,
DDEMENU_NO_ALIAS, STR_HINT_NO_ALIAS,
DDEMENU_ALIAS_PURGE, STR_HINT_ALIAS_PURGE,
DDEMENU_HWND_ALIAS, STR_HINT_HWND_ALIAS,
DDEMENU_TASK_ALIAS, STR_HINT_TASK_ALIAS,
DDEMENU_CONV_ALIAS, STR_HINT_CONV_ALIAS,
DDEMENU_HELP_CONTENTS, STR_HINT_HELP_CONTENTS,
DDEMENU_HELP_SRCH, STR_HINT_HELP_SRCH,
DDEMENU_HELP_ON_HELP, STR_HINT_HELP_ON_HELP,
DDEMENU_ABOUT, STR_HINT_ABOUT
};
/*
* SetMainWndDefault - set the MainWndConfig structure to the default
* values for size/position of the main window
*/
void SetMainWndDefault( void ) {
MainWndConfig.visible = TRUE;
MainWndConfig.xpos = 0;
MainWndConfig.ypos = 0;
MainWndConfig.xsize = GetSystemMetrics( SM_CXSCREEN );
MainWndConfig.ysize = 150;
MainWndConfig.state = 0;
}
/*
* InitMonitoring - check the appropriate menu items to reflect the
* current monitoring state
*/
static void InitMonitoring( HWND hwnd ) {
HMENU mh;
WORD i;
mh = GetMenu( hwnd );
for( i = DDE_MON_FIRST; i <= DDE_MON_LAST; i++ ) {
if( Monitoring[ i - DDE_MON_FIRST] ) {
CheckMenuItem( mh, i, MF_BYCOMMAND | MF_CHECKED );
}
}
}
/*
* MonitorChange - change the check state a menu item to reflect a
* change in the monitoring state
*/
static void MonitorChange( HWND hwnd, WORD wparam ) {
WORD action;
HMENU mh;
action = MF_BYCOMMAND;
mh = GetMenu( hwnd );
Monitoring[ wparam - DDE_MON_FIRST] =
!Monitoring[ wparam - DDE_MON_FIRST];
action |= Monitoring[wparam - DDE_MON_FIRST] ? MF_CHECKED : MF_UNCHECKED;
CheckMenuItem( mh, wparam, action );
}
/*
* ResetFonts - repaint things and recalculate the size of things after
* a font change
*/
static void ResetFonts( DDEWndInfo *info ) {
HFONT font;
HDC dc;
LONG new_char_extent;
SIZE sz;
font = GetMonoFont();
dc = GetDC( info->list.box );
font = SelectObject( dc, font );
GetTextExtentPoint( dc, "0000000000", 10, &sz );
new_char_extent = sz.cx / 10;
SelectObject( dc, font );
ReleaseDC( info->list.box, dc );
/* estimate the new width of the text in the list box */
info->horz_extent = info->horz_extent *
( new_char_extent / info->char_extent + 1 );
info->char_extent = new_char_extent;
SendMessage( info->list.box, LB_SETHORIZONTALEXTENT,
info->horz_extent, 0L );
SendMessage( info->list.box, WM_SETFONT, (WPARAM)GetMonoFont(),
MAKELONG( TRUE, 0 ) );
SetTrackFont();
}
static void hideHintBar( HWND hwnd, DDEWndInfo *info, BOOL hide ) {
HMENU mh;
RECT area;
HWND hinthwnd;
WORD height;
mh = GetMenu( hwnd );
hinthwnd = GetHintHwnd( info->hintbar );
GetClientRect( hwnd, &area );
height = area.bottom - area.top;
if( hide ) {
info->list.hinthite = 0;
ShowWindow( hinthwnd, SW_HIDE );
CheckMenuItem( mh, DDEMENU_HINTBAR, MF_BYCOMMAND | MF_UNCHECKED );
} else {
info->list.hinthite = SizeHintBar( info->hintbar );
if( height < info->list.ypos + info->list.hinthite ) {
ShowWindow( hinthwnd, SW_HIDE );
} else {
ShowWindow( hinthwnd, SW_SHOW );
}
CheckMenuItem( mh, DDEMENU_HINTBAR, MF_BYCOMMAND | MF_CHECKED );
}
ResizeListBox( area.right - area.left, height, &(info->list ) );
}
/*
* DDEMainWndProc - process messages for the main window
*/
BOOL __export FAR PASCAL DDEMainWndProc( HWND hwnd, UINT msg, WPARAM wparam,
DWORD lparam )
{
DDEWndInfo *info;
char *alias_title;
FARPROC fp;
RECT area;
HMENU mh;
WORD flag;
HDC dc;
HFONT font;
about_info ai;
WORD cmd;
SIZE sz;
HWND hinthwnd;
info = (DDEWndInfo *)GetWindowLong( hwnd, 0 );
switch( msg ) {
case WM_CREATE:
DDEMainWnd = hwnd;
MainWndConfig.hwnd = hwnd;
DDEMsgFp = MakeProcInstance( (FARPROC)DDEMsgProc, Instance );
InitMonitoring( hwnd );
DdeInitialize( &DDEInstId, (PFNCALLBACK)DDEMsgFp,
APPCLASS_MONITOR | MF_CALLBACKS | MF_CONV |
MF_ERRORS | MF_HSZ_INFO | MF_LINKS |
MF_POSTMSGS | MF_SENDMSGS, 0L );
info = MemAlloc( sizeof( DDEWndInfo ) );
memset( info, 0, sizeof( DDEWndInfo ) );
memset( &area, 0, sizeof( RECT ) );
info->hintbar = HintWndCreate( hwnd, &area, Instance, NULL);
SetHintText( info->hintbar, (MenuItemHint *)menuHints,
sizeof( menuHints ) / sizeof( MenuItemHint ) );
hinthwnd = GetHintHwnd( info->hintbar );
info->list.ypos = 0;
info->horz_extent = 0;
CreateListBox( hwnd, &( info->list ) );
font = GetMonoFont();
dc = GetDC( info->list.box );
font = SelectObject( dc, font );
GetTextExtentPoint( dc, "0000000000", 10, &sz );
info->char_extent = sz.cx / 10;
SelectObject( dc, font );
ReleaseDC( info->list.box, dc );
SetWindowLong( hwnd, 0, (DWORD) info );
InitAliases();
LogInit( hwnd, Instance, LogHeader );
MakeDDEToolBar( hwnd );
mh = GetMenu( hwnd );
if( ConfigInfo.scroll ) {
CheckMenuItem( mh, DDEMENU_SCROLL, MF_BYCOMMAND | MF_CHECKED );
}
if( !ConfigInfo.alias ) {
CheckMenuItem( mh, DDEMENU_NO_ALIAS, MF_BYCOMMAND | MF_CHECKED );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -