|
We recently upgraded to VC.NET 2003, and have noticed some alignment problems with some of our structures that we serialize to disk. I checked my old settings in VC6, and noticed that all the products have the "Struct Byte Alignment" set to 8 bytes. I wrote code that would check the sizes of all our serialized structs, and all the sizes were calculated correctly.
I then went over to VC7 and checked the project settings, he was also setup to 8 byte alignment. I ran the same size check code, and quite a few of the sizes are not the same as in VC6, which is causing us all kinds of headaches.
I've tried changing the alignments, and our structures are still off in VC7, even though the settings are the same. Has anyone else had this problem? Any tips/tricks? ... What kinds of things do you do when setting up a struct? Which items in the struct have to be on 4/8 byte boundaries etc?
Anything you can send would be appreciated.
Thx.
Mike.
doner@obtain.com
|
|
|
|
|
Are you using #pragma pack() , or the /Zp compiler option?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Dave,
Thanks for your reply.
Currently, we're using the /Zp option, but I've been spending a lot of time in the help files reading more about the #pragma pack() option. I have a list of structs that are giving us hassles here, I'm going to go through and wrap them with the #pragma pack ( push, 1), and see if that does the trick.
I just found it strange that our project in VC6 was aligned at 8 bytes, worked great. I upgraded the project to VC7-2003, it says it was aligned at 8 bytes, but gave me all kinds of errors when running.
Generally, whats safe practice here? What kind of rules should I follow?
Thanks.
Mike.
|
|
|
|
|
Mike Doner wrote:
...it says it was aligned at 8 bytes...
What are you using to verify this?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I checked the project settings, they both had the same settings, both had 8 selected.
What are the drawbacks of putting my structures to 1 byte packing?
Mike.
|
|
|
|
|
You should actually be checking the file itself to see how it is aligning! That will be a sure-fire way to tell if the /Zp option and the #pragma pack() directive are working as expected.
Mike Doner wrote:
What are the drawbacks of putting my structures to 1 byte packing?
As I don't normally pack structures, I don't know of any, which is not to say that none exist.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I have the following components
Component A : a com Server as an exe
Component B : an active X that uses Component A and uses MSXML4 API(Component C)
Component C : msxml4 msi file
I need to package all of this using Installshield .
My problem is that I need the msi file to run automatically during the installation .
|
|
|
|
|
Hello,
I use the class CDialogBar for a simple application with one window and some buttons, sliders and edits on there. I can´t use a normal dialog because I want to display many images within the window and have to handle messages within the same window. To display the images and manipulate them I use operators from a halcon-library, but that´s not the problem. I have placed the buttons and slider and so on in the resource-editor and I enable them in an object of the class CMainFrame with the following code (for example):
Cedit* m_pEdit=(CEdit*)m_wndMainDlg.GetDlgItem(IDC_EDIT1);
m_pEdit->EnableWindow(TRUE);
This is doing right for the statics,the edits and the sliders but why the hell can´t I enable the push-buttons? And no error-message is returned! Please tell me how I can enable push-Buttons in a CDialogBar. And maybe you also can tell me how I can set a sliders position when inputing a value in an edit-box. How do I have to cast the string into int for the slider?
Many thanks!
|
|
|
|
|
This is overridden by the behaviour of the CDialogBar within the cframewnd. Notice that it is disbled when there is no handler, and enabled when there is? This mechanism is overriding your commands. You must instead handle the OnUpdateYourFunction and set it up in the cmdui.
|
|
|
|
|
I am trying to print the text from a CRicheditCtrl with a transparent background.
I have tried to use CDC::SetBkMode(TRANSPARENT) before I attach the printer DC to the FORMATRANGE structure (FormatRange, DisplayBand), but that seems to have no effect.
Has anyone an idea how to print the RTF text with transparent BK?
Thanks in advance.
|
|
|
|
|
Hello,
could someone please tell me which file i have to include to use the class CSlider for creating the activeX-Control MS Slider Version 6.0? I can´t find the class CSlider in the headers of the folder "include".
Thank you for your help!
|
|
|
|
|
The CSliderCtrl class is included in the afxcmn.h file.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
You haven´t understood my question. I don´t look for the class CSliderCtrl but for the class CSlider which is the base for the activeX-Control MS Slider Version 6.0 which you can integrate in Visual C++ by calling new controls from the COM-Interface.
...And about the birds: To decide to fly off is one step before doing it, so they still sit there on the fence with the other birds.
|
|
|
|
|
Indeed I assumed you meant CSliderCtrl. Oops. However, a quick test reveals that when you insert the Microsoft Slider Control control into a project (using Components and Controls Gallery), the files Slider.h and Slider.cpp are created and added to the project. There's nothing more to do, other than adding the control itself from the Controls dialog onto your dialog template.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Dear All,
I am developing an application using MFC VC++ Version 6.0 for Windows 2000.
I need to execute a routine in my application once the windows programs are just loaded.
(I mean to say that once the windows is rebooted or logged in is completed.)
Can anybody please tell any such event or any alternative way out to get such notification.
I hope my question is clear.
Thanks,
Rohit
|
|
|
|
|
There are several solutions. One solution is to simple add the program's path in the register under "Run." Another solution is to design the application as a service.
Kuphryn
|
|
|
|
|
I am sorry if this issue has already been raised but I was not able to find the way to find it.
I am trying to make a small game (Non DirectX) in which there is a lot of motion and hence re-drawing on the client area. Clearing and redrawing is creating a lot of flicker. I have already set WM_ERASEBKGRND to not redraw but still cannot get the motion to be as smooth as Pinball or Solitaire(when you move cards around).
How can I program to have flicker free redrawing motion.
|
|
|
|
|
If you are worried about repeating questions, why not search for "flicker" in the handy search box, first?
|
|
|
|
|
Hi,
What about drawing the image in an area of memory off screen and then copy it across onto the screen using BitBlt? I've done this before and works really well because the BitBlt function is very fast so you don't see the flicker.
I looked through my code but I haven't got a nice simple example, however its basically like this:-
CDC memDC;<br />
memDC.CreateCompatibleDC(pDC);<br />
<br />
CBitmap memBitmap;<br />
memBitmap.CreateCompatibleBitmap(pDC, nWidth, nHeight);<br />
<br />
memDC.SelectObject(&memBitmap);<br />
<br />
<br />
pDC->BitBlt(<br />
nLeft,<br />
nTop,<br />
nRight,<br />
nBottom,<br />
&memDC,<br />
0,<br />
0,<br />
SRCCOPY);
Hope that is some help, cheers
Ali
|
|
|
|
|
hi,
how to create crystal report control in runtime.
thanks in advance.
|
|
|
|
|
Dear Friends,
I have an RGB value. I want to convert it into long how ca i do so ?? Is there any macro or function available ???
|
|
|
|
|
Rather brutal way:
long lColor = *(long*)(&rgb); That's if you want to stuff it into an arbitrary variable.
If it needs to be a particular format for serialization, or working with Device Independent Bitmaps in memory (for example), copy the bytes.
|
|
|
|
|
RGB rgbGreen = RGB(0, 255, 0);<br />
long lColor = (long) rgbGreen;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Are you sure you don't want unsigned long? Why would you need a signed integer to store RGB information?
|
|
|
|
|
I think there's good chance that an RGB value is larger than the range that a signed long could handle.
|
|
|
|