I have one list control and 3 buttons on that which I have created manually Hard-coded , not created on any dialog. I am facing big problem in setting the position of that List Control and 3 buttons. Please let me know if anyone have any suggestions about this. Any help will be appreciated. Regards, Mbatra. Unfortunately the only answer is to create your own layout manager, that checks the dimensions and DPI of the screen on start up, and adjusts each control to fit.
Displaying Image from stream Sachin k Rajput Feb Sachin k Rajput. I'm trying to display an image from a stream data. But there is no image when getting image::from stream. DrawImage image, 0 , 0 , rect. Can anyone help me in this? I am not sure I like the whole thing, but it is kind of an interesting approach - if it works. You do not show how you acquire the data that is stored in chIncomingDataBuffer. Are you sure this buffer contains an entire image? I don't know if it is going to work, but right after you write the data to your pstream , its internal position will be pointing to the end of the data you just wrote.
Try calling Seek in order to change it to point to the start of the data. I checked for an image of a particular data bytes then read it and wrote the code like this..
But on stream, its showing some data in stream but not loading any image. Let me know what happens when you call Seek on pstream after writing the data. I added code for Seek method but problem is same. But there is nothing. Wait a second. I see that you changed the code. Yes i also get this. But If I'm removing this then pstream is having some value. It seems this is not an easy fix, so let me ask you a couple of things.
I'm using Image and Graphics it for ease. Good, I figured it was something like this - there are so many classes and tools that need to load the images from file in order to display them, but you have to search hard to find some that will let you load an image already in memory.
I know it is old and there might be newer stuff out there, but I have used the class to perform similar tasks. I have a project where I am using a button class derived from this class and it makes it possible to display just about any image on the buttons. It has been so long since I looked at the code, that I did not remember it uses a similar approach as you did with the IStream object, so I am sorry I brought that into question.
The whole soltion is shared between us via rational clearcase so we have the same sources and the same project files. Note that you'll have to include the full decorated names to use this flag you can use dumpbin to find these names.
Usually lack of reply is probably because the VC communities doesn't familiar with such problem even when some of them have over 5 years of programming experience, this case, a better choice is try to navigate the forum or newsgroup directory to find a more appropriate place and hopefully you can get more quick and valuable responses when your question reside in right place. If you cannot find a more appropriate place or still believe this forum is the best fit for your questions, please feel free to mark the thread as not resolved and we will look into it again.
Unfortunately, since they would just be CPU reorderings and not reorderings of the instructions themselves, it's physically impossible to force such reorderings to occur or reproduce the similar behavior on a second run of the same test, and so I would likely only be able to witness improper results if I were to personally run rigorous tests on various multicore processors on Windows, and even then I'd have to get lucky enough unlucky enough to have the results of one operation issued earlier appear after the result of another operation issued later.
I do not currently have that luxury and I'd rather not have to wait until users get odd results on Windows considering that from the instructions generated, it looks very clear to me that there are absolutely no guarantees for ordering in place despite what the documentation claims. While they may be rarely apparent when running code, these reorderings are perfectly fine for the CPU to do, and unless I am horribly mistaken, are exactly why instructions such as sfence, lfence, and mfence exist in the first place!
Microsoft seems to somewhat understand the concepts of ordering since they acknowledge that barriers can be expensive, and so they supposedly provide versions with only read barriers acquire semantics and write barriers release semantics in addition to their supposedly fully ordered versions. I don't have access to a Vista machine so I can't check the instructions generated from the Acquire and Release versions Vista only according to documentation, which doesn't make any sense to me since these low-level instrinsics are just a few lines of inlined x86 instructions , but I am really curious as to how they would be implemented if Microsoft believes that a lack of any fences already implies fully ordered semantics with atomic instructions.
If that actually were the case, then it wouldn't be possible to implement strictly acquire and release versions. Does the implementation for the Acquire and Release forms of the instrinsics correctly insert sfence and lfence instructions respectively The acquire and release semantics which are supposedly present in VC8 for volatile variable access do not output any of these fences, so I wouldn't be surprised if the same went for the interlocked intrinsics.
If on Vista the Acquire and Release forms of the intrinsics actually do put in fences, doesn't that seem rather odd that the acquire and release forms have more ordering instructions than the supposedly fully ordered versions In actuality, it looks to me that, at least on VC8 on XP in debug, with no SSE generation, SSE generation, and SSE2 generation applied, the fully ordered forms of these intrinsics are actually totally unordered. For the RMW instructions, proper acquire semantics would imply an lfence after the atomic operation, proper release semantics would imply an sfence before the operation, and strict ordering would imply both an sfence prior to the instruction and an lfence after the instruction.
The important line to take note of is " In other environments, you will need to use memory fence instructions sfence, lfence, and mfence to prevent hardware re-ordering. What does Microsoft think acquire and release semantics mean Are they just interpretting these as being compiler-only reordering requirements If so, they have a horrible misunderstanding of atomic operations and ordering semantics.
It seems to me that the proper output would be a compiler error on attempt to use any ordering semantics without at least SSE generation enabled, a compiler error for store and fully ordered semantics with only SSE generation enabled using sfence prior to "write" operations when release semantics are specified , and finally, release and fully ordered semantics allowable with SSE2 generation enabled using lfence after "read" operations for acquire semantics and using sfence and lfence around RMW operations for fully ordered semantics.
Similarly, this would have to be reflected in the functionality of volatile qualification as well. I have figured it out by following your suggestion. Thank you for your reply! I've done like you suggested. There are also various commercial tools available like the Coverity static code analyzer and Fortify security analyzer that are extremely powerful but also extremely expensive. If you're interested in this sort of thing at a more technical level, Secure Programming with Static Analysis provides a general overview, although much of the book is devoted to general secure-programming issues rather than the juicy details of how a static analyser works.
Luckily though there's a backdoor method of getting it that works with all versions down to the free Express edition, and at least as of late looks like it'll continue to be supported in the future. If you download the latest Windows SDK which is currently the Windows SDK Update for Windows Vista , but use whatever version is current at the time you read this , you can get the latest version of the development tools to go with your existing Visual Studio setup.
Download the installer for the SDK and run it. You'll be given a long list of things to be installed totaling what seems like about half a terabyte of data. The total download size should now be about 50MB, or about MB less if you don't care about the x stuff note that if you're using the free Express edition you definitely don't want to bother getting the x stuff since it won't work with that.
Go through the install and then fire up Visual Studio. Finally, add the library files in the same location. These should be the first entries in each list, before all of the existing entries.
There's an immediate temptation to use the Big Bang approach and build everything in analysis mode to see what happens. If you try this you'll get about, oh, eight million warnings, and probably decide that it's not worth the trouble. This is not a good way to get started. Instead, you're better off building your code file by file, annotating each one as you go. Open the first file and then in turn open the headers that it uses not the system headers, Microsoft has already annotated those for you.
Annotate your header files and the source file and then build just that one file. Fix any problems if possible , or add the necessary annotations to guide PREfast if the problem is genuinely a false positive more on those further on. Then do the same for the next file, until you've completed the entire project.
Unless you're an exceptionally talented programmer who's managed to write near-perfect code, this is not going to be a small task. For any reasonable- sized project plan to spend at least a couple of weeks going through all of your code adding the necessary annotations and making code changes.
On the other hand the level of checking that you're getting by doing this will definitely pay off in the long term. Once we get down to the specifics of using SAL things get a bit complicated since the documentation is rather confusing.
If you look at the documentation for VS you'll see that it actually talks about the low-level attribute notation used internally or at least in very low-level headers by the compiler, and not what you'd be using to annotate your code. There's also an overview page in MSDN that doesn't use the attribute notation, but what's there doesn't correspond to what's in the SAL header file from the SDK or in the previous two linked articles.
There is however an older version of the page available that does correspond to the header and the other articles. If you look inside sal. The resulting mass of annotations can be rather intimidating. Rather than trying to use SAL directly, I've found that it's easier to identify common code patterns and then create a subset of the SAL annotations that work for you, which I'll cover in the next section. This both helps manage the complexity and means that you can retarget your annotations for whatever format might be used in future versions of Visual Studio.
The first step in setting up a SAL workflow is to identify common patterns in your code that correspond to SAL annotations. An example of this is memcpy , which might be annotated as:. Since this is the same as the number of input bytes, the final annotation is:. Using these annotations, PREfast can now check that the dest buffer is large enough to contain what's in src. There are some other annotations that you can add as well, but some of the more obvious ones are automatic if you're reasonably careful with your function declarations.
Windows contains many instances of this pattern, an example being ReadFile , which might be annotated as:. All in all there's a huge number of annotation combinations that are possible. You can get an idea of what's available in the MSDN summary.
0コメント