|
Actually I think you going for Difference Between bool and BOOL.
Let See what MSDN say about bool
"
the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0 and later, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0 and later, the same call yields 1.
"
and BOOL is defined as int in WinDef.h
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
bool is a C++ native type, which is taking 1 byte memory, and that can only take true or false .
BOOL is a type redefined by the VC++ library, like this :
<font color=#0000FF>typedef enum </font> {
FALSE = 0,
TRUE
} BOOL;
this last case equals in memory to an int, so, weights 4 bytes...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
int, so, weights 4 bytes
Isn't this value dependant of the OS and the hardware?
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
of course, but unless you use an atari....... i consider we can think about 4 bytes integers here
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I know, I'm "cutting hair in 4 pieces" ( ) but with the new 64bits CPU and OS, there will be some nice surprises with softwares which made the assumption int variables have a size of 32 bits.
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
On this topic, I have to add this bit;
Some developers prefer to use the following syntax;
bool bFlagIsSet = false;
if (bFlagIsSet == true)
// do something
else
// do something else
instead of;
bool bFlagIsSet = false;
if (bFlagIsSet)
// do something
else
// do something else
fair enough - each to their own. But doing this with the BOOL type, since TRUE is defined as -1, could cause unexpected behaviour;
BOOL Func()
{
return 1; // return true
}
BOOL bFlagFromFunctionThatReturnsBOOL = Func();
if (bFlagIsSet == TRUE)
// this won't happen, but is expected to
else
// stuff
So, the easy rule to remember there is, always check against FALSE, since it's value is always 0, like so;
BOOL Func()
{
return 1; // return true
}
BOOL bFlagFromFunctionThatReturnsBOOL = Func();
if (bFlagIsSet != FALSE)
// this will now work properly
else
// stuff
That's my 2p
(and maybe not related at all)
Martin
|
|
|
|
|
hi,anyone here,i want Powerpoint's presentations to be displayed in my program's window,and can control its "Slides" ,"Scale" ,"Display Position" and so on...i think the OLE can resolve that,but i don't know how to do.If you have a good idea please reply at here ,or mailto: sdcgc@yahoo.com
thanks in advance!
|
|
|
|
|
I've tried to do that before. Basically, you can't. You can't tell PowerPoing where to show its presentation, and if you try to change the parent/owner of the PowerPoint slide show window, PowerPoint exits (it doesn't crash, but immediately exits). You can change the position of the window to make it appear that it's in your window, but you also need to do some pretty horrible hook work to allow your application to capture the mouse events.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
There is a way to fake it. Interested in hearing it ?
|
|
|
|
|
Use the Web Browser control and tell it to navigate to the document you want to open. When the navigation completes you get the iDisp and you can control everything you want.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
thanks for your advices
How to fake it? please give more details,thanks:->
Now i use OLE container application which can open the PPT file,but only the first page was displayed.What methods can be used to let it slide on?please help me
|
|
|
|
|
On Windows XP sp1, I use these three Directshow filters: DV Video Encoder, Stream Buffer Sink and Stream Buffer Source to implement the timeshifting function, and it works well, But on the Windows XP sp2, it has serious delays. I don’t know why and how to solve the problem ,Please give me some advice .Thanks
|
|
|
|
|
|
I'm writing a class to read in a bitmap file, background information for your consumption. I'm trying to implement this but I get the errors:
...\489gui\bitmapFile.h(45): warning C4200: nonstandard extension used : zero-sized array in struct/union
...\489gui\bitmapFile.h(46): error C2229: class 'bitmapFile' has an illegal zero-sized array
...\489gui\bitmapFile.h(46): warning C4200: nonstandard extension used : zero-sized array in struct/union
Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
...\489gui\bitmapFile.h(48): error C2229: class 'bitmapFile' has an illegal zero-sized array
...\489gui\bitmapFile.h(45): warning C4200: nonstandard extension used : zero-sized array in struct/union
...\489gui\bitmapFile.h(46): error C2229: class 'bitmapFile' has an illegal zero-sized array
...\489gui\bitmapFile.h(46): warning C4200: nonstandard extension used : zero-sized array in struct/union
Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
...\489gui\bitmapFile.h(48): error C2229: class 'bitmapFile' has an illegal zero-sized array
Here is the code it's referring to...
(45) RGBQuad aColors[];<br />
(46) BYTE aBitmapBits[];<br />
(47)<br />
(48) bool endOfBitmap;<br />
I know what it says but I can't define the array sizes at compile time because they will change depending on information in the header. What can I do to get this working? Thanks in advance.
|
|
|
|
|
try to use pointer the and assign memory at runtime.
|
|
|
|
|
LighthouseJ wrote:
RGBQuad aColors[];
You can't do that in C, this syntax isn't allowed. You should use a dynamically allocated array.
Define a pointer to point your future array:
RGBQuad *pMyArray;
Allocate it when you know the size:
<br />
pMyArray = (RGBQuad *)calloc(iSize, sizeof(RGBQuad));<br />
Reallocate it if needed
<br />
pMyArray = (RGBQuad *)realloc(iNewSize, sizeof(RGBQuad));<br />
Free the array when you don't need it anymore
<br />
free(pMyArray);<br />
You should have a look in MSDN or other sources for the different functions I mention, and perhaps take time to study memory managment with C.
HTH,
K.
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
I see what you mean and it makes sense but that seems to only allocate one element instead of more than one. The calloc line looks like:
bmpPallette = (RGBQuad *)calloc(palletteCount, sizeof(RGBQuad));
palletteCount is 0x100 (256) which is what it should be. It looks like it's simply allocating a new RGBQuad instead of an array of 256 RGBQuad's which is what it should do when I look at the calloc command.
|
|
|
|
|
From MSDN[^]:
"The calloc function allocates storage space for an array of num elements, each of length size bytes. Each element is initialized to 0."
calloc(num, size) is similar to malloc(num * size)
LighthouseJ wrote:
It looks like it's simply allocating a new RGBQuad instead of an array of 256 RGBQuad's
How can you say that?
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
Because Visual Studio identifies it when I go to write code as a simple pointer to a single RGBQuad's instead of a pointer to 256 RGBQuad's. Maybe it's actually working but I don't know how to address it properly because I've never used a pointer to an array. I have that calloc page in my Visual Studio helpfile already and it made sense of what calloc does.
|
|
|
|
|
Don't worry, it's working.
bmpPallette is a pointer (IMHO, it would be a good idea to have something in its name to identify it as a pointer, as pBmpPallette). A pointer is just an address, right? calloc will return the address of the first element of the array it allocates. bmpPalette points then on the first element of the array. Once the array allocated, you may access the different elements using bmpPallette[0], bmpPallette[1],...,bmpPallette[size-1].
For example:
bmpPallette[0].rgbRed = 255;
bmpPallette[0].rgbGreen = 0;
bmpPallette[0].rgbBlue = 128;
Disclaimer: In C, you have to take care of everything when it is about memory managment. I only mention there some of the basics. You really should have a look to a good tutorial, as http://www.le.ac.uk/cc/tutorials/c/ccccpont.html#PA[^]
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
Thanks Budric, Blake, David, and Micheal! for helping me. I have another problem. Is there any option in "Microsoft Visual C++" compiler to create an "installation packege" of my project i.e. to install project on a pc? if not then please tell me how can i do this?
We Believe in Excellence
|
|
|
|
|
I would suggest Inno Setup which is a very good tool and furthermore it's free. You can download it from this website http://www.jrsoftware.org/isinfo.php[^]
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it. - Spacecast
|
|
|
|
|
Thank you friend...
We Believe in Excellence
|
|
|
|
|
Read my story, I desparately need advice.
Spent the last 8 hours extracting a nasty release build problem from a huge app to a standalone project, reproducing the problem in ca. 40 lines of code (Whew!)
Despite all my trust in Compiler and knowledge of C++ language pitfalls, and with all my debugging assembly experience I would say semi-proudly it is a bug in the optimizer.
The problem
- occurs only in Release Builds
- occurs with various optimization settings (including the release-default)
- with SP5 or SP6 installed
- on 3 different Developer PC's
- exposes an identical pattern of register misuse in all the iterations I took in isolating it
- does NOT occur when no SP is installed (don't have other SP's avail)
- does NOT occur on Standard edition (where no optimizer is included), independent of Service Pack
- it is straightforward code (no templates, but a few classes ond some basic COM stuff
is involved)
I have an workaround for the one place I isolated, but we have multiple problems with identical occurence pattern. They all revolve around a central data class.
Going back? They all surfaced not to long ago, but (a) I cannot safely determine the point of breakage, and (b) to many "pressing changes" have been included since. (Yes, we delayed finding these. Shame on us.)
The repro code still relies on _com_ptr_t, and some (arbitrary) COM object. With all my C++ power I cannot see anything wrong with the code.
options I see:
- disabling optimizations (YUCK. SLOW is not an option)
- going back to no service pack (I Don't want to)
- MS Support indident (I will do, but I don't expect much as this is VC6)
Any experiences with that?
- Disabling optimizations while moving to VC7.1 (messy, no time, wanted to wait for VC 2005)
Thank you for listening. Wish me Luck.
I never really know a killer from a savior boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Are you able to post those 40 lines of code that cause the problem. Perhaps another set of eyes can find something you missed (unlikely I know, but possible).
Man, you really confused me when I replied and found your post had disappeared
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|