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 ); }
void WdeSetBaseObject( int menu_selection ) { HMENU menu; OBJ_ID obj_id; int id; WdeToolBar *tbar; if( WdeGetNumRes() == 0 ) { return; } tbar = WdeControls; menu = WdeGetResMenuHandle(); id = WdeGetCToolID(); obj_id = -1; if( id != -1 && id != menu_selection ) { CheckMenuItem( menu, id, MF_BYCOMMAND | MF_UNCHECKED ); WdeSetToolBarItemState( tbar, id, BUTTON_UP ); } if( menu_selection != -1 ) { obj_id = WdeGetOBJIDFromMenu( menu_selection ); if( obj_id != -1 ) { SetBaseObjType( obj_id ); CheckMenuItem( menu, menu_selection, MF_BYCOMMAND | MF_CHECKED ); WdeSetToolBarItemState( tbar, menu_selection, BUTTON_DOWN ); WdeSetStatusText( NULL, "", true ); } } }
bool WdeSetStickyMode( bool mode ) { HMENU menu; bool old_mode; if( WdeGetNumRes() == 0 ) { return( false ); } menu = WdeGetResMenuHandle(); old_mode = WdeStickyMode; WdeStickyMode = mode; if( WdeStickyMode ) { WdeSetToolBarItemState( WdeControls, IDM_STICKY_TOOLS, BUTTON_DOWN ); CheckMenuItem( menu, IDM_STICKY_TOOLS, MF_BYCOMMAND | MF_CHECKED ); } else { WdeSetToolBarItemState( WdeControls, IDM_STICKY_TOOLS, BUTTON_UP ); CheckMenuItem( menu, IDM_STICKY_TOOLS, MF_BYCOMMAND | MF_UNCHECKED ); } WdeSetStatusText( NULL, "", true ); return( old_mode ); }
Bool WdeDeleteAllObjects( void ) { OBJPTR base; OBJPTR child; if( !WdeGetNumRes() ) { return( FALSE ); } child = NULL; base = GetMainObject(); if( base == NULL ) { return( FALSE ); } Forward( base, GET_FIRST_CHILD, &child, NULL ); while( child != NULL ) { MakeObjectCurrent( child ); Destroy( child, FALSE ); Forward( base, GET_FIRST_CHILD, &child, NULL ); } MakeObjectCurrent( base ); return( TRUE ); }
static void handleInitMenu( HMENU menu ) { WdeEnableCommonControlsMenu( menu ); WdeEnableSelectCustCntl( menu ); WdeEnableCustCntlTools( menu ); if( WdeGetNumRes() ) { WdeEnablePasteItem( menu ); } }
void WdeHandleTabEvent( bool up ) { OBJPTR obj; if( !WdeGetNumRes() ) { return; } if( (obj = WdeGetNextObject( up, NULL, NULL )) != NULL ) { MakeObjectCurrent( obj ); HideSelectBoxes(); WdeHandleGotoCurrentObject(); ShowSelectBoxes(); } }
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow ) { MSG msg; #ifndef __NT__ #if 0 HWND win; HWND child; #endif #endif /* touch unused vars to get rid of warning */ _wde_touch( lpszCmdLine ); _wde_touch( nCmdShow ); #ifdef __NT__ _wde_touch( hinstPrevious ); #endif #if defined( __NT__ ) && !defined( __WATCOMC__ ) _argc = __argc; _argv = __argv; #endif WRInit(); WdeInitDisplayError( hinstCurrent ); /* store the handle to this instance of Wde in a static variable */ hInstWde = hinstCurrent; //check we are running in DDE mode IsDDE = WdeIsDDEArgs( _argv, _argc ); WdeFirstInst = (hinstPrevious == NULL); WdeInitEditClass(); /* is this the first instance of the application? */ #ifndef __NT__ if( WdeFirstInst ) { #endif /* if so call the routine to initialize the application */ if( !WdeInit( hinstCurrent ) ) { if( IsDDE ) { WdeDDEDumpConversation( hinstCurrent ); } return( FALSE ); } #ifndef __NT__ } #if 0 else if( IsDDE ) { WdeDisplayErrorMsg( WDE_NOMULTIPLEINSTANCES ); WdeDDEDumpConversation( hinstCurrent ); return( FALSE ); } else { win = FindWindow( WdeMainClass, NULL ); if( win != NULL ) { child = GetLastActivePopup( win ); PostMessage( win, WM_USER, 0, 0 ); BringWindowToTop( win ); if( child != (HWND)NULL && child != win ) { BringWindowToTop( child ); } } else { WdeDisplayErrorMsg( WDE_NOMULTIPLEINSTANCES ); } return( FALSE ); } #endif #endif if( !WdeInitInst( hinstCurrent ) ) { WdeDisplayErrorMsg( WDE_INITFAILED ); if( IsDDE ) { WdeDDEDumpConversation( hinstCurrent ); } return( FALSE ); } if( IsDDE ) { if( WdeDDEStart( hinstCurrent ) ) { if( !WdeDDEStartConversation() ) { WdeDisplayErrorMsg( WDE_DDEINITFAILED ); PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 ); } } else { WdeDisplayErrorMsg( WDE_DDEINITFAILED ); PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 ); } } WdeEnableMenuInput( TRUE ); if( setjmp( WdeEnv ) ) { PostMessage( hWinWdeMain, WDE_FATAL_EXIT, 0, 0 ); if( setjmp( WdeEnv ) ) { WdeDisplayErrorMsg( WDE_EXCEPTIONDURINGABNORMALEXIT ); exit( -1 ); } WdePushEnv( &WdeEnv ); } else { WdePushEnv( &WdeEnv ); WdeProcessArgs( _argv, _argc ); } if( !WdeGetNumRes() ) { WdeCreateNewResource( NULL ); } /* create the message loop */ while( GetMessage( &msg, (HWND)NULL, 0, 0 ) ) { if( !WdeIsTestMessage( &msg ) && !WdeIsInfoMessage( &msg ) && !WRIsWRDialogMsg( &msg ) ) { if( !WdeWasAcceleratorHandled( &msg ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } } if( IsDDE ) { WdeDDEEndConversation(); } WdePopEnv( &WdeEnv ); if( IsDDE ) { WdeDDEEnd(); } WRFini(); return( msg.wParam ); }
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 ); }
static bool wdeControlsHook( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { MINMAXINFO *minmax; WdeToolBar *tbar; OBJ_ID obj_id; WORD id; char *text; OBJPTR obj; WdeOrderMode mode; ctl_id cid; bool ignore_msg; bool ret; ignore_msg = FALSE; if( WdeGetNumRes() && !WdeInCleanup() ) { obj = WdeGetCurrentDialog(); if( obj != NULL && Forward( obj, GET_ORDER_MODE, &mode, NULL ) && mode != WdeSelect ) { ignore_msg = TRUE; } } if( !ignore_msg && WdeGetTestMode() ) { ignore_msg = TRUE; } if( ignore_msg ) { switch( msg ) { case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: case WM_RBUTTONUP: case WM_LBUTTONUP: return( true ); } } if( (tbar = WdeControls) == NULL ) { if( msg == WM_GETMINMAXINFO ) { minmax = (MINMAXINFO *)lParam; minmax->ptMinTrackSize.x = 8; } return( false ); } ret = false; switch( msg ) { case WM_USER: if( WdeGetNumRes() ) { obj_id = GetBaseObjType(); id = WdeGetMenuFromOBJID( obj_id ); if( id == wParam || (wParam == IDM_STICKY_TOOLS && WdeStickyMode) ) { lParam = !lParam; } WdeHandleStickyToolPress( tbar, wParam, lParam ); } break; case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: if( FindToolIDAtPoint( tbar->tbar, wParam, lParam, &cid ) ) { if( cid == IDM_CUSTOM1_TOOL ) { ret = !WdeIsCurrentCustControlSet( 0 ); } else if( cid == IDM_CUSTOM2_TOOL ) { ret = !WdeIsCurrentCustControlSet( 1 ); } } break; case WM_SIZE: if ( wParam != SIZE_MAXIMIZED && wParam != SIZE_MINIMIZED ) { GetWindowRect( hwnd, &tbar->last_pos ); } break; case WM_MOVE: if( !IsZoomed( hwnd ) ) { GetWindowRect( hwnd, &tbar->last_pos ); } break; case WM_GETMINMAXINFO: if( GetModuleHandle( "COMCTL32.DLL" ) == NULL ) { minmax = (MINMAXINFO *)lParam; minmax->ptMinTrackSize.x = 2 * GetSystemMetrics( SM_CXFRAME ) + tbar->info->dinfo.border_size.x + tbar->info->dinfo.button_size.x - 1; minmax->ptMinTrackSize.y = 2 * GetSystemMetrics( SM_CYFRAME ) + GetSystemMetrics(SM_CYCAPTION) + tbar->info->dinfo.border_size.y + tbar->info->dinfo.button_size.y - 1; ret = true; } break; case WM_CLOSE: WdeDestroyControls(); WdeSetOption ( WdeOptIsCntlsTBarVisible, FALSE ); ret = true; break; case WM_DESTROY: WdeControls = NULL; WdeSetCntlTBarPosOption( &tbar->last_pos ); text = WdeAllocRCString( WDE_SHOWTOOLBOX ); ModifyMenu( WdeGetResMenuHandle(), IDM_SHOW_TOOLS, MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text ); ModifyMenu( WdeGetInitialMenuHandle(), IDM_SHOW_TOOLS, MF_BYCOMMAND | MF_STRING, IDM_SHOW_TOOLS, text ); if( text != NULL ) { WdeFreeRCString( text ); } WdeCloseToolBar( tbar ); break; } return( ret ); }
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 ); } }