Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Endurion

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

#4988616 string::size_type

Posted by Endurion on 09 October 2012 - 11:52 PM

Your question and code do not match up. You never write out something with numbers.

string::size_type is not a function, it's a typedef for size_t usually.


#4987592 C++ -- Undinitialized Variables

Posted by Endurion on 06 October 2012 - 11:45 PM

Also, initialise currentChar to a value != EOF. That could potentially skip your reading loop.

Check if cellPosition gets >= CELLS_IN_GRID. If it does you're writing in memory that is not yours. Once that happens all kind of weird things can happen (hence undefined).
The lines inside the for loop look ok.


#4985672 entering a string of data to an ofstream file

Posted by Endurion on 01 October 2012 - 01:58 AM

Use it in the switch/case where you currently do

std::cin >> filedata

Replace that with

std::getline ( std::cin, filedata );


#4985271 Saving desktops icons dosen't work...

Posted by Endurion on 29 September 2012 - 11:32 PM

Vortez: You're passing a local pointer to a different application with its own heap. For that other application that pointer is probably pointing into invalid territory.

You need to allocate memory in the explorer process with VirtualAllocEx and use ReadProcessMemory and WriteProcessMemory to access it. Also, be sure to chose the right bitness (32bit vs. 64bit).


#4985263 Tile path following algorithm

Posted by Endurion on 29 September 2012 - 10:51 PM

It looks like your current method brings some inprecision. Keep the precision intact.

Pseudocode:

while ( number_of_pixels_to_move > 0 )
{
  if ( number_of_pixels_to_move >= pixels_left_to_move_on_one_tile )
  {
// arrive at a tile
number_of_pixels_to_move -= pixels_left_to_move_on_one_tile;
move pixels_left_to_move_on_one_tile pixels in move direction
adjust direction according to tile below
  }
  else
  {
// move object number_of_pixels_to_move pixels in move direction
number_of_pixels_to_move = 0;
  }
}


Edit: The dumb editor keeps screwing up indentation


#4977518 Zork like text input

Posted by Endurion on 07 September 2012 - 01:41 AM

I'd actually do not direct string comparison. It's easy in the beginning, but will grow too fast to be managable.

Back then the programmer had a list of verb strings (with index so different verbs with the same id existed) and list of object strings.

Then you would parse the input string, split for spaces and try to find all the single words in the lists. The puzzle logic would then analyse the verb and object indices and act accordingly.
If you want to get fancy allow for a secondary object (put xxx in yyy) and fill words that would be discardid ("the", "in", etc.).


Steps:
* Split a string by a separator (space)
* Handle string to index maps (std::map<std::string,int>)


#4976694 Combo Box Insert String

Posted by Endurion on 04 September 2012 - 10:58 PM

Increase the height of the combo box. AFAIR the height of the dropdown list is determined by the rect given in CreateWindow.


#4976677 understanding return by value.

Posted by Endurion on 04 September 2012 - 09:45 PM

If you want all the object creations you also need to look at the copy constructor. Currently you didn't define one, so the compiler did.

The signature looks like this:

Test::Test( const Test& rhs )





#4973467 TotalCmd - delete file from a custom pack

Posted by Endurion on 26 August 2012 - 07:23 AM

Deleting from a .zip is seemingly fast, since the entries are compressed each by it own. Any decent packer will do what you described to remove an entry.

Basically removing a file from a .zip doesn't involve any decompression/recompression at all.


#4973407 TotalCmd - delete file from a custom pack

Posted by Endurion on 25 August 2012 - 11:22 PM

Well, it may not feel nice, but that's the way to do it. If you're hoping for some sort of delete part of file and have the rest data get moved upwards, there is no such thing.


#4971351 Full Screen to Windowed - Window loses border and style

Posted by Endurion on 19 August 2012 - 11:54 PM

D3D removes the border styles. You need to reapply them via SetWindowLong. You can store the wanted styles. Just make sure to also manually remove WS_EX_TOPMOST.

Before going fullscreen:
m_WindowedModeStyles    = GetWindowLong( hwndViewport, GWL_STYLE );
m_WindowedModeExStyles  = GetWindowLong( hwndViewport, GWL_EXSTYLE );
m_WindowedModeExStyles &= ~WS_EX_TOPMOST;

Returning to windowed mode:
SetWindowLong( hwndViewport, GWL_STYLE, m_WindowedModeStyles );
SetWindowLong( hwndViewport, GWL_EXSTYLE, m_WindowedModeExStyles );
SetWindowPos( hwndViewport, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED );


#4968973 win32 dialog question

Posted by Endurion on 13 August 2012 - 01:43 AM

Your main window does exist when the dialog appears, however it hasn't been set visible yet. The WM_CREATE message is sent during your CreateWindow call.

If you want your main window visible, use WS_OVERLAPPEDWINDOW | WS_VISIBLE in CreateWindow. That also relieves you of having to call ShowWindow.


#4968614 Win32 Button Commands

Posted by Endurion on 11 August 2012 - 10:35 PM

And also you should return 0 for handled messages. I don't know if this is the full code, but I can't see a "return 0" statement. Returning 0 is important.

You cannot generally return 0. Look up the handled message and see what you should return (if you should do so).


#4968321 WndProc and WinMain

Posted by Endurion on 10 August 2012 - 10:27 PM

However make sure you call DispatchMessage on the same thread that you called CreateWindow(Ex) on. HWNDs are thread specific.


#4966905 DX7 VC++6 Slow Alpha Blending

Posted by Endurion on 06 August 2012 - 10:45 PM

Is that Direct Draw? If so, reading kills your performance. You might be faster if you completely draw your surface into a memory buffer (with alpha) and do a full blit to the primary surface once you're done.


And additionally, what jbadams said ;)




PARTNERS