|
aquawicket wrote: Any Ideas?
Remove the dependency on SP2
|
|
|
|
|
SP2 for what?
Dialog windows have been created the same way for many years.
Maybe you're leaving out some information that would make it remotely
possible for us to help?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Well, I'm not exactly sure why the dialogs don't open without SP2. I don't really know where to begin on finding out either. I figure if it's not the dialog itself, then it is something within the dialog. Is their a way I can hunt down what is causing the need for SP2? Could it be the version of MFC i'm linking against? What kinda information can I provide to help out?
Program specs:
--------------
MFC statically linked
Unicode
Not Using ATL
No Common Language Runtime support
No Whole Program Optimization and Optimization disabled
PreProcessor Def's WIN32;_WINDOWS;NDEBUG
Link Library Dependencies = YES
I guess I will just start stripping down the class the dialog is in till it works :P
|
|
|
|
|
I still have no idea what SP2 is. I have an idea but I'd be assuming.
Regardless, why not step into CDialog::Create()....does the actual dialog
creation fail at a Win32 API call? Does MFC assert or fail?
If creation succeeds, try breaking at PreCreateWindow(), WM_INITDIALOG, WM_SIZE, WM_PAINT.
Does execution ever get to any of these? If so, do any of them return an invalid value?
Add a PreTranslateMessage() override to the class....do you ever get any messages?
etc...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark..
I'm working on getting VS2005 installed and running on an SP1 machine and I guess I'll work it from there
|
|
|
|
|
You;'ve been asked several times... SP2 of WHAT? XP? VSxxxx? The kettle next to your PC?
The other trick you can try is to go to the dialogs template, and check the NOFAILCREATE style - then you can find out which control is having trouble. As has been said, dialog creation is not much changed for a decade.
Iain.
|
|
|
|
|
I have aa array of struct in my app, each struct is the size of a byte. My problem is that this array is very large, up to 256mb if the machine can cope with it.
I know each struct is small, but I can half that size. I need 1 bit for a flag and 3 bits for a state. How can I declare the stuct to effectivly have two struct members each of which is 4 bits in size?
struct block
{
BYTE Flag : 1;
BYTE State : 3;
};
This is what I currently have, but it's size is still 1 byte even though only 4 bits are being used.
Waldermort
|
|
|
|
|
How are you packing the structure?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
standard #pragma pack ( push, 1 )
Waldermort
|
|
|
|
|
This seems to work, but accessing the members is a pain
struct block
{
union
{
struct Upper
{
BYTE State : 1;
BYTE Repaint : 3;
};
struct Lower
{
BYTE State : 1;
BYTE Repaint : 3;
};
} U;
}
Waldermort
|
|
|
|
|
Doesn't Upper and Lower use the same bits?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yeah, I just realised, I'm still trying to get it...
Waldermort
|
|
|
|
|
AFAIK, byte granularity is all you're going to get unless
you pack two pairs in each struct:
struct block
{
BYTE State : 1;
BYTE Repaint : 3;
BYTE State2 : 1;
BYTE Repaint2 : 3;
}; Do you have to have a struct type?
Can you wrap the array in a class and provide accessors to packed State/Repaint
bits instead?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think struct is creatin a problem.
try doing it by using union inside a struct.
i think it will work.
tHeStRat
|
|
|
|
|
WalderMort wrote: This is what I currently have, but it's size is still 1 byte even though only 4 bits are being used.
I believe the minimum size of your structure is the size of the base type, in this case BYTE.
|
|
|
|
|
|
Funny you say that, I was just playing around with the bitfields and found my solution. Though I'm not sure of how portable it may be.
struct block
{
union
{
struct Upper
{
BYTE Pack : 4;
BYTE State : 3;
BYTE Repaint : 1;
};
struct Lower
{
BYTE State : 3;
BYTE Repaint : 1;
};
BYTE Total;
} U;
};
Waldermort
|
|
|
|
|
Original struct
<br />
struct aablock<br />
{<br />
BYTE Flag : 1; <br />
BYTE State : 3;<br />
};<br />
Original array of size 512
<br />
MAXSIZE = 512<br />
aablock aa[MAXSIZE];<br />
Modified Struct
<br />
struct bbblock<br />
{<br />
BYTE FlagOdd : 1; <br />
BYTE StateOdd : 3;<br />
BYTE FlagEven : 1; <br />
BYTE StateEven : 3;<br />
};<br />
<br />
try to suffle the elements if size of this struct > sizeof(BYTE)<br />
if you are having an array of size say 512 then you may declare array with half of that size.
Each element will store 2 elements of original struct
<br />
bbblock bb[MAXSIZE/2];<br />
<br />
j = -1;<br />
for(i = 0; i < MAXSIZE/2; ++i)<br />
{<br />
j++
bb[i].FlagEven = aa[j].Flag;<br />
bb[i].StateEven = aa[j].State;<br />
j++;
bb[i].FlagOdd = aa[j].Flag;<br />
bb[i].StateOdd = aa[j].State;<br />
}<br />
|
|
|
|
|
Good Ans....
But i have some confusion.
In That code what is the meaning of This
BYTE Flag : 1;
Line.
How we can use one bit from that Byte?
i got the error on that each line..
Please solve my doubt.
hiren Thakkar
|
|
|
|
|
If you read the other answers, you'll see someone refers to bitfields. That's the important clue - you can look that up in your c++ book, as the full answer is too long for me to bother typing here!
Iain.
|
|
|
|
|
Hi,
We are getting ready to start developing a new windows application interface for our research application. The current version was written in MFC (Dialog box version) where there is a main dialog box which covers the whole screen and then several small dialog boxes are defined in it each one performing certain action and currently everything runs in serialized fashion. With this application we are getting closed loop frequencies of not more than 3Hz. For the next generation application we are intending to improve this atleast to 15Hz by implementing multi threading environment.
Here is how the program flow goes in current application.. you capture an image (at certain exposure settings, the longer the exposure time, the more delay you have in capturing the image) and is shown on one of the dialog boxes (say dailog1), do some analysis on that image and comeup with some data that should be shows in graphical format on the image in dialog1 and then using the same data and doing some more calculations you have to draw some graphics on three more dialog boxes and then compute the resultant data that is to be fed to the system and update another graphical dialog box to reflect the final result. At the end update some parameters(values) on the main dialog box.
Before you capture next image for next iteration, you should be done by sending the new values calculated in previous iteration. Currently, this goes one after the other (including graphic dialog boxes update). As far as I can see, updating these graphic dialog boxes is taking lots of time compared to actual data computation.
I am looking forward for some better ideas on implementing this to higher speeds.
thanks in advance.
|
|
|
|
|
Pavan Berkeley wrote: updating these graphic dialog boxes is taking lots of time compared to actual data computation
Screen drawing on modern PCs should be pretty fast.
Are you sure the bottleneck isn't somewhere else?
What exposure time is typical?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think I am sure... but anyway here are the timings that I measured while running the closed loop..
Camera function started 40:48:961.054
Camera function done 40:49:4.228 >> ~43msec (for capturing the image at 20msec exposure time, subtracting the background)
Calculations done 40:49:17.848 (entire calculations are done by this point ~13msec)
Updated displays 40:49:259.003 (entire displays are updated by this point ~242msec)
one iteration completed
Here are the timings that I recorded from the current application. From the above, we cant get rid of 20msec delay from camera (which sometimes changes to even more, but 20msec is the min). This comes out to be 3.37Hz which is very slow comparatively.
PKNT
|
|
|
|
|
Focusing on the display updates, then, what kind of (and how many) operations
are you doing?
Drawing bitmaps? Graphs? Using GDI? GDI+?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The way its implemented currently is just using SetPixel, so its GDI. This is done for 5 dialog windows (including drawing over camera image) after each iteration of calculation. Among these 5 dilaog boxes, two graphical dialog boxes are being updated in the main dialog box file.
PKNT
|
|
|
|