Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Getting random messages in my queue [C++ DirectX]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Fri May 09, 2008 4:24 pm    Post subject: Getting random messages in my queue [C++ DirectX] Reply with quote

I keep getting random stuff in my message queue.
I'm getting a WM_TIMER message about 3 times/second even though I haven't made a timer and a message with the identifier 49419 (0xC10B) about once every 2 seconds.
Sometimes I also get others around 49419 which is strange because messages in the range 0xC000 through 0xFFFF are application defined.

My code:
Code:
//-----------------------------------------------------------------------------
// File: CreateDevice.cpp
//
// Desc: This is the first tutorial for using Direct3D. In this tutorial, all
//       we are doing is creating a Direct3D device and using it to clear the
//       window.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#include <fstream>
#include <d3d9.h>
#pragma warning( disable : 4996 ) // disable deprecated warning
#include <strsafe.h>
#pragma warning( default : 4996 )
#include <iostream.h>

HWND hWnd;
MSG msg;



//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
LPDIRECT3D9             g_pD3D       = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9       g_pd3dDevice = NULL; // Our rendering device


//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object, which is needed to create the D3DDevice.
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        return E_FAIL;
    // Set up the structure used to create the D3DDevice. Most parameters are
    // zeroed out. We set Windowed to TRUE, since we want to do D3D in a
    // window, and then set the SwapEffect to "discard", which is the most
    // efficient method of presenting the back buffer to the display.  And
    // we request a back buffer format that matches the current desktop display
    // format.
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    /*d3dpp.BackBufferWidth;
            d3dpp.BackBufferHeight;
            d3dpp.BackBufferFormat;
            d3dpp.BackBufferCount;
            d3dpp.MultiSampleType;
            d3dpp.MultiSampleQuality;
            d3dpp.SwapEffect;
            d3dpp.hDeviceWindow;
            d3dpp.Windowed;
            d3dpp.EnableAutoDepthStencil;
            d3dpp.AutoDepthStencilFormat;
            d3dpp.Flags;
            d3dpp.FullScreen_RefreshRateInHz;
            d3dpp.PresentationInterval;*/
            d3dpp.BackBufferWidth = 800;
            d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

    // Create the Direct3D device. Here we are using the default adapter (most
    // systems only have one, unless they have multiple graphics hardware cards
    // installed) and requesting the HAL (which is saying we want the hardware
    // device rather than a software one). Software vertex processing is
    // specified since we know it will work on all cards. On cards that support
    // hardware vertex processing, though, we would see a big performance gain
    // by specifying hardware vertex processing.
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }
    // Device state would normally be set here

    return S_OK;
}




//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
    if( g_pd3dDevice != NULL)
        g_pd3dDevice->Release();

    if( g_pD3D != NULL)
        g_pD3D->Release();
}




//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
    if( NULL == g_pd3dDevice )
        return;

    // Clear the backbuffer to a blue color
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( msg.pt.x,100,255), 1.0f, 0 );
   
    // Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
        // Rendering of scene objects can happen here
   
        // End the scene
        g_pd3dDevice->EndScene();
    }

    // Present the backbuffer contents to the display
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}




//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    return DefWindowProc( hWnd, msg, wParam, lParam );
}




//-----------------------------------------------------------------------------
// Name: wWinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT main( HINSTANCE hInst, HINSTANCE, LPWSTR, INT )
{   
    // Register the window class
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                      "D3D Tutorial", NULL };
    RegisterClassEx( &wc );

    // Create the application's window
    hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 01: CreateDevice",
                              WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
                              NULL, NULL, wc.hInstance, NULL );

    // Initialize Direct3D
    if( SUCCEEDED( InitD3D( hWnd ) ) )
    {       
        // Show the window
        ShowWindow( hWnd, SW_SHOWDEFAULT );
        UpdateWindow( hWnd );

        // Enter the message loop
                        std::ofstream fil;
                        fil.open("msgs.txt");
        while( GetMessage( &msg, NULL, 0, 0 ) )
        {
                        fil << "wparam: " << msg.wParam << endl;
                        fil << "lparam: " << (float*)msg.lParam << endl;
                        fil << "message: " << msg.message << endl;
                                                                        fil << "time: " << msg.time << endl;
                                                                        fil << "ptx: " << msg.pt.x << endl;
                                                                        fil << "pty: " << msg.pt.y << endl;
        }
    }
    UnregisterClass( "D3D Tutorial", wc.hInstance );
    return 0;
}


and the output
Quote:
wparam: 17
lparam: 0xc0640
message: 49412
time: 31590031
ptx: 461
pty: 596

wparam: 0
lparam: 0x1e2068f
message: 49419
time: 31590031
ptx: 461
pty: 596

wparam: 1
lparam: 0
message: 275
time: 31590343
ptx: 461
pty: 596

wparam: 1
lparam: 0
message: 275
time: 31590656
ptx: 461
pty: 596

wparam: 1
lparam: 0
message: 275
time: 31590968
ptx: 461
pty: 596

wparam: 1
lparam: 0
message: 275
time: 31591281
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31591593
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31591906
ptx: 461
pty: 595

wparam: 0
lparam: 0x1e20e5f
message: 49419
time: 31592031
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31592218
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31592531
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31592843
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31593156
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31593468
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31593781
ptx: 461
pty: 595

wparam: 0
lparam: 0x1e2162f
message: 49419
time: 31594031
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31594093
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31594406
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31594718
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31595031
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31595343
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31595656
ptx: 461
pty: 595

wparam: 1
lparam: 0
message: 275
time: 31595968
ptx: 868
pty: 241

wparam: 0
lparam: 0
message: 49418
time: 31596031
ptx: 805
pty: 175

wparam: 1
lparam: 0
message: 275
time: 31596281
ptx: 731
pty: 110

wparam: 1
lparam: 0
message: 275
time: 31596593
ptx: 718
pty: 101

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites