
retrieve handle of the control from within the control when the container is vb
AFAIK there are no containers on the market that actually switch the
mode from design to run-time and reuse the existing control. VB creates
a new form at run-time, complete with the new copy of your control. You
can retrieve the current value of the property in, say, your WM_CREATE
handler. At this time and in all containers I know of, the value won't
change for the lifetime of the control.
Having said that, I still believe that the best way is not to jump
through hoops to ensure your control has a valid window, but rather make
it invisible at runtime (that's what it is - why lie to the container?)
and explicitly create a hidden window in FinalConstruct and destroy it
in FinalRelease. I guess you need the HWND so desperately because you
expect some notifications to arrive as messages to this window. Well,
just register your dedicated hidden window for those notifications.
CContainedWindow class is convenient in that with it you fold message
processing into your main class' message map.
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Quote:
> thanx alot for all the help.
> i still have one more query. now that i have done.. it.
> (it works perfectly i get the handle thankx for ur timely
> help) but since my requirement is to make the control
> invisible, for which i check the mode of control(design Vs
> running) and by checking the mode of the control at run
> time u can just make it invisible by calling ShowWindow
> (SW_HIDE), but i don't know where exactly should i call
> this function. bcoz when the container is vb..
> OnAmbientpropertychange is not called when the control
> goes from design mode. to run-mode.. but once a function
> or property has been changed of the control(at runtime)
> then i can easily come to know the mode of the control and
> hide it. but that is too late.. (there is no such
> behaviour in case of Vc++ it works perfecty in that case. )
> is that a bug in vb.. or is there a way round to solve
> this problem.
> once again thankx for the help..
> regards
> Mohan
> regards
> Mohan
> >-----Original Message-----
> >The flag is set in the registry. See .rgs file, look for
> something like
> > 'MiscStatus' = s '0'
> > {
> > '1' = s '131473'
> > }
> >The actual number may be different. Convert the number to
> hex (in this
> >case 131473 == 0x20191) and interpret it as a combination
> of OLEMISC
> >flags. Your number probably has
> OLEMISC_INVISIBLEATRUNTIME = 1024 =
> >0x400 flag set. Remove the flag, convert back to decimal,
> and write it
> >back to .rgs file. Rebuild and reregister your component.
> >--
> >With best wishes,
> > Igor Tandetnik
> >"For every complex problem, there is a solution that is
> simple, neat,
> >and wrong." H.L. Mencken
> >> hi.. igor.
> >> thanx for the help.
> >> bt my problem is that i require the handle of the
> control
> >> badly.. the solution to that it seems that if the
> control
> >> is not set to be invisible at run-time it does has the
> >> handle.. otherwise not (in case of vb).. if u could help
> >> me in reversing this process by making the control
> >> visible.. i.e. removing that flag which i have set..
> >> or find a solution.. for.. this.. would be really of
> >> great.. help..
> >> regards
> >> Mohan
> >> >-----Original Message-----
> >> >If you need a window handle just to process messages,
> not
> >> for UI, the
> >> >best way is to explicitly create a separate hidden
> >> window. See
> >> >CContainedWindow.
> >> >--
> >> >With best wishes,
> >> > Igor Tandetnik
> >> >"For every complex problem, there is a solution that is
> >> simple, neat,
> >> >and wrong." H.L. Mencken
> >> >> hi i hve developed an activex control in atl 3.0
> which
> >> is
> >> >> invisible at run-time. now when i use this control
> and
> >> the
> >> >> container is vb the value of m_hWnd is null. where as
> >> when
> >> >> the container is vc++ then the value of m_hWnd is
> ok..
> >> >> i tested this stuff by creating another. cntrol.
> which
> >> was
> >> >> invisible at run-time the result was same.. bt if i
> >> create
> >> >> the control which is not invisible i get the handle.
> >> >> comfortably..
> >> >> now my dilemma is i require the handle badly and i
> don't
> >> >> even know how to convert an invisible control back to
> >> >> visible control..
> >> >> can any one help me out of this..
> >> >> regards
> >> >> Mohan
> >> >.
> >.