static void getOneFile( HWND dlg, char **files, int *count, bool leave ) { int i, j; HWND list_box; #ifdef __NT__ LVITEM lvi; #endif list_box = GetDlgItem( dlg, ID_FILE_LIST ); #ifdef __NT__ if( IsCommCtrlLoaded() ) { i = SendMessage( list_box, LVM_GETNEXTITEM, (WPARAM)-1, LVNI_SELECTED ); } else { #endif i = SendMessage( list_box, LB_GETCURSEL, 0, 0L ); #ifdef __NT__ } #endif getFile( files[i] ); if( leave ) { EndDialog( dlg, ERR_NO_ERR ); } else { /* remove it from the list box */ #ifdef __NT__ if( IsCommCtrlLoaded() ) { SendMessage( list_box, LVM_DELETEITEM, i, 0L ); lvi.stateMask = LVIS_SELECTED; lvi.state = LVIS_SELECTED; if( !SendMessage( list_box, LVM_SETITEMSTATE, i, (LPARAM)&lvi ) ) { SendMessage( list_box, LVM_SETITEMSTATE, i - 1, (LPARAM)&lvi ); } } else { #endif j = SendMessage( list_box, LB_DELETESTRING, i, 0L ); assert( (j + 1) == (*count) ); if( SendMessage( list_box, LB_SETCURSEL, i, 0L ) == LB_ERR ) { SendMessage( list_box, LB_SETCURSEL, i - 1, 0L ); } #ifdef __NT__ } #endif MemFree( files[i] ); for( j = i; j < *count; j++ ) { files[j] = files[j + 1]; } (*count)--; if( *count == 0 ) { EndDialog( dlg, ERR_NO_ERR ); } } }
/* * StatusWndGetHeight - get the height of the status window for Win32 native status bars */ int StatusWndGetHeight( statwnd *sw ) { #ifdef __NT__ if( IsCommCtrlLoaded() ) { return( sw->wndHeight ); } #endif return( 0 ); }
void WdeEnableCommonControlsMenu( HMENU menu ) { int i; i = WdeIsCurrentMDIWindowZoomed() ? 1 : 0; menu = GetSubMenu( menu, TOOLS_MENU + i ); menu = GetSubMenu( menu, COMM_CTRL_MENU ); WdeEnableAllMenuItems( menu, IsCommCtrlLoaded() ); }
/* * StatusWndSetSeparators - set the separator list */ void StatusWndSetSeparators( statwnd *sw, int num_items, status_block_desc *list ) { int i; if( num_items > MAX_SECTIONS ) { num_items = MAX_SECTIONS; } for( i = 0; i < num_items; i++ ) { sw->sectionDesc[i] = list[i]; } sw->numSections = num_items; #ifdef __NT__ if( IsCommCtrlLoaded() && sw->win != NULL ) { updateParts( sw ); } #endif } /* StatusWndSetSeparators */
/* * StatusWndChangeSysColors - fiddle with what StatusWnd believes * are the system colors */ void StatusWndChangeSysColors( COLORREF btnFace, COLORREF btnText, COLORREF btnHighlight, COLORREF btnShadow ) { #ifdef __NT__ if( !IsCommCtrlLoaded() ) { #endif if( hasGDIObjects ) { _wpi_deleteobject( penLight ); _wpi_deleteobject( penShade ); _wpi_deleteobject( brushButtonFace ); } colorButtonFace = btnFace; colorTextFace = btnText; brushButtonFace = _wpi_createsolidbrush( btnFace ); penLight = _wpi_createpen( PS_SOLID, 1, btnHighlight ); penShade = _wpi_createpen( PS_SOLID, 1, btnShadow ); hasGDIObjects = true; #ifdef __NT__ } #endif }
bool WdeInitControls( HINSTANCE inst ) { bool usingCommonControls; int i; WdeControlsInfo = WdeAllocToolBarInfo( NUM_TOOLS ); if( WdeControlsInfo == NULL ) { return( false ); } usingCommonControls = IsCommCtrlLoaded(); for( i = 0; i < NUM_TOOLS; i++ ) { if( WdeControlBits[i].flags & WCB_FLAG_COMMON_CONTROL ) { if( !usingCommonControls ) { continue; } } WdeControlsInfo->items[i].u.bmp = LoadBitmap( inst, WdeControlBits[i].up ); WdeControlsInfo->items[i].id = WdeControlBits[i].id; WdeControlsInfo->items[i].flags = ITEM_DOWNBMP | ITEM_STICKY; WdeControlsInfo->items[i].depressed = LoadBitmap( inst, WdeControlBits[i].down ); } WdeControlsInfo->dinfo.button_size.x = BUTTONX + BUTTON_PAD; WdeControlsInfo->dinfo.button_size.y = BUTTONY + BUTTON_PAD; WdeControlsInfo->dinfo.border_size.x = TOOL_BORDERX; WdeControlsInfo->dinfo.border_size.y = TOOL_BORDERY; WdeControlsInfo->dinfo.style = WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME; WdeControlsInfo->dinfo.hook = wdeControlsHook; WdeControlsInfo->dinfo.helphook = wdeCToolHelpHook; WdeControlsInfo->dinfo.foreground = NULL; WdeControlsInfo->dinfo.background = LoadBitmap( inst, "WdeToolBk" ); WdeControlsInfo->dinfo.is_fixed = FALSE; return( true ); }
/* * SpyOut - display spy message */ void SpyOut( char *msg, LPMSG pmsg ) { static int i; char res[SPYOUT_LENGTH + 1]; #ifdef __NT__ LVITEM lvi; char hwnd_str[SPYOUT_HWND_LEN + 1]; char msg_str[SPYOUT_MSG_LEN + 1]; char wparam_str[SPYOUT_WPARAM_LEN + 1]; char lparam_str[SPYOUT_LPARAM_LEN + 1]; #endif if( SpyMessagesPaused ) { return; } if( pmsg != NULL ) { FormatSpyMessage( msg, pmsg, res ); } else { strcpy( res, msg ); } SpyLogOut( res ); #ifdef __NT__ if( IsCommCtrlLoaded() ) { lvi.mask = LVIF_TEXT; lvi.iItem = SendMessage( SpyListBox, LVM_GETITEMCOUNT, 0, 0L ); lvi.iSubItem = 0; lvi.pszText = msg; SendMessage( SpyListBox, LVM_INSERTITEM, 0, (LPARAM)&lvi ); if( pmsg != NULL ) { GetHexStr( hwnd_str, (DWORD)(pointer_int)pmsg->hwnd, SPYOUT_HWND_LEN ); hwnd_str[SPYOUT_HWND_LEN] = '\0'; GetHexStr( msg_str, pmsg->message, SPYOUT_MSG_LEN ); msg_str[SPYOUT_MSG_LEN] = '\0'; GetHexStr( wparam_str, pmsg->wParam, SPYOUT_WPARAM_LEN ); wparam_str[SPYOUT_WPARAM_LEN] = '\0'; GetHexStr( lparam_str, pmsg->lParam, SPYOUT_LPARAM_LEN ); lparam_str[SPYOUT_LPARAM_LEN] = '\0'; lvi.iSubItem = 1; lvi.pszText = hwnd_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 2; lvi.pszText = msg_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 3; lvi.pszText = wparam_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 4; lvi.pszText = lparam_str; SendMessage( SpyListBox, LVM_SETITEM, 0, (LPARAM)&lvi ); } if( SpyMessagesAutoScroll ) { SendMessage( SpyListBox, LVM_ENSUREVISIBLE, lvi.iItem, FALSE ); } } else { #endif i = (int)SendMessage( SpyListBox, LB_ADDSTRING, 0, (LPARAM)(LPSTR)res ); if( SpyMessagesAutoScroll ) { SendMessage( SpyListBox, LB_SETCURSEL, i, 0L ); } #ifdef __NT__ } #endif } /* SpyOut */
/* * fileGrep - search a single dir and build list of files */ static void fileGrep( char *dir, char **list, int *clist, window_id wn ) { char fn[FILENAME_MAX], data[FILENAME_MAX], ts[FILENAME_MAX]; char path[FILENAME_MAX]; char drive[_MAX_DRIVE], directory[_MAX_DIR], name[_MAX_FNAME]; char ext[_MAX_EXT]; int i; #if defined( __WIN__ ) && defined( __NT__ ) LVITEM lvi; #endif vi_rc rc; /* * get file path prefix */ _splitpath( dir, drive, directory, name, ext ); strcpy( path, drive ); strcat( path, directory ); // _makepath( path, drive, directory, NULL,NULL ); /* * run through each entry and search it; building a list of matches */ rc = GetSortDir( dir, FALSE ); if( rc != ERR_NO_ERR ) { return; } for( i = 0; i < DirFileCount; i++ ) { if( !(DirFiles[i]->attr & _A_SUBDIR ) ) { strcpy( fn, path ); strcat( fn, DirFiles[i]->name ); #ifdef __WIN__ EditFlags.BreakPressed = SetGrepDialogFile( fn ); #else DisplayLineInWindow( wn, 1, fn ); #endif if( EditFlags.BreakPressed ) { return; } if( isFgrep ) { rc = fSearch( fn, ts ); } else { rc = eSearch( fn, ts ); } if( rc == FGREP_FOUND_STRING ) { ExpandTabsInABuffer( ts, strlen( ts ), data, MAX_DISP ); strcpy( ts, data ); MySprintf( data, "%X \"%s\"", fn, ts ); #ifdef __WIN__ /* * for windows - the handle passed in is the list box * and the entire string is added to it but only the file * name is added to the list */ #ifdef __NT__ if( IsCommCtrlLoaded() ) { lvi.mask = LVIF_TEXT; lvi.iItem = SendMessage( wn, LVM_GETITEMCOUNT, 0, 0L ); lvi.iSubItem = 0; lvi.pszText = fn; SendMessage( wn, LVM_INSERTITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 1; lvi.pszText = ts; SendMessage( wn, LVM_SETITEM, 0, (LPARAM)&lvi ); } else { #endif SendMessage( wn, LB_ADDSTRING, 0, (LPARAM)data ); MySprintf( data, "%X", fn ); #ifdef __NT__ } #endif #endif AddString( &(list[*clist]), data ); (*clist)++; } else if( rc != ERR_NO_ERR ) { return; } } } } /* fileGrep */
/* * StatusWndDrawLine - draws a line in the status bar */ void StatusWndDrawLine( statwnd *sw, WPI_PRES pres, WPI_FONT hfont, const char *str, UINT flags ) { WPI_RECT rect; char buff[256]; char *bptr; int curr_block; curr_block = 0; #ifdef __NT__ hfont = hfont; sw->sectionDataFont = systemDataFont; #else sw->sectionDataFont = hfont; #endif #ifdef __NT__ if( !IsCommCtrlLoaded() ) { #endif if( !initPRES( sw, pres ) ) { return; } getRect( sw, &rect, curr_block ); makeInsideRect( &rect ); bptr = (char *)str; if( flags == DT_ESC_CONTROLLED ) { flags = DT_VCENTER | DT_LEFT; bptr = buff; while( *str != '\0' ) { if( *str == STATUS_ESC_CHAR ) { str++; switch( *str ) { case STATUS_NEXT_BLOCK: *bptr = '\0'; outputText( sw, pres, buff, &rect, flags, curr_block ); curr_block++; getRect( sw, &rect, curr_block ); makeInsideRect( &rect ); flags = DT_VCENTER | DT_LEFT; bptr = buff; break; case STATUS_FORMAT_CENTER: flags &= ~(DT_RIGHT | DT_LEFT); flags |= DT_CENTER; break; case STATUS_FORMAT_RIGHT: flags &= ~(DT_CENTER | DT_LEFT); flags |= DT_RIGHT; break; case STATUS_FORMAT_LEFT: flags &= ~(DT_CENTER | DT_RIGHT); flags |= DT_LEFT; break; } } else { *bptr++ = *str; } str++; } *bptr = '\0'; bptr = buff; } outputText( sw, pres, bptr, &rect, flags, curr_block ); finiPRES( pres ); #ifdef __NT__ } else { bptr = (char *)str; if( flags == DT_ESC_CONTROLLED ) { bptr = buff; while( *str != '\0' ) { if( *str == STATUS_ESC_CHAR ) { str++; if( *str == STATUS_NEXT_BLOCK ) { *bptr = '\0'; if( strlen( buff ) > 0 ) { SendMessage( sw->win, SB_SETTEXT, curr_block, (LPARAM)buff ); } curr_block++; bptr = buff; } } else { *bptr++ = *str; } str++; } *bptr = '\0'; bptr = buff; } if( strlen( bptr ) > 0 ) { SendMessage( sw->win, SB_SETTEXT, curr_block, (LPARAM)bptr ); } } #endif } /* StatusWndDrawLine */
/* * StatusWndCreate - create the status window */ HWND StatusWndCreate( statwnd *sw, HWND parent, WPI_RECT *size, WPI_INST hinstance, LPVOID lpvParam ) { #ifndef __OS2_PM__ /* Win16 and Win32 version of creation */ currentStatWnd = sw; #ifdef __NT__ if( IsCommCtrlLoaded() ) { sw->win = CreateWindow( STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBARS_SIZEGRIP, 0, 0, 0, 0, parent, NULL, hinstance, NULL ); GetWindowRect( sw->win, size ); if( sw->numSections > 0 ) { updateParts( sw ); } #ifndef _WIN64 } else if( LOBYTE( LOWORD( GetVersion() ) ) < 4 ) { sw->win = CreateWindow( className, NULL, WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS, size->left, size->top, size->right - size->left, size->bottom - size->top, parent, (HMENU)NULL, hinstance, lpvParam ); #endif } else { sw->win = CreateWindow( className, NULL, WS_CHILD, size->left, size->top, size->right - size->left, size->bottom - size->top, parent, (HMENU)NULL, hinstance, lpvParam ); } #else sw->win = CreateWindow( className, NULL, WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS, size->left, size->top, size->right - size->left, size->bottom - size->top, parent, (HMENU)NULL, hinstance, lpvParam ); #endif if( sw->win != NULL ) { #ifdef __NT__ #ifndef _WIN64 if( LOBYTE( LOWORD( GetVersion() ) ) < 4 ) { systemDataFont = (HFONT)GetStockObject( SYSTEM_FONT ); } else { #endif /* New shell active, Win95 or later */ systemDataFont = (HFONT)GetStockObject( DEFAULT_GUI_FONT ); #ifndef _WIN64 } #endif #endif ShowWindow( sw->win, SW_SHOWNORMAL ); UpdateWindow( sw->win ); } #else /* OS/2 PM version of creation */ ULONG flags; hinstance = hinstance; lpvParam = lpvParam; flags = FCF_BORDER; currentStatWnd = sw; sw->win = WinCreateStdWindow( parent, WS_VISIBLE, &flags, className, "", 0L, (HMODULE)0, 10, NULL ); if( sw->win != NULLHANDLE ) { WinSetWindowPos( sw->win, HWND_TOP, size->xLeft, size->yBottom, size->xRight - size->xLeft, size->yTop - size->yBottom, SWP_SIZE | SWP_MOVE | SWP_SHOW ); } #endif sw->wndHeight = _wpi_getheightrect( *size ); return( sw->win ); } /* StatusWndCreate */