Jun 28th, 2001, 11:43 AM
#1
Thread Starter
Hyperactive Member
Technocrat
Hey
I did your BitBlt tutorial(which is excellent for me as a beginner
Anyways, when I run the program, the window shows for less that a second, and unloads right away. I checked with the code from the tutorial, and it is exactly the same.
Amon Ra
The Power of Learning.
Jun 28th, 2001, 11:52 AM
#2
Where is the tutorial located(I would like to take a look, as I'm not that good in graphics)?
Jun 28th, 2001, 12:05 PM
#3
Thread Starter
Hyperactive Member
Amon Ra
The Power of Learning.
Jun 28th, 2001, 12:24 PM
#4
I just tried it, and it works fine... Perhaps you accidently deleted break; from the WM_CREATE case?
Jun 28th, 2001, 12:32 PM
#5
Thread Starter
Hyperactive Member
no..
Nope, it's there
Amon Ra
The Power of Learning.
Jun 28th, 2001, 12:36 PM
#6
Here's the one I made(copied & pasted directly from the tutorial), it works just fine.
Attached Files
Jun 28th, 2001, 12:55 PM
#7
Thread Starter
Hyperactive Member
..
I don't see any difference!?
here is my code
Amon Ra
The Power of Learning.
Jun 28th, 2001, 01:22 PM
#8
You screwed up your message loop, here is what you had:
Code:
while(&msg,NULL,0,0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
And here's what you need:
Code:
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
After you make this change, everything should work fine .
Jun 28th, 2001, 01:44 PM
#9
Monday Morning Lunatic
And Dennis, you just screwed yours up
Code:
while(GetMessage(&msg,NULL,0,0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GetMessage can return -1, which will cause your code to go round in circles and hang
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Jun 28th, 2001, 01:47 PM
#10
I didn't do that, Technocrat did!
take a look at main.cpp
http://www.technocracy.f2s.com/Basic%20BitBlt.html
Jun 28th, 2001, 01:50 PM
#11
Frenzied Member
Cool, glad to see the tutorial worked for some one. Like I said in there I did not put in how to keep the screen on.
Just catch WM_PAINT
like so:
PHP Code:
case WM_PAINT :
{
PAINTSTRUCT ps ;
BeginPaint ( hwnd , & ps );
BitBlt ( whatever .....
EndPaint ( hwnd ,& ps );
break;
}
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com
Jun 28th, 2001, 01:57 PM
#12
Thread Starter
Hyperactive Member
ahh..
Finally, thanks Dennis, it worked. Thanks technocrat for the tut. Do you know of more advanced ones? Thanks
Amon Ra
Amon Ra
The Power of Learning.
Jun 28th, 2001, 01:58 PM
#13
Frenzied Member
Acutually I use:
PHP Code:
while( TRUE )
{
if( PeekMessage (& msg , NULL , 0 , 0 , PM_REMOVE )
{
if( msg . message == WM_QUIT )
break;
TranslateMessage (& msg );
DispatchMessage (& msg );
}
}
Now
But:
PHP Code:
while( GetMessage (& msg , NULL , 0 , 0 ))
{
TranslateMessage (& msg );
DispatchMessage (& msg );
}
Should work because GetMessage only return a BOOL and a -1 if error. -1 and 0 would kick out of the While() right because neither one is true
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com
Jun 28th, 2001, 01:58 PM
#14
Monday Morning Lunatic
I don't care who wrote it, it needs correcting
Look up GetMessage in MSDN if you don't believe me
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Jun 28th, 2001, 01:59 PM
#15
Frenzied Member
Re: ahh..
Originally posted by Amon Ra
Finally, thanks Dennis, it worked. Thanks technocrat for the tut. Do you know of more advanced ones? Thanks
Amon Ra
No I dont know of anymore advanced ones and I have not gotten around to writing the advanced version of mine.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com
Jun 28th, 2001, 02:01 PM
#16
Technocrat: How would you keep the picture from disapearing when another window overlaps it? The bit of code you posted to put in WM_PAINT doesn't do that.
Jun 28th, 2001, 02:02 PM
#17
Frenzied Member
All be damned......
From MSDN:
Note that the function return value can be nonzero, zero, or -1. Thus, you should avoid code like this:
while (GetMessage( lpMsg, hWnd, 0, 0)) ...
The possibility of a -1 return value means that such code can lead to fatal application errors.
In Ivor Horton's book it has it as:
while (GetMessage( lpMsg, hWnd, 0, 0))
Dirty book taught me to program wrong
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com
Jun 28th, 2001, 02:03 PM
#18
It says to use something like this instead:
Code:
BOOL bRet;
while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Jun 28th, 2001, 03:13 PM
#19
Monday Morning Lunatic
The urge to say "I told you so" runs high....
As for windows being covered up, can't you use CS_SAVEBITS?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Jun 28th, 2001, 03:14 PM
#20
Monday Morning Lunatic
Oh, Technocrat - doesn't PeekMessage return immediately? I hate to think what the CPU usage of that one is like I think you need a WaitMessage or something like that in there.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Jun 28th, 2001, 04:10 PM
#21
Frenzied Member
If I hadn't been in such a hurry to go to lunch........
Here it what is should be:
PHP Code:
while( TRUE )
{
if( PeekMessage (& msg , NULL , 0 , 0 , PM_REMOVE )
{
if( msg . message == WM_QUIT )
break;
TranslateMessage (& msg );
DispatchMessage (& msg );
}
else
WaitMessage ();
}
Thats what Tricks of the Windows Game Programming Gurus by Andre Lamothe, shows to use while making windows programs. That book kicks ass by the way.
As for keeping the image on the screen, once again, to much in a hurry. Funny how when you are in a hurry you can get so many things wrong.
Ok I personally found how to do it this way, but someone else once told me you can use InvalidateRect() to work also, but I have never tried it.
But here is how I do it
PHP Code:
case WM_PAINT :
{
PAINTSTRUCT ps ;
//We run this to have whatever paint job windows is requesting released.
BeginPaint ( hwnd ,& ps ); //The hWnd here is the one that is passed into the MessageProc
EndPaint ( hwnd ,& ps );
BeginPaint ( hwnd_Window , & ps ); //Begin Painting the window we want the BitBlt Image to stay on
BitBlt ( whatever .....
EndPaint ( hwnd_Window ,& ps ); //End Painting
break;
}
If some knows how to do it with InvalidateRect or knows of a better I would like to know it.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com
Jun 28th, 2001, 04:12 PM
#22
Monday Morning Lunatic
Originally posted by Technocrat
If I hadn't been in such a hurry to go to lunch........
Ok then, all is forgiven
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Jun 28th, 2001, 04:15 PM
#23
Frenzied Member
I was actually 10 mins late because of you people
Since I program on my laptop and use the internet on my desktop I always have to retype everything and I always missing something.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width