Figured it out. LVIF_STATE should have been LVIF_IMAGE. See, I knew it was elementary...
I have a CListView derived class with an OnDoubleClick() handler in a VC++6.0 project. I need to persist the highlighting of the selected item after the OnDoubleClick() handler has done its thing. I had thought that
GetListCtrl().SetItemState(m_nHighlightIndex,LVIS_SELECTED, LVIF_STATE);
would do the trick (assuming that m_nHighlightIndex holds the index of the selected item), but no combination of that and various attempts to invalidate the client area has worked, in either OnDoubleClick() or OnUpdate(). This seems like such an elementary thing to do, but thus far it baffles me. Any help would be greatly appreciated.
Just so it looks answered (and apologies if this is bad form):
LVIF_STATE should have been LVIF_IMAGE. See, I knew it was elementary...
Related
Discord.py won't ever be updated again, but buttons are still implemented. Thing is, they aren't in the docs. It seems rather intuitive, but for one thing: the constructor for the Button class asks only for a "data" parameter of the type ButtonComponent. Could someone please explain what this is? Is it like slash commands where it is a type encompassing specific dictionaries? Am I being completely misguided in my thinking that I understand Buttons on discord?
Thanks!
well, actually the docs for the master branch of discord.py is there, where you can find buttons and the newly implemented things.
also, you can always look up for some demo examples in github.
I have a program which loads multiple images and each image has an array of polygons which are represented by a custom QGraphicsPolygon item. I load 1 image at a time with its respective polygons into two QGraphicsScene (new QGraphicsScene on each load). The problem I am encountering is that after switching between image a couple times I get the following error:
"RuntimeError: wrapped C/C++ object of type ImagePolygon has been deleted". This implementation used to work well, but I have added a lot of stuff to the program since and now I get the error.
I know that I am never loosing my references to the custom QGraphicsPolygons and the only thing that is getting deleted inside them is the polygon itself. All other membervariables stay intact. Unfortunately I have not been able to pinpoint the exact region of the code where the polygon inside the QGraphicsPolygon gets deleted and the code is too long to post here.
I have also tried to simple set a new QPolygon to the QGraphicsPolygon item each time I add it to the scene, but this gives me the same error.
Please let me know if anybody knows what could be deleting this item. Keep in my I am never loosing reference to the QGraphicsPolygonItem.
I would also appreciate if somebody knew of a good way to debug this. I am sure I could fix the error if I could find it.
Thank you in advance
After a lot of testing I think I found the problem. Since in my implementation I delete the QGraphicsScene everytime I show a new image, I believe this was deleting the polygons as well. I don't know why this was not happening before, but I managed to fix it by first removing all items from the scene. I had to iterate through the items, because using the clear() method in the scene deletes them.
I'm just trying to find a way to access the name property of an Area element inside Revit Python Shell, tried looking on Jeremy Tammik's amazingly informative blog, tried AUGI, Revit API docs, been looking for 2 days now...
Tried accessing via a bunch of ways, FilteredElementsCollector(doc).OfCategory(BuiltInCategory.OST_Areas), tried by Area class, tried through AreaTag, every single time I get an error under every circumstance and it's driving me nuts, it seems like such a simple issue that I can't seem to grasp!
EDIT: Also tried by element id, through tags, through area schemes, nada, no go...
Can anyone please tell me how to access this property via RPS?
I would say two things:
areaObject.LookupParameter("Name")
areaObject.GetParameters("Name")
...are valid methods. Please notice how I used GetParameters() NOT GetParameter(). There are some drawbacks to using either one of the two. The lookup method will return FIRST parameter that matches the name which in many cases might be a different parameter for different elements. It's not very reliable.
GetParameters() method will return them all if there are multiple so then you have to deal with a List<Parameter> rather than a single object that you can extract your value from.
I would personally recommend to use areaObject.get_Parameter(BuiltInParameter.ROOM_NAME) method to extract a Name value from Area object. The BuiltInParameter always points at the same parameter, and will reliably return just that one parameter. Here's a little more details about these methods:
http://www.revitapidocs.com/2018/4400b9f8-3787-0947-5113-2522ff5e5de2.htm
To answer my own question, I actually never thought of looking through the code of other Revit Python scripts... in this case of PyRevit, which is in my opinion far more eloquently written than RPS, raelly looking forward for their console work to be done!
Basically, I had mistakenly used GetParameter('parameter') instead of LookupParameter('parameter').
As I said, it was something stupidly simple that I just didn't understand.
If anyone has sufficient knowledge to coherently clarify this, please do answer!
Many thanks!
Maybe your issue is the same as this one ? :
https://groups.google.com/forum/#!searchin/RevitPythonShell/name|sort:relevance/revitpythonshell/uaxB1FLXG80/sdJNrTfoPuUJ
Your_Area.Name # throws error
Element.Name.GetValue(Your_Area) # works great
I have found a workaround for this, which I will be posting as an answer, but it still raises the question of why it happened in the first place.
When I try to add a new id through the Design GUI, I type the name into the box:
id_sample
As soon as I tab out of the box, it prepends #+id/:
#+id/id_sample
which sounds reasonable enough, because - hey, it's got to put in the instruction to add a new id per the documentation, right?
But when I go into the java code, autocomplete is giving me gibberish on the code side - because of the extra #+id/, autocomplete gives me #+id/id_sample for a grand total of
menu.findItem(R.id.#+id/id_sample);
which has invalid characters; while deleting them:
menu.findItem(R.id.id_sample);
gives the error Cannot resolve symbol 'id_sample' because the xml is insisting that the correct name includes the invalid characters. Catch 22.
So how do I properly reference an id?
Looking in the xml, the #+id/ actually gets added to the #+id/id_sample:
android:id=#+id/#+id/id_sample
which obviously gives the compiler a heart attack. Having figured out what was going on, it is easy (though tedious) enough to jump into the xml and delete the extra #+id/ but I can't see any way to get the designer to put it in right in the first place.
Once this is corrected in the xml, it gets automatically corrected in the GUI, autocomplete will give you the correct name when you go into the java code, and the compiler will recognize it.
All that's left is to wonder if there is something I'm doing wrong that is causing this. Is this a known (or unknown) bug? Knowing what is wrong, it can be fixed in the xml, but it seems the GUI should have gotten it right in the first place. Right?
After I submit the form unsuccessfully, the form looses all the values I typed in.
I'm using value="", so that could be related, but if I remove it I get a / in the field, and it still doesn't remember
any idea what I could be doing wrong?
well for now I've used a javascript to do this, it works well but maybe someone has a php/modx/eform solution.
By unsuccessfully submitting the form do you mean it fails validation checks?
No matter what I do, I can't replicate the behaviour you are seeing.
Okay, so I figured it out. I had all the intention of going in and adding the functionality, when I came across line 573 in eform.inc.php "# get SESSION data - thanks to sottwell"
so it's already doing what I want it to.
anyhow, because I couldn't find this in any documentation here is what I've done. Though I must say faintly recall doing this exact thing before. So the next time I need this I might come across this :)
add a value=[+field+]
<input id="femail" name="email" value="[+email+]" eform="Email Address:email:1" />
just remember that the value needs to match the class and NOT the id(unless you want them the same)