HICON TransparentWnd::GetIcon(CefString path){ if(path.ToWString().find(L":")==-1){ wstring _path; _path=url.ToWString(); replace_allW(_path, L"\\", L"/"); _path=_path.substr(0,_path.find_last_of('/')+1); path=_path.append(path); } return (HICON)::LoadImage(NULL,path.ToWString().data(),IMAGE_ICON,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE); //Bitmap bm(path.ToWString().data()); //HICON hIcon; //bm.GetHICON(&hIcon); //return hIcon; }
void TransparentWnd::RunApp(CefString appName, CefString param, CefString baseUrl){ wstring appNameW=appName.ToWString(); wstring path; if(!baseUrl.length()){ path=modulePath; } else{ path=baseUrl.ToWString(); replace_allW(path, L"\\", L"/"); path=path.substr(0,path.find_last_of('/')+1); } if(appNameW.find(L":")==-1){ appNameW=path.append(appNameW); } CreateBrowser(appNameW,param); }
CefString TransparentWnd::GetSaveName(CefString fileName){ TCHAR szFile[2048]; SaveFileDialog(hWnd, fileName.ToWString().data(), szFile); wstring d(szFile); CefString s(d); return s; }
CefString TransparentWnd::GetOpenName(CefString fileName){ TCHAR szFile[4096]; OpenFileDialog(hWnd, fileName.ToWString().data(), szFile); wstring d(szFile); CefString s(d); return s; }
FWebBrowserPopupFeatures::FWebBrowserPopupFeatures( const CefPopupFeatures& PopupFeatures ) { X = PopupFeatures.x; bXSet = PopupFeatures.xSet ? true : false; Y = PopupFeatures.y; bYSet = PopupFeatures.ySet ? true : false; Width = PopupFeatures.width; bWidthSet = PopupFeatures.widthSet ? true : false; Height = PopupFeatures.height; bHeightSet = PopupFeatures.heightSet ? true : false; bMenuBarVisible = PopupFeatures.menuBarVisible ? true : false; bStatusBarVisible = PopupFeatures.statusBarVisible ? true : false; bToolBarVisible = PopupFeatures.toolBarVisible ? true : false; bLocationBarVisible = PopupFeatures.locationBarVisible ? true : false; bScrollbarsVisible = PopupFeatures.scrollbarsVisible ? true : false; bResizable = PopupFeatures.resizable ? true : false; bIsFullscreen = PopupFeatures.fullscreen ? true : false; bIsDialog = PopupFeatures.dialog ? true : false; int Count = PopupFeatures.additionalFeatures ? cef_string_list_size(PopupFeatures.additionalFeatures) : 0; CefString ListValue; for(int ListIdx = 0; ListIdx < Count; ListIdx++) { cef_string_list_value(PopupFeatures.additionalFeatures, ListIdx, ListValue.GetWritableStruct()); AdditionalFeatures.Add(ListValue.ToWString().c_str()); } }
QUrl QCefWebView::url() const { if (GetBrowser().get()) { CefString url = GetBrowser()->GetMainFrame()->GetURL(); return QUrl(QString::fromStdWString(url.ToWString())); } return QUrl(); }
bool CaffeineClientApp::UploadCrashLogs(CefString AppVersion, CefString UserDescription) { bool retval = false; HANDLE hFind = INVALID_HANDLE_VALUE; WIN32_FIND_DATA ffd; // Get the crash logs folder and append '\*.zip' to it. wstring CrashDir = GetCrashLogsDirectory(); wstring ZippedLogs = CrashDir + L"\\*.zip"; // Find the first file in the directory. hFind = FindFirstFile(ZippedLogs.c_str(), &ffd); if (INVALID_HANDLE_VALUE != hFind) { do { TCHAR szFullPath[MAX_PATH*2] = {0,}; StringCchCopy(szFullPath, MAX_PATH*2, CrashDir.c_str()); PathAppend(szFullPath, ffd.cFileName); InterlockedIncrement(&log_count); InsertDescriptionIntoCrashLogs(szFullPath, UserDescription.ToWString()); PostCrashLogs(szFullPath, AppVersion, UserDescription); } while (FindNextFile(hFind, &ffd) != 0); FindClose(hFind); retval = true; } return retval; }
void TransparentWnd::ToImageEx(CefString path, int _x, int _y, int _width, int _height){ if(!hBitMap){ return; } Bitmap bm(_width,_height); Rect r(0,0,_width,_height); BitmapData bmData; bm.LockBits(&r, ImageLockModeWrite, PixelFormat32bppPARGB, &bmData); int l=width*height*4; PBYTE p1=new BYTE[l]; GetBitmapBits(hBitMap, l, p1); byte* p = (byte*)bmData.Scan0; int count=0; for(int j=0;j<_height;++j){ for (int i = 0; i < _width; i++) { for(int k=0; k<4;++k){ int pos = (_y+j)*width*4+(_x+i)*4; p[count]=p1[pos+k]; ++count; } } } delete []p1; bm.UnlockBits(&bmData); CLSID tiffClsid; GetEncoderClsid((L"image/"+GetExtW(path.ToWString())).data(), &tiffClsid); bm.Save(TranslatePath(path).ToWString().data(), &tiffClsid); }
// Inject webinos.js // The file is loaded from the webinos\test\client folder if possible. // If this fails, the current folder is used. void ClientApp::InjectWebinos(CefRefPtr<CefFrame> frame) { CefRefPtr<CefCommandLine> commandLine = AppGetCommandLine(); // First try and load the platform-supplied webinos.js std::string pzpPath = AppGetWebinosWRTConfig(NULL,NULL); CefString wrtPath; // Make sure there is a trailing separator on the path. if (pzpPath.length() > 0) { if (pzpPath.find_last_of('/') == pzpPath.length()-1 || pzpPath.find_last_of('\\') == pzpPath.length()-1) wrtPath = pzpPath + "wrt/webinos.js"; else wrtPath = pzpPath + "/wrt/webinos.js"; } #if defined(OS_WIN) base::FilePath webinosJSPath(wrtPath.ToWString().c_str()); #else base::FilePath webinosJSPath(wrtPath); #endif LOG(INFO) << "webinos.js path is " << wrtPath; int64 webinosJSCodeSize; bool gotJSFile = base::GetFileSize(webinosJSPath, &webinosJSCodeSize); if (gotJSFile) { char* webinosJSCode = new char[webinosJSCodeSize+1]; base::ReadFile(webinosJSPath, webinosJSCode, webinosJSCodeSize); webinosJSCode[webinosJSCodeSize] = 0; if (frame == NULL) { // Register as a Cef extension. CefRegisterExtension("webinos", webinosJSCode, NULL); } else { // Run the code in the frame javascript context right now, // but only if the URL refers to the widget server. int widgetServerPort; AppGetWebinosWRTConfig(NULL,&widgetServerPort); char injectionCandidate[MAX_URL_LENGTH]; sprintf(injectionCandidate,"http://localhost:%d",widgetServerPort); std::string url = frame->GetURL(); if (url.substr(0,strlen(injectionCandidate)) == injectionCandidate) frame->ExecuteJavaScript(webinosJSCode, url, 0); } delete[] webinosJSCode; } else { LOG(ERROR) << "Can't find webinos.js"; } }
void FCEFWebBrowserWindow::SetToolTip(const CefString& CefToolTip) { FString NewToolTipText = CefToolTip.ToWString().c_str(); if (ToolTipText != NewToolTipText) { ToolTipText = NewToolTipText; OnToolTip().Broadcast(ToolTipText); } }
void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title) { REQUIRE_UI_THREAD(); if (!listener_) return; if (m_BrowserId == browser->GetIdentifier()) { listener_->OnTitleChange(QString::fromStdWString(title.ToWString())); } }
CefString TransparentWnd::TranslatePath(CefString path){ wstring pathS=path.ToWString(); wstring urlS=url.ToWString(); replace_allW(urlS,L"file:///",L""); if(pathS.find(L":")==-1){ int index1=urlS.find_last_of(L"/"); pathS=urlS.substr(0,index1+1).append(pathS); } return pathS; }
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& url) { REQUIRE_UI_THREAD(); if (!listener_) return; if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { listener_->OnAddressChange(QString::fromStdWString(url.ToWString())); } }
bool WebRendererHandler::OnBeforePopup(CefRefPtr<CefBrowser> p_Browser, CefRefPtr<CefFrame> p_Frame, const CefString& p_Url, const CefString& p_FrameName, CefLifeSpanHandler::WindowOpenDisposition p_Disposition, bool p_UserGesture, const CefPopupFeatures& p_Features, CefWindowInfo& p_WindowInfo, CefRefPtr<CefClient>& p_Client, CefBrowserSettings& p_Settings, bool* p_NoJavaScript) { // Make sure that the URL starts with http:// or https:// so it can't be used to execute arbitrary shell commands auto s_UrlStr = p_Url.ToWString(); if (!boost::istarts_with(s_UrlStr, L"http://") && !boost::istarts_with(s_UrlStr, L"https://")) s_UrlStr = L"http://" + s_UrlStr; // Open the URL in the user's browser ShellExecuteW(nullptr, L"open", s_UrlStr.c_str(), L"", nullptr, SW_SHOWNORMAL); return true; }
HICON GetIcon(CefString url, CefString path){ if (path.ToWString().find(L":") == -1){// 如果指定的路径是相对路径 wstring _path; _path = url.ToWString(); jw::replace_allW(_path, L"\\", L"/"); _path = _path.substr(0, _path.find_last_of('/') + 1); path = _path.append(path); } Gdiplus::GdiplusStartupInput StartupInput; ULONG_PTR m_gdiplusToken; Gdiplus::Status sResult = Gdiplus::GdiplusStartup(&m_gdiplusToken, &StartupInput, NULL); if (sResult == Gdiplus::Ok){ Gdiplus::Bitmap * bb = Gdiplus::Bitmap::FromFile(path.c_str(), false); HICON hIcon = NULL; bb->GetHICON(&hIcon); delete bb; Gdiplus::GdiplusShutdown(m_gdiplusToken);// 关闭gdi return hIcon; } return NULL; }
CefString TransparentWnd::ReadFile(CefString path){ wstring pathS=path.ToWString(); wstring urlS=url.ToWString(); if(pathS.find(L":")==-1){ if(urlS.find(L"http")==-1){ int index1=urlS.find_last_of(L"/"); pathS=urlS.substr(0,index1+1).append(pathS); } } ifstream fin(pathS); std::stringstream ss; string s; if(getline(fin, s)){ ss << s; while(getline(fin, s)){ ss <<'\n'<< s; } } s=ss.str(); int l=s.length(); const char* s1=s.c_str(); unsigned char* s3=(unsigned char* )s1; int type=3; if(s3[0]==0xff&&s3[1]==0xfe){ type=0; } else if(s3[0]==0xfe&&s3[1]==0xff){ type=1; } else if(s3[0]==0xef&&s3[1]==0xbb&&s3[2]==0xbf){ type=2; } else if(IsTextUTF8(s1,l)){ type=2; } CefString cs; if(type==3){ DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, s1, -1, NULL, 0); WCHAR *s2=new WCHAR[dwNum]; ::MultiByteToWideChar(CP_ACP,0,s1,-1,s2,dwNum); cs=s2; delete []s2; } else if(type==0||type==1){ wstring s4=(WCHAR *)s3; cs=s4; } else{ cs=s; } fin.close(); return cs; }
void TransparentWnd::SetTaskIcon(int id, CefString iconPath, CefString title){ // 将图标放入系统托盘 NOTIFYICONDATA nd; nd.cbSize = sizeof (NOTIFYICONDATA); nd.hWnd = hWnd; nd.uID = id; nd.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP; nd.uCallbackMessage = WM_NOTIFYICON; nd.hIcon = GetIcon(iconPath); wcscpy(nd.szTip, title.ToWString().data()); Shell_NotifyIcon(NIM_ADD, &nd); }
void FWebBrowserHandler::OnLoadError(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefFrame> Frame, CefLoadHandler::ErrorCode InErrorCode, const CefString& ErrorText, const CefString& FailedUrl) { // Don't display an error for downloaded files. if (InErrorCode == ERR_ABORTED) { return; } // notify browser window if (Frame->IsMain()) { TSharedPtr<FWebBrowserWindow> BrowserWindow = BrowserWindowPtr.Pin(); if (BrowserWindow.IsValid()) { BrowserWindow->NotifyDocumentError(); } } // Display a load error message. if (ShowErrorMessage) { FFormatNamedArguments Args; { Args.Add(TEXT("FailedUrl"), FText::FromString(FailedUrl.ToWString().c_str())); Args.Add(TEXT("ErrorText"), FText::FromString(ErrorText.ToWString().c_str())); Args.Add(TEXT("ErrorCode"), FText::AsNumber(InErrorCode)); } FText ErrorMsg = FText::Format(LOCTEXT("WebBrowserLoadError", "Failed to load URL {FailedUrl} with error {ErrorText} ({ErrorCode})."), Args); FString ErrorHTML = TEXT("<html><body bgcolor=\"white\"><h2>") + ErrorMsg.ToString() + TEXT("</h2></body></html>"); Frame->LoadString(*ErrorHTML, FailedUrl); } }
CefString TransparentWnd::GetOpenNames(CefString fileName){ TCHAR szFiles[4096]; OpenMultiFilesDialog(hWnd, fileName.ToWString().data(), szFiles); // Multi-Select std::wstringstream ss; ss<<"[\""; wchar_t* p = szFiles; ss<<p<<"\""; p += lstrlen(p) + 1; while(*p) { wstring s(p); ss<<","<<"\""<<s<<"\""; p += lstrlen(p) + 1; // "p" - name of each files } ss<<"]"; return ss.str(); }
void TransparentWnd::SaveImageFromStream(CefString path,AmfStream* pStream,int width,int height){ Bitmap bm(width,height); Rect r(0,0,width,height); BitmapData bmData; bm.LockBits(&r, ImageLockModeWrite, PixelFormat32bppARGB, &bmData); int l=width*height*4; byte* p = (byte*)bmData.Scan0; BYTE* pb2=pStream->GetStream(); for(int i=0;i<l;i+=4){ p[i+2]=pb2[i]; p[i]=pb2[i+2]; p[i+1]=pb2[i+1]; p[i+3]=pb2[i+3]; } bm.UnlockBits(&bmData); CLSID tiffClsid; wstring type=wstring(L"image/")+GetExtW(path.ToWString()); GetEncoderClsid(type.data(), &tiffClsid); bm.Save(TranslatePath(path).ToWString().data(), &tiffClsid); }
void TransparentWnd::ShowTip(CefString& text){ return; TransparentWnd* pWin; if(!pTipWin){ if(text.length()){ pWin=new TransparentWnd(); pTipWin=(void *)pWin; std::stringstream ss; POINT pt; GetCursorPos(&pt); ss<<"{\"text\":\""<<text.ToString()<<"\",\"x\":"<<pt.x<<",\"y\":"<<pt.y<<"}"; pWin->RunAppIn("tip/index.app",ss.str()); } } else{ pWin=(TransparentWnd *)pTipWin; if(text.length()){ std::wstringstream ss; POINT pt; GetCursorPos(&pt); wstring t=text.ToWString(); replace_allW(t,L"'",L"\'"); ss<<"var e = new CustomEvent('AlloyDesktopShowTip', {" "detail: {" " 'text':'"<<t<<"',"<< " 'x':"<<pt.x<<"," " 'y':"<<pt.y<< "}" "});" "dispatchEvent(e);"; pWin->ExecJS(ss.str()); ExecJS(ss.str()); if(pWin->isHide){ pWin->Restore(); } } else{ pWin->Hide(); } } }
// ------------------------------------ // bool ThriveJSHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception) { if(name == "startNewGame") { auto message = CefProcessMessage::Create("Custom"); auto args = message->GetArgumentList(); args->SetString(0, "startNewGame"); Owner->SendCustomExtensionMessage(message); return true; } else if(name == "editorButtonClicked") { auto message = CefProcessMessage::Create("Custom"); auto args = message->GetArgumentList(); args->SetString(0, "editorButtonClicked"); Owner->SendCustomExtensionMessage(message); return true; } else if(name == "finishEditingClicked") { auto message = CefProcessMessage::Create("Custom"); auto args = message->GetArgumentList(); args->SetString(0, "finishEditingClicked"); Owner->SendCustomExtensionMessage(message); return true; } // This might be a bit expensive... exception = L"Unknown ThriveJSHandler function: " + name.ToWString(); return true; }
bool TransparentWnd::WriteFile(CefString path, const char* s, int length){ wstring pathS=path.ToWString(); wstring urlS=url.ToWString(); replace_allW(urlS,L"file:///",L""); if(pathS.find(L":")==-1){ if(urlS.find(L"http")==-1){ //并上本地目录 int index1=urlS.find_last_of(L"/"); pathS=urlS.substr(0,index1+1).append(pathS); } } ofstream fout(pathS,ios::binary); if(length){ fout.write(s,length); } else{ fout<<s; } fout.flush(); fout.close(); return true; }
void TransparentWnd::ToImage(CefString path){ if(!hBitMap){ return; } Bitmap bm(width,height); Rect r(0,0,width,height); BitmapData bmData; bm.LockBits(&r, ImageLockModeWrite, PixelFormat32bppPARGB, &bmData); int l=width*height*4; PBYTE p1=new BYTE[l]; GetBitmapBits(hBitMap, l, p1); byte* p = (byte*)bmData.Scan0; for (int j = 0; j < l; j++) { p[j]=p1[j]; } delete []p1; bm.UnlockBits(&bmData); CLSID tiffClsid; GetEncoderClsid((L"image/"+GetExtW(path.ToWString())).data(), &tiffClsid); bm.Save(TranslatePath(path).ToWString().data(), &tiffClsid); }
void TransparentWnd::CreateBrowser(CefString url, CefString param){ HANDLE m_hRead; HANDLE m_hWrite; SECURITY_ATTRIBUTES sa; // 父进程传递给子进程的一些信息 sa.bInheritHandle = TRUE; // 还记得我上面的提醒吧,这个来允许子进程继承父进程的管道句柄 sa.lpSecurityDescriptor = NULL; sa.nLength = sizeof(SECURITY_ATTRIBUTES); if (!CreatePipe(&m_hRead, &m_hWrite, &sa, 0)) { return; } STARTUPINFO sui; PROCESS_INFORMATION pi; // 保存了所创建子进程的信息 ZeroMemory(&sui, sizeof(STARTUPINFO)); // 对一个内存区清零,最好用ZeroMemory, 它的速度要快于memset sui.cb = sizeof(STARTUPINFO); sui.dwFlags = STARTF_USESTDHANDLES; sui.hStdInput = m_hRead; sui.hStdOutput = m_hWrite; /* 以上两行也许大家要有些疑问,为什么把管道读句柄(m_hRead)赋值给了hStdInput, 因为管道是双向的,对于父进程写的一端正好是子进程读的一端,而m_hRead就是父进程中对管道读的一端, 自然要把这个句柄给子进程让它来写数据了(sui是父进程传给子进程的数据结构,里面包含了一些父进程要告诉子进程的一些信息),反之一样*/ sui.hStdError = GetStdHandle(STD_ERROR_HANDLE); TCHAR szPath[1000]; GetModuleFileName(NULL,szPath,MAX_PATH); DWORD d; if(::WriteFile(m_hWrite,param.ToString().c_str(),strlen(param.ToString().c_str()),&d,NULL)==FALSE){ MessageBox(NULL,L"写入失败",L"错误",0); } if (!CreateProcess(szPath, (LPWSTR)url.ToWString().c_str(), NULL, NULL, TRUE, 0, NULL, NULL, &sui, &pi)) { CloseHandle(m_hRead); CloseHandle(m_hWrite); } else { CloseHandle(pi.hProcess); // 子进程的进程句柄 CloseHandle(pi.hThread); // 子进程的线程句柄,windows中进程就是一个线程的容器,每个进程至少有一个线程在执行 } }
void TransparentWnd::SetTitle(CefString title){ SetWindowText(renderWindow, title.ToWString().data()); }
void FWebBrowserWindow::SetTitle(const CefString& InTitle) { Title = InTitle.ToWString().c_str(); OnTitleChangedDelegate.Broadcast(Title); }
void FCEFWebBrowserWindow::SetTitle(const CefString& InTitle) { Title = InTitle.ToWString().c_str(); TitleChangedEvent.Broadcast(Title); }
void FCEFWebBrowserWindow::SetUrl(const CefString& Url) { CurrentUrl = Url.ToWString().c_str(); OnUrlChanged().Broadcast(CurrentUrl); }
void TransparentWnd::RunAppIn(CefString appName, CefString param, CefString baseUrl){ wstring appNameW=appName.ToWString(); if(appNameW.find(L":")==-1){ wstring path; if(!baseUrl.length()){ path=modulePath;//szPath; } else{ path=baseUrl.ToWString(); replace_allW(path, L"\\", L"/"); path=path.substr(0,path.find_last_of('/')+1); } appNameW=path.append(appNameW); } replace_allW(appNameW, L"\\", L"/"); int w,h,_x,_y; int enableDrag=0,disableTransparent=0,exStyle=0,hasBorder=false,_max=false,_enableResize=false,disableRefresh=0,disableDevelop=0; TCHAR url[1000],name[100],iconPath[1000]; wstring _folder=appNameW.substr(0,appNameW.find_last_of('/')+1); folder=_folder; GetPrivateProfileString(L"BASE",L"url",NULL,url,1000,appNameW.data()); GetPrivateProfileString(L"BASE",L"name",NULL,name,100,appNameW.data()); GetPrivateProfileString(L"BASE",L"icon",NULL,iconPath,1000,appNameW.data()); w=GetPrivateProfileInt(L"BASE",L"width",0,appNameW.data()); h=GetPrivateProfileInt(L"BASE",L"height",0,appNameW.data()); _x=GetPrivateProfileInt(L"BASE",L"x",0,appNameW.data()); _y=GetPrivateProfileInt(L"BASE",L"y",0,appNameW.data()); enableDrag=GetPrivateProfileInt(L"BASE",L"enableDrag",0,appNameW.data()); disableRefresh=GetPrivateProfileInt(L"BASE",L"disableRefresh",0,appNameW.data()); disableDevelop=GetPrivateProfileInt(L"BASE",L"disableDevelop",0,appNameW.data()); _enableResize=GetPrivateProfileInt(L"BASE",L"enableResize",0,appNameW.data()); disableTransparent=GetPrivateProfileInt(L"BASE",L"disableTransparent",0,appNameW.data()); hasBorder=GetPrivateProfileInt(L"BASE",L"hasBorder",0,appNameW.data()); _max=GetPrivateProfileInt(L"BASE",L"max",0,appNameW.data()); exStyle=GetPrivateProfileInt(L"BASE",L"exStyle",0,appNameW.data()); int l=wcslen(iconPath); if(l>0){ hIcon=GetIcon(iconPath); } if(_enableResize>0){ enableResize=true; } enableRefresh=disableRefresh==0; enableDevelop=disableDevelop==0; CefString cefFile(url); wstring file=cefFile.ToWString(); if(file.find(L":")==-1){ file=_folder.append(file); } bool isTransparent=disableTransparent==0; if(hasBorder){ char t[10]; _itoa(isTransparent,t,10); CefString ct(t); wstring _name(name); file=modulePath.append(L"window\\index.html?name=").append(_name).append(L"&url=").append(file).append(L"&transparent=").append(ct.ToWString().data()).append(L"&x="); _itoa(_x,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&y="); _itoa(_y,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&width="); _itoa(w,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&height="); _itoa(h,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&max="); _itoa(_max,t,10); ct=t; file.append(ct.ToWString().data()); isTransparent=true; if(param.length()){ file.append(L"¶m="+param.ToWString()); } } else { if(param.length()){ file.append(L"?param="+param.ToWString()); } } CreateBrowserWindow(file, exStyle, isTransparent); if(_max){ this->Max(); } else{ SetSize(w,h); Move(_x,_y); } this->SetTitle(name); if(enableDrag>0){ EnableDrag(); } }