void CAlertDlg::OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl) { TRY_CATCH CDHtmlDialogEx::OnDocumentComplete(pDisp, szUrl); if(IsPageLoaded() == TRUE) { // // We give an option for the derived dialog to perfom some actions like update GUI here // OnPageLoaded(); // // // We need to calculate the position of the Next Alert // RECT rc; WINDOWPOS posc; CalcluateAlertPosition(&rc, &posc); // // We need this stuff for parent transparent window // if(m_hWndParent) { ::SendMessage(m_hWndParent,WM_WINDOWPOSCHANGING,NULL,(LPARAM)&posc); CTransparentWindow::OnUserMove(this->m_hWndParent ,&rc); } // // //if( m_hWndParent ) // ::SendMessage(m_hWndParent,WM_USER_BORDER_MOVE,NULL,(LPARAM)&rc); if(m_hWndParent) ::ShowWindow(this->m_hWndParent,SW_SHOWNORMAL); //SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER ); SetWindowPos(NULL, posc.x, posc.y, posc.cx, posc.cy, SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME); //UpdateWindow(); // // // FADEIN/FAEOUT effect without 1/2-transparent border // m_layeredWnd.AddLayeredStyle(this->m_hWnd); // Prepeare window to make it transparent m_iCurrentTransparency = BALLON_START_TRNSPARENCY; MakeWindowTransparent(m_iCurrentTransparency); SetTimer(BALLOON_NEW_FIDEIN_TIMER, BALLOON_NEW_FIDEIN_TIMEOUT, NULL); SetTimer(BALLOON_CLOSEDOWN_TIMER, BALLOON_CLOSEDOWN_TIMEOUT, NULL); SetTimer(BALLOON_MOUSEOUT_WAIT_FADEOUT_TIMER, BALLOON_MOUSEOUT_WAIT_FADEOUT_TIMEOUT, NULL); // SetForegroundWindowEx may be called to fix some issue STL-679 SetForegroundWindowEx(); ShowWindow(SW_NORMAL); } CATCH_LOG(_T("CAlertDlg::OnDocumentComplete")) }
BOOL CMUSHclientDoc::Transparency(long Key, short Amount) { if (Amount < MWT_MIN_FACTOR) Amount = MWT_MIN_FACTOR; else if (Amount > MWT_MAX_FACTOR) Amount = MWT_MAX_FACTOR; return MakeWindowTransparent (App.m_pMainWnd->m_hWnd, Key, (unsigned char) Amount); } // end of CMUSHclientDoc::Transparency
int main(int argc, char* argv[]) { IBNibRef nibRef; WindowRef window; HIViewRef textView; OSStatus err; // Create a Nib reference passing the name of the nib file (without the .nib extension) // CreateNibReference only searches into the application bundle. err = CreateNibReference(CFSTR("main"), &nibRef); require_noerr( err, CantGetNibRef ); // Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar // object. This name is set in InterfaceBuilder when the nib is created. err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")); require_noerr( err, CantSetMenuBar ); // Then create a window. "MainDocumentWindow" is the name of the window object. This name is set in // InterfaceBuilder when the nib is created. err = CreateWindowFromNib(nibRef, CFSTR("MainDocumentWindow"), &window); require_noerr( err, CantCreateWindow ); // We don't need the nib reference anymore. DisposeNibReference(nibRef); // Make the window's content area transparent err = MakeWindowTransparent(window); require_noerr( err, CantMakeWindowTransparent ); // Get a reference to the TextView in the main window err = HIViewFindByID(HIViewGetRoot(window), gTextViewID, &textView); require_noerr( err, CantGetTextView ); // Install our default options in the TextView err = MySetTextViewOptions(textView); require_noerr( err, CantSetTextViewOptions ); // Make the TextView partially transparent err = TextViewSetAlpha(textView, 0.25); require_noerr( err, CantSetTextViewOptions ); // The window was created hidden so show it. ShowWindow( window ); // Call the event loop RunApplicationEventLoop(); CantSetTextViewOptions: CantGetTextView: CantMakeWindowTransparent: CantCreateWindow: CantSetMenuBar: CantGetNibRef: return err; }
WindowRef PluginCarbonWindow::createTransparentWindow() { WindowRef window; OSStatus const createWindowError = CreateNewWindow(kUtilityWindowClass , kWindowNoShadowAttribute | kWindowStandardHandlerAttribute | kWindowNoTitleBarAttribute , &initialWindowBounds , &window); if (createWindowError != noErr) return 0; ASSERT(window); RepositionWindow(window, 0, kWindowCenterOnMainScreen); OSStatus const transparentError = MakeWindowTransparent(window); if (transparentError != noErr) { DisposeWindow(window); return 0; } ShowWindow(window); return window; }
//--------------------------------------------------------------------- // Creates one of our simple document windows and returns a ref to it. // WindowRef MyCreateNewDocumentWindow(void) { IBNibRef nib; WindowRef window = NULL; OSStatus status; // Create one of our special main document windows status = CreateNibReference(CFSTR("main"), &nib); require_noerr( status, CantGetNIBRef ); status = CreateWindowFromNib(nib, CFSTR("MainDocumentWindow"), &window); require_noerr( status, CantCreateWindow ); // Set its default options status = MySetTextViewOptions(GetTextViewFromWindow(window)); check_noerr( status ); // Make the window transparent status = MakeWindowTransparent(window); check_noerr( status ); // Make the TextView partially transparent status = TextViewSetAlpha(GetTextViewFromWindow(window), 0.25); check_noerr( status ); // Initialize the window title and proxy icon status = SetWindowTitleWithCFString(window, CFSTR("Untitled")); check_noerr( status ); status = SetWindowProxyCreatorAndType(window, kUnknownType, kUnknownType, kOnSystemDisk); check_noerr( status ); // Show the window ShowWindow(window); // Cleanup CantGetViewRef: CantCreateWindow: DisposeNibReference(nib); CantGetNIBRef: return window; }
void CKSPlugInEffectPane::SetGUI(kspi::IGUI* pGUI) { tuint32 uiPlugSizeX; tuint32 uiPlugSizeY; pGUI->GetSize(&uiPlugSizeX, &uiPlugSizeY); mpPane->SetSize(ge::SSize(uiPlugSizeX, uiPlugSizeY)); dynamic_cast<CKSPlugInGUIPane*>(mpParent)->SetWidth(uiPlugSizeX); tint32 iY = 24; #ifdef _Mac WindowRef RefParent = (WindowRef)(GetWindow()->GetParent()); Rect rctSize; ::GetWindowBounds(RefParent, kWindowContentRgn, &rctSize); rctSize.right = rctSize.left + uiPlugSizeX; rctSize.bottom = rctSize.top + uiPlugSizeY + iY; ::SetWindowBounds(RefParent, kWindowContentRgn, &rctSize); Rect bnds; bnds.top = 0; bnds.left = 0; bnds.right = uiPlugSizeX; bnds.bottom = uiPlugSizeY; // ::CreateNewWindow(kOverlayWindowClass, kWindowNoShadowAttribute | kWindowStandardHandlerAttribute, &bnds, &mWindowRef); // ::CreateNewWindow(kFloatingWindowClass, kWindowNoShadowAttribute | kWindowStandardHandlerAttribute, &bnds, &mWindowRef); ::CreateNewWindow(kOverlayWindowClass, kWindowCompositingAttribute | kWindowNoShadowAttribute | kWindowStandardHandlerAttribute, &bnds, &mWindowRef); // mWindowRef = RefParent; /* static int a = 0; if (a++ == 0) { HIObjectRegisterSubclass(gViewClassID, kHIViewClassID, 0, ViewClassHandler, GetEventTypeCount(gClassEvents), gClassEvents, 0, &gClass); }*/ /* OSErr err; HIViewRef ViewRef = NULL; EventRef Event = NULL; err = ::CreateEvent( NULL, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, &Event); HIRect Bounds; Bounds.origin.x = 0; Bounds.origin.y = 0; Bounds.size.width = uiPlugSizeX; Bounds.size.height = uiPlugSizeY; err = ::SetEventParameter(Event, kEventParamBounds, typeHIRect, sizeof(HIRect), &Bounds); err = ::HIObjectCreate(gViewClassID, Event, (HIObjectRef*)&ViewRef); err = ::HIViewChangeFeatures(ViewRef, kHIViewAllowsSubviews, 0); HIViewRef contentView; if (HIViewFindByID (HIViewGetRoot ((WindowRef)RefParent), kHIViewWindowContentID, &contentView) == noErr) { err = ::HIViewChangeFeatures(contentView, kHIViewAllowsSubviews, 0); err = ::HIViewAddSubview(contentView, ViewRef); }*/ // mWindowRef = ; // HIViewFindByID(...) ??? /* ControlRef parentView = NULL; ::GetRootControl(/*RefParent*//*mWindowRef, &parentView); OSErr err; HIViewRef ViewRef = NULL; EventRef Event = NULL; err = ::CreateEvent( NULL, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, &Event); HIRect Bounds; Bounds.origin.x = 0; Bounds.origin.y = 0; Bounds.size.width = uiPlugSizeX; Bounds.size.height = uiPlugSizeY; err = ::SetEventParameter(Event, kEventParamBounds, typeHIRect, sizeof( HIRect ), &Bounds); err = ::HIObjectCreate(gViewClassID, Event, (HIObjectRef*)&ViewRef); err = ::HIViewChangeFeatures(ViewRef, kHIViewAllowsSubviews, 0); HIViewChangeFeatures((HIViewRef)/*RefParent*//*mWindowRef, kHIViewAllowsSubviews, 0); // err = ::HIViewAddSubview((HIViewRef)parentView/*RefParent*//*mWindowRef*//*, ViewRef); // err = ::EmbedControl(ViewRef, (HIViewRef)/*RefParent*//*mWindowRef); err = ::HIViewSetVisible(ViewRef, true);*/ Rect r; ::GetWindowBounds(RefParent, kWindowContentRgn, &r); r.right = r.left + uiPlugSizeX; r.top += iY; r.bottom = r.top + uiPlugSizeY; ::SetWindowBounds(mWindowRef, kWindowContentRgn, &r); ::ShowWindow(mWindowRef); /* WindowGroupRef WindowGroup; ::BringToFront(mWindowRef); WindowGroupAttributes windowGroupAttributes = 0; ::CreateWindowGroup(windowGroupAttributes, &WindowGroup); // ::SetWindowGroupParent(WindowGroup, GetWindowGroup(RefParent)); ::SetWindowGroup(mWindowRef, WindowGroup); ::SetWindowGroup(RefParent, WindowGroup); ::SendBehind(RefParent, mWindowRef); ::ChangeWindowGroupAttributes(WindowGroup, kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrSharedActivation, NULL); ::SendBehind(RefParent, mWindowRef); ::ShowWindow(mWindowRef);*/ MakeWindowTransparent(RefParent); ::BringToFront(mWindowRef); ::SendBehind(RefParent, mWindowRef); WindowGroupRef WindowGroup; WindowGroupAttributes windowGroupAttributes = kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrSharedActivation; ::CreateWindowGroup(windowGroupAttributes, &WindowGroup); ::SetWindowGroup(mWindowRef, WindowGroup); ::SetWindowGroup(RefParent, WindowGroup); ::ShowWindow(mWindowRef); // ::DebugPrintWindowGroup(WindowGroup); /* WindowRef window; Rect r = {0,0,300,200}; WindowAttributes attributes = kWindowStandardHandlerAttribute | kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowCompositingAttribute | kWindowAsyncDragAttribute; CreateNewWindow (kDocumentWindowClass, attributes, &r, &window); // short *rect = 0; // vstEffect->dispatch (effEditGetRect, 0, 0, &rect); // vstEffect->dispatch (effEditOpen, 0, 0, window); pGUI->MakeWindow((void*)window); HIViewRef contentView; HIViewFindByID (HIViewGetRoot (window), kHIViewWindowContentID, &contentView); HIViewRef plugView = HIViewGetFirstSubview (contentView); HIRect plugOriginalBounds; HIViewGetBounds (plugView, &plugOriginalBounds); // setWindowSize (plugOriginalBounds.size.width, plugOriginalBounds.size.height); // HIViewSetFrame(windowContentView, &plugOriginalBounds); ::GetWindowBounds(window, kWindowContentRgn, &r); r.right = r.left + plugOriginalBounds.size.width; r.top += iY; r.bottom = r.top + plugOriginalBounds.size.height; ::SetWindowBounds(window, kWindowContentRgn, &r); ShowWindow (window);*/ pGUI->MakeWindow((void*)mWindowRef); pGUI->Paint(); mpGUI = pGUI; mpTimer = ITimer::Create(); mpTimer->Init(0, dynamic_cast<ITimerCallback*>(this), 50); #endif // _Mac #ifdef WIN32 HWND hwndParent = (HWND)(GetWindow()->GetParent()); // ::SetWindowPos(hwndParent, 0, 0, 0, uiPlugSizeX, uiPlugSizeY + iY, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); static tbool gbPlugInClassRegistered = false; if (gbPlugInClassRegistered == false) { WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wc.lpfnWndProc = (WNDPROC)PlugInWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = ghInstance; wc.hIcon = 0; wc.hCursor = NULL; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = 0; wc.lpszClassName = "KSPlugInWnd"; ::RegisterClass(&wc); } DWORD dwStyle = WS_CHILD | WS_VISIBLE; DWORD dwExStyle = 0; ghWndChild = NULL; ::EnumChildWindows(hwndParent, EnumChild, 0); ::SetWindowPos(hwndParent, 0, 0, 0, uiPlugSizeX, uiPlugSizeY + iY, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); RECT rctParent; ::GetClientRect(hwndParent, &rctParent); ::SetWindowPos(hwndParent, 0, 0, 0, uiPlugSizeX + (uiPlugSizeX - rctParent.right), uiPlugSizeY + iY + (uiPlugSizeY + iY - rctParent.bottom), SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); ::SetWindowPos(ghWndChild, 0, 0, 0, uiPlugSizeX, uiPlugSizeY + iY, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); HWND hWndPlug = ::CreateWindowEx(dwExStyle, "KSPlugInWnd", NULL, dwStyle, 0, iY, uiPlugSizeX, uiPlugSizeY, ghWndChild, NULL, ghInstance, (LPVOID)this); pGUI->MakeWindow((void*)hWndPlug); pGUI->Paint(); mpGUI = pGUI; mpTimer = ITimer::Create(); mpTimer->Init(0, dynamic_cast<ITimerCallback*>(this), 50); #endif // WIN32 mbGUILoaded = true; }
LRESULT CALLBACK SplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { UINT_PTR iRes = 0; // for SetTimer ret val switch (message) { case WM_CREATE: TRACE( _T("SplashWndProc> WM_CREATE\n") ); iRes = SetTimer( hWnd, 1, g_dwSplashScreenTimeToLive, NULL ); // InvalidateRect( hWnd, NULL, FALSE ); // OnSplashWndPaint(hWnd); CenterWindow( hWnd ); MakeWindowTransparent( hWnd, transparentFactor, crTransparent ); SetCursor( LoadCursor( NULL, MAKEINTRESOURCE(IDC_ARROW) ) ); break; case WM_PAINT: // TRACE( _T("SplashWndProc> WM_PAINT\n") ); OnSplashWndPaint(hWnd); break; case WM_LBUTTONUP: if( g_bDragSplash ) { g_bDragSplash = FALSE; ReleaseCapture(); } break; case WM_MOUSEMOVE: if( g_bDragSplash ) { POINT p1 = g_ptMouseDragBegin; RECT r = g_rWindowDragBegin; POINT p2; GetCursorPos( &p2 ); int dx = p2.x - p1.x; int dy = p2.y - p1.y; MoveWindow( hWnd, r.left + dx, r.top + dy, r.right - r.left, r.bottom - r.top, TRUE ); } break; case WM_LBUTTONDOWN: #ifdef EXIT_ON_MOUSE_CLICK ::DestroyWindow(hWnd); #else SetCapture(hWnd); GetCursorPos( &g_ptMouseDragBegin ); GetWindowRect( hWnd, &g_rWindowDragBegin ); g_bDragSplash = TRUE; // Set flag to check for key down in mouse move // message. #endif break; case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: // TRACE( _T("SplashWndProc> Mouse click\n") ); #ifdef EXIT_ON_MOUSE_CLICK ::DestroyWindow(hWnd); #else #ifdef TOGGLE_SPLASH g_bStopSplashOnTimer = !g_bStopSplashOnTimer; #endif #endif break; case WM_KEYDOWN: // TRACE( _T("SplashWndProc> WM_KEYDOWN: VK = %X\n"), wParam ); if( wParam == VK_ESCAPE ) { ::DestroyWindow(hWnd); } else { #ifdef EXIT_ON_KBD_HIT ::DestroyWindow(hWnd); #else #ifdef TOGGLE_SPLASH g_bStopSplashOnTimer = !g_bStopSplashOnTimer; #endif #endif } //return DefWindowProc(hWnd, message, wParam, lParam); break; case WM_TIMER: TRACE( _T("SplashWndProc> WM_TIMER\n") ); if( g_bStopSplashOnTimer ) { ::DestroyWindow(hWnd); } break; case WM_DESTROY: TRACE( _T("SplashWndProc> WM_DESTROY\n") ); #ifdef EXIT_AFTER_SPLASH PostQuitMessage( 0 ); #endif break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }