/** public functions **/ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { hInstance = hinstDLL; if ( !controlsInit ) { controlsInit = TRUE; initClassDescArray(); // jaguar controls InitCustomControls(hInstance); #ifdef OLD3DCONTROLS // initialize 3D controls Ctl3dRegister(hinstDLL); Ctl3dAutoSubclass(hinstDLL); #endif // initialize Chicago controls InitCommonControls(); } switch(fdwReason) { case DLL_PROCESS_ATTACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: break; } return(TRUE); }
int WR_EXPORT WRCtl3DInit( HINSTANCE inst ) { DWORD ver; BYTE vm; _wtouch( inst ); ver = GetVersion(); vm = (BYTE)(ver & 0x000000FF); if( vm >= 0x04 ) { return( TRUE ); } WRCtl3DDLLInit(); #if defined( WR_USE_3D ) if( !Ctl3dRegister( inst ) ) { return( FALSE ); } if( !Ctl3dAutoSubclass( inst ) ) { return( FALSE ); } #endif return( TRUE ); }
// ------------------------------------------------------------- BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { hInstance = hinstDLL; // Hang on to this DLL's instance handle. if (!controlsInit) { controlsInit = TRUE; // Initialize Max's custom controls // jaguar controls InitCustomControls(hInstance); #ifdef OLD3DCONTROLS // initialize 3D controls Ctl3dRegister(hinstDLL); Ctl3dAutoSubclass(hinstDLL); #endif InitCommonControls(); } return TRUE; }
/****************************************************************************** * int WinMain( * HINSTANCE hinstCurrent, * HINSTANCE hinstPrevious, * LPSTR lpszCmdLine, * int nCmdShow); * * windows initialization and exit * * parameters: * hinstCurrent - handle to this instance of minerva * hinstPrevious - handle to previous instance of minerva. If hinstPrevious is * NULL, no other instance is active (this is the first and only instance). * lpszCmdLine - command line parameters to this instance * nCmdShow - see ShowWindow() documentation * * returns: * value to be set as exit code for application * * notes: * WinMain is called as the application is starting up. When WinMain returns, * the application is terminated. ******************************************************************************/ int PASCAL WinMain( HINSTANCE hinstCurrent, /* handle to this instance */ HINSTANCE hinstPrevious, /* handle to previous instance or NULL */ LPSTR lpszCmdLine, /* command line */ int nCmdShow) /* see ShowWindow() documentation */ { MSG msg; LPCSTR psz; NOREFERENCE(lpszCmdLine); /* make SURE that (LPBITMAPINFO)&PIC_PARM.Head is valid */ assert(offsetof(PIC_PARM, ColorTable) - offsetof(PIC_PARM, Head) == offsetof(BITMAPINFO, bmiColors) - offsetof(BITMAPINFO, bmiHeader)); hinstThis = hinstCurrent; /* instance handle is globally accessible */ /* allow ctl3d to hook us */ Ctl3dRegister(hinstThis); /* dialogs and controls are automatically 3d */ Ctl3dAutoSubclass(hinstThis); if ( hinstPrevious == NULL ) { /* register window classes for first instance only hinstPrevious == NULL if and only if this is the only active instance of minerva */ if ( !RegisterWindowClasses() ) { Ctl3dUnregister(hinstCurrent); return ( 0 ); } } /* keyboard accelerators for menu commands */ hAcceleratorTable = LoadAccelerators(hinstThis, "MinervaAccelerators"); if ( hAcceleratorTable == NULL ) { ErrorMessage(STYLE_FATAL, IDS_LOADACCELERATORS); /* "An unexpected LoadAccelerators error occurred. Minerva cannot continue." */ Ctl3dUnregister(hinstCurrent); return ( 0 ); } if ( !CreateFrameWindow(nCmdShow) ) { Ctl3dUnregister(hinstCurrent); return ( 0 ); } /* load MRU file list from minerva.ini and update File menu */ if ( !MruLoadList(hwndFrame, APPLICATION_INIFILENAME) ) { DestroyWindow(hwndFrame); Ctl3dUnregister(hinstCurrent); return ( 0 ); } hWaitCursor = LoadCursor(NULL, IDC_WAIT); hArrowCursor = LoadCursor(NULL, IDC_ARROW); hHandCursor = LoadCursor(hinstThis, MAKEINTRESOURCE(IDC_HAND)); assert(hWaitCursor != NULL && hArrowCursor != NULL && hHandCursor != NULL); /* load PIC opcode DLL's */ InitOpList(); bDisableRDTSC = GetPrivateProfileInt("Settings", "DisableRDTSC", 0, APPLICATION_INIFILENAME); psz = lpszCmdLine + _fstrspn(lpszCmdLine, " "); while ( psz != 0 && ( *psz == '-' || *psz == '/' || *psz == '+' ) ) { if ( _fstrnicmp(psz + 1, "RDTSC", sizeof("RDTSC") - 1) == 0 && psz[sizeof("RDTSC")] <= ' ' ) bDisableRDTSC = *psz != '+'; psz = _fstrpbrk(psz, " "); if ( psz != 0 ) psz += _fstrspn(psz, " "); } if ( !bDisableRDTSC ) MiscTickCount(); // calibrate the RDTSC ticks while ( GetMessage(&msg, NULL, 0, 0) ) { if ( !TranslateMDISysAccel(hwndMDIClient, &msg) && !TranslateAccelerator(hwndFrame, hAcceleratorTable, &msg) ) { TranslateMessage(&msg); DispatchMessage(&msg); } } DestroyCursor(hHandCursor); /* unload PIC opcode DLL's */ CleanupOpList(); /* save MRU file list to minerva.ini */ MruSaveList(APPLICATION_INIFILENAME); Ctl3dUnregister(hinstCurrent); return ( msg.wParam ); }
WORD KappaInitKernel(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, WORD cmdShow, BOOL bMulti) { HCURSOR hOldCursor; /* 0: Load the cursors */ arrowCursor = LoadCursor(NULL, IDC_ARROW); hHourGlass = LoadCursor(NULL, IDC_WAIT); hKcross = LoadCursor(hInstance, "KCross"); /* Set the busy cursor */ hOldCursor = SetCursor(hHourGlass); /* FIRST Initialize Some External Variables */ hInstKappa = hInstance; hResThisDll = hInstance; /* 1: Load some important words into strings */ LoadString(hInstance, IDS_BROWSER, szBrowser, 20); LoadString(hInstance, IDS_SESSION, szSession, 20); #ifndef RUNTIME LoadString(hInstance, IDS_INTERPRET, szInterpret, 20); LoadString(hInstance, IDS_TRACE, szTrace, 20); LoadString(hInstance, IDS_KTOOLS, szKTools, 20); LoadString(hInstance, IDS_TOOLS, sztools, 10); LoadString(hInstance, IDS_INFERENCE, szInference, 20); LoadString(hInstance, IDS_UNTITLED, szUntitled, 11); LoadString(hInstance, IDS_RULEREL, szRuleRel, 30); LoadString(hInstance, IDS_FINDER, szFinder, 30); LoadString(hInstance, IDS_KALVIEW, szKalView, 30); #endif /* 2: Set up some default brushes */ hbrWhite = GetStockObject(WHITE_BRUSH); hbrBlack = GetStockObject(BLACK_BRUSH); hbrColor = KppGetBrush(FALSE); /* 3: Load Accelerators table */ hAccelTable = LoadAccelerators(hInstance, szAppName); /* 4: Remember KAPPA's starting and system directories */ { char systemdir[FILENAME_MAX]; GetModuleFileName(hInstKappa, systemdir, FILENAME_MAX - 1); KppSetSystemDirectory(systemdir); getcwd(systemdir, FILENAME_MAX); KppSetStartupDirectory(systemdir); } #ifdef CTL3D /* 4 (ter) Setup 3D controls if enabled in kappa.ini */ if (Kpp3dCtrls()) Ctl3dRegister(hInstKappa); #endif /* 5: Load icons */ #ifndef RUNTIME kappaIcon = LoadIcon(hInstance, szAppName); LoadString(hInstance, IDS_BROWSERICON, szBrowserIcon, 10); browserIcon = LoadIcon(hInstance, szBrowserIcon); #endif #ifndef RUNTIME LoadString(hInstance, IDS_INFERENCEICON, szInferenceIcon, 10); inferenceIcon = LoadIcon (hInstance, szInferenceIcon); LoadString(hInstance, IDS_FINDERICON, szFinderIcon, 10); finderIcon = LoadIcon (hInstance, szFinderIcon); LoadString(hInstance, IDS_KALVIEWICON, szKalViewIcon, 10); kalviewIcon = LoadIcon (hInstance, szKalViewIcon); LoadString(hInstance, IDS_TRACEICON, szTraceIcon, 10); traceIcon = LoadIcon (hInstance, szTraceIcon); LoadString(hInstance, IDS_SESSIONICON, szSessionIcon, 10); sessionIcon = LoadIcon (hInstance, szSessionIcon); LoadString(hInstance, IDS_TOOLSICON, szToolsIcon, 10); toolsIcon = LoadIcon (hInstance, szToolsIcon); LoadString (hInstance, IDS_KALICON, szKALIcon, 10); kalIcon = LoadIcon (hInstance, szKALIcon); LoadString (hInstance, IDS_RULERELICON, szRuleRelIcon, 10); rulerelIcon = LoadIcon (hInstance, szRuleRelIcon); #endif /* not RUNTIME */ /* 7: define screen attributes and post initial message */ /* define global system variables */ InitSystemParams(); #ifndef RUNTIME if (!(hWndKappa = CreateMainWindow(hInstance))) return FALSE; SetFocus(hWndKappa); CreateKappaAbout(hWndKappa); #endif /* 8: Load the library */ KppInitKappaKernel(hInstance, hPrevKappa, bMulti); #ifndef RUNTIME /* Create a child window of the kappa window for comments. */ hWndComment = CreateWindow("EDIT", NULL, WS_CHILD | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0, 0, 0, 0, hWndKappa, ID_COMMENT, hInstance, NULL); ShowWindow(hWndComment, SW_SHOWNORMAL); BringWindowToTop(hWndComment); /* init the protected mode variable, for Global allocation */ if (GetWinFlags() & WF_PMODE) bProtectedLock = TRUE; #endif /* not RUNTIME */ /* Initialize alerts (do it immediately after setting up hWndKappa */ KppInitAlert(); /* 9: intialize others */ /* define some atoms that are often used inside KAPPA */ InitCommonSymbols(); /* Finally, initialize KAPPA functions and top level knowledge items */ InitKappaFunctions(); /* Define callback functions for the DLL's */ InitDLLCallbackFunctions(); /* Initialize Menu */ KppInitMenus(); /* Initialize DDE Objects */ KppInitDDEObjectsCB(); /* Initialize KAPPA-PC tools */ if (!InitKappaTools(hInstance, bMulti)) return FALSE; /* Reset the cursor */ SetCursor(hOldCursor); /* Reset the clock */ ResetClockCB(); #ifndef RUNTIME DestroyKappaAbout(); SetFocus(hWndKappa); #endif #ifdef RUNTIME hWndKappa = KpsGetMainSessionWindow(); browserIcon = NULL; kappaIcon = NULL; if (HIBYTE(LOWORD(GetVersion())) >= 10) { char stIniFileName[_MAX_PATH]; KppGetKappaIniFile(stIniFileName, _MAX_PATH); if (stIniFileName[0]) { char stSessIconFileName[_MAX_PATH], stBrowIconFileName[_MAX_PATH]; GetPrivateProfileString("ICONS", "SESSION", "", stSessIconFileName, _MAX_PATH, stIniFileName); GetPrivateProfileString("ICONS", "BROWSER", "", stBrowIconFileName, _MAX_PATH, stIniFileName); if (stSessIconFileName[0] || stBrowIconFileName[0]) { HANDLE hShell = GetModuleHandle("SHELL"); BOOL bLoaded = FALSE; if (!hShell) { GetSystemDirectory(return_buffer, RET_BUFFER_LEN); strcat(return_buffer, "\\shell.dll"); hShell = LoadLibrary(return_buffer); bLoaded = TRUE; } if (hShell > 32) { HANDLE (EXPORT *ExtractIcon_fn)(HANDLE, LPSTR, WORD); ExtractIcon_fn = (HANDLE (EXPORT *)(HANDLE, LPSTR, WORD)) GetProcAddress(hShell, "ExtractIcon"); if (ExtractIcon_fn) { if (stSessIconFileName[0]) { kappaIcon = (*ExtractIcon_fn)(hInstance, stSessIconFileName, 0); /* check for valid icon handle */ if (kappaIcon == 1) kappaIcon = NULL; } if (stBrowIconFileName[0]) { browserIcon = (*ExtractIcon_fn)(hInstance, stBrowIconFileName, 0); /* check for valid icon handle */ if (browserIcon == 1) browserIcon = NULL; } } if (bLoaded) FreeLibrary(hShell); } } } } if (!kappaIcon) kappaIcon = LoadIcon(hInstance, szAppName); if (!browserIcon) { LoadString(hInstance, IDS_BROWSERICON, szBrowserIcon, 10); browserIcon = LoadIcon(hInstance, szBrowserIcon); } SetClassWord(hWndKappa, GCW_HICON, kappaIcon); SetClassWord(hWndBrowser, GCW_HICON, browserIcon); #else PositionMainWindows(); ShowWindow(hWndKappa, cmdShow); KappaBrowserMode(FALSE, cmdShow); ShowWindow(hWndKTools, cmdShow); SetFocus(hWndKappa); #endif InitPopupCounts(); MarkAppAsUnmodifiedCB(); return TRUE; }
/* * Initialise the GUI. Create all the windows, set up all the call-backs * etc. */ int gui_mch_init(void) { const char szVimWndClass[] = VIM_CLASS; const char szTextAreaClass[] = "VimTextArea"; WNDCLASS wndclass; #ifdef WIN16_3DLOOK Ctl3dRegister(s_hinst); Ctl3dAutoSubclass(s_hinst); #endif /* Display any pending error messages */ display_errors(); gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL); gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL); #ifdef FEAT_MENU gui.menu_height = 0; /* Windows takes care of this */ #endif gui.border_width = 0; gui.currBgColor = INVALCOLOR; s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); if (GetClassInfo(s_hinst, szVimWndClass, &wndclass) == 0) { wndclass.style = 0; wndclass.lpfnWndProc = _WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = s_hinst; wndclass.hIcon = LoadIcon(wndclass.hInstance, MAKEINTRESOURCE(IDR_VIM)); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = s_brush; wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szVimWndClass; if (( #ifdef GLOBAL_IME atom = #endif RegisterClass(&wndclass)) == 0) return FAIL; } s_hwnd = CreateWindow( szVimWndClass, "Vim MSWindows GUI", WS_OVERLAPPEDWINDOW, gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, 100, /* Any value will do */ 100, /* Any value will do */ NULL, NULL, s_hinst, NULL); if (s_hwnd == NULL) return FAIL; #ifdef GLOBAL_IME global_ime_init(atom, s_hwnd); #endif /* Create the text area window */ if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0) { wndclass.style = CS_OWNDC; wndclass.lpfnWndProc = _TextAreaWndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = s_hinst; wndclass.hIcon = NULL; wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = NULL; wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szTextAreaClass; if (RegisterClass(&wndclass) == 0) return FAIL; } s_textArea = CreateWindow( szTextAreaClass, "Vim text area", WS_CHILD | WS_VISIBLE, 0, 0, 100, /* Any value will do for now */ 100, /* Any value will do for now */ s_hwnd, NULL, s_hinst, NULL); if (s_textArea == NULL) return FAIL; #ifdef FEAT_MENU s_menuBar = CreateMenu(); #endif s_hdc = GetDC(s_textArea); #ifdef MSWIN16_FASTTEXT SetBkMode(s_hdc, OPAQUE); #endif DragAcceptFiles(s_hwnd, TRUE); /* Do we need to bother with this? */ /* m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); */ /* Get background/foreground colors from the system */ gui_mch_def_colors(); /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc * file) */ set_normal_colors(); /* * Check that none of the colors are the same as the background color. * Then store the current values as the defaults. */ gui_check_colors(); gui.def_norm_pixel = gui.norm_pixel; gui.def_back_pixel = gui.back_pixel; /* Get the colors for the highlight groups (gui_check_colors() might have * changed them) */ highlight_gui_started(); /* * Start out by adding the configured border width into the border offset */ gui.border_offset = gui.border_width; /* * compute a couple of metrics used for the dialogs */ get_dialog_font_metrics(); #ifdef FEAT_TOOLBAR /* * Create the toolbar */ initialise_toolbar(); #endif #ifdef MSWIN_FIND_REPLACE /* * Initialise the dialog box stuff */ s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING); /* Initialise the struct */ s_findrep_struct.lStructSize = sizeof(s_findrep_struct); s_findrep_struct.lpstrFindWhat = alloc(MSWIN_FR_BUFSIZE); s_findrep_struct.lpstrFindWhat[0] = NUL; s_findrep_struct.lpstrReplaceWith = alloc(MSWIN_FR_BUFSIZE); s_findrep_struct.lpstrReplaceWith[0] = NUL; s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE; s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE; #endif return OK; }