Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: va!n on June 04, 2012

Title: Problem with tiny VS Win32 project
Post by: va!n on June 04, 2012
I am trying to code a small tiny Win32 project with VS11beta, which should open a window with a button as test. On the web i found a lot of different ways how things are done. On the one side people are using WNDLCASS... some others are using WNDCLASSEX... For my project i will use CreateWindowEx... I tried some changes but i can't compile anymore and i have no idea why does WNDCLASS causes an error... :( Maybe someone can take a look to the attached zip? Thanks.

Btw, which version of the EventLoop is correct?

Code: [Select]
while( GetMessage( &msg, NULL, 0, 0 ) > 0 )           // Some sites are talking to use > 0 and some others not...
{
TranslateMessage(&msg);
DispatchMessage( &msg );
}

return 0;

Code: [Select]
    while (GetMessage(&msg, NULL, 0, 0))        // Another version which does not return just 0
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return (int) msg.wParam;                 
Title: Re: Problem with tiny VS Win32 project
Post by: va!n on June 04, 2012
I managed it to get it work again... I will upload my latest version soon...
Title: Re: Problem with tiny VS Win32 project
Post by: hellfire on June 04, 2012
Code: [Select]
while( GetMessage( &msg, NULL, 0, 0 ) > 0 )  // Some sites are talking to use > 0 and some others not...
Win32's "BOOL" is just a signed integer and negative values indicate an error.
In that case the content of msg is undefined and you don't want to process it.


Title: Re: Problem with tiny VS Win32 project
Post by: va!n on June 22, 2012
Okay... here is my Win32 UNICODE project for VS11... It compiles a simple Win32 unicode window to 2560 bytes as release version. However, trying to compile as debug version causes a lot of errors - i dont know why nor whats wrong. If you take a look inside the compiled release version, you will notice, there are three sections atm:  .text, .rdata, .reloc ... And behind the section where are the required dll and functions names are stored - also at 0x800 there is a 512 byte section with 20 bytes of something i dont know what this is for and why does this happens... When i add some more code to this project, some more undefined bytes will be flollow here. Probaly the exe may get one more 512 byte section, which is called .data - again i dont know why nor when does this happens.

I checked the compiler settings and due fact there are so many options, i am not sure if all the options for this project are okay or if there are points, that should be changed.

Title: Re: Problem with tiny VS Win32 project
Post by: Canopy on June 22, 2012
afaik i've only ever done it the peekmessage way, online sources tell me getmessage blocks, sounds bad to me at first glance.

can you give any more info about what the message loop is doing?


some info here http://www.cplusplus.com/forum/beginner/38860/ 

including this quote

Quote
the PeekMessage loop is generally used in video games,