MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / InitInstance

Function InitInstance

src/Notepad2.c:465–725  ·  view source on GitHub ↗

============================================================================= InitInstance()

Source from the content-addressed store, hash-verified

463//
464//
465HWND InitInstance ( HINSTANCE hInstance, LPSTR pszCmdLine, int nCmdShow )
466{
467 RECT rc = { wi.x, wi.y, wi.x + wi.cx, wi.y + wi.cy };
468 RECT rc2;
469 MONITORINFO mi;
470 HMONITOR hMonitor = MonitorFromRect ( &rc, MONITOR_DEFAULTTONEAREST );
471 mi.cbSize = sizeof ( mi );
472 GetMonitorInfo ( hMonitor, &mi );
473 if ( flagDefaultPos == 1 ) {
474 wi.x = wi.y = wi.cx = wi.cy = CW_USEDEFAULT;
475 wi.max = 0;
476 } else if ( flagDefaultPos >= 4 ) {
477 SystemParametersInfo ( SPI_GETWORKAREA, 0, &rc, 0 );
478 if ( flagDefaultPos & 8 ) {
479 wi.x = ( rc.right - rc.left ) / 2;
480 } else {
481 wi.x = rc.left;
482 }
483 wi.cx = rc.right - rc.left;
484 if ( flagDefaultPos & ( 4 | 8 ) ) {
485 wi.cx /= 2;
486 }
487 if ( flagDefaultPos & 32 ) {
488 wi.y = ( rc.bottom - rc.top ) / 2;
489 } else {
490 wi.y = rc.top;
491 }
492 wi.cy = rc.bottom - rc.top;
493 if ( flagDefaultPos & ( 16 | 32 ) ) {
494 wi.cy /= 2;
495 }
496 if ( flagDefaultPos & 64 ) {
497 wi.x = rc.left;
498 wi.y = rc.top;
499 wi.cx = rc.right - rc.left;
500 wi.cy = rc.bottom - rc.top;
501 }
502 if ( flagDefaultPos & 128 ) {
503 wi.x += ( flagDefaultPos & 8 ) ? 4 : 8;
504 wi.cx -= ( flagDefaultPos & ( 4 | 8 ) ) ? 12 : 16;
505 wi.y += ( flagDefaultPos & 32 ) ? 4 : 8;
506 wi.cy -= ( flagDefaultPos & ( 16 | 32 ) ) ? 12 : 16;
507 }
508 } else if ( flagDefaultPos == 2 || flagDefaultPos == 3 ||
509 wi.x == CW_USEDEFAULT || wi.y == CW_USEDEFAULT ||
510 wi.cx == CW_USEDEFAULT || wi.cy == CW_USEDEFAULT ) {
511 // default window position
512 SystemParametersInfo ( SPI_GETWORKAREA, 0, &rc, 0 );
513 wi.y = rc.top + 16;
514 wi.cy = rc.bottom - rc.top - 32;
515 wi.cx = min ( rc.right - rc.left - 32, wi.cy );
516 wi.x = ( flagDefaultPos == 3 ) ? rc.left + 16 : rc.right - wi.cx - 16;
517 } else {
518 // fit window into working area of current monitor
519 wi.x += ( mi.rcWork.left - mi.rcMonitor.left );
520 wi.y += ( mi.rcWork.top - mi.rcMonitor.top );
521 if ( wi.x < mi.rcWork.left ) {
522 wi.x = mi.rcWork.left;

Callers 1

WinMainFunction · 0.85

Calls 15

SetWindowTransparentModeFunction · 0.85
InitScintillaHandleFunction · 0.85
FileLoadFunction · 0.85
ShowNotifyIconFunction · 0.85
Encoding_MatchWFunction · 0.85
OpenFileDlgFunction · 0.85
EditJumpToFunction · 0.85
InstallFileWatchingFunction · 0.85
EditFindPrevFunction · 0.85
EditFindNextFunction · 0.85
SetWindowTitleFunction · 0.85

Tested by

no test coverage detected