|
Hmmm, I must have been brain dead when I posted my earlier reply. You can rewind the file during serialization.
void CMeteoGraficaDoc::Serialize(CArchive& ar)
{
CDocument::Serialize(ar);
if (ar.IsStoring()) {
ar<<datosF.dia<<datosF.mes;
}
else {
ar >> datosF.dia>>datosF.mes;
if (datosF.dia != some_value) {
CFile* pFile = ar.GetFile();
ASSERT (pFile != NULL);
pFile->SeekToBegin();
ar >> datosF.dia>>datosF.mes;
}
}
} /ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ok, thank you so much
I´ll try it.
|
|
|
|
|
I get it working, but I´ve had to add:
CFile* pFile = ar.GetFile();
ASSERT (pFile != NULL);
pFile->SeekToBegin(); // rewind
ar >> datosF.dia>>datosF.mes; // retry
CArchive ar(pFile, CArchive::load); //this one added
Thank you, so much.
|
|
|
|
|
Hi, Can anyone tell me how I can move an image into DIB? I hard coded my program to display images onto the screen correctly with 32bit/pixel, and now the program doesn't work when the screen is set to another color bit depth.
Chris Becke's GDI tutorial was very helpful and led me to the GetDIBits and SetDIBits functions. I am planning to use GetDIBits(HDC, HBITMAP...) for converting my image to DIB, but I don't know what I should put in for HDC. The only context I can think of is my screenDC, but I doubt it is looking for my screenDC, rather, it's looking for the DC I originate my bitmap from... Is this correct? If so, then how can I create a DC for my image? My image is a string of BYTES with xBGRxBGRxBGRxBGR... where x is an unused byte.
Thanks in advance for the help!
|
|
|
|
|
try:
HBITMAP hDib = (HBITMAP)::CopyImage(bmp, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG | LR_CREATEDIBSECTION);
'bmp' can be a DIB, DDB or CBitmap, the returned 'hDib' will be a DIB.
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
Great! Thanks for the CopyImage tip. I'll give it a try. One more question, how does CopyImage know the bit depth of 'bmp'? Is there a flag in there where I set?
This is how I am creating my bitmap:
<br />
CClientDC screenDC(pView);<br />
<br />
bitmapBefore.CreateCompatibleBitmap(&screenDC, sizeBefore.cx, sizeBefore.cy);<br />
bitmapBefore.SetBitmapBits(sizeBefore.cy*sizeBefore.cx*4, imageBuffer);<br />
where imageBuffer is my Byte string with xBGRxBGRxBGR...
Right now image only displays properly for 32bit/pixel displaying modes, and that's because I'm grabing DC from screen. Since the screen and my image are both 32bit/pixel, the image displays correctly. How do I make the bitmap have the information of 32bit/pixel when my screen DC is not? I have to replace CreateCompatibilityBitmap with something else don't I?
Thanks again!
|
|
|
|
|
Ok, if I understand you correctly, what you have is the dimensions of a bitmap (width and height), and an array of BYTEs specifying the data bits for a 32 bit bitmap, but you do not have the bitmap itself.
You can create the bitmap using the CreateDIBitmap() or CreateDIBSection() functions. The HDC used just has to a HDC compatible with the screen.
HDC DC = ::CreateCompatibleDC(NULL);
BITMAPINFO bmi;
::ZeroMemory(&bmi, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitcount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = width * height * 4;
void *dummy;
HBITMAP hDIB = ::CreateDIBSection(DC, &bmi, DIB_RGB_COLORS, &dummy, NULL, 0);
::SetDIBits(DC, hDIB, 0, height, Pointer_to_Data_Bits_Array, &bmi, DIB_RGB_COLORS);
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
Thank you so much PJ for the code. It worked like a charm. I'm able to display images in different bit depths now
|
|
|
|
|
Hi all,
I recently wrote some code for a company to import contacts into Outlook from an access database. This cannot be done via Import.
My problem is that with the VBA code running at a stupidly slow speed through a macro I decided to use Visual C++ and automate Outlook. It runs much better but I have one problem, how do I add extra user properties to an outlook contact?
The code in VBA is:
Set Prop = c.UserProperties.Add("Yours", olText)
How do you do it in C++ though?
Any help appreciated.
Cheers,
James.
|
|
|
|
|
Anyone know hot to check a machine to see if IIS is installed programatically? A CD we're putting together for a customer has several installs on it and so they've requested it have a little pop-up (autorun) with buttons for installing each. Sure, no problem. However, I'd like it to do some of the checking for me as well and recommend things they need to install that I can't package with the CD (like IIS). So, I want to try and determine whether IIS is already installed... Same question for PWS?
Thanks in advance.
|
|
|
|
|
Hello, the codegurus around the world.;)
This job is related to your problem solving skill.
Maybe, we find the answer in MSDN knowledge base soultion.
Otherwise, you may find the answer by yourself.
I guess that IIS and PWS are the system level of application, and
we can't change the installed directory.
Even though we can change the installed directory, we can find the
customized installed directroy in the registry.
So, as far as I am, I try to check the exe file or DLL version of
each IIS or PWS.
But, this is another problem. When I upgrade from NT worksation with PWS to Windows 2000,
I found that PWS and IIS coexists. Ooops.
In this case,
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
Hi all, I want to round a float/double number (to an integer)so that when its less than number.5 it is rounded down and when its greater than or equal to number.5 round up. At the moment I have discovered ceil and floor, but these are no good, as it is an either or solution. VB has a dedicated round function, is there one in VC++?
cheers all
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Why don't you use sprintf? Here's two functions. One returns an int (after rounding), and the other returns a double after rounding to the nPrecision'th decimal point.
int _rounder(double n)
{
char st[16];
sprintf(st, "%.0lf", n);
return atoi(st);
}
double _rounder(double n, int nPrecision)
{
char st[16];
sprintf(st, "%.*lf", nPrecision, n);
return atof(st);
}
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
As far as I know, there's no "round" function, but here's a modified version of the one I use:
#include < math.h >
double round(double dValue, unsigned uDecimalPlaces)
{
dValue *= dValue;
dValue += 0.5;
dValue = floor(dValue);
return (dValue / pow(10.0, uDecimalPlaces));
}
Regards,
Alvaro
|
|
|
|
|
Thanks for the responses guys! You solved my problem! All I needed to do was add 0.5 on and then floor it because that would, in effect round it exactly how I want it.
Many, many thanks
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Hi, everybody, i need some help for writing an operator=
:::::::::::::::::::::::::::::::
class aa
{
public:
int var;
virtual aa& operator=(const aa && c ) throw();
};
:::::::::::::::::::::::::::::::
class bb : public aa {
public:
int varbb;
bb& operator=(const bb && c )
{
varbb=c.varbb;
return *this;
};
};
int main()
{
aa * xx = new bb();
aa * yy = new bb();
*xx=*yy;
};
Problem:
Ok, so when i execute this code "*xx=*yy" the aa operator= was called, but i want to use the bb operator=.
How can i do that?
Ho, sorry for my english.
|
|
|
|
|
In that case you must declare the operator in class bb the same way than
in class aa. Did you notice that they are not compatible?
They both must be virtual. (In fact, that's the first time I saw someone
using virtual operator but hey, it's good to know. Thanks).
|
|
|
|
|
Since the bb operator is not declared exactly as the aa operator, they're not treated polymorphically. In other words, they appear as two different functions and the compiler uses the one that most closely matches.
Regards,
Alvaro
|
|
|
|
|
Ok , thank's a lot
But do you know the solution for my problem.
|
|
|
|
|
The solution is to add another assignment operator inside bb that looks exactly like the one in aa. Then you can call bb operator from there by casting the parameter to bb&:
virtual aa& operator=(const aa& c) throw()
{
return operator=((bb&)c);
}
Regards,
Alvaro
|
|
|
|
|
* reinterpret_cast<bb *>(xx) = * reinterpret_cast<bb *>(yy);
Bomb our homes and threaten our children, and, as difficult as it is, we will still love you --- Martin Luther King, Jr.
|
|
|
|
|
Thank's, but sometimes i don't know the real type of xx and yy, and i dont want to know.
I don't write this code with a switch.
Other idea ?
|
|
|
|
|
Can operators even be virtual? You certainly can't make = virtual, because = always operates on a object, not a pointer to an object, as is required for polymorphism.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Hello experts,
Well,I have a VC++ 6.0 developed application, supporting MBCS, which is the default for VC++ 6.0. Also, let me tell you I am using Windows 2000 platform.
Then, I have compiled it with UNICODE MFC dlls and static librarys[ UAFX*.lib and Unicode MFC dlls] and got the UNICODE version of application.
Now, my requirement is to develop one single application that can support both Unicode and MBCS[DBCS]....
Well, I dont know wehether this is possible, if Possible, please let me know how to go for.
Thanks & Regards,
Mr Prasad G.
|
|
|
|
|
While I'm not an expert, I will try to answer your question.
Use the TCHAR macro's for all your string manipulations (CString does this)
ie.
use 'TCHAR' instead of 'char' or 'WCHAR'
use '_tcscpy' instead of 'strcpy', '_mbscpy', or 'wcscpy'
HTH
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|