Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Feb 2002
Offline Last Active Today, 01:45 PM

#5147174 Need help to draw cursor properly

Posted by Endurion on 15 April 2014 - 12:46 PM

This sounds like you need to get the cursor hotspot. Funnily you need to use GetIconInfo to retrieve that info.



Edit: Ninja'd

#5145851 blurry images

Posted by Endurion on 09 April 2014 - 11:17 PM

If you still want a border you can look into AdjustWindowRect(Ex). It calculates a window rect from the wanted client rect size and the windows (ex) styles of your window.

#5145571 blurry images

Posted by Endurion on 08 April 2014 - 11:48 PM

The keyword here is directly mapping texels to pixels. Looky here (http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx)



Another cause of unwanted blurring may be if the backbuffer size does not match up the used client area size of the window.

#5144909 Expression must have class type?

Posted by Endurion on 06 April 2014 - 11:10 PM

As BHXSpecter said, we need the exact message and the location in the code.


Usually this message appears if you use dot.member (something.member)  on a pointer or something that isn't either struct or class.

#5143833 SDL undeclared filename and apply_surface not working

Posted by Endurion on 01 April 2014 - 11:43 PM

To keep the window running you need to have a "main loop", a loop that keeps the program running. If you leave the main method your program ends. From the tutorial code it's this snippet:


bool quit = false;
//While the user hasn't quit
while( quit == false )
  //While there's events to handle
  while( SDL_PollEvent( &event ) )
    //If the user has Xed out the window
    if( event.type == SDL_QUIT )
      //Quit the program
      quit = true;

#5143621 SDL undeclared filename and apply_surface not working

Posted by Endurion on 31 March 2014 - 11:50 PM

Well, you seem to have simply copy/pasted a few lines of code out of the working tutorial code.


Your main issue right now seems to be to read errors properly.



The filename. You pasted a few lines from a function, which had parameter as a function argument. Obviously that argument is not here, so you have to declare filename yourself above the location where you access it. The compiler simply doesn't know what "filename" is (Hint: In the tutorial code it's a std::string)



apply_surface is the same. It's a function defined in the tutorial code. You only copied lines calling that function. The compiler obviously does not know the function.

Simple solution: Copy also the apply_surface function and paste it above the main function.

#5141273 Why does this work?(Class prototype?)

Posted by Endurion on 22 March 2014 - 12:52 PM

Note however forward declaration only works if the compiler doesn't need to know anything of the inner parts of that class. This means you can only forward declare pointers or references, not direct objects.

#5138903 0..99 or 0..100

Posted by Endurion on 14 March 2014 - 04:43 AM

Win32-API uses inclusive/exclusive. MSs rationale for this is mathematics.


If you want to double a rect you can simply multiply all four values by 2.

#5133500 deinstancing c-strings

Posted by Endurion on 22 February 2014 - 06:01 AM

Seriously, noone comes up with this?


enum Colors
  red = 0xffff0000,
  green = 0xff00ff00,
  blue = 0xff0000ff


You get the best of enums and you get rid of the if/else-code completely.

#5129910 how to create a menu like that?

Posted by Endurion on 08 February 2014 - 02:30 PM

The Tab control is available in raw win32. It provides the tabs and their looks. You do have to manage the changing of child pages yourself.


Simple setup here: http://winapi.freetechsecrets.com/win32/WIN32Creating_a_Tab_Control.htm


More complex wrapper: http://www.codeproject.com/Articles/14712/Win32-SDK-C-Tab-Control-Made-Easy

#5129240 Visual Studio Questions

Posted by Endurion on 06 February 2014 - 12:44 AM

Visual Studio can nicely be uninstalled, but you need to use the main setup for this. Do NOT try to uninstall it's dependencies on your own. It will take care to remove the installed dependencies fine.


I had VS 2003, VS 2008 and VS 2010 installed (in that order). Then I uninstalled VS 2003 without problems, with VS 2008 and VS 2010 still working fine.

#5126539 WIN32 how to put an image on the desktop without a window?

Posted by Endurion on 26 January 2014 - 11:49 AM

That is a window. There's nothing in Win32 without a HWND.


You can disable all borders and the caption via window styles.

#5115579 Win32 programming, relevant in windows 8?

Posted by Endurion on 09 December 2013 - 12:57 AM

soon .NET

You surely have a reference for that bollocks?



Win32 is going to stay for quite a long while yet, as will .NET.


And both work fine in Windows 8. Just way too much software is working with it so Microsoft won't throw them away any time soon.

#5115051 How to detect only attached device using win32 GetRawInputDeviceList?

Posted by Endurion on 07 December 2013 - 01:01 AM

From a MVP page (don't ask me which one) I took this to weed out those "virtual" combined devices like this:


  UINT        numDevices = 0;
  if ( GetRawInputDeviceList( NULL, &numDevices, sizeof( RAWINPUTDEVICELIST ) ) != 0 )
    // Error?
    return false;
  if ( GetRawInputDeviceList( pDeviceData, &numDevices, sizeof( RAWINPUTDEVICELIST ) ) == -1 )
    // Error
    delete[] pDeviceData;
    return false;
  int numTotalControls    = 0;
  int numTotalVirtualKeys = 0;
  int currentHIDJoystickOrGamepad = 0;
  for ( UINT i = 0; i < numDevices; ++i )
    wchar_t             pathBuffer[260 + 4];
    UINT                bufferSize = UINT( sizeof( pathBuffer ) / sizeof( pathBuffer[0] ) );
    std::wstring        name;
    bufferSize = GetRawInputDeviceInfoW( pDeviceData[i].hDevice, RIDI_DEVICENAME, pathBuffer, &bufferSize );
    if ( sizeof pathBuffer / sizeof pathBuffer[0] < bufferSize )
      // Negative UINTs werden sehr groß positiv
      dh::Log( "invalid HID (%d, %x): could not retrieve its path", i, pDeviceData[i].hDevice );
    std::wstring    originalName = pathBuffer;
    pathBuffer[1] = L'\\';
    HANDLE              ntHandle = CreateFileW( pathBuffer,
                                                FILE_SHARE_READ | FILE_SHARE_WRITE, // wir können anderen Prozessen nicht verbieten, das HID zu benutzen
                                                NULL );
    if ( INVALID_HANDLE_VALUE == ntHandle )
      dh::Log( "%d: invalid HID: could not open its handle", i );
    if ( GR::Strings::ToUpper( pathBuffer ).find( L"ROOT" ) != std::string::npos )
      // skip combined devices, we only want real devices
      //dh::Log( "skip combined device %d (%x)", i, pDeviceData[i].hDevice );
    // snip ... from here one gather additional data from devices

#5113812 How to read depth buffer value at a pixel to CPU and get its world coordinate

Posted by Endurion on 02 December 2013 - 12:47 PM

You're probably better off doing it some other way than reading back memory from the card. Aside from totally botching your frame rate the z buffer values are not directly usable. AFAIK the z value is not stored linearly.