POV-Ray : Newsgroups : povray.advanced-users : movie within : Re: movie within Server Time
29 Jul 2024 04:25:54 EDT (-0400)
  Re: movie within  
From: Dan P
Date: 4 Feb 2004 20:23:30
Message: <40219b12$1@news.povray.org>
"Patrick Elliott" <sha### [at] hotmailcom> wrote in message
news:MPG.1a8b3cdca47d8a80989996@news.povray.org...
> In article <402125e4@news.povray.org>, dan### [at] yahoocom says...
> > try
> > {
> >     Do something
> > }
> > catch (Exception ex)
> > {
> >     Failure
> > }
> >
> > Are you saying all these people are wrong?
>
> Just my two cents here, but this isn't exactly the same things.
> However... If you opened the file, then tested to see if it worked and
> intentionally throw an exception, then it would be the same. What you are
> doing is manually handling an event that languages like Java can
> sometimes automatically generate an error event for. When this is the
> case, it is a real good idea to make sure things happen in the correct
> order. There are quite a few cases where checking after the fact can be
> flat out lethal to your program. In fact when dealing with Windows, the
> damn API is so flaky that it may actually appear to work and only crash
> your program, and the OS, *after* you try to shut down the program.
> Believe me, I have had it happen. lol

That's a really good point about the order. Also, I've been really diving
deep into the Windows API and I've noticed two things: 1. it's really,
really poorly documented, and 2. you have to do everything precisely the way
they want you to or it's going to crash and not pretty-like. It only makes
sense what those components are doing after you trace it using the debugger.
And even then, it's not obvious. I'm really worried about writing code that
works great on my PC but crashes elsewhere because of that. What I had to do
to handle window-resizing in an instant, efficient manner best not be said
in mixed company :-)

What I'm really surprised about is that they haven't put all those structs
into convenient-to-use classes. I struggled for an entire night to get
version info from my VS_VERSION_INFO resource. It turns out I have to create
two HGLOBALS, then lock the resource, and then use VerQueryInfo, and it
/still/ didn't work -- I guess they just don't want you reading that
resource directly, and I tried passing the executable file name and it
didn't work /then/ either. I did massive searches on the net to see other
people doing this and I couldn't find a single, consistent explanation of
how to get this information. Why the couldn't just make a class called
CVersionInfo and throw the data in there it is beyond me. I also had to make
some REALLY ugly code to read PNGs from the resource instead of a seperate
file. Here it is:

     IStream *p_objStream;
     HRSRC objResource;
     HGLOBAL objSrc;
     HGLOBAL objData;

     // Load the about image.
     objResource = FindResource(NULL,
MAKEINTRESOURCE(IDR_TITLE_TRANSPARENT), "PNG");
     objSrc = LoadResource(NULL, objResource);
     objData = GlobalAlloc(GMEM_FIXED, SizeofResource(NULL, objResource));
     CopyMemory(LPVOID(objData), LockResource(objSrc), SizeofResource(NULL,
objResource));
     CreateStreamOnHGlobal(objData, TRUE, &p_objStream);
     m_imgAbout.Load(p_objStream);

Why they create a CImage class and not enable it to load image data from a
resource like this:

    m_imgAbout.Load(IDB_PNG_FILE);

is beyond me. And even though I have the PNG now, and have set the window
transparent, and have overridden OnErase, I still wind up getting opaque
white where the alpha=0 area is. The rest of the shadowing and stuff works
(I'm looking to make an AboutBox like Photoshop does), yet when it is
alpha=0, it screws up. I'm still trying to get that to work and haven't
found anything on the web about it.

I've only been on this journey for a week now and already I can understand
why so many of my Windows programs crash. It isn't that the programmers are
bad, it's that Microsoft can't seem to get their act together. From what TF
said, I'm really expecting that to be true about DirectX as well. If anybody
has an suggestions on how to deal with this, I'd really appreciate hearing
them (and don't listen to those guys -- if those suggestions don't contain
blatant insults, I don't bite -- the proof is in the thread.) At least .NET
is cleaning a lot of things up now, although I have yet to figure out how to
use a .NET specific class (like MemoryStream) in my C++ code.

> -- 
> void main () {

>     call functional_code()
>   else
>     call crash_windows();
> }

LOL :-) Take good care of that cat!!!


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.