bool WRESetStatusByID( msg_id id1, msg_id id2 ) { char *str1; char *str2; bool ret; ret = false; str1 = NULL; str2 = NULL; if( id1 > 0 ) { str1 = AllocRCString( id1 ); } if( id2 > 0 ) { str2 = AllocRCString( id2 ); } ret = WRESetStatusText( str1, str2, TRUE ); if( str1 != NULL ) { FreeRCString( str1 ); } if( str2 != NULL ) { FreeRCString( str2 ); } return( ret ); }
bool WQueryClearRes( WAccelEditInfo *einfo ) { int ret; UINT style; char *title; char *text; if( einfo != NULL ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; text = AllocRCString( W_ACCELCLEARWARNING ); title = AllocRCString( W_ACCELCLEARTITLE ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { FreeRCString( text ); } if( title != NULL ) { FreeRCString( title ); } if( ret == IDYES ) { return( TRUE ); } } return( FALSE ); }
static void fillThreadInfo( HWND hwnd, ProcStats *info ) { HWND lb; int index; char buf[100]; DWORD threadid; ThreadStats thdinfo; #ifndef CHICAGO char *str1; #endif lb = GetDlgItem( hwnd, THREAD_LIST ); index = (int)SendMessage( lb, LB_GETCURSEL, 0, 0L ); if( index == LB_ERR ) { SetDlgItemText( hwnd, THREAD_TID, "" ); SetDlgItemText( hwnd, THREAD_SUSPEND_CNT, "" ); SetDlgItemText( hwnd, THREAD_PRIORITY, "" ); } else { enableChoices( hwnd, TRUE ); SendMessage( lb, LB_GETTEXT, index, (LPARAM)(LPSTR)buf ); threadid = getThreadId( buf ); sprintf( buf, "tid = %08lX", threadid ); SetDlgItemText( hwnd, THREAD_TID, buf ); if( GetThreadInfo( info->pid, threadid, &thdinfo ) ) { #ifndef CHICAGO if( thdinfo.state == 5 ) { /* the thread is in a wait state */ str1 = SrchMsg( thdinfo.wait_reason, ThreadWaitMsgs, NULL ); if( str1 == NULL ) { str1 = AllocRCString( STR_WAIT_4_UNKNOWN ); RCsprintf( buf, STR_STATE, str1 ); FreeRCString( str1 ); } else { RCsprintf( buf, STR_STATE, str1 ); } } else { str1 = SrchMsg( thdinfo.state, ThreadStateMsgs, NULL ); if( str1 == NULL ) { str1 = AllocRCString( STR_BRACED_UNKNOWN ); RCsprintf( buf, STR_STATE, str1 ); FreeRCString( str1 ); } else { RCsprintf( buf, STR_STATE, str1 ); } } SetDlgItemText( hwnd, THREAD_SUSPEND_CNT, buf ); #endif /* get priority */ RCsprintf( buf, STR_PRIORITY_X, thdinfo.cur_pri, thdinfo.base_pri ); SetDlgItemText( hwnd, THREAD_PRIORITY, buf ); } } }
bool WSaveSymbols( WAccelEditInfo *einfo, WRHashTable *table, char **file_name, bool prompt ) { char *name; WGetFileStruct gf; bool ok; if( einfo == NULL || table == NULL || file_name == NULL ) { return( FALSE ); } if( WRIsDefaultHashTable( table ) ) { return( TRUE ); } ok = true; WSetWaitCursor( einfo->win, TRUE ); if( prompt || *file_name == NULL ) { gf.file_name = *file_name; gf.title = AllocRCString( W_SAVESYMTITLE ); gf.filter = AllocRCString( W_SYMFILTER ); WMassageFilter( gf.filter ); name = WGetSaveFileName( einfo->win, &gf ); if( gf.title != NULL ) { FreeRCString( gf.title ); } if( gf.filter != NULL ) { FreeRCString( gf.filter ); } ok = (name != NULL); if( ok ) { if( *file_name != NULL ) { WRMemFree( *file_name ); } *file_name = name; } } else { name = *file_name; } if( ok ) { ok = WRWriteSymbolsToFile( table, name ); } if( ok ) { WRMakeHashTableClean( table ); } WSetWaitCursor( einfo->win, FALSE ); return( ok ); }
/* * CreateSpyBox - create the spy listbox */ void CreateSpyBox( HWND parent ) { #ifdef __NT__ LVCOLUMN lvc; int i; #endif setCharSize( parent ); #ifdef __NT__ if( LoadCommCtrl() ) { AllowVariableFonts(); SpyListBox = CreateWindowEx( WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SINGLESEL, LISTBOX_X, LISTBOX_Y, 0, 0, parent, (HANDLE)(pointer_int)SPY_LIST_BOX, Instance, NULL ); lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; for( i = 0; i < NUM_COLUMNS; i++ ) { lvc.cx = columns[i].width; lvc.pszText = AllocRCString( columns[i].string_id ); lvc.iSubItem = i; SendMessage( SpyListBox, LVM_INSERTCOLUMN, i, (LPARAM)&lvc ); FreeRCString( lvc.pszText ); } #ifdef _WIN64 } else #else } else if( LOBYTE( LOWORD( GetVersion() ) ) >= 4 ) {
bool WREQuerySaveResOnDeleteRes( WREResInfo *res_info, bool fatal_exit ) { int ret; UINT style; HWND frame; char *text; if( WRENoInterface ) { return( TRUE ); } if( res_info != NULL && WREIsResModified( res_info ) ) { if( fatal_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } WRECheckIfActiveWindow(); frame = WREGetMDIWindowHandle(); SendMessage( frame, WM_MDIRESTORE, (WPARAM)res_info->res_win, 0 ); SendMessage( frame, WM_MDIACTIVATE, (WPARAM)res_info->res_win, 0 ); text = AllocRCString( WRE_QUERYMODIFIED ); ret = MessageBox( res_info->res_win, text, WREGetQueryName( res_info ), style ); if( text != NULL ) { FreeRCString( text ); } if( ret == IDYES ) { return( WRESaveResource( res_info, FALSE ) ); } else if( ret == IDCANCEL ) { return( FALSE ); } } return( TRUE ); }
static bool WQueryNukePopup( WMenuEditInfo *einfo ) { int ret; UINT style; char *title; char *text; style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; title = WCreateEditTitle( einfo ); text = AllocRCString( W_QUERYNUKEPOPUP ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { FreeRCString( text ); } if( title != NULL ) { WRMemFree( title ); } if( ret == IDYES ) { return( TRUE ); } return( FALSE ); }
/* * SpyLogOpen - open the log file */ BOOL SpyLogOpen( void ) { int f; WORD flags; FARPROC fp; INT_PTR ret; char *msgtitle; flags = 0; if( !LogCurInfo.init ) { SetLogDef(); } if( LogCurInfo.config.query_for_name ) { if( !getLogName( LogCurInfo.config.name, LogCurInfo.hwnd ) ) { return( FALSE ); } } strcpy( LogCurInfo.config.curname, LogCurInfo.config.name ); switch( LogCurInfo.config.def_action ) { case LOG_ACTION_TRUNC: flags = O_TRUNC; break; case LOG_ACTION_APPEND: flags = O_APPEND; break; case LOG_ACTION_QUERY: if( !access( LogCurInfo.config.curname, F_OK ) ) { fp = MakeDlgProcInstance( LogExistsDlgProc, LogCurInfo.instance ); ret = DialogBox( LogCurInfo.instance, "LOG_EXISTS_DLG", LogCurInfo.hwnd, (DLGPROC)fp ); FreeProcInstance( fp ); switch( ret ) { case LOG_APPEND: flags = O_APPEND; break; case LOG_REPLACE: flags = O_TRUNC; break; case LOG_CANCEL: return( FALSE ); } } break; } f = open( LogCurInfo.config.curname, O_TEXT | O_WRONLY | O_CREAT | flags, S_IREAD | S_IWRITE ); if( f < 0 ) { msgtitle = AllocRCString( LOG_LOG_ERROR ); RCMessageBox( LogCurInfo.hwnd, LOG_CANT_OPEN_LOG, msgtitle, MB_OK | MB_ICONEXCLAMATION ); FreeRCString( msgtitle ); return( FALSE ); } if( LogCurInfo.writefn != NULL ) { LogCurInfo.writefn( f ); } close( f ); LogCurInfo.config.logging = TRUE; LogCurInfo.config.paused = FALSE; return( TRUE ); } /* SpyLogOpen */
void WREShowRibbon( HMENU menu ) { char *mtext; if( WRERibbonHeight != 0 ) { ShowWindow( WRERibbon->win, SW_HIDE ); WRERibbonHeight = 0; WREResizeWindows(); mtext = AllocRCString( WRE_SHOWTOOLBAR ); } else { ShowWindow( WRERibbon->win, SW_SHOW ); WRERibbonHeight = 2 * WRERibbonInfo->dinfo.border_size.y + WRERibbonInfo->dinfo.button_size.y + 2 * GetSystemMetrics( SM_CYBORDER ); WREResizeWindows(); mtext = AllocRCString( WRE_HIDETOOLBAR ); } ModifyMenu( menu, IDM_SHOW_RIBBON, MF_BYCOMMAND | MF_STRING, IDM_SHOW_RIBBON, mtext ); if( mtext != NULL ) { FreeRCString( mtext ); } }
static bool WQueryChangeEntry( WMenuEditInfo *einfo ) { int ret; UINT style; char *title; char *text; style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; title = WCreateEditTitle( einfo ); text = AllocRCString( W_CHANGEMODIFIEDMENUITEM ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { FreeRCString( text ); } if( title != NULL ) { WRMemFree( title ); } if( ret == IDYES ) { return( TRUE ); } return( FALSE ); }
void WHandleMemFlags( WStringEditInfo *einfo ) { char *rtext; char *ntext; WResID *rname; ntext = AllocRCString( W_STRINGNAMES ); if( einfo != NULL && einfo->current_block != NULL && ntext != NULL ) { WSetStatusByID( einfo->wsb, W_CHANGESTRINGMEMFLAGS, -1 ); // alloc space for ntext and two 16-bit ints rtext = (char *)WRMemAlloc( strlen( ntext ) + 20 ); if( rtext != NULL ) { sprintf( rtext, ntext, einfo->current_block->blocknum & 0xfff0, (einfo->current_block->blocknum & 0xfff0) + 16 - 1 ); } rname = WResIDFromStr( rtext ); if( rname != NULL ) { einfo->info->modified |= WChangeMemFlags( einfo->win, &einfo->current_block->MemFlags, rname, WGetEditInstance(), WStrHelpRoutine ); WRMemFree( rname ); } FreeRCString( ntext ); WSetStatusReadyText( einfo->wsb ); } }
void WShowRibbon( WMenuEditInfo *einfo, HMENU menu ) { char *mtext; if( einfo == NULL && menu == NULL ) { return; } mtext = NULL; if( einfo->show_ribbon ) { mtext = AllocRCString( W_SHOWTOOLBAR ); ShowWindow( einfo->ribbon->win, SW_HIDE ); WSetStatusByID( einfo->wsb, -1, W_TOOLBARHIDDEN ); } else { mtext = AllocRCString( W_HIDETOOLBAR ); ShowWindow( einfo->ribbon->win, SW_SHOW ); WSetStatusByID( einfo->wsb, -1, W_TOOLBARSHOWN ); } einfo->show_ribbon = !einfo->show_ribbon; WResizeWindows( einfo ); WMovePrevWindow( einfo ); ModifyMenu( menu, IDM_MENU_SHOWRIBBON, MF_BYCOMMAND | MF_STRING, IDM_MENU_SHOWRIBBON, mtext ); if( mtext != NULL ) { FreeRCString( mtext ); } }
/* * ThreadCtlProc */ INT_PTR CALLBACK RetCodeDlgProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { RetCodeInfo *info; WORD cmd; char buf[BUF_SIZE]; char *title; msg_id info_str_id; bool ret; ret = false; info = (RetCodeInfo *)GET_DLGDATA( hwnd ); switch( msg ) { case WM_INITDIALOG: info = (RetCodeInfo *)lparam; info->really_kill = FALSE; SET_DLGDATA( hwnd, lparam ); if( info->type == RETCD_THREAD ) { title = AllocRCString( STR_THREAD_RETURN_CODE ); info_str_id = STR_THREAD_X; } else { title = AllocRCString( STR_PROCESS_RETURN_CODE ); info_str_id = STR_PROCESS_X; } SetWindowText( hwnd, title ); FreeRCString( title ); RCsprintf( buf, info_str_id, info->type, info->id ); SetDlgItemText( hwnd, RET_PROC_INFO, buf ); SetDlgItemText( hwnd, RET_VALUE, "-1" ); ret = true; break; case WM_COMMAND: cmd = LOWORD( wparam ); switch( cmd ) { case IDOK: GetDlgItemText( hwnd, RET_VALUE, buf, BUF_SIZE ); if( !ParseNumeric( buf, TRUE, &info->rc ) ) { RCMessageBox( hwnd, STR_INVALID_RETURN_CODE, AppName, MB_OK | MB_ICONEXCLAMATION ); break; } info->really_kill = TRUE; SendMessage( hwnd, WM_CLOSE, 0, 0L ); break; case IDCANCEL: SendMessage( hwnd, WM_CLOSE, 0, 0L ); break; } ret = true; break; case WM_CLOSE: EndDialog( hwnd, 0 ); ret = true; break; } return( ret ); }
/* * FreeLinkInfo - free memory holding information about a link */ void FreeLinkInfo( LinkInfo *info ) { MemFree( info->service ); MemFree( info->topic ); if( info->item != NULL ) { MemFree( info->item ); } if( info->type != NULL ) { FreeRCString( info->type ); } MemFree( info ); } /* FreeLinkInfo */
bool WQuerySaveSym( WAccelEditInfo *einfo, bool force_exit ) { int ret; UINT style; char *title; char *text; if( einfo == NULL || !einfo->info->stand_alone ) { return( TRUE ); } if( !WRIsHashTableDirty( einfo->info->symbol_table ) ) { return( TRUE ); } if( force_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } title = WCreateEditTitle( einfo ); text = AllocRCString( W_UPDATEMODIFIEDSYM ); ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { FreeRCString( text ); } if( title != NULL ) { WRMemFree( title ); } if( ret == IDYES ) { if( einfo->info->symbol_file == NULL ) { char *fname; if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } einfo->info->symbol_file = WCreateSymName( fname ); } return( WSaveSymbols( einfo, einfo->info->symbol_table, &einfo->info->symbol_file, FALSE ) ); } else if( ret == IDCANCEL ) { return( FALSE ); } return( TRUE ); }
static void WRESetPasteInfo( HWND hDlg, WREPasteData *pdata ) { WRETypeName *tn; char *text; tn = WREGetTypeNameFromRT( pdata->type ); if( tn != NULL ) { text = AllocRCString( tn->name ); WRESetEditWithStr( GetDlgItem( hDlg, IDM_PASTE_TYPE ), text ); if( text != NULL ) { FreeRCString( text ); } } WRESetEditWithWResID( GetDlgItem( hDlg, IDM_PASTE_NAME ), pdata->name ); }
void FormatMemListEntry( char *buf, MemListItem *item ) { char *prot; char *state; MEMORY_BASIC_INFORMATION *mbi; mbi = &item->mbi; switch( mbi->State ) { case MEM_COMMIT: state = AllocRCString( STR_COMMITTED ); break; case MEM_FREE: state = AllocRCString( STR_FREE ); break; case MEM_RESERVE: state = AllocRCString( STR_RESERVED ); break; default: state = AllocRCString( STR_UNKNOWN ); } if( mbi->Protect & PAGE_READONLY ) { prot = "RO"; } else if( mbi->Protect & PAGE_READWRITE ) { prot = "RW"; } else if( mbi->Protect & PAGE_WRITECOPY ) { prot = "WC"; } else if( mbi->Protect & PAGE_EXECUTE ) { prot = "Ex"; } else if( mbi->Protect & PAGE_EXECUTE_READ ) { prot = "ExRO"; } else if( mbi->Protect & PAGE_EXECUTE_READWRITE ) { prot = "ExRW"; } else if( mbi->Protect & PAGE_EXECUTE_WRITECOPY ) { prot = "ExWC"; } else if( mbi->Protect & PAGE_NOACCESS ) { prot = "NA"; } else { if( mbi->State == MEM_RESERVE ) { prot = "NA"; } else { prot = "??"; } } sprintf( buf, "%08lX %08lX %8lX %-4s %-10s %-9s %s", mbi->BaseAddress, mbi->AllocationBase, mbi->RegionSize, prot, state, item->objname, item->modname ); FreeRCString( state ); }
bool WHandleGetKeyValue( WAccelEditInfo *einfo, bool ignore_first ) { RECT r; bool ok; char *text; text = NULL; ok = (einfo != NULL); if( ok ) { if( einfo->current_entry == NULL ) { ok = WInsertAccelEntry( einfo ); } } if( ok ) { text = AllocRCString( W_SELECTKEY ); ok = (text != NULL); } if( ok ) { WGetKeyPressProc( NULL, 0, 0, 0 ); einfo->key_info.key = 0; GetWindowRect( GetDlgItem( einfo->edit_dlg, IDM_ACCEDLIST ), &r ); MapWindowPoints( (HWND)NULL, einfo->edit_dlg, (POINT *)&r, 2 ); einfo->key_info.text_win = CreateWindow( "static", text, WS_CHILD | WS_VISIBLE | SS_LEFT, r.left, r.top, r.right - r.left, r.bottom - r.top, einfo->edit_dlg, (HMENU)NULL, WGetEditInstance(), NULL ); ok = (einfo->key_info.text_win != (HWND)NULL); } if( ok ) { einfo->info->modified = true; SetFocus( einfo->win ); SetCapture( einfo->win ); einfo->key_info.ignore_first_key = ignore_first; einfo->getting_key = TRUE; } if( text != NULL ) { FreeRCString( text ); } return( ok ); }
/* * logSysInfo - record basic system info */ static void logSysInfo( bool wasfault ) { char *str; time_t tod; DWORD ver; SYSTEM_INFO sysinfo; char name[ MAX_COMPUTERNAME_LENGTH + 1 ]; DWORD bufsize; tod = time( NULL ); str = ctime( &tod ); if( wasfault ) { logPrintf( STR_FAULT_FOUND_ON_X, AppName, str ); } else { logPrintf( STR_LOG_TAKEN_ON_X, AppName, str ); } bufsize = sizeof( name ); GetComputerName( name, &bufsize ); logPrintf( STR_COMPUTER_NAME, name ); bufsize = sizeof( name ); GetUserName( name, &bufsize ); logPrintf( STR_USER_NAME, name ); #ifndef _WIN64 ver = GetVersion(); #ifdef CHICAGO // TEMPORARY FIX UNTIL WE CAN CHECK FOR WIN 95 logPrintf( STR_OPERATING_SYSTEM, "Windows 95" ); #else logPrintf( STR_OPERATING_SYSTEM, IsNT( ver ) ? "Windows NT":"Win32s" ); #endif logPrintf( STR_OS_VERSION, (int)GetMajVer( ver ), (int)GetMinVer( ver ) ); #else logPrintf( STR_OPERATING_SYSTEM, "Windows NT 64-bit" ); #endif GetSystemInfo( &sysinfo ); str = SrchMsg( sysinfo.dwProcessorType, ProcessorNames, NULL ); if( str == NULL ) { str = AllocRCString( STR_UNKNOWN ); logPrintf( STR_PROCESSOR_TYPE, str ); FreeRCString( str ); } else { logPrintf( STR_PROCESSOR_TYPE, str ); } logPrintf( STR_NUM_PROCESSORS, sysinfo.dwNumberOfProcessors ); }
bool WREQuerySaveSymOnDeleteRes( WREResInfo *res_info, bool fatal_exit ) { int ret; UINT style; char *text; char *file; HWND frame; if( WRENoInterface ) { return( TRUE ); } if( res_info == NULL || res_info->symbol_table == NULL ) { return( TRUE ); } if( WRIsHashTableDirty( res_info->symbol_table ) ) { if( fatal_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } WRECheckIfActiveWindow(); frame = WREGetMDIWindowHandle(); SendMessage( frame, WM_MDIRESTORE, (WPARAM)res_info->res_win, 0 ); SendMessage( frame, WM_MDIACTIVATE, (WPARAM)res_info->res_win, 0 ); file = WREGetQueryName( res_info ); text = AllocRCString( WRE_SAVEMODIFIEDSYM ); ret = MessageBox( res_info->res_win, text, file, style ); if( text != NULL ) { FreeRCString( text ); } if( ret == IDYES ) { if( res_info->symbol_file == NULL ) { res_info->symbol_file = WRECreateSymName( file ); } if( !WRESaveSymbols( res_info->symbol_table, &res_info->symbol_file, FALSE ) ) { return( FALSE ); } } else if( ret == IDCANCEL ) { return( FALSE ); } } return( TRUE ); }
char *WCreateEditTitle( WAccelEditInfo *einfo ) { char *title; char *fname; char *text; int offset; size_t len; title = NULL; fname = NULL; if( einfo == NULL ) { return( NULL ); } if( einfo->file_name == NULL ) { fname = einfo->info->file_name; } else { fname = einfo->file_name; } text = AllocRCString( W_ACCELAPPTITLE ); if( fname == NULL || text == NULL ) { return( NULL ); } offset = WRFindFnOffset( fname ); fname = &fname[offset]; len = strlen( fname ) + strlen( text ) + 6; title = (char *)WRMemAlloc( len ); if( title != NULL ) { strcpy( title, text ); strcat( title, " - [" ); strcat( title, fname ); strcat( title, "]" ); } if( text != NULL ) { FreeRCString( text ); } return( title ); }
bool WQuerySaveRes( WStringEditInfo *einfo, bool force_exit ) { int msg_ret; bool ret; UINT style; char *title; char *text; ret = true; if( einfo != NULL && einfo->info->modified ) { msg_ret = IDYES; if( einfo->info->stand_alone ) { if( force_exit ) { style = MB_YESNO | MB_APPLMODAL | MB_ICONEXCLAMATION; } else { style = MB_YESNOCANCEL | MB_APPLMODAL | MB_ICONEXCLAMATION; } title = WCreateEditTitle( einfo ); text = AllocRCString( W_UPDATEMODIFIEDSTRING ); msg_ret = MessageBox( einfo->edit_dlg, text, title, style ); if( text != NULL ) { FreeRCString( text ); } if( title != NULL ) { WRMemFree( title ); } } if( msg_ret == IDYES ) { if( einfo->info->stand_alone ) { ret = WSaveObject( einfo, FALSE, FALSE ); } else { SendMessage( einfo->info->parent, STRING_PLEASE_SAVEME, 0, (LPARAM)einfo->hndl ); } } else if( msg_ret == IDCANCEL ) { ret = false; } } return( ret ); }
/* * 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; } /* makePushWin */
bool WREDeleteStringResources( WRECurrentResInfo *curr, bool removing ) { WResTypeNode *tnode; char *text; bool ok; ok = true; if( !removing ) { text = AllocRCString( WRE_ALLSTRINGS ); ok = WREQueryDeleteName( text ); if( text != NULL ) { FreeRCString( text ); } } if( ok ) { tnode = curr->type; if( tnode == NULL ) { tnode = WRFindTypeNode( curr->info->info->dir, RESOURCE2INT( RT_STRING ), NULL ); } if( tnode != NULL ) { curr->info->modified = true; ok = WRRemoveTypeNodeFromDir( curr->info->info->dir, tnode ); } } // nuke any edit sessions on these string resources if( ok ) { curr->type = NULL; if( !removing ) { WREEndResStringSessions( curr->info ); } curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, 0 ); } return( ok ); }
void WSetEditTitle( WAccelEditInfo *einfo ) { char *title; bool is_rc; title = WCreateEditTitle( einfo ); is_rc = FALSE; if( title == NULL ) { title = AllocRCString( W_ACCELAPPTITLE ); is_rc = TRUE; } if( title != NULL ) { SendMessage( einfo->win, WM_SETTEXT, 0, (LPARAM)title ); if( is_rc ) { FreeRCString( title ); } else { WRMemFree( title ); } } }
/* * updateHintText - updated the text shown when a menu item is selected */ static void updateHintText( statwnd *wnd, msg_id msgid ) { HDC dc; HFONT font; char *str; HWND hint; HLOCAL hinfo; HintWndInfo *info; hint = GetHintHwnd( wnd ); dc = GetDC( hint ); font = GetMonoFont(); str = AllocRCString( msgid ); StatusWndDrawLine( wnd, dc, font, str, DT_LEFT | DT_SINGLELINE | DT_VCENTER ); ReleaseDC( hint, dc ); FreeRCString( str ); hinfo = GetProp( hint, HINT_PROP_ID ); info = LocalLock( hinfo ); info->curmsg = msgid; LocalUnlock( hinfo ); } /* updateHintText */
WResID *WRECreateAccTitle( void ) { char *text; char *title; WResID *name; WRENumAccTitles++; name = NULL; text = AllocRCString( WRE_DEFACCELNAME ); if( text != NULL ) { title = (char *)WRMemAlloc( strlen( text ) + 20 + 1 ); if( title != NULL ) { title[0] = '\0'; sprintf( title, text, WRENumAccTitles ); name = WResIDFromStr( title ); WRMemFree( title ); } FreeRCString( text ); } return( name ); }
UINT CALLBACK WREOpenHookProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { char *title; _wre_touch( wparam ); _wre_touch( lparam ); switch( msg ) { case WM_INITDIALOG: // We must call this to subclass the directory listbox even // if the app calls Ctl3dAutoSubclass (commdlg bug) //WRECtl3dSubclassDlg( hwnd, CTL3D_ALL ); title = AllocRCString( WRE_GETFNCOMBOTITLE ); if( title != NULL ) { SendDlgItemMessage( hwnd, stc2, WM_SETTEXT, 0, (LPARAM)title ); FreeRCString( title ); } return( TRUE ); } return( FALSE ); }
/* * getLogName - get a filename for the log and check if the file already exists */ static BOOL getLogName( char *buf, HWND hwnd ) { OPENFILENAME of; int rc; static char fname[LOG_MAX_FNAME]; static char filterList[] = "File (*.*)" \ "\0" \ "*.*" \ "\0\0"; strcpy( fname, LogCurInfo.config.name ); memset( &of, 0, sizeof( OPENFILENAME ) ); of.lStructSize = sizeof( OPENFILENAME ); of.hwndOwner = hwnd; of.lpstrFilter = (LPSTR)filterList; of.lpstrDefExt = NULL; of.nFilterIndex = 1L; of.lpstrFile = fname; of.nMaxFile = LOG_MAX_FNAME; of.lpstrTitle = AllocRCString( LOG_CHOOSE_LOG_NAME ); of.Flags = OFN_HIDEREADONLY; #ifndef NOUSE3D of.Flags |= OFN_ENABLEHOOK; of.lpfnHook = (LPOFNHOOKPROC)MakeOpenFileHookProcInstance( LogSaveHook, LogCurInfo.instance ); #endif rc = GetSaveFileName( &of ); #ifndef NOUSE3D FreeProcInstance( (FARPROC)of.lpfnHook ); #endif FreeRCString( (char *)of.lpstrTitle ); if( !rc ) { return( FALSE ); } strcpy( buf, fname ); return( TRUE ); } /* getLogName */
/* * ThreadCtlProc */ BOOL CALLBACK ThreadCtlProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { WORD cmd; ThreadCtlInfo *info; LRESULT index; char buf[200]; DWORD threadid; ThreadNode *thread; ProcNode *process; DWORD susp_cnt; DWORD rc; char *action; info = (ThreadCtlInfo *)GET_DLGDATA( hwnd ); switch( msg ) { case WM_INITDIALOG: info = MemAlloc( sizeof( ThreadCtlInfo ) ); if( !GetProcessInfo( lparam, &info->procinfo ) ) { RCsprintf( buf, STR_CANT_GET_PROC_INFO, info->procid ); MessageBox( hwnd, buf, AppName, MB_OK | MB_ICONEXCLAMATION ); SendMessage( hwnd, WM_CLOSE, 0, 0 ); } info->procid = lparam; ThreadDlg = hwnd; SET_DLGDATA( hwnd, info ); fillThreadCtl( hwnd, &info->procinfo, buf ); RCsprintf( buf, STR_THREAD_4_PROC_X, lparam ); SetDlgItemText( hwnd, THREAD_PROC_NAME, buf ); sprintf( buf, "(%s)", info->procinfo.name ); SetDlgItemText( hwnd, THREAD_PROC_PATH, buf ); SendDlgItemMessage( hwnd, THREAD_LIST, LB_SETCURSEL, 0, 0L ); index = SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETCURSEL, 0, 0L ); if( index != LB_ERR ) { enableChoices( hwnd, TRUE ); } fillThreadInfo( hwnd, &info->procinfo ); break; case WM_COMMAND: cmd = LOWORD( wparam ); if( cmd == THREAD_SUSPEND || cmd == THREAD_RESUME || cmd == THREAD_KILL || cmd == THREAD_SET_PRIORITY ) { index = SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETCURSEL, 0, 0L ); if( index == LB_ERR ) { RCMessageBox( hwnd, STR_NO_SELECTED_THREAD, AppName, MB_OK | MB_ICONEXCLAMATION ); break; } SendDlgItemMessage( hwnd, THREAD_LIST, LB_GETTEXT, (WPARAM)index, (LPARAM)(LPSTR)buf ); threadid = getThreadId( buf ); process = FindProcess( info->procinfo.pid ); thread = FindThread( process, threadid ); } switch( cmd ) { case IDOK: SendMessage( hwnd, WM_CLOSE, 0, 0L ); break; case THREAD_REFRESH: RefreshInfo(); if( GetProcessInfo( info->procid, &info->procinfo ) ) { fillThreadCtl( hwnd, &info->procinfo, buf ); fillThreadInfo( hwnd, &info->procinfo ); } else { action = AllocRCString( STR_REFRESH ); RCMessageBox( hwnd, STR_CANT_REFRESH_THRD, action, MB_OK | MB_ICONEXCLAMATION ); FreeRCString( action ); } break; case THREAD_SUSPEND: action = AllocRCString( STR_THREAD_SUSPEND ); if( thread == NULL ) { RCsprintf( buf, STR_CANT_GET_HDL_4_THD_X, threadid ); MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION ); } else { susp_cnt = SuspendThread( thread->threadhdl ); if( susp_cnt == -1 ) { RCsprintf( buf, STR_CANT_SUSPEND_THRD_X, threadid ); MessageBox( hwnd, buf, action, MB_ICONQUESTION | MB_OK ); } else if( susp_cnt > 0 ) { RCsprintf( buf, STR_THREAD_ALREADY_SUSP, threadid, susp_cnt ); index = MessageBox( hwnd, buf, action, MB_ICONQUESTION | MB_YESNO ); if( index == IDNO ) { ResumeThread( thread->threadhdl ); } } SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L ); } FreeRCString( action ); break; case THREAD_RESUME: action = AllocRCString( STR_RESUME ); if( thread == NULL ) { RCsprintf( buf, STR_THREAD_NOT_RESUMED , threadid ); MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION ); } else { susp_cnt = ResumeThread( thread->threadhdl ); if( susp_cnt == -1 ) { RCsprintf( buf, STR_CANT_RESUME_THRD_X, threadid ); MessageBox( hwnd, buf, action, MB_ICONEXCLAMATION | MB_OK ); } else if( susp_cnt == 0 ) { RCsprintf( buf, STR_THRD_IS_NOT_SUSP, threadid ); MessageBox( hwnd, buf, action, MB_ICONEXCLAMATION | MB_OK ); } else if( susp_cnt > 1 ) { RCsprintf( buf, STR_SUSP_COUNT_DECREMENTED, threadid, susp_cnt ); MessageBox( hwnd, buf, action, MB_ICONEXCLAMATION | MB_OK ); } SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L ); } FreeRCString( action ); break; case THREAD_KILL: action = AllocRCString( STR_KILL ); if( thread == NULL ) { RCsprintf( buf, STR_THRD_NOT_TERMINATED, threadid ); MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION ); } else if( GetRetCode( hwnd, RETCD_THREAD, thread->threadid, &rc ) ) { if( !TerminateThread( thread->threadhdl, rc ) ) { RCsprintf( buf, STR_CANT_KILL_THRD_X, threadid ); MessageBox( hwnd, buf, action, MB_OK | MB_ICONEXCLAMATION ); } SendMessage( hwnd, WM_COMMAND, THREAD_REFRESH, 0L ); } FreeRCString( action ); break; case THREAD_SET_PRIORITY: // { // ThreadPriorityInfo prinfo; // // if( thread == NULL ) { // sprintf( buf, "Unable to get a handle for thread %08X.\n", // threadid ); // MessageBox( hwnd, buf, "Set Priority", // MB_OK | MB_ICONEXCLAMATION ); // } else { // prinfo.procid = info->procid; // prinfo.thread = thread; // prinfo.priority = GetThreadPriority( thread->threadhdl ); // prinfo.procinfo = &info->procinfo; // DialogBoxParam( Instance, "THREAD_PRIORITY_DLG", hwnd, // ThreadPriorityDlgProc, (DWORD)&prinfo ); // fillThreadInfo( hwnd, &info->procinfo ); // } // } // break; case THREAD_LIST: if( HIWORD( wparam ) == LBN_SELCHANGE ) { fillThreadInfo( hwnd, &info->procinfo ); } break; } break; case DR_TASK_LIST_CHANGE: /* make sure this process still exists */ //here if( FindProcess( info->procid ) == NULL ) { //here SendDlgItemMessage( hwnd, THREAD_LIST, LB_RESETCONTENT, 0, 0L ); //here enableChoices( hwnd, FALSE ); //here info->proc = NULL; //here } else { //here fillThreadCtl( hwnd, info->proc, buf ); //here } break; case WM_CLOSE: EndDialog( hwnd, 0 ); break; case WM_DESTROY: MemFree( info ); ThreadDlg = NULL; break; default: return( FALSE ); } return( TRUE ); }