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 » Ctrl creation via dll stuff
Ctrl creation via dll stuff [message #49426] Thu, 08 February 2018 17:08 Go to next message
luoganda is currently offline  luoganda
Messages: 203
Registered: November 2016
Experienced Member
I have a main loop and all in main.exe, but want to assign new ctrl(that is for Tab)
through dll, any suggestions about that?
It works ok, but when any functions being displayed as TopWindow,like PromptOK,
it complains something about "Top...".

And another one:
when assigning new TopWindow as a child to any Ctrl, then it works(opens) as child Ctrl,
is this the intent? probably yes.
Wouldn't it be easier to use TopWindow(orNewDerivedOne) instead of DHCtrl?
I don't know much about code in there, but that may be somehow complicated.

And another one / how to get Ctrl rect relative to main TopWindow?
Re: Ctrl creation via dll stuff [message #49434 is a reply to message #49426] Fri, 09 February 2018 13:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
luoganda wrote on Thu, 08 February 2018 17:08
I have a main loop and all in main.exe, but want to assign new ctrl(that is for Tab)
through dll, any suggestions about that?
It works ok, but when any functions being displayed as TopWindow,like PromptOK,
it complains something about "Top...".


Maybe you could quite the whole complaint here...

Quote:

And another one:
when assigning new TopWindow as a child to any Ctrl, then it works(opens) as child Ctrl,
is this the intent? probably yes.


Yes.

Quote:

Wouldn't it be easier to use TopWindow(orNewDerivedOne) instead of DHCtrl?


No. If you use TopWindow derived Ctrl as child, it is child (and does not have host platform widget handle, e.g. HWND). The idea is rather that you e.g. have some dialog that you want to use both standalone and as tab of some larger dialog.

Quote:

And another one / how to get Ctrl rect relative to main TopWindow?


What exactly does that mean?

[Updated on: Fri, 09 February 2018 13:53]

Report message to a moderator

Re: Ctrl creation via dll stuff [message #49440 is a reply to message #49426] Fri, 09 February 2018 20:51 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 203
Registered: November 2016
Experienced Member
Quote:
Maybe you could quite the whole complaint here...

"Assertion failed in ...CtrlCore\Win32Wnd.cpp,line 528
top->hwnd"
Dll has regular DLL_APP_MAIN and PromptOK is called within LeftDown.
Couldn't it be done without DLL_APP_MAIN, that is without Ctrl::InitWin32(AppGetHandle()); and AppInitEnvironment__();,
just regular DllMain(onWVer)?
Or are this totally different(nonsharable) things and that 2calls must be called for Ctrl's to work properly?

Quote:
And another one / how to get Ctrl rect relative to main TopWindow?
Quote:
What exactly does that mean?

If i have a DHCtrl and want to use it in TabCtrl for exact child position where "slaveCtrl" usually is,
how do i get that position? for regular Ctrl you just call TabCtrl.Set(...), but here it's a little different.
When DHCtrl is assigned to TabCtrl.Set(...) it becomes child of a main TopWindow, so a little hokus pokus must be used to set position of DHCtrl correctly
Re: Ctrl creation via dll stuff [message #49654 is a reply to message #49440] Thu, 22 March 2018 11:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
luoganda wrote on Fri, 09 February 2018 20:51
Quote:
Maybe you could quite the whole complaint here...

"Assertion failed in ...CtrlCore\Win32Wnd.cpp,line 528
top->hwnd"


My guess is that CreateWindowEx has failed.

My guts feeling is that this is because U++ is not properly initialized. Initialization creates window classes used with CreateWindowEx and that is what IMO fails here.

This is at the moment unsupported scenario. Anyway, if you want to try, check the definition of GUI_APP_MAIN macro and try to reproduice it with DLL_APP_MAIN (e.g. create something like DLL_GUI_APP_MAIN?)

Keep me informed, it would be nice to support this...

Mirek
Re: Ctrl creation via dll stuff [message #49655 is a reply to message #49440] Thu, 22 March 2018 11:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
luoganda wrote on Fri, 09 February 2018 20:51

If i have a DHCtrl and want to use it in TabCtrl for exact child position where "slaveCtrl" usually is,
how do i get that position? for regular Ctrl you just call TabCtrl.Set(...), but here it's a little different.
When DHCtrl is assigned to TabCtrl.Set(...) it becomes child of a main TopWindow, so a little hokus pokus must be used to set position of DHCtrl correctly


I believe that this should work out of box - position of that slave HWND should be recomputed correctly.

If it does not, we need to fix that... Testcase package would be very welcome here. (I mean: provide me a testcase and I will fix this Smile

Mirek
Re: Ctrl creation via dll stuff [message #49658 is a reply to message #49426] Thu, 22 March 2018 21:46 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 203
Registered: November 2016
Experienced Member
DLL_APP_MAIN fix:
I remember that i had similar problem when not using hinstDll.
GetModuleHandle... did not returned same value, so
UPP::Ctrl::InitWin32(hinstDll/*AppGetHandle()*/);
Maybe adding UPP:: in front to all, like in EXE_APP_MAIN.

DHCtrl in TabCtrl:
I am not sure yet for this, maybe testcase another time, but:
how do i get any Ctrl rect position relative to TopWindow? And possibly in Layout override func?
Now i am using
rc=GetRect(); struct sZ{int x,y,w,h;}sz={rc.left,rc.top,rc.Width(),rc.Height()};
but rc.left/rc.top is always zero - how do i get that?

And, by the way, can another exe be implemented - something like a plugin - into upp application,
or is too much trouble implementing this because of separate event loops and such?

[Updated on: Thu, 22 March 2018 21:47]

Report message to a moderator

Re: Ctrl creation via dll stuff [message #49659 is a reply to message #49658] Fri, 23 March 2018 10:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
luoganda wrote on Thu, 22 March 2018 21:46

DHCtrl in TabCtrl:
I am not sure yet for this, maybe testcase another time, but:
how do i get any Ctrl rect position relative to TopWindow? And possibly in Layout override func?
Now i am using
rc=GetRect(); struct sZ{int x,y,w,h;}sz={rc.left,rc.top,rc.Width(),rc.Height()};
but rc.left/rc.top is always zero - how do i get that?


I guess I do not fully undestand the question, but in general: If you want to get relative position of two (possibly) unrelated Ctrls, the easiest way is to use GetScreenView (or GetScreenRect if you want 'outer' dimensions) and compute it from these.

Quote:

And, by the way, can another exe be implemented - something like a plugin - into upp application,
or is too much trouble implementing this because of separate event loops and such?

[/quote]

ATM no. Would be nice to have, not all that hard to do IMO. Not a priority for me right now...

Mirek

[Updated on: Fri, 23 March 2018 10:20]

Report message to a moderator

Re: Ctrl creation via dll stuff [message #49738 is a reply to message #49426] Sun, 15 April 2018 11:57 Go to previous messageGo to next message
luoganda is currently offline  luoganda
Messages: 203
Registered: November 2016
Experienced Member
Quote:
I guess I do not fully undestand the question, but in general: If you want to get relative position of two (possibly) unrelated Ctrls, the easiest way is to use GetScreenView (or GetScreenRect if you want 'outer' dimensions) and compute it from these.

Yes, this is what i was asking.

DHCtrl in TabCtrl works as expected - like other controls, BUT,
zorder does not - this is when one want's to have another usual Ctrl somewhere
intersecting that DHCtrl in TabCtrl and above it, that is when DHCtrl is below it.
DHCtrl below is somehow shown - incorectly - more or less painting problems.

By the way, adding ScrollBars to Ctrl created wia dll does not work, this error is when AddFrame is called,
this was the same error message when i wanted to allocate memory in exe but then release
it in dll or vice versa, breakpoint with heap corruption.
Can for example, String(or any other) core class be used globally through exe/dll?
Or must they use some kind of allocator where class is - allocation/deallocation in exe/dll separatelly?
Exact error message was: Heap is corrupted --memory-breakpoint__61843922
Re: Ctrl creation via dll stuff [message #49754 is a reply to message #49738] Mon, 23 April 2018 11:13 Go to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
luoganda wrote on Sun, 15 April 2018 11:57
Quote:
I guess I do not fully undestand the question, but in general: If you want to get relative position of two (possibly) unrelated Ctrls, the easiest way is to use GetScreenView (or GetScreenRect if you want 'outer' dimensions) and compute it from these.

Yes, this is what i was asking.

DHCtrl in TabCtrl works as expected - like other controls, BUT,
zorder does not - this is when one want's to have another usual Ctrl somewhere
intersecting that DHCtrl in TabCtrl and above it, that is when DHCtrl is below it.
DHCtrl below is somehow shown - incorectly - more or less painting problems.


Yes, that is what I would expect. This cannot work for technical reasons.

Quote:

By the way, adding ScrollBars to Ctrl created wia dll does not work, this error is when AddFrame is called,
this was the same error message when i wanted to allocate memory in exe but then release
it in dll or vice versa, breakpoint with heap corruption.
Can for example, String(or any other) core class be used globally through exe/dll?
Or must they use some kind of allocator where class is - allocation/deallocation in exe/dll separatelly?
Exact error message was: Heap is corrupted --memory-breakpoint__61843922


First of all, it is not supported scenario at the moment. One problem here is that probably there are two heaps (one managed by .dll other by application). You can easily solve that by using USEMALLOC - that will switch off U++ heap and use standard new/delete. Expect a drop in performance (10-20% in allocation heavy code).

Mirek
Previous Topic: Random problems with destructors in GUI classes
Next Topic: DHCtrl, Ctrl NoBackPaint ignored?
Goto Forum:
  


Current Time: Sun Jun 16 07:06:07 CEST 2024

Total time taken to generate the page: 0.01367 seconds