Home » U++ Library support » U++ Widgets - General questions or Mixed problems » why the ctrl does`t have HWND?
|
|
|
|
|
Re: why the ctrl does`t have HWND? [message #46398 is a reply to message #46397] |
Thu, 05 May 2016 04:08   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
This is a small demonstration. If you resize the mainwindow or move it, you will notice the popup will detach from the ctrl it's faking.
To make it work better, you should write a small control to take care of reset the popup's size/position even visibility when that of the ctrl it's faking has changed. Some of the Ctrl virtual functions you should override could by Layout, State()...
Hopefully someone more knowledgeble will give you a complete list or even a more appropriate way to do that.
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp: public TopWindow
{
MyApp()
{
Add(e.LeftPos(30,600).TopPos(40,400));
}
LineEdit e;
Label l;
typedef MyApp CLASSNAME;
};
GUI_APP_MAIN
{
MyApp a;
a.MinimizeBox().MaximizeBox().Open();
a. l.SetRect(a.e.GetRect()+a.GetScreenRect().TopLeft());
a. l.PopUp(&a.e, true, false, false,false);
a.Run();
}
|
|
|
Re: why the ctrl does`t have HWND? [message #46399 is a reply to message #46398] |
Thu, 05 May 2016 04:56   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Still very primitive, but you can get some idea.
Not all State (reason) needs to be taken care of. Seems it's fine if you only do the POSITION case.
Flicks, flicks, flicks. Let's see if somebody can make it smoother.
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class MyPopup : public Ctrl
{
public:
virtual void Paint(Draw& w)
{
w.DrawText(10,20,String().Cat()<<"Daw in the faked Ctrl,"
" my HWND is"<<GetHWND(),StdFont(),White());
}
};
class PopupHolder : public Ctrl
{
public:
void Reset()
{
if(!GetTopCtrl())
return;
popup.Close();
popup.SetRect( GetRect() + this->GetTopCtrl()->GetScreenRect().TopLeft() );
popup.PopUp(this,true,false);
}
virtual void State(int reason)
{
switch(reason)
{
// FOCUS = 10,
case ACTIVATE: // = 11,
LOG("ACTIVATE");
Reset();
break;
case DEACTIVATE:// = 12,
LOG("DEACTIVATE");
popup.Close();
break;
case SHOW:// = 13,
LOG("SHOW");
Reset();
break;
// ENABLE = 14,
// EDITABLE = 15,
case OPEN:// = 16,
LOG("OPEN");
Reset();
break;
case CLOSE:// = 17,
LOG("CLOSE");
popup.Close();
break;
case POSITION:// = 100,
LOG("Position");
Reset();
break;
case LAYOUTPOS:// = 101,
LOG("LAYOUTPOS");
Reset();
break;
}
}
MyPopup popup;
};
struct MyApp: public TopWindow
{
MyApp()
{
//Add(e.LeftPos(30,600).TopPos(40,400));
Add(h.SizePos());
}
PopupHolder h;
typedef MyApp CLASSNAME;
};
GUI_APP_MAIN
{
MyApp().MinimizeBox().MaximizeBox().Sizeable().Run();
}
[Updated on: Thu, 05 May 2016 04:59] Report message to a moderator
|
|
|
|
|
Re: why the ctrl does`t have HWND? [message #46404 is a reply to message #46390] |
Thu, 05 May 2016 20:52   |
|
Hello akabee!
Sorry for replying so late, but I think there is better way to do this. Have a look at DHCtrl in CtrlCore/Win32GuiA.h (or CtrlCore/X11GuiA.h for Linux version). DHCtrl is a special Ctrl that does nothing, but has its own HWND (or Window in X11 backend). DHCtrl can be added to your layouts and manipulated just like any other widget, so you don't need to keep track of the popup and move it all the time.
I think one of the original intents behind DHCtrl was actually quite similar to your usecase: It is used for direct rendering of OpenGL in GLCtrl. You can have a look at that one too, to get some hints about DHCtrl usage.
Best regards,
Honza
|
|
|
|
|
Re: why the ctrl does`t have HWND? [message #46432 is a reply to message #46428] |
Tue, 10 May 2016 17:40  |
|
If I remember correctly, sometimes the flickering problems can be be solved by using Ctrl::Backpaint(). You can try experimenting with the various values it can take (NOBACKPAINT, FULLBACKPAINT, TRANSPARENTBACKPAINT and EXCLUDEPAINT).
Honza
|
|
|
Goto Forum:
Current Time: Fri May 09 20:19:23 CEST 2025
Total time taken to generate the page: 0.01919 seconds
|