Results 1 to 23 of 23

Thread: Technocrat

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Unhappy 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.

  2. #2
    denniswrenn
    Guest
    Where is the tutorial located(I would like to take a look, as I'm not that good in graphics)?

  3. #3

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    Amon Ra
    The Power of Learning.

  4. #4
    denniswrenn
    Guest
    I just tried it, and it works fine... Perhaps you accidently deleted break; from the WM_CREATE case?

  5. #5

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Unhappy no..

    Nope, it's there
    Amon Ra
    The Power of Learning.

  6. #6
    denniswrenn
    Guest
    Here's the one I made(copied & pasted directly from the tutorial), it works just fine.
    Attached Files Attached Files

  7. #7

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Unhappy ..

    I don't see any difference!?
    here is my code
    Amon Ra
    The Power of Learning.

  8. #8
    denniswrenn
    Guest
    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 .

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  10. #10
    denniswrenn
    Guest
    I didn't do that, Technocrat did!

    take a look at main.cpp
    http://www.technocracy.f2s.com/Basic%20BitBlt.html

  11. #11
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  12. #12

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Wink 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.

  13. #13
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  15. #15
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024

    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


  16. #16
    denniswrenn
    Guest
    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.

  17. #17
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  18. #18
    denniswrenn
    Guest
    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); 
        }
    }

  19. #19
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  20. #20
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  21. #21
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  22. #22
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  23. #23
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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
  •  



Click Here to Expand Forum to Full Width