📄 ddetrack.c
字号:
MemFree( item );
return( NULL );
}
/*
* TrackLinkMsg - update the links tracking window
*/
void TrackLinkMsg( MONLINKSTRUCT *info ) {
DDETrackInfo *listinfo;
LinkInfo *item;
LinkInfo **itempos;
listinfo = (DDETrackInfo *)
GetWindowLong( Tracking[ DDEMENU_TRK_LINK - DDE_TRK_FIRST ].hwnd, 0 );
itempos = FindLinkInfo( listinfo, info );
if( info->fEstablished ) {
if( itempos != NULL ) return;
itempos = GetNextPos( listinfo );
item = MemAlloc( sizeof( LinkInfo ) );
*itempos = item;
item->service = HSZToString( info->hszSvc );
item->topic = HSZToString( info->hszTopic );
item->item = HSZToString( info->hszItem );
item->format = MemAlloc( 20 );
GetFmtStr( info->wFmt, item->format );
if( info->fNoData ) {
item->type = AllocRCString( STR_WARM );
} else {
item->type = AllocRCString( STR_HOT );
}
item->client = info->hConvClient;
item->server = info->hConvServer;
if( strlen( item->service ) > MAX_TRK_STR ) {
item->service[MAX_TRK_STR] = '\0';
}
if( strlen( item->topic ) > MAX_TRK_STR ) {
item->topic[MAX_TRK_STR] = '\0';
}
if( strlen( item->item ) > MAX_TRK_STR ) {
item->item[MAX_TRK_STR] = '\0';
}
} else {
if( itempos != NULL ) {
FreeLinkInfo( *itempos );
*itempos = NULL;
}
}
RedispLinkTrk( listinfo, TRUE );
}
/*
* DoLinkSort - handle a change in the sort type of the link tracking
* window
*/
static BOOL DoLinkSort( WORD type, DDETrackInfo *info ) {
switch( type ) {
case PUSH_CLIENT:
case PUSH_SERVER:
case PUSH_SERVICE:
case PUSH_TOPIC:
case PUSH_TYPE:
case PUSH_ITEM:
case PUSH_FORMAT:
info->sorttype = type;
RedispLinkTrk( info, TRUE );
break;
default:
return( FALSE );
}
return( TRUE );
}
/* #########################################################################
* CONVERSATION TRACKING STUFF
* #########################################################################*/
/*
* FindLinkInfo - find the location of information about a given conversation
* if the conversation is already recorded
*/
static LinkInfo **FindConvInfo( DDETrackInfo *info, MONCONVSTRUCT *find ) {
unsigned i;
LinkInfo *cur;
char *service;
char *topic;
service = HSZToString( find->hszSvc );
topic = HSZToString( find->hszTopic );
for( i=0; i < info->cnt; i++ ) {
cur = info->data[i];
if( cur == NULL ) break;
if( cur->client == find->hConvClient
&& cur->server == find->hConvServer
&& !stricmp( service, cur->service )
&& !stricmp( topic, cur->topic ) ) return( info->data + i );
}
MemFree( service );
MemFree( topic );
return( NULL );
}
/*
* TrackConvMsg - update the coversations tracking window
*/
void TrackConvMsg( MONCONVSTRUCT *info ) {
LinkInfo *item;
LinkInfo **itempos;
DDETrackInfo *listinfo;
listinfo = (DDETrackInfo *)
GetWindowLong( Tracking[ DDEMENU_TRK_CONV - DDE_TRK_FIRST ].hwnd, 0 );
itempos = FindConvInfo( listinfo, info );
if( info->fConnect ) {
if( itempos != NULL ) return;
itempos = GetNextPos( listinfo );
item = MemAlloc( sizeof( LinkInfo ) );
*itempos = item;
item->service = HSZToString( info->hszSvc );
item->topic = HSZToString( info->hszTopic );
item->client = info->hConvClient;
item->server = info->hConvServer;
item->type = NULL;
item->item = NULL;
item->format = NULL;
if( strlen( item->service ) > MAX_TRK_STR ) {
item->service[MAX_TRK_STR] = '\0';
}
if( strlen( item->topic ) > MAX_TRK_STR ) {
item->topic[MAX_TRK_STR] = '\0';
}
} else {
if( itempos != NULL ) {
FreeLinkInfo( *itempos );
*itempos = NULL;
}
}
RedispLinkTrk( listinfo, FALSE );
}
/*
* DoConvSort - change the sort type for( the conversation tracking window
*/
static BOOL DoConvSort( WORD type, DDETrackInfo *info ) {
switch( type ) {
case PUSH_CLIENT:
case PUSH_SERVER:
case PUSH_TOPIC:
case PUSH_SERVICE:
info->sorttype = type;
RedispLinkTrk( info, FALSE );
break;
default:
return( FALSE );
}
return( TRUE );
}
/*
* DisplayTracking - toggle a tracking window between displayed and hidden
*/
void DisplayTracking( WPARAM wparam ) {
int action;
WORD index;
HMENU mh;
mh = GetMenu( DDEMainWnd );
index = wparam - DDE_TRK_FIRST;
Tracking[ index ].visible = !Tracking[ index ].visible;
if( Tracking[ index ].visible ) {
CheckMenuItem( mh, wparam, MF_BYCOMMAND | MF_CHECKED );
action = SW_SHOWNORMAL;
} else {
CheckMenuItem( mh, wparam, MF_BYCOMMAND | MF_UNCHECKED );
action = SW_HIDE;
}
DDESetStickyState( wparam, Tracking[ index ].visible );
ShowWindow( Tracking[ wparam - DDE_TRK_FIRST ].hwnd, action );
}
/*
* MakePushWin - create the push window headers for a window
*/
static void MakePushWin( DDETrackInfo *info, HWND hwnd,
TrackHeaderInfo *hdrinfo, WORD hdrcnt ) {
WORD i;
SIZE sz;
char test[40];
int left;
HDC dc;
HFONT font;
HFONT old_font;
char *win_title;
if( info->hdr == NULL ) {
info->hdr = MemAlloc( hdrcnt * sizeof( HWND ) );
info->hdrcnt = hdrcnt;
info->hdrinfo = hdrinfo;
}
left = 0;
font = GetMonoFont();
for( i=0; i < hdrcnt; i++ ) {
if( IsWindow( info->hdr[i] ) ) DestroyWindow( info->hdr[i] );
win_title = AllocRCString( hdrinfo[i].textid );
info->hdr[i] = CreatePushWin( hwnd, win_title, hdrinfo[i].id,
font, Instance );
FreeRCString( win_title );
memset( test, '0', hdrinfo[i].size );
test[ hdrinfo[i].size ] = '\0';
dc = GetDC( info->hdr[i] );
old_font = SelectObject( dc, font );
GetTextExtentPoint( dc, test, hdrinfo[i].size, &sz );
SelectObject( dc, old_font );
ReleaseDC( info->hdr[i], dc );
MoveWindow( info->hdr[i], left, 0, sz.cx, sz.cy, TRUE );
ShowWindow( info->hdr[i], SW_SHOW );
left += sz.cx;
}
info->list.ypos = sz.cy + 1;
}
/*
* DDETrackingWndProc - handle messages from the tracking windows
*/
BOOL __export FAR PASCAL DDETrackingWndProc( HWND hwnd, UINT msg, WPARAM wparam,
DWORD lparam )
{
DDETrackInfo *info;
WORD i;
void **ptr;
RECT area;
WORD cmd;
char *wintitle;
info = (DDETrackInfo *)GetWindowLong( hwnd, 0 );
switch( msg ) {
case WM_CREATE:
info = MemAlloc( sizeof( DDETrackInfo ) );
memset( info, 0, sizeof( DDETrackInfo ) );
info->type = *(WORD *)( ( (CREATESTRUCT *)lparam )->lpCreateParams );
SetWindowLong( hwnd, 0, (DWORD) info );
switch( info->type ) {
case DDEMENU_TRK_CONV:
info->sorttype = PUSH_CLIENT;
MakePushWin( info, hwnd, ConvHdr, CNV_HDR_CNT );
wintitle = GetRCString( STR_CONVERSATIONS );
break;
case DDEMENU_TRK_STR:
info->sorttype = PUSH_STR_TEXT;
MakePushWin( info, hwnd, StrHdr, STR_HDR_CNT );
wintitle = GetRCString( STR_STRINGS );
break;
case DDEMENU_TRK_LINK:
info->sorttype = PUSH_CLIENT;
MakePushWin( info, hwnd, LnkHdr, LNK_HDR_CNT );
wintitle = GetRCString( STR_LINKS );
break;
case DDEMENU_TRK_SERVER:
info->sorttype = PUSH_INST;
MakePushWin( info, hwnd, SrvHdr, SRV_HDR_CNT );
wintitle = GetRCString( STR_REG_SERVERS );
break;
}
SetWindowText( hwnd, wintitle );
CreateListBox( hwnd, &( info->list ) );
info->config = &( Tracking[ info->type - DDE_TRK_FIRST ] );
if( info->config->visible ) {
ShowWindow( hwnd, SW_SHOWNORMAL );
}
break;
case WM_MOVE:
GetWindowRect( hwnd, &area );
info->config->xpos = area.left;
info->config->ypos = area.top;
break;
case WM_SIZE:
ResizeListBox( LOWORD( lparam ), HIWORD( lparam ), &( info->list ) );
GetWindowRect( hwnd, &area );
if( wparam != SIZE_MAXIMIZED && wparam != SIZE_MINIMIZED ) {
info->config->xsize = area.right - area.left;
info->config->ysize = area.bottom - area.top;
}
break;
case WM_COMMAND:
cmd = LOWORD( wparam );
switch( info->type ) {
case DDEMENU_TRK_STR:
DoStrSort( cmd, info );
break;
case DDEMENU_TRK_CONV:
DoConvSort( cmd, info );
break;
case DDEMENU_TRK_LINK:
DoLinkSort( cmd, info );
break;
case DDEMENU_TRK_SERVER:
DoServerSort( cmd, info );
break;
}
break;
case WM_CLOSE:
DisplayTracking( info->type );
break;
case WM_DESTROY:
ptr = info->data;
for( i=0; i < info->cnt; i++ ) {
MemFree( ptr[i] );
}
if( ptr != NULL ) {
MemFree( ptr );
}
if( info->hdr != NULL ) MemFree( info->hdr );
MemFree( info );
break;
default:
return( DefWindowProc( hwnd, msg, wparam, lparam ) );
}
return( TRUE );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -