int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { MSG msg; /* Other instances of app running? */ if (!hPrevInstance) { /* stuff to be done once */ if (!InitApplication(hInstance)) { return FALSE; /* exit */ } } /* stuff to be done every time */ if (!InitInstance(hInstance, nCmdShow)) { return FALSE; } HandleCommandLine(lpCmdLine); /* Main loop */ /* Acquire and dispatch messages until a WM_QUIT message is received */ while (GetMessageW(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessageW(&msg); } return msg.wParam; }
bool wxConvertApp::OnInit() { //Initialize all image loaders(JPEG,BMP,PNG,and etc) wxInitAllImageHandlers(); SetAppName(_T("wxConvertApp")); if (HandleCommandLine()) return true; // Create the main frame window m_pFrame = new wxMainFrame(NULL, wxID_ANY, _T("wxConvertApp"), wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL); InitMenu(); m_pFrame->Show(true); SetTopWindow(m_pFrame); return true; }
int main(int argc, FCSTR argv[]) { IService* pService = CreateServerObject(); IServiceLogic* pLogic = new FCLogicWorld; CCmdLineInfo cmdLine(argc, argv); char buffer[MAX_PATH]; size_t bufLen = sizeof(buffer); pService->ISRV_GetBinPath(buffer, bufLen); #ifdef _WIN32 SetCurrentDirectory(buffer); #else #endif // create the logger Logging::IDynLogWriter* pWriter = Logging::createLogWriter( Logging::LOGWRITER_TEXTFILE); ((Logging::IDynLogTextFileWriter*)pWriter)->setFilename("FCWorldServer.log"); Logging::getLogger()->addWriter(pWriter); Logging::getLogger()->setLogLevelFilter(5); pWriter->release(); if ( pService ) { pService->ISRV_AttachLogic(pLogic); // handle any command line options passed in if ( HandleCommandLine(cmdLine, pService) ) { // if we get here, we can boot the service/daemon pService->ISRV_Run(NULL); } // time to free up the resources pLogic->Free(); } // and release the service/daemon object ReleaseServerObject(pService); Logging::destroyLogger(); return 0; }
/*********************************************************************** * * WinMain */ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int show) { MSG msg; HACCEL hAccel; WNDCLASSEX wndclass; HMONITOR monitor; MONITORINFO info; INT x, y; static const TCHAR className[] = _T("NPClass"); static const TCHAR winName[] = _T("Notepad"); UNREFERENCED_PARAMETER(prev); aFINDMSGSTRING = (ATOM) RegisterWindowMessage(FINDMSGSTRING); ZeroMemory(&Globals, sizeof(Globals)); Globals.hInstance = hInstance; LoadSettings(); ZeroMemory(&wndclass, sizeof(wndclass)); wndclass.cbSize = sizeof(wndclass); wndclass.lpfnWndProc = NOTEPAD_WndProc; wndclass.hInstance = Globals.hInstance; wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NPICON)); wndclass.hCursor = LoadCursor(0, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wndclass.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU); wndclass.lpszClassName = className; wndclass.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_NPICON), IMAGE_ICON, 16, 16, 0); if (!RegisterClassEx(&wndclass)) return FALSE; /* Setup windows */ monitor = MonitorFromRect( &Globals.main_rect, MONITOR_DEFAULTTOPRIMARY ); info.cbSize = sizeof(info); GetMonitorInfoW( monitor, &info ); x = Globals.main_rect.left; y = Globals.main_rect.top; if (Globals.main_rect.left >= info.rcWork.right || Globals.main_rect.top >= info.rcWork.bottom || Globals.main_rect.right < info.rcWork.left || Globals.main_rect.bottom < info.rcWork.top) x = y = CW_USEDEFAULT; Globals.hMainWnd = CreateWindow(className, winName, WS_OVERLAPPEDWINDOW, x, y, Globals.main_rect.right - Globals.main_rect.left, Globals.main_rect.bottom - Globals.main_rect.top, NULL, NULL, Globals.hInstance, NULL); if (!Globals.hMainWnd) { ShowLastError(); ExitProcess(1); } DoCreateEditWindow(); NOTEPAD_InitData(); DIALOG_FileNew(); ShowWindow(Globals.hMainWnd, show); UpdateWindow(Globals.hMainWnd); DragAcceptFiles(Globals.hMainWnd, TRUE); DIALOG_ViewStatusBar(); HandleCommandLine(cmdline); hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) ); while (GetMessage(&msg, 0, 0, 0)) { if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) && !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; }
int main(int argc, char** argv) { SigInit(FurtherSignalHandling); if ( HandleCommandLine(argc, argv) != 0 ) return 10; if (CsfProcInit(true, true, NULL, INI_CORECONFIG, INI_STACKCONFIG, INIDEF_CORECONFIG, INIDEF_STACKCONFIG) != 0) CsErrx("main: could not initialise core/stack dump on error"); alarmInitialise(); clearAlarms(); if ( IpcInit() != 0 ) { CsErrx("IpcInit() failed"); return -1; } LoadIniFile(); CsMutexInit(&g_rxQueueLock , CSSYNC_THREAD); CsMutexInit(&g_queueLock , CSSYNC_THREAD); CsMutexInit(&g_heartbeatMapLock , CSSYNC_THREAD); CsMutexInit(&g_persistLock , CSSYNC_THREAD); CsMutexInit(&g_LANCommunicationTimerLock, CSSYNC_THREAD); CsMutexInit(&g_stateLock, CSSYNC_THREAD); appQueueId = IpcGetID(DC_TASK); wsQueueId = IpcGetID(WS_TASK); asQueueId = IpcGetID(AS_TASK); avlTaskId = IpcGetID(MYKI_AVL_TaskId); printerTaskId = IpcGetID(DC_PRINTER_TASK); if(InitialiseWebsocket()!=0) { return -1; } // Create Timer Service InitTimerService(); getNetworkSettings(); while(initCCE()!=0) { CsErrx("Cannot connect to CCE waiting 5 seconds"); CsSleep(5, 0); } // Execute application ProcessMessages(NULL); if (IpcClose() != 0) CsErrx("IpcClose: failed to close"); CsMutexDestroy(&g_rxQueueLock ); CsMutexDestroy(&g_queueLock ); CsMutexDestroy(&g_heartbeatMapLock ); CsMutexDestroy(&g_LANCommunicationTimerLock ); CsMutexDestroy(&g_persistLock ); CsMutexDestroy(&g_stateLock ); return 0; }
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*cmdShow*/) { SetDllDirectory(L""); git_libgit2_init(); HandleCommandLine(lpCmdLine); CAutoGeneralHandle hReloadProtection = ::CreateMutex(NULL, FALSE, GetCacheMutexName()); if ((!hReloadProtection) || (GetLastError() == ERROR_ALREADY_EXISTS)) { // An instance of TGitCache is already running CTraceToOutputDebugString::Instance()(__FUNCTION__ ": TGitCache ignoring restart\n"); return 0; } CGitStatusCache::Create(); CGitStatusCache::Instance().Init(); SecureZeroMemory(szCurrentCrawledPath, sizeof(szCurrentCrawledPath)); DWORD dwThreadId; MSG msg; TCHAR szWindowClass[] = {TGIT_CACHE_WINDOW_NAME}; // create a hidden window to receive window messages. WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = 0; wcex.hbrBackground = 0; wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = 0; RegisterClassEx(&wcex); hWnd = CreateWindow(TGIT_CACHE_WINDOW_NAME, TGIT_CACHE_WINDOW_NAME, WS_CAPTION, 0, 0, 800, 300, NULL, 0, hInstance, 0); hTrayWnd = hWnd; if (hWnd == NULL) { return 0; } if (CRegStdDWORD(_T("Software\\TortoiseGit\\CacheTrayIcon"), FALSE)==TRUE) { SecureZeroMemory(&niData,sizeof(NOTIFYICONDATA)); DWORD dwMajor = 0; DWORD dwMinor = 0; GetShellVersion(&dwMajor, &dwMinor); DWORD dwVersion = PACKVERSION(dwMajor, dwMinor); if (dwVersion >= PACKVERSION(6,0)) niData.cbSize = sizeof(NOTIFYICONDATA); else if (dwVersion >= PACKVERSION(5,0)) niData.cbSize = NOTIFYICONDATA_V2_SIZE; else niData.cbSize = NOTIFYICONDATA_V1_SIZE; niData.uID = TRAY_ID; // own tray icon ID niData.hWnd = hWnd; niData.uFlags = NIF_ICON|NIF_MESSAGE; // load the icon niData.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_TGITCACHE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); // set the message to send // note: the message value should be in the // range of WM_APP through 0xBFFF niData.uCallbackMessage = TRAY_CALLBACK; Shell_NotifyIcon(NIM_ADD,&niData); // free icon handle if(niData.hIcon && DestroyIcon(niData.hIcon)) niData.hIcon = NULL; } // Create a thread which waits for incoming pipe connections CAutoGeneralHandle hPipeThread = CreateThread( NULL, // no security attribute 0, // default stack size PipeThread, (LPVOID) &bRun, // thread parameter 0, // not suspended &dwThreadId); // returns thread ID if (!hPipeThread) { return 0; } else hPipeThread.CloseHandle(); // Create a thread which waits for incoming pipe connections CAutoGeneralHandle hCommandWaitThread = CreateThread( NULL, // no security attribute 0, // default stack size CommandWaitThread, (LPVOID) &bRun, // thread parameter 0, // not suspended &dwThreadId); // returns thread ID if (!hCommandWaitThread) { return 0; } // loop to handle window messages. while (bRun) { BOOL bLoopRet = GetMessage(&msg, NULL, 0, 0); if ((bLoopRet != -1)&&(bLoopRet != 0)) { DispatchMessage(&msg); } } bRun = false; CGitStatusCache::Destroy(); HandleRestart(); return 0; }
long DoCommand( HWND hWindow, UINT idCmd, HWND hControl, UINT codeNotify ) /***********************************************************************/ { FNAME szFileName; BOOL bPrint; LPTSTR lpszCmdLine; LPIMAGE lpImage; lpImage = GetActiveImage(); //if ( lpImage && idCmd >= PS_FIRST_PLUGIN && idCmd <= PS_LAST_PLUGIN ) if( idCmd >= PS_FIRST_PLUGIN && idCmd <= PS_LAST_PLUGIN ) { DeactivateTool(); return( HandlePluginCommand( lpImage, MDIFrame_wParam, MDIFrame_lParam )); } //if ( lpImage && idCmd >= PS_FIRST_ADOBEPLUGIN && idCmd <= PS_LAST_ADOBEPLUGIN ) if( idCmd >= PS_FIRST_ADOBEPLUGIN && idCmd <= PS_LAST_ADOBEPLUGIN ) { DeactivateTool(); return( HandleAdobePluginCommand( lpImage, idCmd )); } // handle messages which should be passed to the ribbons if (WITHIN(idCmd, IDM_FIRST_RIBBONMENU, IDM_LAST_RIBBONMENU)) { if(Tool.hRibbon) SEND_WM_COMMAND(Tool.hRibbon, idCmd, hControl, codeNotify); } switch (idCmd) { case IDM_RECALLIMAGE0: case IDM_RECALLIMAGE1: case IDM_RECALLIMAGE2: case IDM_RECALLIMAGE3: case IDM_RECALLIMAGE4: case IDM_RECALLIMAGE5: case IDM_RECALLIMAGE6: case IDM_RECALLIMAGE7: case IDM_RECALLIMAGE8: case IDM_RECALLIMAGE9: DeactivateTool(); lstrcpy(szFileName, Control.RecallImage[idCmd - IDM_RECALLIMAGE0]); if( OPTION3 && Control.Retail ) DoLowResLoad( 0, szFileName ); else if( OPTION1 && Control.Retail ) PictPubApp.OpenDocumentFileImmediate( szFileName, OM_FASTBITS ); else AstralImageLoadBG( 0, szFileName, YES ); break; case IDM_ALTOPEN: DeactivateTool(); // Command line sent from a second instance prior to it closing /* If the caller passed in a file name, try to load it or print it */ /* if ( !(lpszCmdLine = (LPTR)lParam) ) break; */ HandleCommandLine( hWindow, lpszCmdLine, &bPrint ); break; case PS_SERVICE_ABORT_BEGIN: case PS_SERVICE_ABORT_CHECK: case PS_SERVICE_ABORT_END: case PS_SERVICE_ABORT_BEGIN_NOESC: case PS_SERVICE_BUF_DELETE: case PS_SERVICE_GET_IMAGE_INFO: case PS_SERVICE_PRIVATE_INI: case PS_SERVICE_BUF_ALLOC: case PS_SERVICE_BUF_LOCK1: case PS_SERVICE_BUF_UNLOCK1: case PS_SERVICE_BUF_NEXTLINE: case PS_SERVICE_BUF_LINEPTR: case PS_SERVICE_BUF_LINE_TABLE: return( HandlePluginMessage( lpImage, MDIFrame_wParam, MDIFrame_lParam )); break; case IDM_RUN0: case IDM_RUN1: case IDM_RUN2: case IDM_RUN3: case IDM_RUN4: case IDM_RUN5: case IDM_RUN6: case IDM_RUN7: case IDM_RUN8: case IDM_RUN9: RunTask( hWindow, idCmd, IDS_RUNTASKLIST ); break; case IDM_CLOSEIT: DeactivateTool(); PictPubApp.CloseDocumentFile(lpImage); break; default: return( FALSE ); } return( TRUE ); }
/*********************************************************************** * WinMain */ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, char *cmdline, int show) { MSG msg; HACCEL accel; WNDCLASSEX wc; HMONITOR monitor; MONITORINFO info; int x, y; static const char className[] = {'N','o','t','e','p','a','d',0}; static const char winName[] = {'N','o','t','e','p','a','d',0}; ZeroMemory(&Globals, sizeof(Globals)); Globals.hInstance = hInstance; NOTEPAD_SetParams(); ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.lpfnWndProc = NOTEPAD_WndProc; wc.hInstance = Globals.hInstance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = (HBRUSH)BLACK_BRUSH;//(HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU); wc.lpszClassName = className; if (!RegisterClassEx(&wc)) return false; /* Setup windows */ monitor = MonitorFromRect(&main_rect, MONITOR_DEFAULTTOPRIMARY); info.cbSize = sizeof(info); GetMonitorInfo(monitor, &info); x = main_rect.left; y = main_rect.top; if (main_rect.left >= info.rcWork.right || main_rect.top >= info.rcWork.bottom || main_rect.right < info.rcWork.left || main_rect.bottom < info.rcWork.top) x = y = CW_USEDEFAULT; Globals.hMainWnd = CreateWindow(className, winName, WS_OVERLAPPEDWINDOW | WS_VSCROLL | WS_HSCROLL, x, y, main_rect.right - main_rect.left, main_rect.bottom - main_rect.top, NULL, NULL, Globals.hInstance, NULL); if (!Globals.hMainWnd) { ShowLastError(); ExitProcess(1); } NOTEPAD_InitData(); DIALOG_FileNew(); //ShowWindow(Globals.hMainWnd, SW_HIDE); ShowWindow(Globals.hMainWnd, SW_SHOW); UpdateWindow(Globals.hMainWnd); DragAcceptFiles(Globals.hMainWnd, true); HandleCommandLine(cmdline); accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL)); while (GetMessage(&msg, 0, 0, 0)) { if (!TranslateAccelerator(Globals.hMainWnd, accel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; }
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam ) /***********************************************************************/ { FNAME szFileName; LPFRAME lpFrame; LPOBJECT lpObject, lpBase; RECT rect, rMask, rTemp, rAll; HWND hWnd; STRING szString; int i, idFileType, x, y, dx, dy; BOOL fDoZoom, bPrint, fHasZoom; LPSTR lpszCmdLine; HGLOBAL hMem; ITEMID idDataType; DWORD dwReturn; int NewShape; UINT wID; SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ ); /* WIN16: ID = wParam ctrl handle = LOWORD(lParam) notify code = HIWORD(lParam) WIN32: ID = LOWORD(wParam) ctrl handle = lParam notify code = HIWORD(wParam) */ #ifdef WIN32 wID = LOWORD(wParam); #else wID = wParam; #endif switch (wID) { case IDM_EXIT: DeactivateTool(); PostMessage( hWndAstral, WM_CLOSE, 0, 0L); Delay (750); break; case IDM_CLOSE: DeactivateTool(); /* Check to see if the image needs to be saved */ if ( !ConfirmClose(NO,NO) ) break; CloseImage( NO, lpImage ); // Close the active image break; case IDM_ABOUT: /* Bring up the modal 'About' dialog box */ AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc); break; case IDM_NEXTPAGE: if ( !lpImage ) break; DeactivateTool(); SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L ); break; case IDM_NEW: DeactivateTool(); SoundStartResource( "magic01", NO, NULL ); AstralCursor( IDC_WAIT ); New( Control.NewWidth, Control.NewHeight, Control.NewResolution, Control.NewDepth ); AstralCursor( NULL ); break; case IDM_OPEN: DeactivateTool(); /* Bring up the modal 'File Open' box */ if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN, Save.FileType, szFileName, NO )) ) break; idFileType = LOWORD( dwReturn ); Save.FileType = idFileType; PutDefaultInt( "FileType", idFileType - IDN_TIFF ); AstralImageLoad( idFileType, szFileName, MAYBE, YES ); break; case IDM_ALTOPEN: DeactivateTool(); // Command line sent from a second instance prior to it closing /* If the caller passed in a file name, try to load it or print it */ if ( !(lpszCmdLine = (LPSTR)lParam) ) break; HandleCommandLine( hWindow, lpszCmdLine, &bPrint ); break; case IDM_SAVE: DeactivateTool(); HandleSaveCommand(hWindow, wID, YES); break; case IDM_SAVEAS: DeactivateTool(); HandleSaveCommand(hWindow, wID, YES); break; case IDM_SAVESPECIAL: DeactivateTool(); HandleSaveCommand(hWindow, wID, YES); break; case IDM_SAVEWALLPAPER: DeactivateTool(); SaveWallpaper( "CRAYOLA", NO/*fTiled*/ ); break; case IDM_REVERT: if ( !lpImage ) break; DeactivateTool(); if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out break; if ( ImgChanged(lpImage) ) { /* Check to see if its OK to trash changes */ if ( AstralOKCancel(IDS_OKTOREVERT, (LPSTR)lpImage->CurFile) == IDCANCEL ) break; } lstrcpy( szFileName, lpImage->CurFile ); idFileType = lpImage->FileType; fDoZoom = IsZoomed(lpImage->hWnd); fHasZoom = Window.fHasZoom; CloseImage( NO, lpImage ); // Close the active image if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) ) break; break; case IDM_RECALLIMAGE0: case IDM_RECALLIMAGE1: case IDM_RECALLIMAGE2: case IDM_RECALLIMAGE3: case IDM_RECALLIMAGE4: case IDM_RECALLIMAGE5: case IDM_RECALLIMAGE6: case IDM_RECALLIMAGE7: case IDM_RECALLIMAGE8: case IDM_RECALLIMAGE9: DeactivateTool(); GetMenuString( GetMenu(hWindow), wID, szFileName, sizeof(szFileName), MF_BYCOMMAND ); i = 0; while ( szFileName[i] && szFileName[i] != ' ' ) i++; // Skip over the numeric id in the string (3. junk.tif) lstrcpy(szString, &szFileName[i+1]); GetRecallFileName(szString); AstralImageLoad( NULL, szString, MAYBE, YES ); break; case IDM_PRINT: if ( !lpImage ) break; DeactivateTool(); AstralCursor( IDC_WAIT ); DoPrintSizeInits(); SoundStartResource( "print", YES, NULL ); PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL ); SoundStop(); AstralCursor( NULL ); break; case IDM_PRINTSETUP: /* Bring up the setup dialog box for the active printer */ AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP, DlgPrintSetupProc); break; case IDC_SOUND: SoundToggle(); break; case IDM_UNDO: if ( !lpImage ) break; DeactivateTool(); ImgEditUndo(lpImage, YES, NO); break; case IDM_CUT: case IDM_COPY: if ( !lpImage ) break; DeactivateTool(); // Create the clipboard files from the image ProgressBegin(1, IDS_PROGCOPY); if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) ) { ProgressEnd(); Message(IDS_EMEMALLOC); break; } ProgressEnd(); OpenClipboard(hWindow); EmptyClipboard(); // Passing a NULL data handle in SetClipboardData() means that // the data will be requested in a WM_RENDERFORMAT message hMem = ConstructObject( lpImage, IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask ); if ( pOLE ) { // Any data put on before Native will become staticly copied SetClipboardData( pOLE->cfNative, NULL ); SetClipboardData( pOLE->cfOwnerLink, hMem ); } SetClipboardData( CF_DIB, NULL ); if ( Control.DoPicture ) SetClipboardData( CF_METAFILEPICT, NULL ); if ( Control.DoBitmap ) SetClipboardData( CF_BITMAP, NULL ); SetClipboardData( CF_PALETTE, NULL ); SetClipboardData( Control.cfImage, NULL ); if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled ) { // ObjectLink is retrieved during a Paste Link... SetClipboardData( pOLE->cfObjectLink, hMem ); } CloseClipboard(); if ( wID == IDM_COPY ) break; // else fall through to IDM_DELETE case IDM_DELETE: if ( !lpImage ) break; { COLORINFO ColorInfo; DeactivateTool(); ColorInfo.gray = 255; SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY ); TintFill( lpImage, &ColorInfo, 255, MM_NORMAL, wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE ); } break; case IDM_PASTE: if ( !lpImage ) break; case IDM_PASTEASNEW: if ( !OpenClipboard(hWndAstral) ) { Message( IDS_ECLIPOPEN ); break; } if ( !IsClipboardFormatAvailable(CF_DIB) && !IsClipboardFormatAvailable(CF_BITMAP) && !IsClipboardFormatAvailable(Control.cfImage) ) { Message( IDS_ECLIPOPEN ); CloseClipboard(); break; } CloseClipboard(); DeactivateTool(); // First put clipboard contents into a file(s) AstralCursor(IDC_WAIT); if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) ) { AstralCursor(NULL); Message(IDS_EMEMALLOC); break; } if ( wID == IDM_PASTE ) { ProgressBegin(1, IDS_PROGPASTECLIP); TransformObjectsStart( YES/*fNewObject*/ ); if ( ImgCreateClipInObject( lpImage, NO ) ) ; ProgressEnd(); } else if ( wID == IDM_PASTEASNEW ) { if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1, &idDataType, &idFileType) ) { if ( NewImageWindow( NULL, // lpOldFrame NULL, // Name lpFrame, // lpNewFrame idFileType, // lpImage->FileType idDataType, // lpImage->DataType FALSE, // New view? IMG_DOCUMENT, // lpImage->DocumentType NULL, // lpImage->ImageName MAYBE ) ) lpImage->fChanged = YES; } } break; case IDM_ESCAPE: if (!lpImage) break; if (lpImage->hWnd == hZoomWindow) break; if ( Tool.bActive && Tool.lpToolProc ) DestroyProc( lpImage->hWnd, 1L ); break; case IDM_SIZEUP: case IDM_SIZEDOWN: if (!Retouch.hBrush) break; SetFocus( hWindow ); // Take focus away from any controls if ( Retouch.BrushShape == IDC_BRUSHCUSTOM ) break; if ( wID == IDM_SIZEUP ) { if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) Retouch.BrushSize += 2; else Retouch.BrushSize++; } else { if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) Retouch.BrushSize -= 2; else Retouch.BrushSize--; } if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE ) { Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE); MessageBeep(0); break; } if (lpImage) DisplayBrush(0, 0, 0, OFF); SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize); if (lpImage && Window.hCursor == Window.hNullCursor) DisplayBrush(lpImage->hWnd, 32767, 32767, ON); if ( Tool.hRibbon ) SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize ); break; case IDM_SHAPEUP: case IDM_SHAPEDOWN: if (!Retouch.hBrush) break; SetFocus( hWindow ); // Take focus away from any controls NewShape = Retouch.BrushShape; if ( wID == IDM_SHAPEUP ) NewShape++; else NewShape--; if ( NewShape > IDC_BRUSHCUSTOM ) NewShape = IDC_BRUSHCIRCLE; if ( NewShape < IDC_BRUSHCIRCLE ) NewShape = IDC_BRUSHCUSTOM; if (lpImage) DisplayBrush(0, 0, 0, OFF); if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush)) { NewShape = IDC_BRUSHCIRCLE; SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush); } Retouch.BrushShape = NewShape; if (lpImage && Window.hCursor == Window.hNullCursor) DisplayBrush(lpImage->hWnd, 32767, 32767, ON); if ( Tool.hRibbon ) { CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE, IDC_BRUSHCUSTOMNEW, Retouch.BrushShape ); SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L ); } break; case IDM_MOVEUP: case IDM_MOVEDOWN: case IDM_MOVELEFT: case IDM_MOVERIGHT: if (!lpImage) break; lpBase = ImgGetBase(lpImage); if (ImgGetSelObject(lpImage, NULL) == lpBase) break; dx = dy = 0; if (wID == IDM_MOVEUP) --dy; if (wID == IDM_MOVEDOWN) ++dy; if (wID == IDM_MOVELEFT) --dx; if (wID == IDM_MOVERIGHT) ++dx; lpObject = NULL; while (lpObject = ImgGetSelObject(lpImage, lpObject)) { rect = lpObject->rObject; OffsetRect(&rect, dx, dy); if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect)) break; } if (lpObject) break; AstralSetRectEmpty(&rAll); lpObject = NULL; while (lpObject = ImgGetSelObject(lpImage, lpObject)) { rect = lpObject->rObject; OffsetRect(&lpObject->rObject, dx, dy); AstralUnionRect(&rAll, &rAll, &lpObject->rObject); if (!lpObject->Pixmap.fNewFrame && EqualRect(&rect, &lpObject->rUndoObject)) lpObject->rUndoObject = lpObject->rObject; UpdateImage(&rect, TRUE); UpdateImage(&lpObject->rObject, TRUE); } if (wID == IDM_MOVEUP) { x = (rAll.left + rAll.right)/2; y = rAll.top; } else if (wID == IDM_MOVEDOWN) { x = (rAll.left + rAll.right)/2; y = rAll.bottom; } else if (wID == IDM_MOVELEFT) { x = rAll.left; y = (rAll.top + rAll.bottom)/2; } else if (wID == IDM_MOVERIGHT) { x = rAll.right; y = (rAll.top + rAll.bottom)/2; } File2Display(&x, &y); AutoScroll(lpImage->hWnd, x, y); AstralUpdateWindow(lpImage->hWnd); DisplayInfo(-1, &rAll); break; case IDM_LASTTOOL: DeactivateTool(); if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) ) SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L); break; case IDM_PREF: // prevent problems if running animations and they change // the wave mix dll setting in preferences StopAnimation(); AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc ); break; case IDC_VIEWLAST: // duplicate of function in the view ribbon if ( !lpImage ) break; RevertLastView(); break; // case IDC_VIEWFULL: // duplicate of function in the view ribbon // if ( !lpImage ) // break; // AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc ); // break; case IDC_VIEWALL: // duplicate of function in the view ribbon if ( !lpImage ) break; ViewAll(); break; case IDC_ZOOMIN: // duplicate of function in the view ribbon if ( !lpImage ) break; if (!lpImage->lpDisplay) break; if (!lpImage->lpDisplay->ViewPercentage) break; x = ( lpImage->lpDisplay->FileRect.left + lpImage->lpDisplay->FileRect.right ) / 2; y = ( lpImage->lpDisplay->FileRect.top + lpImage->lpDisplay->FileRect.bottom ) / 2; SaveLastView(); Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) ); break; case IDC_ZOOMOUT: // duplicate of function in the view ribbon if ( !lpImage ) break; if (!lpImage->lpDisplay) break; if (!lpImage->lpDisplay->ViewPercentage) break; x = ( lpImage->lpDisplay->FileRect.left + lpImage->lpDisplay->FileRect.right ) / 2; y = ( lpImage->lpDisplay->FileRect.top + lpImage->lpDisplay->FileRect.bottom ) / 2; SaveLastView(); Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) ); break; case IDM_HELP: Control.Hints = !Control.Hints; PutDefInt (Control.Hints,Control.Hints); break; default: return( FALSE ); } return( TRUE ); }