几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 05:45 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】message from modeless box, toggle layers

message from modeless box, toggle layers
message from modeless box, toggle layers
hi!
i have a dialogbox ( modeless ) in which i can set layers 擮n?or 揙ff?using pretty much the same technique seen
in the odamfcapp application. now i need to refresh the drawing so my hiding/showing activities are taking place in
the main window as well. my initial guess was that i only needed to do a;
code:
afxgetapp()->getmainwnd()->sendmessage(wm_paint, 0, 0);to make a refresh to the main window but it wasn抰 so easy it seems. my question is simply what to do?
i have made a messagebox to see that my database is affected by my changes in the dialogbox and it looks okay:
code:
void odalayerpropmanagerdlg:nclicksubitemlayerslist(int itemindex, int labelindex)
{
oddbobjectid id = (oddbstub*) (unsigned long)m_listlayerslist.getitemdata(itemindex);
oddblayertablerecordptr player = id.safeopenobject(oddb::kforwrite);
m_bclicktocolumnname = false;
switch(labelindex)
{
?
?
?
case column_on:
{
player->setisoff(!player->isoff());

//char* bstate = bstate = player->isoff() ? "off" : "on";
//////////// checks to see that it takes place in the db as well ////////////
cstring mystring = _t("");
char* bstate = "";
oddblayertableptr players = m_pdb->getlayertableid().safeopenobject(oddb::kforwrite);
oddbsymboltableiteratorptr piter = players->newiterator();
for (piter->start(); !piter->done(); piter->step())
{
mystring = player->getname().c_str();
bstate = player->isoff() ? "off" : "on";
}
afxmessagebox( "layer " + mystring + " is " + bstate);
//////////////////////////////////////////////////////////////////////////////////////////
//this isn't good enought!!
afxgetapp ()->getmainwnd()->sendmessage(wm_paint, 0, 0);
//afxgetmainwnd()->sendmessage(wm_paint, 0, 0);
//afxgetmainwnd()->sendmessage(theapp.
}
break;
case blabla:
?
?
?
m_listlayerslist.invalidate();
}i hope above makes sence to you if not please add questions/remarks to the tread and i will try to add needed information to clairify.
best to you all
kennet
message from modeless box, toggle layers
okay! let me rephrase my self a little bit. the issue here is actually a question about
is it enough do an invalidate() the main window since the database has been modified.
or...
do i need to repaint in the sense of digging in the database to get the changes onto the screen
is there a general approach used in cases like this
you need to regen gs model in that case.
see void cdwgviewer:nviewerregen() in ./examples/win/odamfcapp/dwgviewer.cpp
vladimir
message from modeless box, toggle layers
hi! again
yes it seems pretty obvious at first but still i find it difficult. below code is wrong, i'm well aware of that but it gives you a hint on how i would like to do my refresh. it is the odgslayouthelperptr that gives me a hard time. below attempt comes from the fact that i can't get my member variable m_phelpdevice to work in any conventional way it seems. please, give me a hand with this.
code:
void cdxfdocview::layerrefresh()
{
odgsmoduleptr pgs = :: odrxdynamiclinker()->loadmodule("wingdi.gs");
m_phelpdevice = (odgslayouthelperptr)pgs->createdevice();
m_phelpdevice->invalidate();
if(m_phelpdevice->gsmodel())
m_phelpdevice->gsmodel()->invalidate(odgsmodel::kinvalidateall);
postmessage(wm_paint);
quote:
originally posted by kennet
hi! again
yes it seems pretty obvious at first but still i find it difficult. below code is wrong, i'm well aware of that but it gives you a hint on how i would like to do my refresh. it is the odgslayouthelperptr that gives me a hard time. below attempt comes from the fact that i can't get my member variable m_phelpdevice to work in any conventional way it seems. please, give me a hand with this.
code:
void cdxfdocview::layerrefresh()
{
odgsmoduleptr pgs = :: odrxdynamiclinker()->loadmodule("wingdi.gs");
m_phelpdevice = (odgslayouthelperptr)pgs->createdevice();
m_phelpdevice->invalidate();
if(m_phelpdevice->gsmodel())
m_phelpdevice->gsmodel()->invalidate(odgsmodel::kinvalidateall);
postmessage(wm_paint);
}
gs device should be stored with the view, not recreated any time.
vladimir
message from modeless box, toggle layers
hi again!
as i leave the dialogbox and gets back to the main window i go to the below code:
code:
void cdxfview::layerrefresh()
{
m_phelpdevice->invalidate();
if(m_phelpdevice->gsmodel())
m_phelpdevice->gsmodel()->invalidate(odgsmodel::kinvalidateall);
postmessage(wm_paint);
}in the *h file i have
code:
odgslayouthelperptr m_phelpdevice;why have i tryied to kickstart the gs? because when leaving the child and getting back to the main window it seems as if the gs device no longer exists. i抳e been in front of this code for some time now and i have probably missed something obvious it would be typical but what?
/kennet
message from modeless box, toggle layers
okay
i need to rewind a reference counter i guess. maybe i can find some easy-to-understand sample somewhere. i've been looking around but so fare no luck!
/kennet
message from modeless box, toggle layers
hi!
i've tried to get the device from my view
code:
void cdxfdocview::layerrefresh()
{
////////////////////////////////////////////
//restart the device
////////////////////////////////////////////
odgsview* pview = (odgsview*)afxgetapp()->getmainwnd();
odgsdeviceptr pdevice(pview);
odgslayouthelperptr m_phelpdevice = odgslayouthelper::cast(pdevice);
m_phelpdevice->invalidate();
if(m_phelpdevice->gsmodel())
m_phelpdevice->gsmodel()->invalidate(odgsmodel::kinvalidateall);
postmessage(wm_paint);
}i don't know, maybe i'm doing this totaly wrong in some way but what i get from above code is just a close-down of my debug window like the "ctrl + f5". besides that nothing happens at all, no messages of any kind.
/kennet
study odamfcapp sample, it should help.
vladimir
the easy way out
okay!
don't misunderstand me, no offence but what do you think people are doing? i抳e been all over the samples and tried to find answers. sure answers are there, for sure, but it抯 not easy to find anything in them. what i can see from reading the forum i probably have a good number of people agreeing with me on this.
now back to business. i still find it very strange the behaviour i have come across. there should be some sort of error message something that could guide me, but nothing. i just wonder, is there anyone out there who has experienced something like this? if so, maybe you can give me a hint?br />
best to all of you
kennet
what does your onpaint() handler look like?
vladimir
my onpaint()
here it is, not much.
code:
void cdxfdocview:npaint()
{
cview:npaint();
if(!m_pdevice.isnull())
m_pdevice->update();
}/kennet
hi! again
as far as i can tell it seems as if i never reach the onpaint() handler. i get stuck when i do below cast:
code:
odgslayouthelperptr m_phelpdevice = odgslayouthelper::cast(pdevice);
as i understand there must be something fundamently wrong with the way i extract pdevice. to cast the way it抯 been done in above code line have been used all over the place. it抯 a question of getting the device back on track after the smartpoint cleaned out the old device pointer. i must somehow get it from my view, just as you wrote above.
/kennet
your code in post looks correct.
in what way it doesn't work?
where do you create m_phelpdevice associated with the view?
vladimir
message from modeless box, toggle layers
hi! again
the code you refer to in post is probably right and would work perfect as long as i don't leave the window in which it resides.
i think i have this problem because i want to be able to make a refresh of the main window from my child window when clicking on 搕he lamps? hiding/unhiding layers. the layer window is pretty much the same as the one in odamfcapp with the difference that mine is a modeless one.
i have checked that when i hide/unhide layers it really takes place in the database as well. so, my original idea was to just refresh the main windows 搊n the fly?when i click on my lamps in the layer window. this is where the layerrefresh() function finally came into the picture.
the m_phelpdevice in above mentioned post is simply not there and the only reason must be that the smartptr have done its duty and removed all references. that抯 why i thought i had to 搑estart?the gs. now i understand that i must extract the device handle from my view to be able to do my refresh. this is where i get in to the mysterious close-down of my debug window like i was doing a "ctrl + f5". no warnings, no errors appears anywhere.
finally, i抦 prepared to take a new approach on this. maybe i抦 doing this fundamentally wrong somehow. i抦 open for any suggestion as long as i can hide/unhide layers from a modeless window.
if above don抰 make sense please let me know and i抣l add/remove info to clarify.
regards
kennet
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】dwgdirect fails to load correct layers yang686526 DirectDWG 0 2009-05-05 08:32 AM
toggle的点选求教 yang686526 ObjectARX(AutoLISP) 0 2009-04-25 09:03 PM
VC中Combo Box控件使用大全 huangyhg vc编程 2 2009-03-22 10:45 PM
PC-DMIS hot key一览表 pcdims PC-DMIS 3 2008-05-23 09:40 PM


所有的时间均为北京时间。 现在的时间是 03:21 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多