int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int iCmdShow) { HWND hwnd; MSG msg; WNDCLASS wndclass; INITCOMMONCONTROLSEX ice; HACCEL hAccelTable; hInstance = hInst; /* Load application title */ LoadString(hInst, IDS_SPI_NAME, szAppName, sizeof(szAppName) / sizeof(szAppName[0])); /* Load MsgBox() texts here to avoid loading them many times later */ LoadString(hInst, IDS_SPI_ABOUT, MsgAbout, sizeof(MsgAbout) / sizeof(MsgAbout[0])); LoadString(hInst, IDS_SPI_QUIT, MsgQuit, sizeof(MsgQuit) / sizeof(MsgQuit[0])); LoadString(hInst, IDS_SPI_WIN, MsgWin, sizeof(MsgWin) / sizeof(MsgWin[0])); LoadString(hInst, IDS_SPI_DEAL, MsgDeal, sizeof(MsgDeal) / sizeof(MsgDeal[0])); /* Window class for the main application parent window */ wndclass.style = 0; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInst; wndclass.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IDI_SPIDER)); wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)NULL; wndclass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wndclass.lpszClassName = szAppName; RegisterClass(&wndclass); ice.dwSize = sizeof(ice); ice.dwICC = ICC_BAR_CLASSES; InitCommonControlsEx(&ice); srand((unsigned)GetTickCount()); /* InitCardLib(); */ /* Construct the path to our help file */ MakePath(szHelpPath, MAX_PATH, _T(".hlp")); hwnd = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 0, /*The real size will be computed in WndProc through WM_GETMINMAXINFO */ 0, /* The real size will be computed in WndProc through WM_GETMINMAXINFO */ NULL, NULL, hInst, NULL); hwndMain = hwnd; ShowWindow(hwnd, iCmdShow); UpdateWindow(hwnd); hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1)); DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIFFICULTY), hwnd, DifficultyDlgProc); while(GetMessage(&msg, NULL,0,0)) { if(!TranslateAccelerator(hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; }
// // Unrostered runs report // BOOL FAR TMSRPT14(TMSRPTPassedDataDef *pPassedData) { TMSRPT14RDataDef *pTMSRPT14RData[ROSTER_MAX_DAYS]; HFILE hfOutputFile; BOOL bKeepGoing = FALSE; BOOL bFound; long numRuns[ROSTER_MAX_DAYS]; char szOutputString[128]; char szDay[16]; char dummy[256]; long maxRuns; int days[ROSTER_MAX_DAYS] = {TEXT_009, TEXT_010, TEXT_011, TEXT_012, TEXT_013, TEXT_014, TEXT_015}; int nI; int nJ; int nK; int nL; int rcode2; pPassedData->nReportNumber = 13; pPassedData->numDataFiles = 1; for(nI = 0; nI < m_LastReport; nI++) { if(TMSRPT[nI].originalReportNumber == pPassedData->nReportNumber) { StatusBarStart(hWndMain, TMSRPT[nI].szReportName); break; } } // // Open the output file // StatusBarText("Opening output file..."); strcpy(tempString, szReportsTempFolder); strcat(tempString, "\\tmsrpt14.txt"); hfOutputFile = _lcreat(tempString, 0); if(hfOutputFile == HFILE_ERROR) { LoadString(hInst, ERROR_202, szFormatString, sizeof(szFormatString)); sprintf(szarString, szFormatString, tempString); MessageBeep(MB_ICONSTOP); MessageBox((HWND)NULL, szarString, TMS, MB_ICONSTOP); goto deallocate; } strcpy(pPassedData->szReportDataFile[0], tempString); // // Initialize the TMSRPT14RData and TMSRPT14RDataData structures // rcode2 = btrieve(B_STAT, TMS_RUNS, &BSTAT, dummy, 0); if(rcode2 != 0 || BSTAT.numRecords == 0) { TMSError((HWND)NULL, MB_ICONSTOP, ERROR_266, (HANDLE)NULL); goto deallocate; } maxRuns = BSTAT.numRecords; for(nI = 0; nI < ROSTER_MAX_DAYS; nI++) { numRuns[nI] = 0; pTMSRPT14RData[nI] = (TMSRPT14RDataDef *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(TMSRPT14RDataDef) * maxRuns); if(pTMSRPT14RData[nI] == NULL) { AllocationError(__FILE__, __LINE__, FALSE); goto deallocate; } } // // Read the runs into TMSRPT14RData // for(nI = 0; nI < ROSTER_MAX_DAYS; nI++) { LoadString(hInst, days[nI], szDay, sizeof(szDay)); sprintf(tempString, "Reading %s runs...", szDay); StatusBarText(tempString); if(StatusBarAbort()) { goto deallocate; } if(ROSTERPARMS.serviceDays[nI] == NO_RECORD) { continue; } RUNSKey1.DIVISIONSrecordID = m_DivisionRecordID; RUNSKey1.SERVICESrecordID = ROSTERPARMS.serviceDays[nI]; RUNSKey1.runNumber = NO_RECORD; RUNSKey1.pieceNumber = NO_RECORD; rcode2 = btrieve(B_GETGREATER, TMS_RUNS, &RUNS, &RUNSKey1, 1); while(rcode2 == 0 && RUNS.DIVISIONSrecordID == m_DivisionRecordID && RUNS.SERVICESrecordID == ROSTERPARMS.serviceDays[nI]) { if(RUNS.pieceNumber == 1) { pTMSRPT14RData[nI][numRuns[nI]].recordID = RUNS.recordID; pTMSRPT14RData[nI][numRuns[nI]].runNumber = RUNS.runNumber; pTMSRPT14RData[nI][numRuns[nI]].cutAsRuntype = RUNS.cutAsRuntype; numRuns[nI]++; } rcode2 = btrieve(B_GETNEXT, TMS_RUNS, &RUNS, &RUNSKey1, 1); } } // // Go through the roster. Each time a run number shows up, kill it // from the list inside TMSRPT14RData. // rcode2 = btrieve(B_GETFIRST, TMS_ROSTER, &ROSTER, &ROSTERKey0, 0); while(rcode2 == 0) { StatusBarText("Cycling through the roster..."); for(nI = 0; nI < ROSTER_MAX_DAYS; nI++) { if(StatusBarAbort()) { goto deallocate; } if(ROSTER.WEEK[m_RosterWeek].RUNSrecordIDs[nI] == NO_RECORD) { continue; } for(nJ = 0; nJ < numRuns[nI]; nJ++) { if(ROSTER.WEEK[m_RosterWeek].RUNSrecordIDs[nI] == pTMSRPT14RData[nI][nJ].recordID) { pTMSRPT14RData[nI][nJ].recordID = NO_RECORD; break; } } } rcode2 = btrieve(B_GETNEXT, TMS_ROSTER, &ROSTER, &ROSTERKey0, 0); } // // Dump out the remaining runs // for(nI = 0; nI < ROSTER_MAX_DAYS; nI++) { if(StatusBarAbort()) { goto deallocate; } LoadString(hInst, days[nI], szDay, sizeof(szDay)); sprintf(tempString, "Writing output for day %s...", szDay); StatusBarText(tempString); for(bFound = FALSE, nJ = 0; nJ < numRuns[nI]; nJ++) { if(pTMSRPT14RData[nI][nJ].recordID != NO_RECORD) { bFound = TRUE; break; } } if(!bFound) { sprintf(szOutputString, "%10s\t", szDay); strcat(szOutputString, " 0\tNo runs\r\n"); _lwrite(hfOutputFile, szOutputString, strlen(szOutputString)); } else { for(; nJ < numRuns[nI]; nJ++) { sprintf(szOutputString, "%10s\t", szDay); if(pTMSRPT14RData[nI][nJ].recordID != NO_RECORD) { sprintf(tempString, "%6ld\t", pTMSRPT14RData[nI][nJ].runNumber); strcat(szOutputString, tempString); nK = (short int)LOWORD(pTMSRPT14RData[nI][nJ].cutAsRuntype); nL = (short int)HIWORD(pTMSRPT14RData[nI][nJ].cutAsRuntype); if(nK >= 0 && nK < NUMRUNTYPES && nL >= 0 && nL < NUMRUNTYPESLOTS) { strcat(szOutputString, RUNTYPE[nK][nL].localName); } strcat(szOutputString, "\r\n"); _lwrite(hfOutputFile, szOutputString, strlen(szOutputString)); } } } } bKeepGoing = TRUE; // // Free allocated memory // deallocate: for(nI = 0; nI < ROSTER_MAX_DAYS; nI++) { TMSHeapFree(pTMSRPT14RData[nI]); } _lclose(hfOutputFile); StatusBarEnd(); if(!bKeepGoing) { return(FALSE); } // // All done // return(TRUE); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nCmdShow*/) { SetDllDirectory(L""); SetTaskIDPerUUID(); CRegStdDWORD loc = CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033); long langId = loc; CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); CLangDll langDLL; hResource = langDLL.Init(_T("TortoiseIDiff"), langId); if (hResource == NULL) hResource = hInstance; CCmdLineParser parser(lpCmdLine); if (parser.HasKey(_T("?")) || parser.HasKey(_T("help"))) { TCHAR buf[1024] = { 0 }; LoadString(hResource, IDS_COMMANDLINEHELP, buf, _countof(buf)); MessageBox(NULL, buf, _T("TortoiseIDiff"), MB_ICONINFORMATION); langDLL.Close(); return 0; } MSG msg; hInst = hInstance; INITCOMMONCONTROLSEX used = { sizeof(INITCOMMONCONTROLSEX), ICC_STANDARD_CLASSES | ICC_BAR_CLASSES | ICC_WIN95_CLASSES }; InitCommonControlsEx(&used); // load the cursors we need curHand = (HCURSOR)LoadImage(hInst, MAKEINTRESOURCE(IDC_PANCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE); curHandDown = (HCURSOR)LoadImage(hInst, MAKEINTRESOURCE(IDC_PANDOWNCUR), IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE); std::unique_ptr<CMainWindow> mainWindow(new CMainWindow(hResource)); mainWindow->SetRegistryPath(_T("Software\\TortoiseGit\\TortoiseIDiffWindowPos")); std::wstring leftfile = parser.HasVal(_T("left")) ? parser.GetVal(_T("left")) : _T(""); std::wstring rightfile = parser.HasVal(_T("right")) ? parser.GetVal(_T("right")) : _T(""); if ((leftfile.empty()) && (lpCmdLine[0] != 0)) { int nArgs; LPWSTR * szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); if (szArglist) { if (nArgs == 3) { // Four parameters: // [0]: Program name // [1]: left file // [2]: right file if (PathFileExists(szArglist[1]) && PathFileExists(szArglist[2])) { leftfile = szArglist[1]; rightfile = szArglist[2]; } } } // Free memory allocated for CommandLineToArgvW arguments. LocalFree(szArglist); } mainWindow->SetLeft(leftfile.c_str(), parser.HasVal(_T("lefttitle")) ? parser.GetVal(_T("lefttitle")) : _T("")); mainWindow->SetRight(rightfile.c_str(), parser.HasVal(_T("righttitle")) ? parser.GetVal(_T("righttitle")) : _T("")); if (parser.HasVal(L"base")) mainWindow->SetSelectionImage(FileTypeBase, parser.GetVal(L"base"), parser.HasVal(L"basetitle") ? parser.GetVal(L"basetitle") : L""); if (parser.HasVal(L"mine")) mainWindow->SetSelectionImage(FileTypeMine, parser.GetVal(L"mine"), parser.HasVal(L"minetitle") ? parser.GetVal(L"minetitle") : L""); if (parser.HasVal(L"theirs")) mainWindow->SetSelectionImage(FileTypeTheirs, parser.GetVal(L"theirs"), parser.HasVal(L"theirstitle") ? parser.GetVal(L"theirstitle") : L""); if (parser.HasVal(L"result")) mainWindow->SetSelectionResult(parser.GetVal(L"result")); if (mainWindow->RegisterAndCreateWindow()) { HACCEL hAccelTable = LoadAccelerators(hResource, MAKEINTRESOURCE(IDR_TORTOISEIDIFF)); if (!parser.HasVal(L"left") && parser.HasVal(L"base") && !parser.HasVal(L"mine") && !parser.HasVal(L"theirs")) { PostMessage(*mainWindow, WM_COMMAND, ID_FILE_OPEN, 0); } if (parser.HasKey(_T("overlay"))) { PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_OVERLAPIMAGES, 0); } if (parser.HasKey(_T("fit"))) { PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEHEIGHTS, 0); PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEWIDTHS, 0); } if (parser.HasKey(_T("fitwidth"))) { PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEWIDTHS, 0); } if (parser.HasKey(_T("fitheight"))) { PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_FITIMAGEHEIGHTS, 0); } if (parser.HasKey(_T("showinfo"))) { PostMessage(*mainWindow, WM_COMMAND, ID_VIEW_IMAGEINFO, 0); } // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(*mainWindow, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; } langDLL.Close(); DestroyCursor(curHand); DestroyCursor(curHandDown); CoUninitialize(); return 1; }
BOOL APIENTRY ExtractFilesProc(HANDLE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG lParam) { char szTmpFile[MAX_PATH]; char szArcLstFile[MAX_PATH]; HRSRC hResInfo; HGLOBAL hGlobal; LPBYTE lpBytes; LPBYTE lptr; LPBYTE lpBytesUnCmp; HANDLE hFile; char szStatus[128]; char szText[4096]; // Update the UI LoadString(hInst, IDS_STATUS_EXTRACTING, szText, sizeof(szText)); wsprintf(szStatus, szText, lpszName); SetStatusLine(szStatus); if(gbUncompressOnly == TRUE) lstrcpy(szTmpFile, lpszName); else { // Create a file in the temp directory GetFullTempPathName(lpszName, sizeof(szTmpFile), szTmpFile); CreateDirectoriesAll(szTmpFile); } if((*gszFileToUncompress != '\0') && (lstrcmpi(lpszName, gszFileToUncompress) != 0)) // We have a file to uncompress, but the one found is not the one we want, // so return TRUE to continue looking for the right one. return TRUE; // Extract the file hResInfo = FindResource((HINSTANCE)hModule, lpszName, lpszType); hGlobal = LoadResource((HINSTANCE)hModule, hResInfo); lpBytes = (LPBYTE)LockResource(hGlobal); // Create the file hFile = CreateFile(szTmpFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL); if (hFile != INVALID_HANDLE_VALUE) { DWORD dwSize; DWORD dwSizeUnCmp; DWORD dwTemp; GetFullTempPathName("Archive.lst", sizeof(szArcLstFile), szArcLstFile); WritePrivateProfileString("Archives", lpszName, "TRUE", szArcLstFile); lptr = (LPBYTE)malloc((*(LPDWORD)(lpBytes + sizeof(DWORD))) + 1); if(!lptr) { char szBuf[512]; LoadString(hInst, IDS_ERROR_OUT_OF_MEMORY, szBuf, sizeof(szBuf)); MessageBox(NULL, szBuf, NULL, MB_OK | MB_ICONEXCLAMATION); return FALSE; } lpBytesUnCmp = lptr; dwSizeUnCmp = *(LPDWORD)(lpBytes + sizeof(DWORD)); // Copy the file. The first DWORD specifies the size of the file dwSize = *(LPDWORD)lpBytes; lpBytes += (sizeof(DWORD) * 2); dwTemp = uncompress(lpBytesUnCmp, &dwSizeUnCmp, lpBytes, dwSize); while (dwSizeUnCmp > 0) { DWORD dwBytesToWrite, dwBytesWritten; ProcessWindowsMessages(); dwBytesToWrite = dwSizeUnCmp > 4096 ? 4096 : dwSizeUnCmp; if (!WriteFile(hFile, lpBytesUnCmp, dwBytesToWrite, &dwBytesWritten, NULL)) { char szBuf[512]; LoadString(hInst, IDS_STATUS_EXTRACTING, szText, sizeof(szText)); wsprintf(szBuf, szText, szTmpFile); MessageBox(NULL, szBuf, szTitle, MB_OK | MB_ICONEXCLAMATION); FreeResource(hResInfo); if(lptr) free(lptr); return FALSE; } dwSizeUnCmp -= dwBytesWritten; lpBytesUnCmp += dwBytesWritten; // Update the UI to reflect the total number of bytes written static DWORD nBytesWritten = 0; nBytesWritten += dwBytesWritten; UpdateProgressBar(nBytesWritten * 100 / nTotalBytes); } CloseHandle(hFile); } // Release the resource FreeResource(hResInfo); if(lptr) free(lptr); if((*gszFileToUncompress != '\0') && (lstrcmpi(lpszName, gszFileToUncompress) == 0)) // We have a file to uncompress, and we have uncompressed it, // so return FALSE to stop uncompressing any other file. return FALSE; return TRUE; // keep enumerating }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS wc; HWND hwndFW; hInst = hInstance; LoadString(hInst, IDS_TITLE, szTitle, MAX_BUF); // Parse the command line ParseCommandLine(lpCmdLine); /* Allow multiple installer instances with the provision that each instance is guaranteed to have its own unique setup directory */ if(FindWindow("NSExtracting", "Extracting...") != NULL || (hwndFW = FindWindow(CLASS_NAME_SETUP_DLG, NULL)) != NULL || (hwndFW = FindWindow(CLASS_NAME_SETUP, NULL)) != NULL) { if (gbAllowMultipleInstalls) { char szTempPath[MAX_BUF]; GetFullTempPathName("", MAX_BUF, szTempPath); DWORD dwLen = lstrlen(gszWizTempDir); for(int i = 1; i <= 100 && (FileExists(szTempPath) != FALSE); i++) { itoa(i, (gszWizTempDir + dwLen), 10); GetFullTempPathName("", MAX_BUF, szTempPath); } if (FileExists(szTempPath) != FALSE) { MessageBox(NULL, "Cannot create temp directory", NULL, MB_OK | MB_ICONEXCLAMATION); exit(1); } } else { if (hwndFW!=NULL) { ShowWindow(hwndFW, SW_RESTORE); SetForegroundWindow(hwndFW); } return(1); } } // Figure out the total size of the resources EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)SizeOfResourcesProc, 0); // Register a class for the gauge memset(&wc, 0, sizeof(wc)); wc.lpfnWndProc = (WNDPROC)GaugeWndProc; wc.hInstance = hInstance; wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wc.lpszClassName = "NSGauge"; RegisterClass(&wc); // Register a class for the main dialog memset(&wc, 0, sizeof(wc)); wc.style = CS_DBLCLKS | CS_SAVEBITS | CS_BYTEALIGNWINDOW; wc.lpfnWndProc = DefDlgProc; wc.cbClsExtra = 0; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszClassName = "NSExtracting"; RegisterClass(&wc); if(dwMode != SILENT) { // Display the dialog box dlgInfo.hWndDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EXTRACTING), NULL, (DLGPROC)DialogProc); UpdateWindow(dlgInfo.hWndDlg); } // Extract the files EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)ExtractFilesProc, 0); // Launch the install program and wait for it to finish RunInstaller(); return 0; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: ここにコードを挿入してください。 MSG msg; HACCEL hAccelTable; // グローバル文字列を初期化しています。 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_WALL, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // アプリケーションの初期化を実行します: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } int ret; ret = OneTimeSceneInit(); if( ret ){ _ASSERT( 0 ); return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WALL)); // Now we're ready to recieve and process Windows messages. BOOL bGotMsg; //MSG msg; PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE ); while( WM_QUIT != msg.message ) { // Use PeekMessage() if the app is active, so we can use idle time to // render the scene. Else, use GetMessage() to avoid eating CPU time. // if( m_bActive ) bGotMsg = PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ); //else // bGotMsg = GetMessage( &msg, NULL, 0U, 0U ); if( bGotMsg ) { // Translate and dispatch the message if( 0 == TranslateAccelerator(msg.hwnd, hAccelTable, &msg) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } }else{ if( Render3DEnvironment() != 0 ){ SendMessage( msg.hwnd, WM_CLOSE, 0, 0 ); } } } E3DBye(); return (int)msg.wParam; }
//--------------------------------------------------------------------------- void __fastcall TGroundGroupForm::OpenGroundGroupMobile(int X,int Y) { // int* ctrlarray; char buff[50]; if (!dialheight[0][0]) { dialheight[0][0]=Height; dialheight[0][1]=Panel1->Top; dialheight[0][2]=ButtonPanel->Top; int delta=GGPanel->Height; dialheight[1][0]=dialheight[0][0]-delta; dialheight[1][1]=dialheight[0][1]-delta; dialheight[1][2]=dialheight[0][2]-delta; } Height=dialheight[0][0]; Panel1->Top=dialheight[0][1]; ButtonPanel->Top=dialheight[0][2]; info_grndgrp* G=*Persons2::ConvertPtrUID(MissionEditor->currobj); // MissionEditor->FillComboBox(IDS_CENTRALPOWERS, IDS_ALLIES, NationalityComboBox, // G->Nationality); UniqueID uidwp; GGAltLabel->Visible = false; GGEditAlt->Visible = false; int groupindex = -1; if (G->shape==ENABLE_COMPLEX_VAL) if (G->shape->type==Expr::EXPR_GLOB) FindShapes(G->shape->UsesGlobRef(),groupindex,3); else if (G->shape[2]->type==Expr::EXPR_GLOB) FindShapes(G->shape[2]->UsesGlobRef(),groupindex,3); else FindShapes(G->shape.Evaluate(2),groupindex,-1); else FindShapes(G->shape.Evaluate(2),groupindex,-1); RefreshText(); BfieldLabel->Caption = MissionEditor->loadedbfs[G->bfieldindex].name; UniqueIDBand uidband; if ((int)G->Status.size > (int)ITEMSIZE) { grndvel = G->vel.Evaluate(); uidwp=G->wpref; }else { uidwp = UID_Null; } uidband = Persons2::getbandfromUID(MissionEditor->currobj); int text = MissionEditor->GetBandorShapeText(MissionEditor->currobj); LoadString(HInstance,text,buff,sizeof(buff)); Caption = buff; GGPanel->Visible = true; // ButtonPanel->Top = 147; // Height = 284; //325; // MissionEditor->FillComboBox(IDS_CENTRALPOWERS, IDS_ALLIES, NationalityComboBox, // G->nationality-1); GGSpeedLabel->Visible = true; GGSpeedData->Visible = true; AltSpinButton->Visible = true; SpdComboBox->Visible = true; GGFormationSizeLabel->Visible = true; GGFormationTypeLabel->Visible = true; GGFormationSpinEdit->Visible = true; GGFormTypeBox->Visible = true; GG_StatusLabel->Visible = true; GG_StatusComboBox->Visible = true; // if ( ((int)G->shape.Evaluate(2) == (int)TRAIN3) // || ((int)G->shape.Evaluate(2) == (int)TRAIN4) // ) // GG_StatusComboBox->Enabled = false; //else GG_StatusComboBox->Enabled = true; GGEventMore->Visible = false; if ((int)G->Status.size > (int)ITEMSIZE) // if (uidwp != UID_Null) { GGRoute->Visible = true; GGRoute->Enabled = true; SpdComboBox->OnChange = NULL; RefreshSpeedInfo(); SpdComboBox->OnChange = SpdComboBoxChange; int inform = G->inform.Evaluate(); if ( inform == ENABLE_COMPLEX_VAL) //default set and never been filled in inform = 1; int maxmobiles = 6; // if ( ((int)G->shape.Evaluate(2) == (int)BTANK) // || ((int)G->shape.Evaluate(2) == (int)GTANK) // ) //{ // if ((int)uidband == (int)RedSAMBAND) // { // if ((maxmobiles+MissionEditor->RedTanksCnt-inform) > MissionEditor->RedTanksMax) // maxmobiles = MissionEditor->RedTanksMax - MissionEditor->RedTanksCnt+inform; // }else // { // if ((maxmobiles+MissionEditor->BlueTanksCnt-inform) > MissionEditor->BlueTanksMax) // maxmobiles = MissionEditor->BlueTanksMax - MissionEditor->BlueTanksCnt+inform; // } // }else { if ((int)uidband == (int)RedArmourBAND) { if ((maxmobiles+MissionEditor->RedGroundMobilesCnt-inform) > MissionEditor->RedGroundMobilesMax) maxmobiles = MissionEditor->RedGroundMobilesMax - MissionEditor->RedGroundMobilesCnt+inform; }else { if ((maxmobiles+MissionEditor->BlueGroundMobilesCnt-inform) > MissionEditor->BlueGroundMobilesMax) maxmobiles = MissionEditor->BlueGroundMobilesMax - MissionEditor->BlueGroundMobilesCnt+inform; } } GGFormationSpinEdit->MaxValue = maxmobiles; GGFormationSpinEdit->Text = IntToStr(inform); int form = G->form.Evaluate(); if ( form == ENABLE_COMPLEX_VAL) //default set and never been filled in form = IDS_TEXT_SINGLEFILE_FORM-IDS_TEXT_STACKED; MissionEditor->PartFillComboBox(IDS_TEXT_STACKED, IDS_TEXT_SINGLEFILE_FORM, GGFormTypeBox, form,GroundFormCtrl); // if ( ((int)G->band == (int)BlueSAMBAND) // || ((int)G->band == (int)RedSAMBAND) // || ((int)G->shape.Evaluate(2) == (int)TROOPS) // || ((int)G->shape.Evaluate(2) == (int)TROOP1) // ) // { // GGSpeedLabel->Enabled = false; // SpdComboBox->Enabled = false; // GGSpeedData->Enabled = false; // }else // { GGSpeedLabel->Enabled = true; SpdComboBox->Enabled = true; GGSpeedData->Enabled = true; // } GGFormationSizeLabel->Enabled = true; GGFormationTypeLabel->Enabled = true; GGFormationSpinEdit->Enabled = true; // if ( ((int)G->shape.Evaluate(2) == (int)TRAIN3) // || ((int)G->shape.Evaluate(2) == (int)TRAIN4) // ) // { // GGFormTypeBox->Enabled = false; // GGFormTypeBox->ItemIndex = IDS_TEXT_SINGLEFILE_FORM-IDS_TEXT_STACKED; // } // else GGFormTypeBox->Enabled = true; GG_StatusComboBox->ItemIndex = 0; }else { GGRoute->Visible = false; GGRoute->Enabled = false; SpdComboBox->Enabled = false; GGSpeedLabel->Enabled = false; GGSpeedData->Enabled = false; GGFormationSizeLabel->Enabled = false; GGFormationTypeLabel->Enabled = false; GGFormationSpinEdit->Value = 1; GGFormationSpinEdit->Enabled = false; GGFormTypeBox->Enabled = false; GG_StatusComboBox->ItemIndex = 1; } MissionEditor->currwp = uidwp; int result = GroundGroupForm->ShowModal(); // MissionEditor->PaintBox->Invalidate(); switch (result) { case mrOk: { // MissionEditor->MissionEdited=true; info_itemS* curritem =*Persons2::ConvertPtrUID(MissionEditor->currobj); MissionEditor->loadedbfs[curritem->bfieldindex].changed=true; int shape=ShapeComboBox->ItemIndex; if (shape>=0) { int shapepage=ShapeCat->ItemIndex; if (shapepage==3) { GlobRefExpr* gr=new GlobRefExpr(AvailableShapes[3][shape]); if (G->shape.complex && G->shape.complex->type==Expr::EXPR_FORM) G->shape[2]=gr; else G->shape = gr; } else { shape=AvailableShapes[shapepage][shape]; if (G->shape.complex && G->shape.complex->type==Expr::EXPR_FORM) G->shape[2]=shape; else G->shape = shape; } } if (curritem->shape.complex && curritem->shape.complex->type==Expr::EXPR_FORM) curritem->shape[2]=shape; else curritem->shape = shape; MissionEditor->ChangeTag(groupindex,shape); if ((int)curritem->Status.size > (int)ITEMSIZE) { info_grndgrp* G=*Persons2::ConvertPtrUID(MissionEditor->currobj); // if ( ((int)G->shape.Evaluate(2) == (int)BTANK) // || ((int)G->shape.Evaluate(2) == (int)GTANK) // ) // { // if ((int)uidband == (int)RedSAMBAND) // { // MissionEditor->RedTanksCnt -= G->inform; // G->inform =GGFormationSpinEdit->Value; // MissionEditor->RedTanksCnt += (int)G->inform; // }else // { // MissionEditor->BlueTanksCnt -= G->inform; // G->inform =GGFormationSpinEdit->Value; // MissionEditor->BlueTanksCnt += (int)G->inform; // } // }else { if ((int)uidband == (int)RedArmourBAND) { MissionEditor->RedGroundMobilesCnt -= G->inform; G->inform =GGFormationSpinEdit->Value; MissionEditor->RedGroundMobilesCnt += (int)G->inform; }else { MissionEditor->BlueGroundMobilesCnt -= G->inform; G->inform =GGFormationSpinEdit->Value; MissionEditor->BlueGroundMobilesCnt += (int)G->inform; } } G->form = MissionEditor->FindOrginalIndex(IDS_TEXT_STACKED,IDS_TEXT_SINGLEFILE_FORM, GGFormTypeBox->ItemIndex,GroundFormCtrl); if (GGSpeedData->Visible) { if (MissionEditor->Configure_Units == METRIC) G->vel = (MissionEditor->ValidEdit(GGSpeedData) * 100+50)/36; else if (MissionEditor->Configure_Units == IMPERIAL) G->vel = (MissionEditor->ValidEdit(GGSpeedData) * 1000+500)/224; else G->vel = (MissionEditor->ValidEdit(GGSpeedData) * 100+50)/36; } } EditText(); break; } case mrRoute: { WayPointForm->ShowWpDialog( 0,0); break; } case mrDelete: { AcItemForm->DeleteCurrTransItem(); break; } } GGCancel->Enabled = true; // MissionEditor->MobileSpdButtonState(); MissionEditor->DisableWPUsageifnecessary(); //rdh }
/*---------------------------------------------------------------------- Get info about JRE from registry. ----------------------------------------------------------------------*/ static int findJreInfoFromRegistry(char *path, char *args) { INT i; HKEY hKey; /* Key handle of NetShell */ CHAR ValueName[MAX_PATH]; /* Name of value. */ DWORD cbValueName; /* Size of value name. */ DWORD dwType; /* Type of data. */ CHAR bData[MAX_PATH]; /* Data buffer. */ DWORD cbData; /* Size of data buffer. */ DWORD retCode; CHAR *Param; BOOL found = FALSE; /* We have found info in the registry */ /* Open the key for jre and get info about it. */ retCode = RegOpenKeyEx(hKeyRoot, SubKey, 0, KEY_EXECUTE, &hKey); if (retCode != ERROR_SUCCESS) { DPRINT(("stub: RegOpenKeyEx error for hKey = %d\n", retCode)); return FALSE; } for (i = 0; retCode == ERROR_SUCCESS; i++) { bData[0] = '\0'; ValueName[0] = '\0'; cbData = MAX_PATH; cbValueName = MAX_PATH; /* Enumerate the key values. */ retCode = RegEnumValue(hKey, i, ValueName, &cbValueName, NULL, &dwType, bData, &cbData); if (retCode != ERROR_SUCCESS) { if (dwType < REG_FULL_RESOURCE_DESCRIPTOR && retCode != ERROR_NO_MORE_ITEMS) { DPRINT(("stub: ERROR, RegEnumValue = %d cbData = %d line %d\n" , retCode, cbData, __LINE__)); return FALSE; } } DPRINT(("stub.findJreInfo...: i=%d, ValueName=%s, cbValueName=%d, dwType=%d,\n\t bData=%s, cbData=%d; retCode=%d\n", i, ValueName, cbValueName, dwType, bData, cbData, retCode)); /* Process the value accordingly. */ Param = _strlwr(ValueName); if(!strcmp("javahome", Param)) { DPRINT(("stub.findJreInfo...: Setting path and args to %s\n",bData)); strcat(path, bData); strcat(args, bData); found = TRUE; } if(!strcmp("microversion", Param)) { DPRINT(("stub.findJreInfo...: found JRE 1.1.%s\n",bData)); if(atoi(bData) < 6) { CHAR title[TITLELEN]; CHAR msg[MSGLEN]; LoadString(NULL, IDS_OLD_JRE_TITLE, title, TITLELEN); LoadString(NULL, IDS_OLD_JRE_MSG, msg, MSGLEN); MessageBox(NULL, msg, title, MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND); DPRINT(("stub: version of jre is too old")); return FALSE; } } } DPRINT(("stub.findJreInfo...: done, found=%d",found)); return found; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Hook spew output. SpewOutputFunc( MySpewOutputFunc ); // Get access to the registry.. RegCreateKey( HKEY_LOCAL_MACHINE, VMPI_SERVICE_KEY, &g_hVMPIServiceKey ); // Setup our version string. LoadString( hInstance, VMPI_SERVICE_IDS_VERSION_STRING, g_VersionString, sizeof( g_VersionString ) ); // Setup the base app path. if ( !GetModuleFileName( GetModuleHandle( NULL ), g_BaseAppPath, sizeof( g_BaseAppPath ) ) ) { Warning( "GetModuleFileName failed.\n" ); return false; } V_StripLastDir( g_BaseAppPath, sizeof( g_BaseAppPath ) ); // Setup the cache path. V_ComposeFileName( g_BaseAppPath, "vmpi_service_cache", g_FileCachePath, sizeof( g_FileCachePath ) ); const char *pArg = FindArg( __argc, __argv, "-mpi_pw", NULL ); SetPassword( pArg ); if ( FindArg( __argc, __argv, "-console" ) ) { g_RunMode = RUNMODE_CONSOLE; } else { g_RunMode = RUNMODE_SERVICE; } if ( FindArg( __argc, __argv, "-superdebug" ) ) g_bSuperDebugMode = true; g_AppStartTime = GetTickCount(); g_bMinimized = FindArg( __argc, __argv, "-minimized" ) != NULL; ServiceHelpers_Init(); g_hInstance = hInstance; LoadStateFromRegistry(); // Install the service? if ( g_RunMode == RUNMODE_CONSOLE ) { RunAsNonServiceApp(); } else { RunService(); } return 0; }
// // FUNCTION: InitInstance(HINSTANCE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; TCHAR szTitle[MAX_LOADSTRING]; // title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // main window class name g_hInst = hInstance; // Store instance handle in our global variable LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_WEMAP, szWindowClass, MAX_LOADSTRING); if (!MyRegisterClass(hInstance, szWindowClass)) { return FALSE; } EnumWindows( enum_proc, (LPARAM)"Ѕлокнот" ); if (!hWnd_navitel) { FILE * pFileTXT; SYSTEMTIME st; GetLocalTime(&st); pFileTXT = fopen (fname,"a"); fprintf(pFileTXT, "---> Date: [%02d, %02d, %d] Time: [%02d:%02d:%02d] " ,st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond); fprintf (pFileTXT, " navitel not running - "); STARTUPINFO cif; ZeroMemory(&cif,sizeof(STARTUPINFO)); /*LPSHELLEXECUTEINFO lpExecInfo; ZeroMemory(&SHExecInfo, sizeof(SHExecInfo)); SHExecInfo.cbSize = sizeof(SHExecInfo); SHExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS; SHExecInfo.nShow = SW_SHOWNORMAL; SHExecInfo.lpFile = "\\Storage Card\\navi\\navitel.exe"; if(!ShellExecuteEx(&SHExecInfo)) { */ if (CreateProcess(L"\\Doc Disk\\igo8\\igo8.exe",NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&cif,&pi_navitel)==TRUE) { fprintf (pFileTXT, " navitel runned.\n"); } else fprintf (pFileTXT, " navitel run faied.\n"); fclose (pFileTXT); } hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } hWnd_self = hWnd; /* RegisterHotKey(hWnd, 10001, MOD_KEYUP, VK_APP1); RegisterHotKey(hWnd, 10002, MOD_KEYUP, VK_APP2); RegisterHotKey(hWnd, 10003, MOD_KEYUP, VK_APP3); RegisterHotKey(hWnd, 10004, MOD_KEYUP, VK_APP4); RegisterHotKey(hWnd, 10005, MOD_KEYUP, VK_APP5); RegisterHotKey(hWnd, 10006, MOD_KEYUP, VK_APP6); */ ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); if (g_hWndCommandBar) { CommandBar_Show(g_hWndCommandBar, TRUE); } return TRUE; }
/*-------------------------------------------------------------------------- Launches NetShell, waits for Netshell and all of NetShell's launched processes to die and then relaunches NetShell if nothing exited with non-zero exit status. --------------------------------------------------------------------------*/ int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE hinstExePrev, LPSTR lpszCmdLine, int nCmdShow) { int firsttime = 1; char cmd[2*MAX_PATH]; char args[MAX_PATH]; char cwd[MAX_PATH]; char strhandle[MAX_HSTR]; DWORD nhandles = 0; DWORD exitCode = 0; DWORD dwThreadId, iSignal; HANDLE hpipeRead, hpipeWrite, hSelf; HANDLE *hArray, *hStartArr; SECURITY_ATTRIBUTES saAttr; STARTUPINFO si; PROCESS_INFORMATION pi; #ifdef DEBUG #ifndef PRINT_STDOUT { char logfile[MAX_PATH]; sprintf(logfile, "%x", time(NULL)); strcat(logfile, ".log"); flog = fopen(logfile, "w"); } #endif #endif /* Pick random session id for benefit of serial and modem drivers */ sprintf(strhandle, "%x", GetTickCount()); if (!SetEnvironmentVariable(DPSTUBID, strhandle)) { DPRINT(("stub: set environment variable error %x.\n", GetLastError())); exit(1); } hArray = (HANDLE *)malloc(MAXIMUM_WAIT_OBJECTS * sizeof(HANDLE)); hStartArr = hArray; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; if (!DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(), &hSelf, 0, TRUE, DUPLICATE_SAME_ACCESS)) { DPRINT(("stub: error duplicating own handle\n")); exit(1); } sprintf(strhandle, "%x", hSelf); if (!SetEnvironmentVariable(DPSTUB, strhandle)) { DPRINT(("stub: set environment variable error %x.\n", GetLastError())); exit(1); } // DPRINT(("stub: current process handle is %s\n", strhandle)); /* create event so read thread can signal when it's read a new process */ if (!(hreadEvent = CreateEvent(NULL, FALSE, FALSE, "ReadEvent"))) { DPRINT(("stub: create read event error %x.\n", GetLastError())); exit(1); } *hArray++ = hreadEvent; nhandles++; // DPRINT(("stub: read event handle is %x\n", *(hArray - 1))); /* create event so read thread knows main thread has finished processing hSpawn and can continue to get new processes */ if (!(hcontEvent = CreateEvent(NULL, FALSE, FALSE, "ContinueReadEvent"))) { DPRINT(("stub: create continue read event error %x.\n", GetLastError())); exit(1); } // DPRINT(("stub: continue read event handle is %x\n", hcontEvent)); /* create a pipe with read end uninheritable and write end inheritable*/ if(!CreatePipe(&hpipeRead, &hpipeWrite, &saAttr, sizeof(HANDLE))) { DPRINT(("stub: create pipe error %x.\n", GetLastError())); exit(1); } sprintf(strhandle, "%x", hpipeWrite); if (!SetEnvironmentVariable(DPSTUBWPIPE, strhandle)) { DPRINT(("stub: set environment variable error %x.\n", GetLastError())); exit(1); } if (!DuplicateHandle(GetCurrentProcess(), hpipeRead, GetCurrentProcess(), &hpipeReadDup, 0, FALSE, DUPLICATE_SAME_ACCESS)) { DPRINT(("stub: error duplicating uninheritable handle\n")); exit(1); } CloseHandle(hpipeRead); // DPRINT(("stub: uninheritable pipe handle is %x.\n", hpipeReadDup)); /* create a thread to read from pipe about new processes*/ if (CreateThread(NULL, 0, readThread, 0, 0, &dwThreadId) < 0) { DPRINT(("stub: create thread error %x.\n", GetLastError())); exit(1); } /* set command and current working directory for CreateProcess() */ { char *buf; char path[2*MAX_PATH]; char cmdline[1024]; if (getinfo(path, args, cwd) != 0) { CHAR title[TITLELEN]; CHAR msg[MSGLEN]; LoadString(NULL, IDS_NO_JRE_TITLE, title, TITLELEN); LoadString(NULL, IDS_NO_JRE_MSG, msg, MSGLEN); MessageBox(NULL, msg, title, MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND); exit(1); } strcat(cmd, "\""); strcat(cmd, path); strcat(cmd, "\" "); strcat(cmd, args); buf = GetCommandLine(); if (!buf) { DPRINT(("stub: error getting commandline args; quitting\n")); exit(1); } strcpy(cmdline, buf); #ifdef DEFAULTARGS /* If no switches given, append default args */ if (!strstr(cmdline, " -")) { strcat(cmdline, " "); strcat(cmdline, DEFAULTARGS); } #endif buf = cmdline; DPRINT(("args: %s\n", buf)); { OSVERSIONINFO VersionInfo; VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx(&VersionInfo)) { DPRINT(("stub: cannot determine OS; quitting\n")); exit(1); } if (VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT || VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { while (' ' == *buf || '\t' == *buf) buf++; if (*buf == '\"') { buf++; if (!(buf = strchr(buf, '\"'))) { DPRINT(("stub: cannot get commandline args; quitting\n")); exit(1); } buf++; } else { if (buf = strchr(buf, ' ')) { buf++; } else { buf = "\0"; } } } else { CHAR title[TITLELEN]; CHAR msg[MSGLEN]; LoadString(NULL, IDS_UNSP_OS_TITLE, title, TITLELEN); LoadString(NULL, IDS_UNSP_OS_MSG, msg, MSGLEN); MessageBox(NULL, msg, title, MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND); DPRINT(("OS not supported; quitting\n")); exit(1); } while (' ' == *buf || '\t' == *buf) buf++; if (2 * MAX_PATH < strlen(cmd) + strlen(buf) + 2) { DPRINT(("stub: cmd buffer not large enough to hold args; quitting\n")); exit(1); } strcat(cmd, " "); strcat(cmd, buf); } } DPRINT(("cmd: %s\n", cmd)); /* launch NetShell then wait for NetShell and all its launched processes to die, then if all exit status are zero, relaunch NetShell */ do { memset(&pi, 0, sizeof(pi)); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); /* launch NetShell */ DPRINT(("stub: Launching %s from %s.\n", cmd, cwd)); if (!CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, cwd, &si, &pi)) { DPRINT(("stub: Error launching %s from %s; quitting\n", cmd, cwd)); DPRINT(("stub: GetLastError returns %x", GetLastError())); exit(1); } if (firsttime) { char *buf = " -r"; if (2 * MAX_PATH < strlen(cmd) + strlen(buf) + 1) { DPRINT(("stub: cmd buffer not large enough to hold args\n")); exit(1); } strcat(cmd, buf); firsttime = 0; } CloseHandle(pi.hThread); *hArray++ = pi.hProcess; nhandles++; DPRINT(("stub: Launch complete; shell handle %x.\n", *(hArray-1))); /* Wait for NetShell and all its launched processes to exit */ do { iSignal = WaitForMultipleObjects(nhandles, hStartArr, FALSE, INFINITE); if (WAIT_FAILED == iSignal) { DPRINT(("stub: wait error %x.\n", GetLastError())); exit(1); } iSignal -= WAIT_OBJECT_0; if (iSignal >= 0 && iSignal < nhandles) { if (*(hStartArr + iSignal) != hreadEvent) { if (!GetExitCodeProcess(*(hStartArr + iSignal), &exitCode)) { DPRINT(("stub: Error reading spawned process\n")); exit(1); } DPRINT(("stub: deleting handle %x, exit code %d.\n", *(hStartArr + iSignal), exitCode)); if (exitCode) break; CloseHandle(*(hStartArr + iSignal)); if (nhandles && iSignal < nhandles - 1) { *(hStartArr + iSignal) = *(hStartArr + nhandles - 1); } nhandles--; hArray = hStartArr + nhandles; } else { // DPRINT(("stub: got new handle %x\n", hSpawn)); if (hSpawn != 0) { if (hSpawn < 0) { DPRINT(("stub: Error reading spawned process; hSpawn %x\n", hSpawn)); exit(1); } DPRINT(("stub: adding handle %x.\n", hSpawn)); *hArray++ = hSpawn; nhandles++; hSpawn = 0; } else if (hSerial != 0) { char *pstrhandle; if (hSerial < 0 && hSerial != INVALID_HANDLE_VALUE) { DPRINT(("stub: Error reading serial handle; hSerial %x\n", hSerial)); exit(1); } if (hSerial == INVALID_HANDLE_VALUE) { if (GetEnvironmentVariable(DPSTUBMODEM, strhandle, 256)) { HANDLE baseadr; sscanf(strhandle, "%x", &baseadr); CloseHandle(baseadr); DPRINT(("stub: deleted serial h:%x\n",baseadr)); pstrhandle = NULL; } } else { DPRINT(("stub: setting serial h:%x.\n", hSerial)); sprintf(strhandle, "%x", hSerial); pstrhandle = strhandle; } if (!SetEnvironmentVariable(DPSTUBMODEM, pstrhandle)) { DPRINT(("stub: set environment variable error %x.\n", GetLastError())); exit(1); } hSerial = 0; } else { DPRINT(("stub: Error no handle set\n")); exit(1); } if (!SetEvent(hcontEvent)) { DPRINT(("stub: set continue read event error %x.\n", GetLastError())); exit(1); } } } else { DPRINT(("stub: error wait returned invalid handle %d\n", iSignal)); exit(1); } // DPRINT(("stub: nhandles = %d\n", nhandles)); } while (nhandles > 1); // DPRINT(("stub: exited inside loop\n")); #ifdef NOLOOP break; #endif } while (!exitCode); return 0; }
/* Main program */ int main (int argc, char **argv) { char *opt, *needle = NULL; int ret = 0; TCHAR lpMessage[4096]; int invert_search = 0; /* flag to invert the search */ int count_lines = 0; /* flag to whether/not count lines */ int number_output = 0; /* flag to print line numbers */ int ignore_case = 0; /* flag to be case insensitive */ int at_start = 0; /* flag to Match if at the beginning of a line. */ int at_end = 0; /* flag to Match if at the beginning of a line. */ int reg_express = 0; /* flag to use/not use regular expressions */ int exact_match = 0; /* flag to be exact match */ int sub_dirs= 0; /* this and all subdirectories */ int only_fname= 0; /* print only the name of the file*/ int literal_search=0; FILE *pfile; /* file pointer */ int hfind; /* search handle */ struct _finddata_t finddata; /* _findfirst, filenext block */ /* Scan the command line */ while ((--argc) && (needle == NULL)) { if (*(opt = *++argv) == '/') { switch (opt[1]) { case 'b': case 'B': /* Matches pattern if at the beginning of a line */ at_start = 1; break; //case 'c': //case 'C': /* Literal? */ // literal_search = 1; // break; case 'e': case 'E': /* matches pattern if at end of line */ at_end = 1; break; case 'i': case 'I': /* Ignore */ ignore_case = 1; break; case 'm': case 'M': /* only filename */ only_fname = 1; break; case 'n': case 'N': /* Number */ number_output = 1; break; case 'r': case 'R': /* search strings as regular expressions */ reg_express = 1; break; case 's': case 'S': /* search files in child directory too*/ sub_dirs = 1; break; case 'v': case 'V': /* Not with */ invert_search = 1; break; case 'x': case 'X': /* exact match */ exact_match = 1; break; default: usage (); exit (2); /* syntax error .. return error 2 */ break; } } else { /* Get the string */ if (needle == NULL) { /* Assign the string to find */ needle = *argv; } } } /* Check for search string */ if (needle == NULL) { /* No string? */ usage (); exit (1); } /* Scan the files for the string */ if (argc == 0) { ret = find_str (needle, stdin, invert_search, count_lines, number_output, ignore_case, at_start, literal_search, at_end, reg_express, exact_match, sub_dirs, only_fname); } while (--argc >= 0) { hfind = _findfirst (*++argv, &finddata); if (hfind < 0) { /* We were not able to find a file. Display a message and set the exit status. */ LoadString( GetModuleHandle(NULL), IDS_NO_SUCH_FILE, (LPTSTR)lpMessage, 4096); CharToOem(lpMessage, lpMessage); fprintf (stderr, lpMessage, *argv);// } else { /* repeat find next file to match the filemask */ do { /* We have found a file, so try to open it */ if ((pfile = fopen (finddata.name, "r")) != NULL) { printf ("---------------- %s\n", finddata.name); ret = find_str (needle, pfile, invert_search, count_lines, number_output, ignore_case, at_start, literal_search, at_end, reg_express, exact_match, sub_dirs, only_fname); fclose (pfile); } else { LoadString(GetModuleHandle(NULL), IDS_CANNOT_OPEN, (LPTSTR)lpMessage, 4096); CharToOem(lpMessage, lpMessage); fprintf (stderr, lpMessage, finddata.name); } } while (_findnext(hfind, &finddata) > 0); } _findclose(hfind); } /* for each argv */ /* RETURN: If the string was found at least once, returns 0. * If the string was not found at all, returns 1. * (Note that find_str.c returns the exact opposite values.) */ exit ( (ret ? 0 : 1) ); }
LRESULT CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { RECT rectOwner, rectDlg, rectDiff; GetWindowRect(GetDesktopWindow(), &rectOwner); GetWindowRect(hwndDlg, &rectDlg); CopyRect(&rectDiff, &rectOwner); OffsetRect(&rectDlg, -rectDlg.left, -rectDlg.top); OffsetRect(&rectDiff, -rectDiff.left, -rectDiff.top); OffsetRect(&rectDiff, -rectDlg.right, -rectDlg.bottom); SetWindowPos(hwndDlg, HWND_TOP, rectOwner.left + (rectDiff.right / 2), rectOwner.top + (rectDiff.bottom / 2), 0, 0, SWP_NOSIZE); HWND hwndProg = GetDlgItem(hwndDlg, IDC_PROGRESS); DWORD dwStyle = GetWindowLong(hwndProg, GWL_STYLE); SetWindowLong(hwndProg, GWL_STYLE, dwStyle | PBS_MARQUEE); SendMessage(hwndProg, PBM_SETMARQUEE, TRUE, 70 /* = scroll speed */); HWND hwndOK = GetDlgItem(hwndDlg, IDC_OK); if (silentFlag) { RECT rectProg, rectOK; GetWindowRect(hwndProg, &rectProg); GetWindowRect(hwndOK, &rectOK); POINT posProg; posProg.x = rectProg.left; posProg.y = rectProg.top; ScreenToClient(hwndDlg, &posProg); MoveWindow(hwndProg, posProg.x, posProg.y, rectOK.right - rectProg.left, rectProg.bottom - rectProg.top, TRUE); ShowWindow(hwndOK, SW_HIDE); } else { EnableWindow(hwndOK, FALSE); } HWND hwndDetails = GetDlgItem(hwndDlg, IDC_DETAILS); ShowWindow(hwndDetails, SW_HIDE); LPTSTR dialogText = (LPTSTR)malloc(MAX_STRING_LENGTH * sizeof(TCHAR)); UINT titleID = (uninstallFlag ? IDS_UNINSTALL : IDS_INSTALL); LoadString(GetModuleHandle(NULL), titleID, dialogText, MAX_STRING_LENGTH); SetWindowText(hwndDlg, dialogText); LoadString(GetModuleHandle(NULL), IDS_CLOSE, dialogText, MAX_STRING_LENGTH); SetDlgItemText(hwndDlg, IDC_OK, dialogText); LoadString(GetModuleHandle(NULL), IDS_DETAILS, dialogText, MAX_STRING_LENGTH); SetDlgItemText(hwndDlg, IDC_DETAILS, dialogText); LPTSTR message = (LPTSTR)malloc((2 * MAX_STRING_LENGTH + 10) * sizeof(TCHAR)); UINT loadingID = (uninstallFlag ? IDS_LOADING_U : IDS_LOADING); LoadString(GetModuleHandle(NULL), loadingID, message, MAX_STRING_LENGTH); loadingID = (estTime) ? IDS_TIMESPEC : IDS_TIMEUNDEF; LoadString(GetModuleHandle(NULL), loadingID, dialogText, MAX_STRING_LENGTH); LPTSTR time = (LPTSTR)malloc(9 * sizeof(TCHAR)); _itot(estTime, time, 10); DWORD_PTR messageArguments[] = { (DWORD_PTR)time }; HLOCAL formattedString = NULL; DWORD formatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY; FormatMessage(formatFlags, dialogText, loadingID, 0, (LPTSTR)&formattedString, 0, (va_list*)messageArguments); free(time); _tcsncat(message, _T("\n"), 2 * MAX_STRING_LENGTH + 10); _tcsncat(message, formattedString, 2 * MAX_STRING_LENGTH + 10); SetDlgItemText(hwndDlg, IDC_MESSAGE, message); LocalFree(formattedString); free(dialogText); free(message); } SetTimer(hwndDlg, IDT_TIMER1, 500, (TIMERPROC)NULL); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: if (hChildProc == 0) { EndDialog(hwndDlg, wParam); return TRUE; } break; case IDC_DETAILS: { LPTSTR errorMsg = _tcserror(exitCode); LPTSTR messsageFormat = (LPTSTR)malloc(MAX_STRING_LENGTH); LoadString(NULL, IDS_ERRORCODE, messsageFormat, MAX_STRING_LENGTH); HLOCAL messageString = NULL; DWORD_PTR messageArguments[] = { (DWORD_PTR)exitCode, (DWORD_PTR)errorMsg }; DWORD formatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY; FormatMessage(formatFlags, messsageFormat, IDS_ERRORCODE, 0, (LPTSTR)&messageString, 0, (va_list*)messageArguments); MessageBox(NULL, (LPTSTR)messageString, NULL, MB_OK | MB_ICONEXCLAMATION); LocalFree(messageString); free(messsageFormat); break; } } break; case WM_TIMER: switch (wParam) { case IDT_TIMER1: GetExitCodeProcess(hChildProc, &exitCode); if (exitCode != STILL_ACTIVE) { KillTimer(hwndDlg, IDT_TIMER1); hChildProc = 0; if (silentFlag) { EndDialog(hwndDlg, 0); } else { FlashWindow(hwndDlg, TRUE); HWND hwndProg; DWORD dwStyle; hwndProg = GetDlgItem(hwndDlg, IDC_PROGRESS); SendMessage(hwndProg, PBM_SETMARQUEE, FALSE, 0); dwStyle = GetWindowLong(hwndProg, GWL_STYLE); SetWindowLong(hwndProg, GWL_STYLE, dwStyle & ~PBS_MARQUEE); SendMessage(hwndProg, PBM_SETPOS, 100, 0); LPTSTR dialogText = (LPTSTR)malloc(MAX_STRING_LENGTH * sizeof(TCHAR)); if (exitCode == ERROR_SUCCESS) { UINT successID = (uninstallFlag ? IDS_SUCCESS_U : IDS_SUCCESS); LoadString(GetModuleHandle(NULL), successID, dialogText, MAX_STRING_LENGTH); } else { UINT failureID = (uninstallFlag ? IDS_FAILURE_U : IDS_FAILURE); LoadString(GetModuleHandle(NULL), failureID, dialogText, MAX_STRING_LENGTH); SendMessage(hwndProg, PBM_SETSTATE, PBST_ERROR, 0); HWND hwndDetails = GetDlgItem(hwndDlg, IDC_DETAILS); ShowWindow(hwndDetails, SW_SHOW); } SetDlgItemText(hwndDlg, IDC_MESSAGE, dialogText); free(dialogText); HWND hwndOK = GetDlgItem(hwndDlg, IDC_OK); EnableWindow(hwndOK, TRUE); } } break; } break; } return FALSE; }
UINT ShowMessageBox (UINT Id, UINT Button, UINT Help, ...) { CString temp; TCHAR *pszstring, *pszpaste, *pszcut, *pszdone, *pszconvert; TCHAR chread; va_list params; int x; pszconvert = new TCHAR[255]; va_start(params, Help); LoadString (temp, Id); pszstring = temp.GetBuffer(512); _tcscpy(pszstring,pszstring); temp.ReleaseBuffer(); // Look and see - is there a need to insert chars (95% of the time, there won't) if (!_tcsstr(pszstring, _T("%"))) { delete pszconvert; return AfxMessageBox(pszstring, Button, Help); } x = _tcscspn(pszstring, _T("%")); pszdone = new TCHAR[512]; pszcut = new TCHAR[512]; pszpaste = new TCHAR[512]; _tcscpy(pszcut, &pszstring[x+2]); _tcsncpy(pszpaste, pszstring, x); pszpaste[x] = _T('\0'); chread = pszstring[x+1]; for ( ; ; ) { switch (chread) { case _T('i') : case _T('d') : { int anint = va_arg(params, int); _itot( anint, pszconvert, 10); break; } case _T('u') : { UINT anuint = va_arg(params, UINT); _itot( anuint, pszconvert, 10); break; } case _T('x') : case _T('X') : { int ahex = va_arg(params, int); _itot( ahex, pszconvert, 16); break; } case _T('g') : case _T('f') : case _T('e') : { double adbl = va_arg(params, double); _stprintf(pszconvert, _T("%g"), adbl); break; } case _T('s') : { TCHAR *pStr = va_arg(params, TCHAR*); ASSERT(_tcslen(pStr) <= 255); _tcscpy(pszconvert, pStr); break; } case _T('l') : { chread = pszdone[x+2]; switch(chread) { case _T('x') : { long int alhex = va_arg(params, long int); _ltot(alhex, pszconvert, 16); _tcscpy(pszcut, &pszcut[1]); break; } case _T('d') : default : { long int along = va_arg(params, long int); _ltot( along, pszconvert, 10); // For the L, there will be one character after it, // so move ahead another letter _tcscpy(pszcut, &pszcut[1]); break; } } break; } case _T('c') : { int letter = va_arg(params, int); pszconvert[0] = (TCHAR)letter; pszconvert[1] = '\0'; break; } case _T('a') : { CString zeta; TCHAR* lsc; UINT ls = va_arg(params, UINT); LoadString (zeta, ls); lsc = zeta.GetBuffer(255); _tcscpy(pszconvert, lsc); zeta.ReleaseBuffer(); break; } case _T('o') : { CString get = va_arg(params, CString); TCHAR* ex = get.GetBuffer(255); _tcscpy(pszconvert,ex); get.ReleaseBuffer(); break; } default : { _tcscpy(pszconvert, _T(" Could not load message. Invalid %type in string table entry. ")); delete pszdone; pszdone = new TCHAR[_tcslen(pszpaste)+_tcslen(pszcut)+_tcslen(pszconvert)+5]; _tcscpy(pszdone, pszpaste); _tcscat(pszdone, pszconvert); _tcscat(pszdone, pszcut); AfxMessageBox(pszdone, Button, Help); delete pszcut; delete pszpaste; delete pszconvert; delete pszdone; ASSERT(FALSE); return 0; } } // case delete pszdone; pszdone = new TCHAR[_tcslen(pszpaste)+_tcslen(pszcut)+_tcslen(pszconvert)+5]; _tcscpy(pszdone, pszpaste); _tcscat(pszdone, pszconvert); _tcscat(pszdone, pszcut); // Now pszdone holds the entire message. // Check to see if there are more insertions to be made or not if (!_tcsstr(pszdone, _T("%"))) { UINT rt_type = AfxMessageBox(pszdone, Button, Help); delete pszcut; delete pszpaste; delete pszconvert; delete pszdone; return rt_type; } // if // there are more insertions to make, prepare the strings to use. x = _tcscspn(pszdone, _T("%")); _tcscpy(pszcut, &pszdone[x+2]); _tcsncpy(pszpaste, pszdone, x); pszpaste[x] = _T('\0'); chread = pszdone[x+1]; } // for ASSERT(FALSE); return 0; } // ShowMessageBox
LONG FAR PASCAL WndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam) { char chbuf[50]; HICON hIcon; switch (message) { case WM_CREATE: break; case WM_DESTROY: // ignore since wowexec must stay around return 0; #ifdef DEBUG case WM_COMMAND: switch (LOWORD(wParam)) { case MM_ABOUT: LoadString(hAppInstance, errTitle, (LPSTR)chbuf, sizeof(chbuf)); hIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(ID_WOWEXEC_ICON)); ShellAbout(ghwndMain, (LPSTR)chbuf, (LPSTR)lpszAppTitle, hIcon); break; case MM_BREAK: _asm int 3 break; case MM_FAULT: _asm mov cs:0,ax break; case MM_EXIT: ExitKernelThunk(0); break; case MM_WATSON: WinExec("drwatson", SW_MINIMIZE ); break; case MM_PARTY: { FARPROC lpPartyDialogProc; lpPartyDialogProc = MakeProcInstance(PartyDialogProc, hAppInstance); DialogBox(hAppInstance, MAKEINTRESOURCE(ID_PARTY_DIALOG), hwnd, lpPartyDialogProc); FreeProcInstance(lpPartyDialogProc); } break; } break; #endif case WM_WOWEXECSTARTAPP: // WM_USER+0 #ifdef DEBUG OutputDebugString("WOWEXEC - got WM_WOWEXECSTARTAPP\n"); #endif // // Either BaseSrv or Wow32 asked us to go looking for // commands to run. // if (!gfSharedWOW) { // // We shouldn't get this message unless we are the shared // WOW VDM! // #ifdef DEBUG OutputDebugString("WOWEXEC - separate WOW VDM got WM_WOWEXECSTARTAPP!\n"); _asm int 3; #endif break; } // // Start requested apps until there are no more to start. // This handles the case where several Win16 apps are launched // in a row, before BaseSrv has the window handle for WowExec. // while (StartRequestedApp()) { /* Null stmt */ ; } break; #define WM_WOWEXEC_START_TASK (WM_USER+2) case WM_WOWEXEC_START_TASK: { char sz[512]; sz[ GlobalGetAtomName(wParam, sz, sizeof sz) ] = 0; GlobalDeleteAtom(wParam); WinExec(sz, (WORD)lParam); } case WM_WOWEXECHEARTBEAT: // Probably will never get here... break; case WM_TIMECHANGE: *((DWORD *)(((DWORD)40 << 16) | FIXED_NTVDMSTATE_REL40)) |= VDM_TIMECHANGE; break; case WM_DDE_INITIATE: { // In win31, the Program Manager WindowProc calls peekmessage to filterout // otherwindowcreated and otherwindowdestroyed messages (which are atoms in win31) // whenever it receives WM_DDE_INITIATE message. // // This has a side effect - basically when peekmessage is called the app ie program // manager effectively yields allowing scheduling of other apps. // // So we do the side effect thing (simulate win31 behaviour) - // // The bug: 20221, rumba as/400 can't connect the firsttime to sna server. // Scenario: Rumbawsf execs snasrv and blocks on yield, snasrv execs wnap and blocks // on yield. Eventually wnap yields and rumbawsf is scheduled which // broadcasts a ddeinitiate message. When WOWEXEC receives this message // it will peek for nonexistent msg, which allows snasrv to get scheduled MSG msg; while (PeekMessage(&msg, NULL, 0xFFFF, 0xFFFF, PM_REMOVE)) DispatchMessage(&msg); } break; case WM_CLOSE: #ifdef DEBUG ExitKernelThunk(0); #else // ignore since wowexec must stay around return 0; #endif // ! DEBUG default: return DefWindowProc(hwnd, message, wParam, lParam); }
LRESULT CALLBACK CMainWindow::WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { CMainWindow *that = (CMainWindow *) GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (uMsg) { case WM_CREATE: { LPCREATESTRUCT pcs = (LPCREATESTRUCT) lParam; that = (CMainWindow *) pcs->lpCreateParams; // Create the MDI client window that will handle the MDI child windows CLIENTCREATESTRUCT ccs = { 0 }; ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), WINDOW_MENU_POSITION); ccs.idFirstChild = FIRST_MDI_CHILD; that->m_hMDIClient = CreateWindowEx( 0, _T("MDICLIENT"), 0, WS_CLIPCHILDREN | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, NULL, g_hInstance, &ccs ); if (that->m_hMDIClient == NULL) { return -1; } that->AddRef(); SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) that); break; } case WM_DESTROY: { SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL); that->Release(); PostQuitMessage(0); break; } case WM_SETCURSOR: { if (that->m_bDisplayWaitCursor) { SetCursor(LoadCursor(NULL, IDC_WAIT)); return TRUE; } break; } case WM_INITMENU: { if (that->m_pEventCallback != NULL) { LONG nNumDevices = that->m_pEventCallback->GetNumDevices(); UINT uEnable = nNumDevices > 0 ? MF_ENABLED : MF_GRAYED; EnableMenuItem((HMENU) wParam, ID_FILE_FROM_SCANNER_OR_CAMERA, uEnable); } break; } case WM_COMMAND: { switch (LOWORD(wParam)) { case ID_FILE_FROM_SCANNER_OR_CAMERA: { that->OnFromScannerOrCamera(); break; } case ID_FILE_EXIT: { DestroyWindow(hWnd); break; } case ID_WINDOW_CASCADE: { SendMessage(that->m_hMDIClient, WM_MDICASCADE, 0, 0); break; } case ID_WINDOW_TILE_HORIZONTALLY: { SendMessage(that->m_hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0); break; } case ID_WINDOW_TILE_VERTICALLY: { SendMessage(that->m_hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0); break; } case ID_WINDOW_ARRANGE_ICONS: { SendMessage(that->m_hMDIClient, WM_MDIICONARRANGE, 0, 0); break; } case ID_HELP_ABOUT: { TCHAR szAppName[DEFAULT_STRING_SIZE] = _T(""); LoadString(g_hInstance, IDS_APP_NAME, szAppName, COUNTOF(szAppName)); ShellAbout(hWnd, szAppName, NULL, NULL); break; } } break; } } return DefFrameProc( hWnd, that == NULL ? NULL : that->m_hMDIClient, uMsg, wParam, lParam ); }
TCHAR *GetString(int id){ static TCHAR buf[256]; if (hInstance) return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : NULL; return NULL; }
LRESULT CMainWindow::OnFromScannerOrCamera() { HRESULT hr; m_bDisplayWaitCursor = TRUE; // Launch the get image dialog WiaWrap::CComPtrArray<IStream> ppStream; hr = WiaWrap::WiaGetImage( m_hMDIClient, StiDeviceTypeDefault, 0, WIA_INTENT_NONE, NULL, NULL, NULL, NULL, NULL, &ppStream.Count(), &ppStream ); m_bDisplayWaitCursor = FALSE; // If there was an error, display an error message box if (FAILED(hr)) { TCHAR szError[DEFAULT_STRING_SIZE] = _T(""); LoadString(g_hInstance, IDS_ERROR_GET_IMAGE_DLG, szError, COUNTOF(szError)); MessageBox(m_hMDIClient, szError, NULL, MB_ICONHAND | MB_OK); } // Open a new window for each successfully transferred image for (int i = 0; i < ppStream.Count(); ++i) { CComPtr<CBitmapWnd> pBitmapWnd = new CBitmapWnd(ppStream[i]); if (pBitmapWnd != NULL) { m_nNumImages += 1; TCHAR szFormat[DEFAULT_STRING_SIZE] = _T("%d"); LoadString(g_hInstance, IDS_BITMAP_WINDOW_TITLE, szFormat, COUNTOF(szFormat)); TCHAR szTitle[DEFAULT_STRING_SIZE]; _sntprintf_s(szTitle, COUNTOF(szTitle), COUNTOF(szTitle) - 1, szFormat, m_nNumImages); szTitle[COUNTOF(szTitle) - 1] = _T('\0'); CreateWindowEx( WS_EX_MDICHILD, _T("BitmapWindow"), szTitle, WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hMDIClient, NULL, g_hInstance, pBitmapWnd ); } } return 0; }
//--------------------------------------------------------------------------- void __fastcall TGroundGroupForm::OpenGroundGroupStatic(int X,int Y) { char buff[50]; // UniqueID CurrUID; if (!dialheight[0][0]) { dialheight[0][0]=Height; dialheight[0][1]=Panel1->Top; dialheight[0][2]=ButtonPanel->Top; int delta=GGPanel->Height; dialheight[1][0]=dialheight[0][0]-delta; dialheight[1][1]=dialheight[0][1]-delta; dialheight[1][2]=dialheight[0][2]-delta; } Height=dialheight[1][0]; Panel1->Top=dialheight[1][1]; ButtonPanel->Top=dialheight[1][2]; GGAltLabel->Visible = false; GGEditAlt->Visible = false; UniqueIDBand uidband; uidband = Persons2::getbandfromUID(MissionEditor->currobj); ItemBasePtr i=Persons2::ConvertPtrUID(MissionEditor->currobj); // MissionEditor->FillComboBox(IDS_CENTRALPOWERS, IDS_ALLIES, NationalityComboBox, // i->Nationality); info_itemS* I= *Persons2::ConvertPtrUID(MissionEditor->currobj); int groupindex = -1; if (I->shape==ENABLE_COMPLEX_VAL) if (I->shape->type==Expr::EXPR_GLOB) FindShapes(I->shape->UsesGlobRef(),groupindex,3); else if (I->shape[2]->type==Expr::EXPR_GLOB) FindShapes(I->shape[2]->UsesGlobRef(),groupindex,3); else FindShapes(I->shape.Evaluate(2),groupindex,-1); else FindShapes(I->shape.Evaluate(2),groupindex,-1); FillUIDBandList(I->band.Evaluate()); // MissionEditor->FillComboBox(IDS_CENTRALPOWERS, IDS_ALLIES, NationalityComboBox, // I->nationality-1); GGPanel->Visible = false; // ButtonPanel->Top = 38; // Height = 181; //216; GGSpeedLabel->Visible = false; GGSpeedData->Visible = false; AltSpinButton->Visible = false; SpdComboBox->Visible = false; RefreshText(); if (MissionEditor->loadedbfs[I->bfieldindex].name[0]) BfieldLabel->Caption = MissionEditor->loadedbfs[I->bfieldindex].name; else BfieldLabel->Caption = MissionEditor->loadedbfs[I->bfieldindex].fname; switch (uidband) { case MissileBAND: { break; } case RedGICBAND: case BlueGICBAND: { GGAltLabel->Visible = true; GGEditAlt->Visible = true; GGPanel->Visible = true; // ButtonPanel->Top = 144; // Height = 279; char altitude[50]; LoadString(HInstance,TEXT_ALT,altitude,sizeof(altitude)); if (MissionEditor->Configure_Units == METRIC) { strcat(altitude,"m"); GGEditAlt->Text = IntToStr(-i->World.Y/100); }else if (MissionEditor->Configure_Units == IMPERIAL) { strcat(altitude,"ft"); GGEditAlt->Text = IntToStr(-(i->World.Y*100-50)/3048); }else { strcat(altitude,"ft"); GGEditAlt->Text = IntToStr(-(i->World.Y*100-50)/3048); } GGAltLabel->Caption = altitude; break; } } int text = MissionEditor->GetBandorShapeText(MissionEditor->currobj); LoadString(HInstance,text,buff,sizeof(buff)); Caption = buff; GG_StatusLabel->Visible = true; GG_StatusComboBox->Visible = true; GGEventMore->Visible = false; GGRoute->Visible = false; GG_StatusComboBox->ItemIndex = 1; GG_StatusComboBox->Enabled = false; GGRoute->Visible = false; GGFormationSizeLabel->Visible = false; GGFormationTypeLabel->Visible = false; GGFormationSpinEdit->Visible = false; GGFormTypeBox->Visible = false; int result = ShowModal(); switch (result) { case mrOk: { info_itemS* I=*i; MissionEditor->loadedbfs[I->bfieldindex].changed=true; // MissionEditor->MissionEdited=true; if (GGEditAlt->Visible) { if (MissionEditor->Configure_Units == METRIC) I->position[0][1] = -MissionEditor->ValidEdit(GGEditAlt) * 100; else if (MissionEditor->Configure_Units == IMPERIAL) I->position[0][1] = -MissionEditor->ValidEdit(GGEditAlt) * 3048/100; else I->position[0][1] = -MissionEditor->ValidEdit(GGEditAlt) * 3048/100; I->position.EvalW(I->World); } int shape=ShapeComboBox->ItemIndex; if (shape>=0) { int shapepage=ShapeCat->ItemIndex; if (shapepage==3) { GlobRefExpr* gr=new GlobRefExpr(AvailableShapes[3][shape]); if (I->shape.complex && I->shape.complex->type==Expr::EXPR_FORM) I->shape[2]=gr; else I->shape = gr; } else { shape=AvailableShapes[shapepage][shape]; if (I->shape.complex && I->shape.complex->type==Expr::EXPR_FORM) I->shape[2]=shape; else I->shape = shape; } } I->band= UIDBandList[UIDGroupCombo->ItemIndex]; // I->nationality= NationalityComboBox->ItemIndex+1; MissionEditor->ChangeTag(groupindex,shape); EditText(); break; } case mrDelete: { AcItemForm->DeleteCurrTransItem(); break; } } //MissionEditor->MobileSpdButtonState(); MissionEditor->DisableWPUsageifnecessary(); //rdh }
BOOL CPropFile::PropPageProc( HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam ) { switch(uMessage) { case WM_INITDIALOG: { CPropFile * sheetpage = (CPropFile*) ((LPPROPSHEETPAGE) lParam)->lParam; SetWindowLongPtr (hwnd, GWLP_USERDATA, (LONG_PTR) sheetpage); sheetpage->SetHwnd(hwnd); AfxSetResourceHandle(m_hInst); CString sText; if (filenames.GetCount() <= 0) { ShowWindow(GetDlgItem(m_hwnd, IDC_REMOVEMOUNTPOINT), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_SYMLINK_LABEL), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_MOUNTPOINT_LABEL), SW_HIDE); EnableUnixMode(FALSE); } else if(filenames.GetCount() > 1) { // multiple items selected LoadString(sText, IDS_PROP_MULTIPLEITEMS); SetDlgItemText(hwnd, IDC_PROP_TYPE, sText); ShowWindow(GetDlgItem(m_hwnd, IDC_REMOVEMOUNTPOINT), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_SYMLINK_LABEL), SW_HIDE); ShowWindow(GetDlgItem(m_hwnd, IDC_MOUNTPOINT_LABEL), SW_HIDE); EnableUnixMode(FALSE); sText = GetCellName(filenames.GetAt(0), FALSE); m_cellName = sText; SetDlgItemText(hwnd, IDC_PROP_CELL, sText); } else { if (m_bIsMountpoint) LoadString(sText, IDS_PROP_TYPEMOUNTPOINT); else if (m_bIsSymlink) LoadString(sText, IDS_PROP_TYPESYMLINK); else if (m_bIsDir) LoadString(sText, IDS_PROP_TYPEDIRECTORY); else LoadString(sText, IDS_PROP_TYPEFILE); SetDlgItemText(hwnd, IDC_PROP_TYPE, sText); if (m_bIsMountpoint) { ShowWindow(GetDlgItem(m_hwnd, IDC_REMOVEMOUNTPOINT), SW_SHOW); } if (!m_bIsSymlink) { ShowWindow(GetDlgItem(m_hwnd, IDC_SYMLINK_LABEL), SW_HIDE); } if (!m_bIsMountpoint) { ShowWindow(GetDlgItem(m_hwnd, IDC_MOUNTPOINT_LABEL), SW_HIDE); } if (!m_bIsMountpoint && !m_bIsSymlink) { ShowWindow(GetDlgItem(m_hwnd, IDC_EDIT), SW_HIDE); } if (m_bIsSymlink) { ShowWindow(GetDlgItem(m_hwnd, IDC_REMOVESYMLINK), SW_SHOW); } CString user, group, other, suid; EnableUnixMode(TRUE); GetUnixModeBits(filenames.GetAt(0), user, group, other, suid); ShowUnixMode(user, group, other, suid); SetDlgItemText(hwnd, IDC_PROP_FILENAME, filenames.GetAt(0)); if (!GetFID(filenames.GetAt(0), sText, TRUE)) sText = _T("(unknown)"); SetDlgItemText(hwnd, IDC_PROP_FID, sText); sText = GetOwner(filenames.GetAt(0)); SetDlgItemText(hwnd, IDC_PROP_OWNER, sText); sText = GetGroup(filenames.GetAt(0)); SetDlgItemText(hwnd, IDC_PROP_GROUP, sText); if (m_bIsMountpoint){ sText = GetMountpoint(filenames.GetAt(0)); sText = sText.Mid(sText.Find('\t')+1); SetDlgItemText(hwnd, IDC_PROP_SMINFO, sText); } if (m_bIsSymlink){ sText = GetSymlink(filenames.GetAt(0)); sText = sText.Mid(sText.Find('\t')+1); SetDlgItemText(hwnd, IDC_PROP_SMINFO, sText); } sText = GetCellName(filenames.GetAt(0)); m_cellName = sText; SetDlgItemText(hwnd, IDC_PROP_CELL, sText); } return TRUE; } break; case WM_NOTIFY: { LPNMHDR point = (LPNMHDR)lParam; int code = point->code; BOOL bRet = FALSE; switch (code) { case PSN_APPLY: { CString user, group, other, suid; MakeUnixModeString(user, group, other, suid); SetUnixModeBits(filenames, user, group, other, suid); // Return PSNRET_NOERROR to allow the sheet to close if the user clicked OK. SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, PSNRET_NOERROR); } break; } SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, FALSE); return bRet; } break; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD(wParam)) { case IDC_FLUSH: Flush(filenames); return TRUE; case IDC_REMOVESYMLINK: { int nChoice = ShowMessageBox(IDS_REALLY_REMOVE_SYMLINK, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_REMOVE_SYMLINK); if (nChoice == IDYES) RemoveSymlink(filenames.GetAt(0)); return TRUE; } case IDC_REMOVEMOUNTPOINT: { int nChoice = ShowMessageBox(IDS_REALLY_DEL_MOUNT_POINTS, MB_ICONQUESTION | MB_YESNO, IDS_REALLY_DEL_MOUNT_POINTS); if (nChoice == IDYES) RemoveMount(filenames); return TRUE; } case IDC_EDIT: { if (m_bIsMountpoint){ CMakeMountPointDlg dlg; dlg.SetDir(filenames.GetAt(0)); dlg.SetCell(m_cellName); dlg.SetVol(m_volName); dlg.DoModal(); } if (m_bIsSymlink){ CMakeSymbolicLinkDlg dlg; CStringA msg(filenames.GetAt(0)); int i; if ((i=msg.ReverseFind('\\'))>0) msg=msg.Left(i+1); else if ((i=msg.ReverseFind(':'))>0) msg=msg.Left(i+1)+"\\"; dlg.Setbase(msg); dlg.m_strDir = filenames.GetAt(0); dlg.m_strName = GetSymlink(filenames.GetAt(0)); dlg.DoModal(); } } case IDC_ATTR_USER_READ: case IDC_ATTR_USER_WRITE: case IDC_ATTR_USER_EXECUTE: case IDC_ATTR_GROUP_READ: case IDC_ATTR_GROUP_WRITE: case IDC_ATTR_GROUP_EXECUTE: case IDC_ATTR_OTHER_READ: case IDC_ATTR_OTHER_WRITE: case IDC_ATTR_OTHER_EXECUTE: SendMessage(GetParent(m_hwnd), PSM_CHANGED, (WPARAM)m_hwnd, 0); // enable the "apply" button return TRUE; } break; } break; } return FALSE; }
void CSearchResultsBox::OnPaint() { CString strFormat, strText; CPaintDC dc( this ); CRect rc; GetClientRect( &rc ); CSize size = rc.Size(); CDC* pDC = CoolInterface.GetBuffer( dc, size ); if ( ! CoolInterface.DrawWatermark( pDC, &rc, CBitmap::FromHandle( m_hbmWatermark ) ) ) { pDC->FillSolidRect( &rc, CoolInterface.m_crTaskBoxClient ); } CFont* pOldFont = (CFont*)pDC->SelectObject( &CoolInterface.m_fntBold ); pDC->SetTextColor( CoolInterface.m_crText ); pDC->SetBkMode( TRANSPARENT ); pDC->SetBkColor( CoolInterface.m_crTaskBoxClient ); LoadString( strText, IDS_SEARCH_PANEL_RESULTS_STATUS ); DrawText( pDC, BOX_MARGIN, BOX_MARGIN, ETO_CLIPPED, strText ); LoadString( strText, IDS_SEARCH_PANEL_RESULTS_FOUND ); DrawText( pDC, BOX_MARGIN, BOX_MARGIN + 32, ETO_CLIPPED, strText ); pDC->SelectObject( &CoolInterface.m_fntNormal ); if ( m_bActive ) { LoadString( strFormat, IDS_SEARCH_PANEL_RESULTS_ACTIVE ); strText.Format( strFormat, m_nHubs, m_nLeaves ); } else { LoadString( strText, IDS_SEARCH_PANEL_RESULTS_INACTIVE ); } DrawText( pDC, BOX_MARGIN + 8, BOX_MARGIN + 14, ETO_CLIPPED, strText ); if ( m_nFiles ) { LoadString( strFormat, IDS_SEARCH_PANEL_RESULTS_FORMAT ); if ( strFormat.Find( '|' ) >= 0 ) { if ( m_nFiles == 1 && m_nHits == 1 ) Skin.SelectCaption( strFormat, 0 ); else if ( m_nFiles == 1 ) Skin.SelectCaption( strFormat, 1 ); else Skin.SelectCaption( strFormat, 2 ); strText.Format( strFormat, m_nFiles, m_nHits ); } else { strText.Format( strFormat, m_nFiles, m_nFiles != 1 ? _T("s") : _T(""), m_nHits, m_nHits != 1 ? _T("s") : _T("") ); } } else { LoadString( strText, IDS_SEARCH_PANEL_RESULTS_NONE ); } DrawText( pDC, BOX_MARGIN + 8, BOX_MARGIN + 32 + 14, ETO_CLIPPED, strText ); pDC->SelectObject( pOldFont ); dc.BitBlt( 0, 0, rc.Width(), rc.Height(), pDC, 0, 0, SRCCOPY ); dc.ExcludeClipRect( &rc ); }
// Program entry point function. int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); void* sandbox_info = NULL; #if CEF_ENABLE_SANDBOX // Manage the life span of the sandbox information object. This is necessary // for sandbox support on Windows. See cef_sandbox_win.h for complete details. CefScopedSandboxInfo scoped_sandbox; sandbox_info = scoped_sandbox.sandbox_info(); #endif CefMainArgs main_args(hInstance); CefRefPtr<ClientApp> app(new ClientApp); // Execute the secondary process, if any. int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info); if (exit_code >= 0) return exit_code; // Retrieve the current working directory. if (_getcwd(szWorkingDir, MAX_PATH) == NULL) szWorkingDir[0] = 0; // Parse command line arguments. The passed in values are ignored on Windows. AppInitCommandLine(0, NULL); CefSettings settings; #if !CEF_ENABLE_SANDBOX settings.no_sandbox = true; #endif // Populate the settings based on command line arguments. AppGetSettings(settings); // Initialize CEF. CefInitialize(main_args, settings, app.get(), sandbox_info); // Register the scheme handler. scheme_test::InitTest(); HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDS_OSR_WIDGET_CLASS, szOSRWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization if (!InitInstance (hInstance, nCmdShow)) return FALSE; hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CEFCLIENT)); // Register the find event message. uFindMsg = RegisterWindowMessage(FINDMSGSTRING); int result = 0; if (!settings.multi_threaded_message_loop) { // Run the CEF message loop. This function will block until the application // recieves a WM_QUIT message. CefRunMessageLoop(); } else { // Create a hidden window for message processing. hMessageWnd = CreateMessageWindow(hInstance); ASSERT(hMessageWnd); MSG msg; // Run the application message loop. while (GetMessage(&msg, NULL, 0, 0)) { // Allow processing of find dialog messages. if (hFindDlg && IsDialogMessage(hFindDlg, &msg)) continue; if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } DestroyWindow(hMessageWnd); hMessageWnd = NULL; result = static_cast<int>(msg.wParam); } // Shut down CEF. CefShutdown(); return result; }
static BOOL RunInstaller() { PROCESS_INFORMATION pi; STARTUPINFO sti; char szCmdLine[MAX_BUF]; char szSetupFile[MAX_BUF]; char szUninstallFile[MAX_BUF]; char szArcLstFile[MAX_BUF]; BOOL bRet; char szText[256]; char szTempPath[MAX_BUF]; char szTmp[MAX_PATH]; char xpiDir[MAX_PATH]; char szFilename[MAX_BUF]; char szBuf[MAX_BUF]; if(gbUncompressOnly == TRUE) return(TRUE); // Update UI UpdateProgressBar(100); LoadString(hInst, IDS_STATUS_LAUNCHING_SETUP, szText, sizeof(szText)); SetStatusLine(szText); memset(&sti,0,sizeof(sti)); sti.cb = sizeof(STARTUPINFO); // Setup program is in the directory specified for temporary files GetFullTempPathName("", MAX_BUF, szTempPath); GetFullTempPathName("Archive.lst", sizeof(szArcLstFile), szArcLstFile); GetFullTempPathName("SETUP.EXE", sizeof(szSetupFile), szSetupFile); GetFullTempPathName("uninstall.exe", sizeof(szUninstallFile), szUninstallFile); GetPrivateProfileString("Archives", "uninstall.exe", "", szBuf, sizeof(szBuf), szArcLstFile); if((FileExists(szUninstallFile) != FALSE) && (*szBuf != '\0')) { lstrcpy(szCmdLine, szUninstallFile); } else { lstrcpy(szCmdLine, szSetupFile); GetModuleFileName(NULL, szFilename, sizeof(szFilename)); ParsePath(szFilename, xpiDir, sizeof(xpiDir), PP_PATH_ONLY); AppendBackSlash(xpiDir, sizeof(xpiDir)); lstrcat(xpiDir, "xpi"); if(FileExists(xpiDir)) { GetShortPathName(xpiDir, szBuf, sizeof(szBuf)); lstrcat(szCmdLine, " -a "); lstrcat(szCmdLine, szBuf); } lstrcat(szCmdLine, " -n "); lstrcat(szCmdLine, szFilename); } if(szCmdLine != NULL) lstrcat(szCmdLine, szCmdLineToSetup); // Launch the installer bRet = CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, szTempPath, &sti, &pi); if (!bRet) return FALSE; CloseHandle(pi.hThread); // Wait for the InstallShield UI to appear before taking down the dialog box WaitForInputIdle(pi.hProcess, 3000); // wait up to 3 seconds if(dwMode != SILENT) { DestroyWindow(dlgInfo.hWndDlg); } // Wait for the installer to complete WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); // Delete the files from the temp directory EnumResourceNames(NULL, "FILE", (ENUMRESNAMEPROC)DeleteTempFilesProc, 0); // delete archive.lst file in the temp directory GetFullTempPathName("Archive.lst", sizeof(szTmp), szTmp); DeleteFile(szTmp); GetFullTempPathName("xpcom.ns", sizeof(szTmp), szTmp); DirectoryRemove(szTmp, TRUE); DirectoryRemove(szTempPath, FALSE); return TRUE; }
int InitCommDlg(int iWhichOper) { OFN.lpstrDefExt = NULL; OFN.lpstrFile = szFileName; OFN.lpstrFilter = szFilterSpec; OFN.lpstrCustomFilter = szCustFilterSpec; switch(iWhichOper) { case 0: // beginning of Write session OFN.lStructSize = sizeof(OPENFILENAME); OFN.hInstance = hINSTANCE; OFN.lCustData = NULL; OFN.lpTemplateName = NULL; OFN.lpstrFileTitle = NULL; OFN.nMaxFileTitle = 0; OFN.nMaxFile = CBPATHMAX; OFN.lpstrInitialDir = NULL; OFN.nMaxCustFilter = CBFILTERSIZE; LoadString(hINSTANCE, IDSTROpenfile, szOpenFile, sizeof(szOpenFile)); LoadString(hINSTANCE, IDSTRSavefile, szSaveFile, sizeof(szSaveFile)); LoadString(hINSTANCE, IDSTRDefWriExtension, szDefWriExtension, sizeof(szDefWriExtension)); LoadString(hINSTANCE, IDSTRDefDocExtension, szDefDocExtension, sizeof(szDefDocExtension)); LoadString(hINSTANCE, IDSTRDefTxtExtension, szDefTxtExtension, sizeof(szDefTxtExtension)); LoadString(hINSTANCE, IDSTRWriDescr, szWriDescr, sizeof(szWriDescr)); LoadString(hINSTANCE, IDSTRDocDescr, szDocDescr, sizeof(szDocDescr)); LoadString(hINSTANCE, IDSTRTxtDescr, szTxtDescr, sizeof(szTxtDescr)); LoadString(hINSTANCE, IDSTRDocTextDescr, szDocTxtDescr, sizeof(szDocTxtDescr)); LoadString(hINSTANCE, IDSTRAllFilesDescr, szAllFilesDescr, sizeof(szAllFilesDescr)); LoadString(hINSTANCE, IDSTROldWriteDescr, szOldWriteDescr, sizeof(szOldWriteDescr)); return FALSE; case imiOpen: if ((lpfnOFNHook = MakeProcInstance(fnOFNHook, hINSTANCE)) == NULL) return TRUE; OFN.hwndOwner = hPARENTWINDOW; OFN.Flags = OFN_ENABLEHOOK|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST; OFN.lpfnHook = lpfnOFNHook; lstrcpy(szFileName,szWild); lstrcat(szFileName,szDefWriExtension); OFN.lpstrTitle = szOpenFile; szCustFilterSpec[0] = '\0'; fDefFileType = SA_WRITE; /* see MakeFilterSpec */ MakeFilterString(iWhichOper); return FALSE; case imiSaveAs: /* read only will become the backup check box */ if ((lpfnOFNHook = MakeProcInstance(fnOFNHook, hINSTANCE)) == NULL) return TRUE; OFN.hwndOwner = hPARENTWINDOW; OFN.Flags = OFN_ENABLEHOOK|OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT; OFN.lpfnHook = lpfnOFNHook; OFN.lpstrTitle = szSaveFile; szCustFilterSpec[0] = '\0'; MakeFilterString(iWhichOper); return FALSE; } }
void CLibraryAlbumTrack::PaintText(CDC* pDC, const CRect& rcTrack, int nFrom, int nTo, int nID, BOOL bCenter) { CString str; LoadString( str, nID ); PaintText( pDC, rcTrack, nFrom, nTo, &str, bCenter ); }
void CTriggerFX::CheckPlayersWithinTrigger() { if( m_cs.bLocked ) return; // Get a list of all the characters... CSpecialFXList *pList = g_pGameClientShell->GetSFXMgr()->GetFXList( SFX_CHARACTER_ID ); if( !pList ) return; int nListSize = pList->GetSize(); int nNumChars = pList->GetNumItems(); int nNumFoundChars = 0; int nNumPlayersFound = 0; uint32 dwLocalId = 0; g_pLTClient->GetLocalClientID( &dwLocalId ); LTVector vTrigPos, vPlayerPos, vPlayerDims, vPlayerMin, vPlayerMax; g_pLTClient->GetObjectPos( m_hServerObject, &vTrigPos ); // Setup the triggers box... LTVector vTrigMin = vTrigPos - m_cs.vDims; LTVector vTrigMax = vTrigPos + m_cs.vDims; bool bLocalPlayerIn = false; // Initialize our containers to zero. Don't call clear, since we'll be using // these vectors every frame and most likely they will have the same // number of elements across multiple frames. m_lstPlayersNotInTrigger.resize( 0 ); m_lstNewPlayersInTrigger.resize( 0 ); for( int i = 0; i < nListSize; ++i ) { // Try not to go through the entire list... if( nNumFoundChars == nNumChars ) break; if( (*pList)[i] ) { CCharacterFX *pChar = (CCharacterFX*)(*pList)[i]; if( !pChar ) continue; // Found another char.. ++nNumFoundChars; if( pChar->m_cs.bIsPlayer && pChar->m_cs.nClientID != ( uint8 )-1 ) { ++nNumPlayersFound; HOBJECT hPlayer = pChar->GetServerObj(); g_pLTClient->GetObjectPos( hPlayer, &vPlayerPos ); g_pPhysicsLT->GetObjectDims( hPlayer, &vPlayerDims ); vPlayerMin = vPlayerPos - vPlayerDims; vPlayerMax = vPlayerPos + vPlayerDims; // Check the current list of players in the trigger for this player... CharFXList::iterator iter; for( iter = m_lstCurPlayersInTrigger.begin(); iter != m_lstCurPlayersInTrigger.end(); ++iter ) { if( pChar == (*iter) ) break; } // Check if we are within the height of the trigger... bool bWithinHeight = false; if( vPlayerMax.y > vTrigMin.y && vPlayerMin.y < vTrigMax.y ) bWithinHeight = true; if( bWithinHeight && BoxesIntersect( vTrigMin, vTrigMax, vPlayerMin, vPlayerMax ) && !pChar->IsPlayerDead()) { if( dwLocalId == pChar->m_cs.nClientID ) bLocalPlayerIn = true; // If it wasn't in the list add it... if( iter == m_lstCurPlayersInTrigger.end() ) { m_lstCurPlayersInTrigger.push_back( pChar ); m_lstNewPlayersInTrigger.push_back( pChar ); } } else { if( iter != m_lstCurPlayersInTrigger.end() ) m_lstCurPlayersInTrigger.erase( iter ); m_lstPlayersNotInTrigger.push_back( pChar ); } } } } wchar_t wszBuffer[256]; if( (m_lstNewPlayersInTrigger.size() > 0) && (nNumPlayersFound > 1) ) { CClientInfoMgr *pInfoMgr = g_pInterfaceMgr->GetClientInfoMgr(); if( !pInfoMgr ) return; if( bLocalPlayerIn ) { // Display a general transmission and messages for each player you are waiting for... int nPlayersNotInTrig = m_lstPlayersNotInTrigger.size(); if( m_cs.nPlayerInsideID != (uint32)-1 ) { g_pTransmission->Show( StringIDFromIndex(m_cs.nPlayerInsideID) ); } else if( nPlayersNotInTrig > 1 ) { //sTransmission.Format( "You are waiting for %i players.", nPlayersNotInTrig ); FormatString( "IDS_EXIT_PLAYER_WAITING", wszBuffer, LTARRAYSIZE(wszBuffer), nPlayersNotInTrig ); g_pTransmission->Show( wszBuffer ); } else { //sTransmission.Format( "You are waiting for 1 player." ); FormatString( "IDS_EXIT_PLAYER_WAITING_1", wszBuffer, LTARRAYSIZE(wszBuffer) ); g_pTransmission->Show( wszBuffer ); } CharFXList::iterator iter; for( iter = m_lstPlayersNotInTrigger.begin(); iter != m_lstPlayersNotInTrigger.end(); ++iter ) { //sMessage.Format( "You are waiting for %s.", pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID )); FormatString( "IDS_EXIT_PLAYER_WAITING_NAME", wszBuffer, LTARRAYSIZE(wszBuffer), pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID) ); g_pGameMsgs->AddMessage( wszBuffer ); } } else { // Display a general transmission and messages for each player waiting for you... int nPlayersInTrig = m_lstCurPlayersInTrigger.size(); if( m_cs.nPlayerOutsideID != (uint32)-1 ) { g_pTransmission->Show( LoadString(m_cs.nPlayerOutsideID) ); } else if( nPlayersInTrig > 1 ) { // sTransmission.Format( "%i players are waiting for you",nPlayersInTrig ); FormatString( "IDS_EXIT_WAITING", wszBuffer, LTARRAYSIZE(wszBuffer), nPlayersInTrig ); g_pTransmission->Show( wszBuffer ); } else { // sTransmission.Format( "1 player is waiting for you." ); FormatString( "IDS_EXIT_WAITING_1", wszBuffer, LTARRAYSIZE(wszBuffer) ); g_pTransmission->Show( wszBuffer ); } CharFXList::iterator iter; for( iter = m_lstCurPlayersInTrigger.begin(); iter != m_lstCurPlayersInTrigger.end(); ++iter ) { FormatString( "IDS_EXIT_WAITING_NAME", wszBuffer, LTARRAYSIZE(wszBuffer), pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID) ); g_pGameMsgs->AddMessage( wszBuffer ); } } } }
// // FillListBox // // Fill the list box with an enumeration of the media type // void NullIPProperties::FillListBox() { IEnumMediaTypes * pMTEnum=0; AM_MEDIA_TYPE *pMediaType=0; ULONG count=0; TCHAR szBuffer[200]; int Loop = 0, wextent = 0; SIZE extent={0}; FILTER_STATE state; CMediaType *pmtCurrent=0; // // get the current media type // ASSERT(m_pINullIPP); m_pINullIPP->get_MediaType (&pmtCurrent); m_nIndex = 0 ; // // Fill the first entry of the list box with a choice to select any media. // LoadString(g_hInst, IDS_ANYTYPE, szBuffer, 200); SendMessage (m_hwndLB, LB_ADDSTRING, 0, (LPARAM)szBuffer) ; // // if the filter is not connected on the input, nothing more to fill // also return if we haven't gotten any pin interface // if (m_pPin == NULL) return ; // // get a dc for the control. need this to get the extent of the strings // that we put in the list box (so that we can get a horiz scroll bar). // HDC hdc = GetDC (m_hwndLB) ; // // now enumerate the media types from our pin. // HRESULT hr = m_pPin->EnumMediaTypes(&pMTEnum); if (SUCCEEDED(hr)) { ASSERT(pMTEnum); pMTEnum->Next(1, &pMediaType, &count); while (count == 1) // While a media type retrieved OK { ASSERT(pMediaType); if (!pMediaType) continue; // // Count it - used to set m_nIndex. // Loop++; // // convert the media type to string. // CTextMediaType(*pMediaType).AsText(szBuffer, 200, TEXT(" - "), TEXT(" - "), TEXT("\0")); // // if the mediatype matches the current one, set m_nIndex to cur index // if (*pmtCurrent == *pMediaType) { m_nIndex = Loop; } // // get the extent of the string and save the max extent // GetTextExtentPoint (hdc, szBuffer, lstrlen(szBuffer), &extent) ; if (extent.cx > wextent) wextent = extent.cx ; // // add the string to the list box. // SendMessage (m_hwndLB, LB_ADDSTRING, 0, (LPARAM)szBuffer) ; // // enumerate the next media type and loop. // DeleteMediaType(pMediaType); pMTEnum->Next(1, &pMediaType, &count); } pMTEnum->Release(); SendMessage (m_hwndLB, LB_SETHORIZONTALEXTENT, wextent, 0) ; SendMessage (m_hwndLB, LB_SETCURSEL, m_nIndex, 0) ; } ASSERT(m_pINullIPP); // // if the filter is in a running state, disable the list box and allow // no input. // m_pINullIPP->get_State(&state); EnableWindow (m_hwndLB, state != State_Running) ; } // FillListBox
BOOL InitializeApp(LPSTR lpszCommandLine) { WNDCLASS wc; int cyExecStart, cxExecStart; USHORT TitleLen, cbCopy; HWND hwndFax; // Remove Real Mode Segment Address wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hAppInstance; wc.hIcon = LoadIcon(hAppInstance, MAKEINTRESOURCE(ID_WOWEXEC_ICON)); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = GetStockObject(WHITE_BRUSH); wc.lpszClassName = "WOWExecClass"; #ifdef DEBUG wc.lpszMenuName = "MainMenu"; #else wc.lpszMenuName = NULL; #endif if (!RegisterClass(&wc)) { OutputDebugString("WOWEXEC: RegisterClass failed\n"); return FALSE; } /* * Guess size for now. */ cyExecStart = GetSystemMetrics(SM_CYMENU) * 6; cxExecStart = GetSystemMetrics(SM_CXSCREEN) / 2; /* Load these strings now. If we need them later, we won't be able to load * them at that time. */ LoadString(hAppInstance, IDS_OOMEXITTITLE, szOOMExitTitle, sizeof(szOOMExitTitle)); LoadString(hAppInstance, IDS_OOMEXITMSG, szOOMExitMsg, sizeof(szOOMExitMsg)); LoadString(hAppInstance, IDS_APPTITLE, szAppTitleBuffer, sizeof(szAppTitleBuffer)); ghwndMain = CreateWindow("WOWExecClass", lpszAppTitle, WS_OVERLAPPED | WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_SYSMENU, 30, 30, cxExecStart, cyExecStart, NULL, NULL, hAppInstance, NULL); if (ghwndMain == NULL ) { #ifdef DEBUG OutputDebugString("WOWEXEC: ghwndMain Null\n"); #endif return FALSE; } hwndFax = FaxInit(hAppInstance); // // Give our window handle to BaseSrv, which will post WM_WOWEXECSTARTAPP // messages when we have commands to pick up. The return value tells // us if we are the shared WOW VDM or not (a seperate WOW VDM). // We also pick up the ShowWindow parameter (SW_SHOW, SW_MINIMIZED, etc) // for the first WOW app here. Subsequent ones we get from BaseSrv. // // // gwFirstCmdShow is no longer used, and is available. // gfSharedWOW = WOWRegisterShellWindowHandle(ghwndMain, &gwFirstCmdShow, hwndFax ); // // If this isn't the shared WOW, tell the kernel to exit when the // last app (except WowExec) exits. // if (!gfSharedWOW) { WowSetExitOnLastApp(TRUE); } /* Remember the original directory. */ GetCurrentDirectory(NULL, szOriginalDirectory); GetWindowsDirectory(szWindowsDirectory, MAXITEMPATHLEN+1); #ifdef DEBUG ShowWindow(ghwndMain, SW_MINIMIZE); // // If this is the shared WOW, change the app title string to // reflect this and change the window title. // if (gfSharedWOW) { LoadString(hAppInstance, IDS_SHAREDAPPTITLE, szAppTitleBuffer, sizeof(szAppTitleBuffer)); } SetWindowText(ghwndMain, lpszAppTitle); UpdateWindow(ghwndMain); #endif return TRUE; }
/* * Sets the title text for the main window. */ void Explorerplusplus::HandleMainWindowText(void) { TCHAR szTitle[512]; TCHAR szFolderDisplayName[MAX_PATH]; TCHAR szOwner[512]; /* Don't show full paths for virtual folders (as only the folders GUID will be shown). */ if(m_bShowFullTitlePath && !m_pActiveShellBrowser->InVirtualFolder()) { GetDisplayName(m_CurrentDirectory,szFolderDisplayName,SHGDN_FORPARSING); } else { GetDisplayName(m_CurrentDirectory,szFolderDisplayName,SHGDN_NORMAL); } StringCchPrintf(szTitle,SIZEOF_ARRAY(szTitle), _T("%s - Explorer++"),szFolderDisplayName); if(m_bShowUserNameInTitleBar || m_bShowPrivilegeLevelInTitleBar) StringCchCat(szTitle,SIZEOF_ARRAY(szTitle),_T(" [")); if(m_bShowUserNameInTitleBar) { GetProcessOwner(szOwner,SIZEOF_ARRAY(szOwner)); StringCchCat(szTitle,SIZEOF_ARRAY(szTitle),szOwner); } if(m_bShowPrivilegeLevelInTitleBar) { TCHAR szPrivilegeAddition[64]; TCHAR szPrivilege[64]; if(CheckGroupMembership(GROUP_ADMINISTRATORS)) { LoadString(m_hLanguageModule,IDS_PRIVILEGE_LEVEL_ADMINISTRATORS,szPrivilege,SIZEOF_ARRAY(szPrivilege)); } else if(CheckGroupMembership(GROUP_POWERUSERS)) { LoadString(m_hLanguageModule,IDS_PRIVILEGE_LEVEL_POWER_USERS,szPrivilege,SIZEOF_ARRAY(szPrivilege)); } else if(CheckGroupMembership(GROUP_USERS)) { LoadString(m_hLanguageModule,IDS_PRIVILEGE_LEVEL_USERS,szPrivilege,SIZEOF_ARRAY(szPrivilege)); } else if(CheckGroupMembership(GROUP_USERSRESTRICTED)) { LoadString(m_hLanguageModule,IDS_PRIVILEGE_LEVEL_USERS_RESTRICTED,szPrivilege,SIZEOF_ARRAY(szPrivilege)); } if(m_bShowUserNameInTitleBar) StringCchPrintf(szPrivilegeAddition,SIZEOF_ARRAY(szPrivilegeAddition), _T(" - %s"),szPrivilege); else StringCchPrintf(szPrivilegeAddition,SIZEOF_ARRAY(szPrivilegeAddition), _T("%s"),szPrivilege); StringCchCat(szTitle,SIZEOF_ARRAY(szTitle),szPrivilegeAddition); } if(m_bShowUserNameInTitleBar || m_bShowPrivilegeLevelInTitleBar) StringCchCat(szTitle,SIZEOF_ARRAY(szTitle),_T("]")); SetWindowText(m_hContainer,szTitle); }
STDMETHODIMP CShellExt::XMenuExt::GetCommandString(UINT_PTR idCmd, UINT uType, UINT* pwReserved, LPSTR pszName, UINT cchMax) { if (uType != GCS_HELPTEXT) return NOERROR; // ????????????????????????????????????????????????? UINT nCmdStrID; AfxSetResourceHandle(theApp.m_hInstance); switch (idCmd) { case IDM_AUTHENTICATION: nCmdStrID = ID_AUTHENTICATE; break; case IDM_ACL_SET: nCmdStrID = ID_ACL_SET; break; case IDM_VOLUME_PROPERTIES: nCmdStrID = ID_VOLUME_PROPERTIES; break; case IDM_VOLUMEPARTITION_UPDATENAMEIDTABLE: nCmdStrID = ID_VOLUMEPARTITION_UPDATENAMEIDTABLE; break; case IDM_MOUNTPOINT_SHOW: nCmdStrID = ID_MOUNTPOINT_SHOW; break; case IDM_MOUNTPOINT_REMOVE: nCmdStrID = ID_MOUNTPOINT_REMOVE; break; case IDM_MOUNTPOINT_MAKE: nCmdStrID = ID_MOUNTPOINT_MAKE; break; case IDM_FLUSH: nCmdStrID = ID_FLUSH; break; case IDM_FLUSH_VOLUME: nCmdStrID = ID_VOLUME_FLUSH; break; case IDM_SHOW_SERVER: nCmdStrID = ID_WHEREIS; break; case IDM_SHOWCELL: nCmdStrID = ID_SHOWCELL; break; case IDM_SERVER_STATUS: nCmdStrID = ID_SERVER_STATUS; break; case IDM_SYMBOLICLINK_ADD: nCmdStrID = ID_SYMBOLICLINK_ADD; break; case IDM_SYMBOLICLINK_SHOW: nCmdStrID = ID_SYMBOLICLINK_SHOW; break; case IDM_SYMBOLICLINK_REMOVE: nCmdStrID = ID_SYMBOLICLINK_REMOVE; break; case IDM_REMOVE_SYMLINK: nCmdStrID= ID_REMOVE_SYMLINK; break; default: ASSERT(FALSE); Release(); return E_INVALIDARG; } CString strMsg; LoadString (strMsg, nCmdStrID); _tcsncpy((LPTSTR) pszName, strMsg, cchMax); return NOERROR; }