//--------------------------------------------------------------------------- void __fastcall TfrmMain::New1Click(TObject *Sender) { TForm* p = new TfrmView(this); p->Caption = "Untitled"; p->FreeOnRelease(); p->Show(); this->Tile(); }
//--------------------------------------------------------------------------- void __fastcall TfrmMain::CreateExample1Click(TObject *Sender) { g_painterType = GDI1->Checked ? PAINTER_GDI : PAINTER_OPENGL; g_viewType = VIEW_EXAMPLE; TForm* p = new TfrmView(this); p->Caption = "Example Window"; p->FreeOnRelease(); p->Show(); fLayers->Caption = "Example Window"; fPropertiesMain->Caption = "Example Window"; this->Tile(); }
void __fastcall TfrmMain::LayerExample1Click(TObject *Sender) { this->Properties1->Enabled = true; g_painterType = GDI1->Checked ? PAINTER_GDI : PAINTER_OPENGL; g_viewType = VIEW_LAYEREX; TForm* p = new TfrmView(this); p->Caption = "Layer Example"; p->FreeOnRelease(); p->Show(); fLayers->Caption = "Layer Example"; fPropertiesMain->Caption = "Layer Example"; this->Tile(); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::btnApplyClick(TObject *Sender) { TForm* processForm = new TForm(this); TLabel* lb = new TLabel(this); lb->Parent = processForm; lb->ParentFont = FALSE; lb->ParentColor = FALSE; lb->Color = clBlack; lb->Caption = "IP 변경 중 입니다..."; lb->Font->Name = "나눔고딕"; lb->Font->Size = 14; lb->Top = (processForm->Height / 2) - (lb->Height / 2); lb->Left = (processForm->Width / 2) - (lb->Width / 2); processForm->BorderStyle = bsNone; processForm->Position = poScreenCenter; processForm->Show(); processForm->AlphaBlend = TRUE; processForm->AlphaBlendValue = 0; for(int i=0; i<255; i++) { for(int x=0; x<50000; x++){} processForm->AlphaBlendValue = i; } //Delay(1000); //cmd 이용하기 위한 선언 STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi)); // 도스창이 안보이게 si.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; TCHAR* cmd = new TCHAR[MAX_PATH]; TCHAR* buf = NULL; INT cmdSize = 0; TCHAR* networkName = new TCHAR[36]; RegSearchNetworkName(g_selectNetworkCardID_Key, networkName); DWORD* result = new DWORD; //프로세스 실행 후 결과값 받아오기 위한 변수. if(SelectDHCP->Buttons[1]->Checked == TRUE) { _stprintf(cmd, _T("netsh interface ipv4 set address name=\"%s\" source=dhcp"), networkName);; cmdSize = _tcslen(cmd); buf = new TCHAR[cmdSize]; _tcscpy(buf, cmd); //cmd 실행. if(!CreateProcess(NULL, buf, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { ShowMessage("DHCP CreateProcess Error"); delete buf; Abort(); } WaitForSingleObject(pi.hProcess, INFINITE); //프로세스 종료 시까지 기다림. GetExitCodeProcess(pi.hProcess, result); //프로세스 결과 값 리턴. 정상 : 0, 비정상 : 1 if(*result != 0) { ShowMessage("변경하지 못하였습니다.\n" "다음과 같은 문제일 수 있습니다.\n" "1.사용자 계정 컨트롤 사용중\n" "2.이미 DHCP 사용중"); for(int i=255; i>0; i--) { processForm->AlphaBlendValue = i; for(int x=0; x<50000; x++){} } processForm->Hide(); delete result; delete lb; delete buf; Abort(); } delete buf; } else { _stprintf(cmd, _T("netsh interface ipv4 set address name=\"%s\" source=static %s %s %s"), networkName, SelectIP->Text.w_str(), SelectSM->Text.w_str(), SelectDG->Text.w_str()); cmdSize = _tcslen(cmd); buf = new TCHAR[cmdSize]; _tcscpy(buf, cmd); if(!CreateProcess(NULL, buf, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { ShowMessage("CreateProcess : 고정 IP 적용 실패"); delete buf; Abort(); } WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, result); int t = GetLastError(); if(*result != 0) { ShowMessage("변경하지 못하였습니다.\n" "다음과 같은 문제일 수 있습니다.\n" "1.사용자 계정 컨트롤 사용중\n" "2.서로 다른 네트워크에서 같은 IP / DefaultGateway 사용 시도\n" "3.정확하지 않은 IP 주소 입력"); for(int i=255; i>0; i--) { processForm->AlphaBlendValue = i; for(int x=0; x<500000; x++){} } processForm->Hide(); delete buf; Abort(); } _stprintf(cmd, _T("netsh interface ipv4 set dnsserver name=\"%s\" source=static address=%s"), networkName, SelectDNS->Text.w_str()); cmdSize = _tcslen(cmd); buf = new TCHAR[cmdSize]; _tcscpy(buf, cmd); if(!CreateProcess(NULL, buf, NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { ShowMessage("CreateProcess : 고정 DNS 적용 실패"); delete buf; Abort(); } WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, result); //프로세스 결과 값 리턴. 정상 : 0, 비정상 : 1 if(*result != 0) { ShowMessage("고정 DNS 적용 실패"); for(int i=255; i>0; i--) { processForm->AlphaBlendValue = i; for(int x=0; x<500000; x++){} } processForm->Hide(); delete buf; Abort(); } // Close process and thread handles. CloseHandle(pi.hProcess); CloseHandle(pi.hThread); delete buf; } lb->Caption = "변경 완료!"; lb->Top = (processForm->Height / 2) - (lb->Height / 2); lb->Left = (processForm->Width / 2) - (lb->Width / 2); //Delay(1000); this->Init(); for(int i=255; i>0; i--) { processForm->AlphaBlendValue = i; for(int x=0; x<500000; x++){} } processForm->Hide(); delete result; delete lb; delete cmd; }