Author Topic: Basic window setup  (Read 6945 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Basic window setup
« on: September 28, 2007 »
I'm trying to re organise things in my code a bit and thought this may (or may not) be useful. It's the basic window and gfx buffer setup I'm using based on Jims code. It's been modified quite a bit though and if anyone that knows any better thinks that something could/should be done differently I'd be grateful of any input.

You'll need to create an empty win32 project and put these files into it (I think they're all there).
« Last Edit: November 25, 2007 by Stonemonkey »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Basic window setup
« Reply #1 on: September 28, 2007 »
Looks OK to me :)

I see one tiny bug
Code: [Select]
        if (!GetMessage(&msg, fetch_project()->window, 0, 0))
            break;
should be
Code: [Select]
        if (GetMessage(&msg, fetch_project()->window, 0, 0)>0)
            break;
since GetMessage returns < 0 on error, 0 for exit, and > 0 for success.  I can't imagine any situation where that would happen on a stable system though.

Jim
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Basic window setup
« Reply #2 on: September 29, 2007 »
Heh, cheers Jim. I am surprised that's all tbh. I'll fix that and uplaod again.

EDIT: sorted.
« Last Edit: September 29, 2007 by Stonemonkey »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Basic window setup
« Reply #3 on: September 29, 2007 »
Might be more in there, but the structure looks OK, which is far more important. :)
Jim
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Basic window setup
« Reply #4 on: September 29, 2007 »
Yeah, I hadn't expected you'd gone through it all but if that's about the worst that stands out I'll be quite happy.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Basic window setup
« Reply #5 on: September 29, 2007 »
Thanks for posting :) K+
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Basic window setup
« Reply #6 on: November 25, 2007 »
Hmmm. Jim, I've just been looking back at something and made the change you suggested and now the windows aren't working at all right, they can't be dragged, the buttons don't work and I don't get feedback from the mouse. Should it have been:

Code: [Select]
if (GetMessage(&msg, fetch_project()->window, 0, 0)<0)
            break;

as that appears to get everything working.

EDIT:
Sorry to anyone trying to run that code as it would've just given a blank screen :(
« Last Edit: November 25, 2007 by Stonemonkey »

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Basic window setup
« Reply #7 on: November 25, 2007 »
strange i use GetMessage()>0 in my code and it works fine although i use NULL where you youse fetch_project is the fetch project window needed?

edit sorry just went through your code, you do things diffrent to me so maybe < 0 is more correct in your case.
 
« Last Edit: November 25, 2007 by ninogenio »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Basic window setup
« Reply #8 on: November 25, 2007 »
Should be <=.  Just check the docs for GetMessage.  It returns 0 when WM_QUIT comes through and -ve on error.  So just "if (GetMessage())" isn't right, but then again, I got the check wrong too :(

Jim
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Basic window setup
« Reply #9 on: November 26, 2007 »
Thanks Jim.

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: Basic window setup
« Reply #10 on: November 26, 2007 »
That gfx mode doesn't work on my pc :(
anything i could do to make it work?
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Basic window setup
« Reply #11 on: November 27, 2007 »
Hi paul, what's happening exactly? are the results the same whether it's fullscreen or windowed?

stonemonkey.

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: Basic window setup
« Reply #12 on: November 28, 2007 »
hehe. I most have had more than 1 tab going, I was supposed to post that in Shockwaves 32b topic :P
sry
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Basic window setup
« Reply #13 on: November 30, 2007 »
lol, no problem.

Fryer.