Jump to content

  • Log In with Google      Sign In   
  • Create Account

Endurion

Member Since 21 Feb 2002
Offline Last Active Today, 05:26 AM

#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;
  }
  RAWINPUTDEVICELIST*   pDeviceData = new RAWINPUTDEVICELIST[numDevices];
  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 );
      continue;
    }
    std::wstring    originalName = pathBuffer;
    pathBuffer[1] = L'\\';
    HANDLE              ntHandle = CreateFileW( pathBuffer,
                                                0u,
                                                FILE_SHARE_READ | FILE_SHARE_WRITE, // wir können anderen Prozessen nicht verbieten, das HID zu benutzen
                                                NULL,
                                                OPEN_EXISTING,
                                                0u,
                                                NULL );
    if ( INVALID_HANDLE_VALUE == ntHandle )
    {
      dh::Log( "%d: invalid HID: could not open its handle", i );
      continue;
    }
    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 );
      continue;
    }
    // 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.




#5099265 Java Image problem

Posted by Endurion on 06 October 2013 - 11:34 PM

In Java wouldn't you have to use .equals with strings? Otherwise you just compare the references (the pointers) which may differ.




#5096884 Learning Assembly on retro consoles?

Posted by Endurion on 26 September 2013 - 01:54 AM

Targetting older stuff first is seconded. The 6502 instruction set is also very similar to its successor, the 6510, which was used in the C64. There's plenty of material out there giving you a glimpse of what to expect.




#5092218 Handling Input as Generic Data (Multiple Inputs)

Posted by Endurion on 06 September 2013 - 10:40 PM

I do something similar to you. I enumerate all devices and their controls (I've got libraries for pure Win32, DirectInput and RawInput).

 

I differ between digital values (interpreted as button presses) and analog values (joystick axes for example). Analog axes are also mapped to digital (with threshold).

 

All these virtual buttons and axes can then be assigned to different actions; customizable by the player. The player can then map any buttons at will (mix joystick, keyboard, mouse).

 

Fun fact: Mapping the analog axis to digital lets me play jump ´n´ runs with the mouse, and it's actually playable :)




#5090528 Replacement for Xna?

Posted by Endurion on 30 August 2013 - 11:45 PM

XNA doesn't stop working just because there's no more support for it. It's a mature, working API and will continue working for a while.

 

You could however look into Monogame, which is a open replacement for XNA (even tries to rebuild the API 1:1) and is properly updated.




#5090132 Weird issue losing characters from std::string

Posted by Endurion on 29 August 2013 - 10:08 AM

Anything that is not C, resides in different build units (lib/dll/exe) and is interfacing means trouble if they are not built with the same exact settings.

 

Exact settings in the sense that the objects created in one unit may not safely be passed to a different unit if they do not compile to the same code in both.

 

Esp. classes from templates fall in this category. Even when they are just inside a header, every compilation unit will have it's own copy of the actual code.




#5090107 Weird issue losing characters from std::string

Posted by Endurion on 29 August 2013 - 08:27 AM

I assume you did a full rebuild?

 

If so, put a breakpoint at the start of ShipWright::ShipWrightLoader::Load and inspect the content of filename in the debugger.

Does the size and content match what you expect?




#5088938 [winapi] to check avaliable memory

Posted by Endurion on 25 August 2013 - 11:07 AM

Depending on how you allocate that memory Windows will let you do that (use more memory than is physically available).

 

Back in the old days of yore (Win 3.11) I could load and scroll on a 8 MB bitmap on a 4 MB machine. No, it was not particularely fluid, but it worked.

 

 

Checking the state is good, however having a forced abort is not. Even if you deem memory not sufficient, let it run (maybe with a warning).






PARTNERS