2021-06-28
07:31 AM
- last edited on
2021-09-14
12:31 AM
by
Noemi Balogh
Solved! Go to Solution.
2021-06-28 10:56 PM
/* [ 1] */ UserItem 100 100 50 50 ClientEdge
myUserItem (GetReference (), MyUserItemID)
void MyDialog::UserItemUpdate (const DG::UserItemUpdateEvent& ev) { NewDisplay::UserItemUpdateNativeContext context (ev); // ... context.DrawImage (image, width, height, 0.0f, 0.0f, 0.0f, false); // ... }
2021-06-28 09:50 AM
2021-06-28 02:39 PM
2021-06-28 10:56 PM
/* [ 1] */ UserItem 100 100 50 50 ClientEdge
myUserItem (GetReference (), MyUserItemID)
void MyDialog::UserItemUpdate (const DG::UserItemUpdateEvent& ev) { NewDisplay::UserItemUpdateNativeContext context (ev); // ... context.DrawImage (image, width, height, 0.0f, 0.0f, 0.0f, false); // ... }
2021-06-29 12:19 AM
2021-06-29 12:57 AM
Viktor wrote:If someone arrives to this post and does not know where the UserItemUpdateNativeContext is located it is here: AC_DEV_KIT_PATH\Support\Modules\DGGraphix
Unfortunately there is no easy example among the example add-ons, but here are the basics.
void MyDialog::UserItemUpdate (const DG::UserItemUpdateEvent& ev) { NewDisplay::UserItemUpdateNativeContext context (ev); // ... context.DrawImage (image, width, height, 0.0f, 0.0f, 0.0f, false); // ... }
2021-06-29 02:19 AM
Mihalcea wrote:Hi Michalcea,
I was thinking about buying the Developer Support for a year. Where can I find some information about the services included in this subscription from GRAPHISOFT?
2021-06-29 04:16 AM
2021-06-29 08:16 AM
Viktor wrote:This code works only inside the "UserItemUpdate" function when the UserItem updates. I am having a real hard time figuring out how to pass this context to a function like
void MyDialog::UserItemUpdate (const DG::UserItemUpdateEvent& ev) { NewDisplay::UserItemUpdateNativeContext context (ev); // ... context.DrawImage (image, width, height, 0.0f, 0.0f, 0.0f, false); // ... }
virtual void UserItemClicked(const DGUserItemClickEvent &ev) { //draw something when user clicks } virtual void SpecDragStarting(const ItemDragSourceEvent &ev) { //do something when user starts dragging like fetch an image from Google Earth based on the new coordinates }I tried to reference it, but obviously I get Memory Access Exception.
2021-06-29 09:49 PM
2021-06-29 10:55 PM
Viktor wrote:I did observe this behaviour, I thought that this kind of approach is wrong(I have some JavaScript webgl background where the context is a variable accessible by any function). Thank you again!
It's a general rule for all applications that they should draw only when the operating system requests them to do so. In your case it means that you can draw only in the UserItemUpdate function, so the context can't be reused. Fortunately, you can request the operating system to redraw. Call the userItem.Redraw (true, true) function which will force the call of UserItemUpdate.