Thread: [GD-Windows] VS 2003 generating duplicate COMDAT for template instantiation?
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2007-05-12 00:47:36
|
I'm trying to generate a SAS parser/binder using just a little bit of template programing, and I'm running into the following link error (I'm using VS 2003). I would like any help I can get in how to work around this problem. I got it when I was reinterpret_cast-ing from type Foo::*Bar[N] to Foo::*Bar[], but I worked around that by explicitly passing in the array size. However, here there are no skanky casts involved; this should "just work." (And I've tried with and without the inline Access() function). Win32DX9Graphics.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT '?Access@?$FieldAccessor@USasAmbientLight@impl_DX9@@VFastTriple@pit@@$GA@A@A@@impl_DX9@@QAEABVFastTriple@pit@@ABUSasAmbientLight@2@@Z' Looking at the templates FieldAccessor, here is the code: template<typename Container, typename Type, Type Container::*Field> class FieldAccessor { public: typedef Container ContainerType; typedef Type FieldType; inline Type const &Access(Container const &c) { return c.*Field; } }; Here are the two cases where FieldAccessor<> is referenced for the SasAmbientLight: // dispatch the child if (!wcscmp(path, L"color")) { setter_ = PIT_SYSTEMNEW0("ValueSetter") ValueSetter< FieldAccessor<SasAmbientLight, pit::FloatTriple, &SasAmbientLight::color> > (this, core_->ambientlight_[l]); return true; } return false; ... // dispatch the child, then return an iterator on that if (!wcscmp(path, L"color")) { setter_ = PIT_SYSTEMNEW0("OuterArraySetter") OuterArraySetter< FieldAccessor<SasAmbientLight, pit::FloatTriple, &SasAmbientLight::color> > (this, core_->ambientlight_, &core_->numambientlights_.get()); return true; } return false; pit::FloatTriple is what you'd expect, as is struct SasAmbientLight: struct SasAmbientLight { pit::FloatTriple color; }; Btw: upgrading to 2005 isn't the preferred solution right now. |
From: Kent Q. <ken...@co...> - 2007-05-12 04:37:15
|
Well, my template-fu is a bit underused on my current project, so I can't look at this and give you a solution. But try this: chop this code down into the smallest compileable file you can, and then feed it to GCC 4 and maybe the Comeau computing compiler test page: http://www.comeaucomputing.com/tryitout/ I've found in the past that when I've had tricky template troubles, one or the other of those compilers will generate some message that will give me a clue. I know this is failing on the link, but if you turn on maximum warnings, I wouldn't be surprised to have one of these compilers spit out a warning or an error. Kent Jon Watte wrote: > I'm trying to generate a SAS parser/binder using just a little bit of > template programing, and I'm running into the following link error (I'm > using VS 2003). I would like any help I can get in how to work around > this problem. I got it when I was reinterpret_cast-ing from type > Foo::*Bar[N] to Foo::*Bar[], but I worked around that by explicitly > passing in the array size. However, here there are no skanky casts > involved; this should "just work." (And I've tried with and without the > inline Access() function). > > > Win32DX9Graphics.obj : fatal error LNK1179: invalid or corrupt file: > duplicate COMDAT > '?Access@?$FieldAccessor@USasAmbientLight@impl_DX9@@VFastTriple@pit@@$GA@A@A@@impl_DX9@@QAEABVFastTriple@pit@@ABUSasAmbientLight@2@@Z' > > Looking at the templates FieldAccessor, here is the code: > > > template<typename Container, typename Type, Type Container::*Field> > class FieldAccessor { > public: > typedef Container ContainerType; > typedef Type FieldType; > inline Type const &Access(Container const &c) { return c.*Field; } > }; > > > Here are the two cases where FieldAccessor<> is referenced for the > SasAmbientLight: > > > // dispatch the child > if (!wcscmp(path, L"color")) { > setter_ = PIT_SYSTEMNEW0("ValueSetter") ValueSetter< > FieldAccessor<SasAmbientLight, pit::FloatTriple, > &SasAmbientLight::color> > > (this, core_->ambientlight_[l]); > return true; > } > return false; > > ... > > // dispatch the child, then return an iterator on that > if (!wcscmp(path, L"color")) { > setter_ = PIT_SYSTEMNEW0("OuterArraySetter") OuterArraySetter< > FieldAccessor<SasAmbientLight, pit::FloatTriple, > &SasAmbientLight::color> > > (this, core_->ambientlight_, &core_->numambientlights_.get()); > return true; > } > return false; > > > > pit::FloatTriple is what you'd expect, as is struct SasAmbientLight: > > struct SasAmbientLight { > pit::FloatTriple color; > }; > > > > Btw: upgrading to 2005 isn't the preferred solution right now. > > > -- ------------------------------------------------------------ Kent Quirk I'm making a game about global warming. Game Architect Track the progress at: CogniToy http://www.cognitoy.com/meltingpoint |
From: Matt J <mjo...@gm...> - 2007-05-12 06:19:43
|
I'm curious where Field is defined, and if the compiler can understand it is a type. Im thinking something like this might work... but my templates are rusty template<class T> { typedef typename T* FieldPtr } Container; And a pointer being passed as: Container<pit::FloatTriple>(core_->ambientlight_[l]) The other template being template<class Field, class C = Container<Field> > class FieldAccessor { typedef C::FieldPtr TypePtr; FieldAccessor(TypePtr &t) :MyTypePtr(t) {} // accessor returns &MyTypePtr TypePtr &MyTypePtr; } Anyway, good luck :p Matthew > > I'm trying to generate a SAS parser/binder using just a little bit of > template programing, and I'm running into the following link error (I'm > using VS 2003). I would like any help I can get in how to work around > this problem. I got it when I was reinterpret_cast-ing from type > Foo::*Bar[N] to Foo::*Bar[], but I worked around that by explicitly > passing in the array size. However, here there are no skanky casts > involved; this should "just work." (And I've tried with and without the > inline Access() function). > > > Win32DX9Graphics.obj : fatal error LNK1179: invalid or corrupt file: > duplicate COMDAT > '?Access@?$FieldAccessor@USasAmbientLight@impl_DX9@@VFastTriple@pit@@$GA@A@A@@impl_DX9@@QAEABVFastTriple@pit@@ABUSasAmbientLight@2@@Z' > > Looking at the templates FieldAccessor, here is the code: > > > template<typename Container, typename Type, Type Container::*Field> > class FieldAccessor { > public: > typedef Container ContainerType; > typedef Type FieldType; > inline Type const &Access(Container const &c) { return c.*Field; } > }; > > > Here are the two cases where FieldAccessor<> is referenced for the > SasAmbientLight: > > > // dispatch the child > if (!wcscmp(path, L"color")) { > setter_ = PIT_SYSTEMNEW0("ValueSetter") ValueSetter< > FieldAccessor<SasAmbientLight, pit::FloatTriple, > &SasAmbientLight::color> > > (this, core_->ambientlight_[l]); > return true; > } > return false; > > ... > > // dispatch the child, then return an iterator on that > if (!wcscmp(path, L"color")) { > setter_ = PIT_SYSTEMNEW0("OuterArraySetter") OuterArraySetter< > FieldAccessor<SasAmbientLight, pit::FloatTriple, > &SasAmbientLight::color> > > (this, core_->ambientlight_, &core_->numambientlights_.get()); > return true; > } > return false; > > > > pit::FloatTriple is what you'd expect, as is struct SasAmbientLight: > > struct SasAmbientLight { > pit::FloatTriple color; > }; > > > > Btw: upgrading to 2005 isn't the preferred solution right now. > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > -- ----- Matt Johnson http://otowngraphics.blogspot.com |
From: Jon W. <hp...@mi...> - 2007-05-12 17:34:38
|
Hmm. Well, the error in question here is that the compiler seems to emit two instantiations of the same template, in the same object file, without marking them as merge-able. Thus, the linker claims (rightly) that the .obj file is bad. I can try to chop it down and feed it to GCC 4, but given that the syntax is, I think, correct, I don't have high hopes. I think this is a MSVC specific problem. Anyway, I'll report back. Cheers, / h+ Matt J wrote: > I'm curious where Field is defined, and if the compiler can understand > it is a type. > > Im thinking something like this might work... but my templates are rusty > > template<class T> > { > typedef typename T* FieldPtr > > } Container; > > And a pointer being passed as: > > Container<pit::FloatTriple>(core_->ambientlight_[l]) > > The other template being > > template<class Field, class C = Container<Field> > > > class FieldAccessor > { > typedef C::FieldPtr TypePtr; > > FieldAccessor(TypePtr &t) :MyTypePtr(t) {} > > // accessor returns &MyTypePtr > > TypePtr &MyTypePtr; > > } > > Anyway, good luck :p > > Matthew > > >> I'm trying to generate a SAS parser/binder using just a little bit of >> template programing, and I'm running into the following link error (I'm >> using VS 2003). I would like any help I can get in how to work around >> this problem. I got it when I was reinterpret_cast-ing from type >> Foo::*Bar[N] to Foo::*Bar[], but I worked around that by explicitly >> passing in the array size. However, here there are no skanky casts >> involved; this should "just work." (And I've tried with and without the >> inline Access() function). >> >> >> Win32DX9Graphics.obj : fatal error LNK1179: invalid or corrupt file: >> duplicate COMDAT >> '?Access@?$FieldAccessor@USasAmbientLight@impl_DX9@@VFastTriple@pit@@$GA@A@A@@impl_DX9@@QAEABVFastTriple@pit@@ABUSasAmbientLight@2@@Z' >> >> Looking at the templates FieldAccessor, here is the code: >> >> >> template<typename Container, typename Type, Type Container::*Field> >> class FieldAccessor { >> public: >> typedef Container ContainerType; >> typedef Type FieldType; >> inline Type const &Access(Container const &c) { return c.*Field; } >> }; >> >> >> Here are the two cases where FieldAccessor<> is referenced for the >> SasAmbientLight: >> >> >> // dispatch the child >> if (!wcscmp(path, L"color")) { >> setter_ = PIT_SYSTEMNEW0("ValueSetter") ValueSetter< >> FieldAccessor<SasAmbientLight, pit::FloatTriple, >> &SasAmbientLight::color> > >> (this, core_->ambientlight_[l]); >> return true; >> } >> return false; >> >> ... >> >> // dispatch the child, then return an iterator on that >> if (!wcscmp(path, L"color")) { >> setter_ = PIT_SYSTEMNEW0("OuterArraySetter") OuterArraySetter< >> FieldAccessor<SasAmbientLight, pit::FloatTriple, >> &SasAmbientLight::color> > >> (this, core_->ambientlight_, &core_->numambientlights_.get()); >> return true; >> } >> return false; >> >> >> >> pit::FloatTriple is what you'd expect, as is struct SasAmbientLight: >> >> struct SasAmbientLight { >> pit::FloatTriple color; >> }; >> >> >> >> Btw: upgrading to 2005 isn't the preferred solution right now. >> >> >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Gamedevlists-windows mailing list >> Gam...@li... >> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows >> Archives: >> http://sourceforge.net/mailarchive/forum.php?forum_id=555 >> >> > > > |
From: Matt J <mjo...@gm...> - 2007-05-12 17:55:28
|
I was saying if the construct was confusing the compiler maybe try a different approach. Template code often has problems with disambiguation or it has problems with discerning between valid types and unnamed types. IIRC I've seen stuff compile before that did not link properly. Matthew > Hmm. Well, the error in question here is that the compiler seems to emit > two instantiations of the same template, in the same object file, > without marking them as merge-able. Thus, the linker claims (rightly) > that the .obj file is bad. > > I can try to chop it down and feed it to GCC 4, but given that the > syntax is, I think, correct, I don't have high hopes. I think this is a > MSVC specific problem. Anyway, I'll report back. > > Cheers, > > / h+ |
From: Mat N. (BUNGIE) <Mat...@mi...> - 2007-05-12 19:16:05
|
Well, if that's the case... do you have anything that is a function local s= tatic function? I've hit a similar problem when trying to generate a unique= class static function per inline function. No valid workaround either. MSN -----Original Message----- From: gam...@li... [mailto:gamedevlis= ts-...@li...] On Behalf Of Jon Watte Sent: Saturday, May 12, 2007 10:35 AM To: Game Development for MS Windows Subject: Re: [GD-Windows] VS 2003 generating duplicate COMDAT for template = instantiation? Hmm. Well, the error in question here is that the compiler seems to emit two instantiations of the same template, in the same object file, without marking them as merge-able. Thus, the linker claims (rightly) that the .obj file is bad. I can try to chop it down and feed it to GCC 4, but given that the syntax is, I think, correct, I don't have high hopes. I think this is a MSVC specific problem. Anyway, I'll report back. Cheers, / h+ Matt J wrote: > I'm curious where Field is defined, and if the compiler can understand > it is a type. > > Im thinking something like this might work... but my templates are rusty > > template<class T> > { > typedef typename T* FieldPtr > > } Container; > > And a pointer being passed as: > > Container<pit::FloatTriple>(core_->ambientlight_[l]) > > The other template being > > template<class Field, class C =3D Container<Field> > > > class FieldAccessor > { > typedef C::FieldPtr TypePtr; > > FieldAccessor(TypePtr &t) :MyTypePtr(t) {} > > // accessor returns &MyTypePtr > > TypePtr &MyTypePtr; > > } > > Anyway, good luck :p > > Matthew > > >> I'm trying to generate a SAS parser/binder using just a little bit of >> template programing, and I'm running into the following link error (I'm >> using VS 2003). I would like any help I can get in how to work around >> this problem. I got it when I was reinterpret_cast-ing from type >> Foo::*Bar[N] to Foo::*Bar[], but I worked around that by explicitly >> passing in the array size. However, here there are no skanky casts >> involved; this should "just work." (And I've tried with and without the >> inline Access() function). >> >> >> Win32DX9Graphics.obj : fatal error LNK1179: invalid or corrupt file: >> duplicate COMDAT >> '?Access@?$FieldAccessor@USasAmbientLight@impl_DX9@@VFastTriple@pit@@$GA= @A@A@@impl_DX9@@QAEABVFastTriple@pit@@ABUSasAmbientLight@2@@Z' >> >> Looking at the templates FieldAccessor, here is the code: >> >> >> template<typename Container, typename Type, Type Container::*Field> >> class FieldAccessor { >> public: >> typedef Container ContainerType; >> typedef Type FieldType; >> inline Type const &Access(Container const &c) { return c.*Field; } >> }; >> >> >> Here are the two cases where FieldAccessor<> is referenced for the >> SasAmbientLight: >> >> >> // dispatch the child >> if (!wcscmp(path, L"color")) { >> setter_ =3D PIT_SYSTEMNEW0("ValueSetter") ValueSetter< >> FieldAccessor<SasAmbientLight, pit::FloatTriple, >> &SasAmbientLight::color> > >> (this, core_->ambientlight_[l]); >> return true; >> } >> return false; >> >> ... >> >> // dispatch the child, then return an iterator on that >> if (!wcscmp(path, L"color")) { >> setter_ =3D PIT_SYSTEMNEW0("OuterArraySetter") OuterArraySetter< >> FieldAccessor<SasAmbientLight, pit::FloatTriple, >> &SasAmbientLight::color> > >> (this, core_->ambientlight_, &core_->numambientlights_.get()= ); >> return true; >> } >> return false; >> >> >> >> pit::FloatTriple is what you'd expect, as is struct SasAmbientLight: >> >> struct SasAmbientLight { >> pit::FloatTriple color; >> }; >> >> >> >> Btw: upgrading to 2005 isn't the preferred solution right now. >> >> >> >> >> ------------------------------------------------------------------------= - >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Gamedevlists-windows mailing list >> Gam...@li... >> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows >> Archives: >> http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 >> >> > > > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |
From: Jon W. <hp...@mi...> - 2007-05-13 15:18:43
|
Mat Noguchi (BUNGIE) wrote: > Well, if that's the case... do you have anything that is a function local static function? I've hit a similar problem when trying to generate a unique class static function per inline function. No valid workaround either. > > I did, but I removed them (it was actually a static of a function local class). Thanks for the suggestion, though! Cheers, / h+ |
From: Mat N. (BUNGIE) <Mat...@mi...> - 2007-05-13 17:36:14
|
Let me guess... you had something like this: inline void f() { class foo { public: static void blah() { printf("blah"); } }; foo::blah(); } And then use f() all over the place? There's some standardese about the lin= kage type of function local class static functions. I don't know what it is= , but it manifests as multiple COMDATs that can't be combined if you use th= e inline function in multiple places. MSN -----Original Message----- From: gam...@li... [mailto:gamedevlis= ts-...@li...] On Behalf Of Jon Watte Sent: Sunday, May 13, 2007 8:19 AM To: Game Development for MS Windows Subject: Re: [GD-Windows] VS 2003 generating duplicate COMDAT for template = instantiation? Mat Noguchi (BUNGIE) wrote: > Well, if that's the case... do you have anything that is a function local= static function? I've hit a similar problem when trying to generate a uniq= ue class static function per inline function. No valid workaround either. > > I did, but I removed them (it was actually a static of a function local class). Thanks for the suggestion, though! Cheers, / h+ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |
From: Jon W. <hp...@mi...> - 2007-05-16 03:55:13
|
Right, but that's not the problem at this point. I get a very similar error, though. No statics involved this time. Cheers, / h+ PS: Why is it that the goal in question (getting SAS bound to our data model) is never the real problem; the real problem is always something stupid? No, don't answer :-) Mat Noguchi (BUNGIE) wrote: > Let me guess... you had something like this: > > inline void f() > { > class foo { public: static void blah() { printf("blah"); } }; > foo::blah(); > } > > And then use f() all over the place? There's some standardese about the linkage type of function local class static functions. I don't know what it is, but it manifests as multiple COMDATs that can't be combined if you use the inline function in multiple places. > > MSN > |
From: Mat N. (BUNGIE) <Mat...@mi...> - 2007-05-16 05:41:43
|
What is SAS? And it's likely that there's some edge cases you're hitting if you hit mult= iple COMDAT errors :) Not that that helps. -----Original Message----- From: gam...@li... [mailto:gamedevlis= ts-...@li...] On Behalf Of Jon Watte Sent: Monday, May 14, 2007 10:30 AM To: Game Development for MS Windows Subject: Re: [GD-Windows] VS 2003 generating duplicate COMDAT for template = instantiation? Right, but that's not the problem at this point. I get a very similar error, though. No statics involved this time. Cheers, / h+ PS: Why is it that the goal in question (getting SAS bound to our data model) is never the real problem; the real problem is always something stupid? No, don't answer :-) Mat Noguchi (BUNGIE) wrote: > Let me guess... you had something like this: > > inline void f() > { > class foo { public: static void blah() { printf("blah"); } }; > foo::blah(); > } > > And then use f() all over the place? There's some standardese about the l= inkage type of function local class static functions. I don't know what it = is, but it manifests as multiple COMDATs that can't be combined if you use = the inline function in multiple places. > > MSN > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |
From: Dan G. <dan...@gm...> - 2007-05-16 06:24:47
|
On 5/16/07, Mat Noguchi (BUNGIE) <Mat...@mi...> wrote: > What is SAS? I think he means something like DXSAS. Jon's trying to bind his shader parameters to his engine internals. cheers DanG -- Dan Glastonbury, Dan dot Glastonbury at gmail dot com `Pour encourjay lays ortras' |
From: Jon W. <hp...@mi...> - 2007-05-16 22:01:57
|
That is correct: DirectX Standard Annotations and Semantics. Which, of course, seems to be way too under-specified to be truly useful, but as I need *some* kind of binding, I might as well make it that, and augment it with my own. Cheers, / h+ Dan Glastonbury wrote: > On 5/16/07, Mat Noguchi (BUNGIE) <Mat...@mi...> wrote: > >> What is SAS? >> > > I think he means something like DXSAS. Jon's trying to bind his > shader parameters to his engine internals. > > cheers > DanG > |
From: Pierre T. <pte...@ag...> - 2007-07-04 13:22:24
|
Hi, I'm trying to override the treeview wndproc to catch some messages. For other controls it worked fine, but with this one it crashes as soon as I call the old wndproc. So it looks like this: mHWnd = IceCore::CreateWindowEx( WS_EX_CLIENTEDGE, WC_TREEVIEW, "", dwStyle, desc.mX, desc.mY, desc.mWidth, desc.mHeight, hwndParent, (HMENU)desc.mID, (HINSTANCE)GetModuleHandle(null), null ); And then to override the wndproc: typedef LRESULT (CALLBACK * WndProc_t)(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam); static WndProc_t OldWndProc = 0; OldWndProc = (WndProc_t) SetWindowLong(mHWnd, GWL_WNDPROC, (LONG)MyTreeViewWndProc); The new wndproc is simply calling the old one at the moment: static LRESULT CALLBACK MyTreeViewWndProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { return (OldWndProc)(hwnd, uMessage, wParam, lParam); } ==> this crashes inside the old wndproc somewhere. However this same procedure worked fine for other controls (list boxes, edit boxes....) so I'm not sure what's going on. Is there something special about the treeview's wndproc? Thanks, - Pierre |
From: Roman K. <Rom...@Pi...> - 2007-07-04 13:31:06
|
Pierre, i think you're supposed to use the CallWindowProc API instead of calling the superclass proc yourself. static LRESULT CALLBACK MyTreeViewWndProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { return ::CallWindowProc( OldWndProc, hwnd, uMessage, wParam, lParam); } Roman ----- Original Message ----- From: "Pierre Terdiman" <pte...@ag...> To: "Game Development for MS Windows" <gam...@li...> Sent: Wednesday, July 04, 2007 3:23 PM Subject: [GD-Windows] Crash when overriding tree view wndproc > Hi, > > I'm trying to override the treeview wndproc to catch some messages. For > other controls it worked fine, but with this one it crashes as soon as I > call the old wndproc. So it looks like this: > > mHWnd = IceCore::CreateWindowEx( > WS_EX_CLIENTEDGE, > WC_TREEVIEW, > "", > dwStyle, > desc.mX, desc.mY, > desc.mWidth, desc.mHeight, > hwndParent, > (HMENU)desc.mID, > (HINSTANCE)GetModuleHandle(null), > null > ); > > > And then to override the wndproc: > > typedef LRESULT (CALLBACK * WndProc_t)(HWND hwnd, UINT uMessage, WPARAM > wParam, LPARAM lParam); > > static WndProc_t OldWndProc = 0; > > OldWndProc = (WndProc_t) SetWindowLong(mHWnd, GWL_WNDPROC, > (LONG)MyTreeViewWndProc); > > > The new wndproc is simply calling the old one at the moment: > > static LRESULT CALLBACK MyTreeViewWndProc(HWND hwnd, UINT uMessage, WPARAM > wParam, LPARAM lParam) > { > return (OldWndProc)(hwnd, uMessage, wParam, lParam); > } > > ==> this crashes inside the old wndproc somewhere. However this same > procedure worked fine for other controls (list boxes, edit boxes....) so > I'm > not sure what's going on. > > Is there something special about the treeview's wndproc? > > Thanks, > - Pierre > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Pierre T. <pte...@ag...> - 2007-07-04 13:37:27
|
Excellent, this seems to work! Thanks! - Pierre ----- Original Message ----- From: "Roman Keskenti" <Rom...@Pi...> To: "Game Development for MS Windows" <gam...@li...> Sent: Wednesday, July 04, 2007 3:30 PM Subject: [****** SPAM: ******] Re: [GD-Windows] Crash when overriding tree view wndproc > Pierre, > > i think you're supposed to use the CallWindowProc API instead of calling the > superclass proc yourself. > > static LRESULT CALLBACK MyTreeViewWndProc(HWND hwnd, UINT uMessage, WPARAM > wParam, LPARAM lParam) > { > return ::CallWindowProc( OldWndProc, hwnd, uMessage, wParam, lParam); > } > > Roman > > ----- Original Message ----- > From: "Pierre Terdiman" <pte...@ag...> > To: "Game Development for MS Windows" > <gam...@li...> > Sent: Wednesday, July 04, 2007 3:23 PM > Subject: [GD-Windows] Crash when overriding tree view wndproc > > > > Hi, > > > > I'm trying to override the treeview wndproc to catch some messages. For > > other controls it worked fine, but with this one it crashes as soon as I > > call the old wndproc. So it looks like this: > > > > mHWnd = IceCore::CreateWindowEx( > > WS_EX_CLIENTEDGE, > > WC_TREEVIEW, > > "", > > dwStyle, > > desc.mX, desc.mY, > > desc.mWidth, desc.mHeight, > > hwndParent, > > (HMENU)desc.mID, > > (HINSTANCE)GetModuleHandle(null), > > null > > ); > > > > > > And then to override the wndproc: > > > > typedef LRESULT (CALLBACK * WndProc_t)(HWND hwnd, UINT uMessage, WPARAM > > wParam, LPARAM lParam); > > > > static WndProc_t OldWndProc = 0; > > > > OldWndProc = (WndProc_t) SetWindowLong(mHWnd, GWL_WNDPROC, > > (LONG)MyTreeViewWndProc); > > > > > > The new wndproc is simply calling the old one at the moment: > > > > static LRESULT CALLBACK MyTreeViewWndProc(HWND hwnd, UINT uMessage, WPARAM > > wParam, LPARAM lParam) > > { > > return (OldWndProc)(hwnd, uMessage, wParam, lParam); > > } > > > > ==> this crashes inside the old wndproc somewhere. However this same > > procedure worked fine for other controls (list boxes, edit boxes....) so > > I'm > > not sure what's going on. > > > > Is there something special about the treeview's wndproc? > > > > Thanks, > > - Pierre > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Gamedevlists-windows mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Pierre T. <pte...@ag...> - 2007-07-05 14:46:35
|
Ok, I have another treeview question, about label editing. So I'm trying to let the user change the label of a treeview item by double-clicking on it. My problem is that no edit box ever shows up, even though I receive the expected messages. So it's like this: - the treeview is created with TVS_EDITLABELS - when user double-click on an item I call TreeView_EditLabel - then I correctly receive the TVN_BEGINLABELEDIT and TVN_ENDLABELEDIT. In the first one I can catch the edit control handle using TreeView_GetEditControl, which returns a valid handle. Yet no edition ever happens. I receive the TVN_ENDLABELEDIT notification immediately after the TVN_BEGINLABELEDIT one, and the text in the associated structure is null. What did I miss? I browsed the net in vain. I can't find a single example clearly showing me how to do that. The MSDN didn't help much either. Thanks, - Pierre |
From: Sander v. R. <san...@gm...> - 2007-07-05 14:52:44
|
if the text value is null then the edit is cancelled... probably because your breakpoint caused the edit box to lose focus and visual studio to gain focus... On 7/5/07, Pierre Terdiman <pte...@ag...> wrote: > Ok, I have another treeview question, about label editing. So I'm trying to > let the user change the label of a treeview item by double-clicking on it. > My problem is that no edit box ever shows up, even though I receive the > expected messages. > > So it's like this: > > - the treeview is created with TVS_EDITLABELS > - when user double-click on an item I call TreeView_EditLabel > - then I correctly receive the TVN_BEGINLABELEDIT and TVN_ENDLABELEDIT. In > the first one I can catch the edit control handle using > TreeView_GetEditControl, which returns a valid handle. > > Yet no edition ever happens. I receive the TVN_ENDLABELEDIT notification > immediately after the TVN_BEGINLABELEDIT one, and the text in the associated > structure is null. > > What did I miss? I browsed the net in vain. I can't find a single example > clearly showing me how to do that. The MSDN didn't help much either. > > Thanks, > - Pierre > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Pierre T. <pte...@ag...> - 2007-07-05 15:16:33
|
> if the text value is null then the edit is cancelled... > probably because your breakpoint caused the edit box to lose focus and > visual studio to gain focus... Well, it also doesn't work outside the debugguer of course.... Not that easy :) - Pierre |
From: Sander v. R. <san...@gm...> - 2007-07-05 15:18:41
|
Hehehe, ok. Can you edit the label? or does it dissappear before you can edit it? On 7/5/07, Pierre Terdiman <pte...@ag...> wrote: > > if the text value is null then the edit is cancelled... > > probably because your breakpoint caused the edit box to lose focus and > > visual studio to gain focus... > > Well, it also doesn't work outside the debugguer of course.... Not that easy > :) > > - Pierre > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Pierre T. <pte...@ag...> - 2007-07-05 15:20:23
|
> Can you edit the label? or does it dissappear before you can edit it? No I can't edit it. I don't see the edit box. Nothing seems to happen. |
From: Sander v. R. <san...@gm...> - 2007-07-05 15:27:37
|
are you handling other events? i mean, are you, for instance, focussing a control under some circumstances? or doing something else which would cause another control to receive focus? (and therefore making it impossible for the edit label to keep focus somehow?) On 7/5/07, Pierre Terdiman <pte...@ag...> wrote: > > Can you edit the label? or does it dissappear before you can edit it? > > No I can't edit it. I don't see the edit box. Nothing seems to happen. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Pierre T. <pte...@ag...> - 2007-07-05 15:38:37
|
> are you handling other events? > i mean, are you, for instance, focussing a control under some circumstances? > or doing something else which would cause another control to receive focus? > (and therefore making it impossible for the edit label to keep focus somehow?) Well I sure handle other events, but the focus seems fine. I'll try to create a small repro case if nobody gets a better idea. Thanks, - Pierre |