bool WdeRemoveResource( WdeResInfo *res_info ) { LIST *node; if( WdeResList == NULL ) { return( FALSE ); } if( (node = ListFindElt( WdeResList, res_info )) != NULL ) { ListRemoveElt( &WdeResList, (void *)ListElement( node ) ); } else { WdeWriteTrail( "WdeRemoveResource: res_info not found!" ); return( FALSE ); } if( WdeGetNumRes() == 1 ) { WdeOldStickyMode = WdeSetStickyMode( FALSE ); WdeSetBaseObject( IDM_SELECT_MODE ); } WdeFreeResInfo( res_info ); if( WdeGetNumRes() == 1 ) { WdeSetAppMenuToRes( FALSE ); } WdeDecNumRes(); return( TRUE ); }
bool WdeCreateResourceWindow( WdeResInfo *res_info, int fn_offset, char *title ) { MDICREATESTRUCT mdics; LRESULT ret; HWND win; bool ok; bool old; DWORD style; RECT r; HMENU sys_menu; char *win_title; int win_title_len; _wde_touch( fn_offset ); WdeIncNumRes(); style = 0; if( WdeGetNumRes() == 1 ) { WdeSetAppMenuToRes( TRUE ); old = WdeSetStickyMode( WdeOldStickyMode ); style = WS_MAXIMIZE; } else { if( WdeIsCurrentMDIWindowZoomed() ) { style = WS_MAXIMIZE; } } mdics.szClass = "WdeResClass"; win_title = NULL; if( title == NULL ) { if( res_info->info->file_name ) { // perhaps make this an option //title = &res_info->info->file_name[fn_offset]; mdics.szTitle = res_info->info->file_name; } else { WdeResCounter++; win_title_len = strlen( WdeResUntitled ) + 7; win_title = (char *)WRMemAlloc( win_title_len ); sprintf( win_title, "%s.%d", WdeResUntitled, 0xffff & WdeResCounter ); mdics.szTitle = win_title; } } else { mdics.szTitle = title; } win = WdeGetMDIWindowHandle(); GetClientRect( win, &r ); mdics.hOwner = WdeGetAppInstance(); mdics.x = CW_USEDEFAULT; mdics.y = CW_USEDEFAULT; mdics.cx = CW_USEDEFAULT; mdics.cy = CW_USEDEFAULT; //mdics.cx = r.right - r.left; //mdics.cy = r.bottom - r.top; mdics.style = style; mdics.lParam = (LPARAM)res_info; ret = SendMessage( win, WM_MDICREATE, 0, (LPARAM)&mdics ); if( win_title != NULL ) { WRMemFree( win_title ); } #ifdef __NT__ win = (HWND)ret; #else win = (HWND)LOWORD( ret ); #endif ok = (res_info->res_win != NULL && res_info->res_win == win); if( !ok ) { WdeWriteTrail( "WdeCreateResourceWindow: Bad window handle!" ); } if( WdeIsDDE() ) { sys_menu = GetSystemMenu( win, FALSE ); if( sys_menu != (HMENU)NULL ) { EnableMenuItem( sys_menu, SC_CLOSE, MF_GRAYED ); } } if( ok ) { ok = WdeCreateEditWindows( res_info ); if( !ok ) { WdeWriteTrail( "WdeCreateResourceWindow: Could not create edit windows!" ); } } if( ok ) { OpenFormEdit( res_info->forms_win, WdeGetCreateTable(), MENU_NONE, SCROLL_NONE ); WdeSetEditMode( res_info, TRUE ); SetHorizontalInc( 1 ); SetVerticalInc( 1 ); InitState( res_info->forms_win ); SetMouseRtn( res_info->forms_win, WdeMouseRtn ); //MakeObjectCurrent( GetMainObject() ); } else { if( WdeGetNumRes() == 1 ) { WdeSetAppMenuToRes( FALSE ); WdeSetStickyMode( old ); } WdeDecNumRes(); } return( ok ); }
bool WdeCreateControlsToolBar( void ) { RECT t, r, screen; HWND parent; int id; char *text; if( WdeControls != NULL ) { return ( true ); } WdeSetStatusText( NULL, "", false ); WdeSetStatusByID( WDE_CREATINGTOOLBOX, 0 ); parent = WdeGetMainWindowHandle(); WdeGetCntlTBarPosOption( &t ); if( t.left == t.right && t.top == t.bottom ) { GetWindowRect( parent, &r ); #ifdef __NT__ if( GetModuleHandle( "COMCTL32.DLL" ) == NULL ) { #endif t.left = r.right - CONTROLS_DEFX; t.top = r.top + CONTROLS_INSET; t.right = r.right; t.bottom = t.top + CONTROLS_DEFY; #ifdef __NT__ } else { t.left = r.right - CONTROLS_DEFXCC; t.top = r.top + CONTROLS_INSET; t.right = r.right; t.bottom = t.top + CONTROLS_DEFYCC; } #endif } GetWindowRect( GetDesktopWindow(), &screen ); if( !IntersectRect( &r, &screen, &t ) ) { r.right = t.right - t.left; r.bottom = t.bottom - t.top; r.left = 0; if( screen.right > r.right ) r.left = ( screen.right - r.right ) / 2; r.top = 0; if( screen.bottom - screen.top - r.bottom > 0 ) r.top = ( screen.bottom - screen.top - r.bottom ) / 2; r.right += r.left; r.bottom += r.top; t = r; } WdeControlsInfo->dinfo.area = t; WdeControls = WdeCreateToolBar( WdeControlsInfo, parent ); if( WdeControls == NULL ) { return( false ); } text = WdeAllocRCString( WDE_TOOLBOXCAPTION ); SendMessage( WdeControls->win, WM_SETTEXT, 0, (LPARAM)(LPCSTR)text ); if( text != NULL ) { WdeFreeRCString( text ); } text = WdeAllocRCString( WDE_HIDETOOLBOX ); ModifyMenu ( WdeGetInitialMenuHandle(), IDM_SHOW_TOOLS, MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text ); ModifyMenu ( WdeGetResMenuHandle(), IDM_SHOW_TOOLS, MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text ); if( text != NULL ) { WdeFreeRCString( text ); } if( WdeGetNumRes() ) { id = WdeGetMenuFromOBJID( GetBaseObjType() ); if( id != -1 ) { WdeSetToolBarItemState( WdeControls, id, BUTTON_DOWN ); } WdeSetStickyMode( WdeStickyMode ); } WdeSetStatusReadyText(); return( true ); }
void WdeToggleStickyTools( void ) { if( WdeGetNumRes() ) { WdeSetStickyMode( !WdeStickyMode ); } }