Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Window move virtual function
Window move virtual function [message #28456] Thu, 02 September 2010 14:11 Go to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello all

Working to get the MediaPlayer, I am trying to prepare a SDLCtrl control.

Unfortunately that is not easy: as SDL creates its own window. It is not possible to set SDL to an existing U++ window.

Because of it a SDLCtrl (a Ctrl with SDL inside) would have to move and resize its SDL window, and has to put it over it or has to be transparent to let SDL window to be visible. If not the SDLCtrl would hide its SDL window.

In summary, I have two questions:

- Is there a virtual function that is called if a Ctrl is moved?.
Now it exists Layout() that is run if Ctrl is resized.

- Is there a way to force a window always to be over a U++ window. When I try it U++ window always finally sets on top.

or

- Is there a way to set transparent both an U++ Ctrl and the parent window rect under it.

You can see these problems in the picture. Size is right but SDLCtrl and window is over SDL, and SDL does not move with SDLCtrl because it does not know when it is moved.

index.php?t=getfile&id=2779&private=0

Thank you very much!
  • Attachment: dib.PNG
    (Size: 43.52KB, Downloaded 692 times)


Best regards
Iñaki
Re: Window move virtual function [message #28457 is a reply to message #28456] Thu, 02 September 2010 15:33 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Hello Koldo,

I don't know much about SDL but i think it's possible to use a window created in U++ and put SDL into it. See SDL_CreateWindowFrom

That may solve your problems Smile

Andrei

[Updated on: Thu, 02 September 2010 15:36]

Report message to a moderator

Re: Window move virtual function [message #28459 is a reply to message #28457] Thu, 02 September 2010 15:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Andrei

Good answer. However that function is only available in SDL v1.3, that is experimental from many years ago so is not expected to be released soon Sad.

An excellent option would be the opposite: Is it possible to create a DHCtrl using an existing window handle? Smile Smile


Best regards
Iñaki
Re: Window move virtual function [message #28463 is a reply to message #28459] Thu, 02 September 2010 16:20 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Well, at least in windows, the way to move the SDL window with the window is using virtual void DHCTrl::State(int reason).

The only problem is that the SDL window is under the U++ window Sad


Best regards
Iñaki
Re: Window move virtual function [message #28464 is a reply to message #28459] Thu, 02 September 2010 16:20 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Well, at least in windows, the way to move the SDL window with the window is using virtual void DHCTrl::State(int reason).

The only problem is that the SDL window is under the U++ window Sad


Best regards
Iñaki
Re: Window move virtual function [message #28468 is a reply to message #28464] Thu, 02 September 2010 18:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello

Finally it works in Windows.

The trick has been this:

void SDLCtrl::State(int reason) {
	switch(reason) {
	case OPEN:
		{
			GuiLock __;
			CloseHWND();
			HWND phwnd = GetTopCtrl()->GetHWND();
			if(phwnd) {
				hwnd = hwndSDL;
				SetParent(hwndSDL, phwnd);
			}
		}
		break;
	default:
		DHCtrl::State(reason);
	}
}


index.php?t=getfile&id=2783&private=0

The only problem is that it is necessary to change DHCtrl, as hwnd and CloseHWND() have to be "protected:" instead of "private:".

Mirek, Daniel, Massimo, other, what do you think about this?
  • Attachment: dib.PNG
    (Size: 47.97KB, Downloaded 623 times)


Best regards
Iñaki
Re: Window move virtual function [message #28515 is a reply to message #28468] Sat, 04 September 2010 23:40 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Quote:

The only problem is that it is necessary to change DHCtrl, as hwnd and CloseHWND() have to be "protected:" instead of "private:".

Mirek, Daniel, Massimo, other, what do you think about this?

Do you approve this?

#ifdef PLATFORM_WIN32
#ifndef PLATFORM_WINCE

class DHCtrl : public Ctrl {
public:
	virtual void    State(int reason);
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	virtual void    NcCreate(HWND hwnd);
	virtual void    NcDestroy();

private:
	void OpenHWND();
	void SyncHWND();
	
protected: // NEW
	void CloseHWND();
	HWND   hwnd;

public:
	HWND    GetHWND()                              { return hwnd; }
//	void    Refresh()                              { InvalidateRect(GetHWND(), NULL, false); }

	DHCtrl();
	~DHCtrl();
};


Best regards
Iñaki
Re: Window move virtual function [message #29100 is a reply to message #28515] Tue, 05 October 2010 08:17 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Done in other post thanks to Mirek Smile.

Best regards
Iñaki
Previous Topic: GLCtrl questions
Next Topic: ColumnList - Set(Value key, Value val) - Working right?
Goto Forum:
  


Current Time: Fri Apr 19 03:30:26 CEST 2024

Total time taken to generate the page: 0.04563 seconds