Bool WInit( HINSTANCE inst ) { Bool ok; ok = (inst != (HINSTANCE)NULL); if( ok ) { WCtl3DInit( inst ); ok = JDialogInit(); } if( ok ) { ok = WRegisterMainClass( inst ); } if( ok ) { ok = WRegisterPrevClass( inst ); } if( ok ) { ok = WInitStatusLines( inst ); } if( ok ) { WClipbdFormat = RegisterClipboardFormat( WR_CLIPBD_MENU ); ok = (WClipbdFormat != 0); } if( ok ) { WItemClipbdFormat = RegisterClipboardFormat( WItemClipbdFmt ); ok = (WItemClipbdFormat != 0); } if( ok ) { GetConfigFilePath( WProfileName, sizeof( WProfileName ) ); strcat( WProfileName, "\\" WATCOM_INI ); WInitOpts( WProfileName, WSectionName ); WInitEditWindows( inst ); ok = WInitRibbons( inst ); } return( ok ); }
/* * everyInstInit - do initialization required by every instance of the spy */ static BOOL everyInstInit( int cmdshow ) { MemStart(); JDialogInit(); ReadConfig(); #ifndef NOUSE3D CvrCtl3DInit( Instance ); CvrCtl3dRegister( Instance ); CvrCtl3dAutoSubclass( Instance ); #endif HintWndInit( Instance, NULL, 0 ); DDEMainWnd = CreateWindow( MAIN_CLASS, /* Window class name */ AppName, /* Window caption */ WS_OVERLAPPEDWINDOW, /* Window style */ MainWndConfig.xpos, /* Initial X position */ MainWndConfig.ypos, /* Initial Y position */ MainWndConfig.xsize, /* Initial X size */ MainWndConfig.ysize, /* Initial Y size */ NULL, /* Parent window handle */ NULL, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ if( DDEMainWnd == NULL ) { return( FALSE ); } if( !CreateTrackWnd() ) { return( FALSE ); } InitTrackWnd( DDEMainWnd ); ShowWindow( DDEMainWnd, cmdshow ); UpdateWindow( DDEMainWnd ); return( TRUE ); } /* everyInstInit */
/* Function to initialize all instances of Wde */ bool WdeInitInst( HINSTANCE app_inst ) { RECT rect, screen, t; char *title; /* initialize global variables */ WdeInitOpts(); if( !JDialogInit() ) { return( FALSE ); } if( !WdeInitResStrings() ) { return( FALSE ); } if( !WdeInitCreateTable() ) { WdeDisplayErrorMsg( WDE_NOINITCONTROLOBJECTS ); return( FALSE ); } WdeCtl3DInit( app_inst ); WdeGetScreenPosOption( &rect ); /* load the accelerator table */ WdeAccel = LoadAccelerators( app_inst, "WdeAccelTable"); /* if the window could not be created return FALSE */ if( WdeAccel == (HACCEL)NULL ) { WdeDisplayErrorMsg( WDE_LOADACCELFAILED ); return( FALSE ); } GetWindowRect( GetDesktopWindow(), &screen ); if( !IntersectRect( &t, &screen, &rect ) ) { t.right = rect.right - rect.left; t.bottom = rect.bottom - rect.top; t.left = 0; if( screen.right - screen.left - t.right > 0 ) t.left = ( screen.right - screen.left - t.right ) / 2; t.top = 0; if( screen.bottom - screen.top - t.bottom > 0 ) t.top = ( screen.bottom - screen.top - t.bottom ) / 2; t.right += t.left; t.bottom += t.top; } else { t = rect; } title = WdeAllocRCString( WDE_APPTITLE ); /* attempt to create the main application window */ hWinWdeMain = CreateWindow( WdeMainClass, title, WS_OVERLAPPEDWINDOW, t.left, t.top, t.right - t.left, t.bottom - t.top, (HWND)NULL, (HMENU)NULL, app_inst, NULL ); if( title != NULL ) { WdeFreeRCString( title ); } /* if the window could not be created return FALSE */ if( hWinWdeMain == NULL ) { WdeDisplayErrorMsg( WDE_NOCREATEMAINWINDOW ); return( FALSE ); } hWinWdeMDIClient = WdeCreateMDIClientWindow( hWinWdeMain, app_inst ); /* attempt to create the main application info window */ if( !WdeCreateInfoWindow( hWinWdeMain, app_inst ) ) { WdeDisplayErrorMsg( WDE_NOCREATEINFOWINDOW ); return( FALSE ); } if( !WdeCreateStatusLine( hWinWdeMain, app_inst ) ) { WdeDisplayErrorMsg( WDE_NOCREATESTATUSLINE ); return( FALSE ); } WdeInitialMenu = GetMenu( hWinWdeMain ); WdeCurrentMenu = WdeInitialMenu; WdeResMenu = LoadMenu( app_inst, "WdeResMenu" ); WdeDDEMenu = LoadMenu( app_inst, "WdeDDEMenu" ); if( IsDDE ) { WdeSetAppMenuToRes( TRUE ); } if( !WdeInitialMenu || !WdeResMenu ) { WdeDisplayErrorMsg( WDE_NOINITMENUS ); return( FALSE ); } if( !WdeInitHints() ) { WdeDisplayErrorMsg( WDE_NOINITHINTS ); return( FALSE ); } WdeInitRibbon( app_inst ); if( WdeGetOption( WdeOptIsRibbonVisible ) ) { WdeShowRibbon(); } /* if the window was created Show and Update it */ if( WdeGetOption( WdeOptIsScreenMax ) ) { ShowWindow( hWinWdeMain, SW_SHOWMAXIMIZED ); } else { ShowWindow( hWinWdeMain, SW_SHOWNORMAL ); } UpdateWindow( hWinWdeMain ); WdeSetFontList( hWinWdeMain ); if( !IsDDE ) { WdeDisplaySplashScreen( hInstWde, hWinWdeMain, 1125 ); } if( IsDDE ) { WdeInitToolMenu( app_inst, WdeDDEMenu ); } else { WdeInitToolMenu( app_inst, WdeResMenu ); } WdeInitControls( app_inst ); if( WdeGetOption( WdeOptIsCntlsTBarVisible ) ) { if( !WdeCreateControlsToolBar ( ) ) { WdeDisplayErrorMsg( WDE_NOCREATETOOLBOX ); return( FALSE ); } } SetFocus( hWinWdeMain ); return( TRUE ); }
/* Function to initialize all instances of WRE */ Bool WREInitInst( HINSTANCE app_inst ) { RECT r, screen, t; char *title; DWORD style; if( !WRERegisterClipFormats( app_inst ) ) { WREDisplayErrorMsg( WRE_NOREGISTERCLIPFORMATS ); return( FALSE ); } if( !JDialogInit() ) { return( FALSE ); } WRECtl3DInit( app_inst ); WREInitOpts(); WREInitRibbon( app_inst ); WREInitTypeNames(); WREInitTotalText(); if( !WREInitResources( app_inst ) ) { return( FALSE ); } /* load the accelerator table */ WREAccel = LoadAccelerators( app_inst, "WREAccelTable" ); /* if the window could not be created return FALSE */ if( WREAccel == NULL ) { WREDisplayErrorMsg( WRE_NOLOADACCELTABLE ); return( FALSE ); } WREGetScreenPosOption( &r ); GetWindowRect( GetDesktopWindow(), &screen ); IntersectRect( &t, &screen, &r ); title = WREAllocRCString( WRE_APPNAME ); /* attempt to create the main application window */ style = WS_OVERLAPPEDWINDOW; if( IsRectEmpty( &r ) ) { WREMainWin = CreateWindow( WREMainClass, title, style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND)NULL, (HMENU)NULL, app_inst, NULL ); } else { WREMainWin = CreateWindow( WREMainClass, title, style, r.left, r.top, r.right - r.left, r.bottom - r.top, (HWND)NULL, (HMENU)NULL, app_inst, NULL ); } if( title != NULL ) { WREFreeRCString( title ); } /* if the window could not be created return FALSE */ if( WREMainWin == NULL ) { WREDisplayErrorMsg( WRE_NOCREATEAPPWINDOW ); return( FALSE ); } WREMDIWin = WRECreateMDIClientWindow( WREMainWin, app_inst ); /* attempt to create the main application ribbon */ if( !WRECreateRibbon( WREMainWin ) ) { WREDisplayErrorMsg( WRE_NOCREATETOOLRIBBON ); return( FALSE ); } if( !WRECreateStatusLine( WREMainWin, app_inst ) ) { WREDisplayErrorMsg( WRE_NOCREATESTATUSLINE ); return( FALSE ); } WREMenu = GetMenu( WREMainWin ); if( WREMenu != (HMENU)NULL ) { EnableMenuItem( WREMenu, IDM_CUT, MF_GRAYED ); EnableMenuItem( WREMenu, IDM_COPY, MF_GRAYED ); EnableMenuItem( WREMenu, IDM_OPTIONS, MF_GRAYED ); } WREEnableMenus( FALSE ); if( !WREInitHints() ) { WREDisplayErrorMsg( WRE_NOINITHINTS ); return( FALSE ); } /* if the window was created Show and Update it */ if( !WRENoInterface ) { if( WREGetOption( WREOptScreenMax ) ) { ShowWindow( WREMainWin, SW_SHOWMAXIMIZED ); } else { ShowWindow( WREMainWin, SW_SHOWNORMAL ); } UpdateWindow( WREMainWin ); WREDisplaySplashScreen( WREInst, WREMainWin, 1250 ); } return( TRUE ); }
/* * spyInit - initialization */ static BOOL spyInit( HANDLE currinst, HANDLE previnst, int cmdshow ) { WNDCLASS wc; HANDLE memhdl; WORD i; i=i; memhdl = memhdl; /* shut up the compiler for non-NT version */ JDialogInit(); Instance = currinst; ResInstance = currinst; if( !InitGblStrings() ) { return( FALSE ); } SpyMenu = LoadMenu( ResInstance, "SPYMENU" ); #ifdef __WATCOMC__ _STACKLOW = 0; #endif MemStart(); HandleMessageInst = MakeProcInstance( (FARPROC) HandleMessage, Instance ); HintWndInit( Instance, NULL, 0 ); /* * set up window class */ if( !previnst ) { wc.style = 0L; wc.lpfnWndProc = SpyWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof( LONG_PTR ); wc.hInstance = Instance; wc.hIcon = LoadIcon( ResInstance, "APPLICON" ); wc.hCursor = LoadCursor( (HANDLE)NULL, IDC_ARROW); #ifdef __NT__ wc.hbrBackground = NULL; #else wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); #endif wc.lpszMenuName = NULL; wc.lpszClassName = SPY_CLASS_NAME; if( !RegisterClass( &wc ) ) { return( FALSE ); } #ifdef USE_SNAP_WINDOW if( !RegisterSnapClass( Instance ) ) { return( FALSE ); } #endif } #ifndef NOUSE3D CvrCtl3DInit( Instance ); CvrCtl3dRegister( Instance ); CvrCtl3dAutoSubclass( Instance ); #endif /* * now make the main window */ LoadSpyConfig( NULL ); SpyMainWindow = CreateWindow( SPY_CLASS_NAME, /* Window class name */ SpyName, /* Window caption */ WS_OVERLAPPEDWINDOW, /* Window style */ SpyMainWndInfo.xpos, /* Initial x position */ SpyMainWndInfo.ypos, /* Initial y position */ SpyMainWndInfo.xsize, /* Initial x size */ SpyMainWndInfo.ysize, /* Initial y size */ (HWND)NULL, /* Parent window handle */ (HMENU)SpyMenu, /* Window menu handle */ Instance, /* Program instance handle */ NULL ); /* Create parameters */ if( SpyMainWindow == NULL ) { return( FALSE ); } MyTask = GetWindowTask( SpyMainWindow ); ShowWindow( SpyMainWindow, cmdshow ); UpdateWindow( SpyMainWindow ); InitMessages(); return( TRUE ); } /* spyInit */