Duoas 1,025 Postaholic Featured Poster

If you are not on windows, or you just want something more cross-platform, you'll need to use a GUI toolkit. The universal favorites are (in no particular order):

Trolltech Qt
GTK+ (and a nice C++ wrapper: GTK++)
wxWidgets
FLTK
FOX Toolkit

You may also want to take a look through The GUI Toolkit, Framework Page.

With the exception of Qt, all those I listed are GPL or better. Qt requires strict non-commercial use (now and in the future) for programs written with the free version.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

If you are going to be using buttons with pixel images (like a GIF) you will need to do pixel-hit testing yourself.

Use the OnMouseDown event's X and Y values (which are relative to the button) to index a pixel in the image. Check that pixel's color against the transparent color to see if the user has clicked outside or inside the button's image.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

In addition, you should have a removeBook() (or some such named) method(s) for the user's convenience.

Undertech commented: It's a good idea although I wouldn't be able to implement it for this particular assignment. +1
Duoas 1,025 Postaholic Featured Poster

There isn't really any clean solution.

Remember, a template class is an incomplete type. It is only when you parameterize it that it becomes a complete, concrete, usable, valid type.

So vector <> * pvec_of_anything; just can't work. Such a type doesn't exist.

However, vector <int> * pvec_of_int; is a complete type.
As is vector <double> * pvec_of_double; . The obvious problem is that double and int are distinct types, so vectors of them are also distinct types. There is really no way of getting around that using generic programming --that isn't the problem it was intended to solve.

A common answer is to use a union and implement a "variant" datatype. Or, if you just have a special need, add a tag field to your container class that identifies the type of T.

Alas, sorry there isn't a simpler answer.

Duoas 1,025 Postaholic Featured Poster

You know, I thought I had responded to this thread yesterday, but now I remember I was called away before I could finish typing.

'Bitfields', in the sense of using individual bits in an integer value, are very useful.

'Bitfields', in the sense of the C++ foo:1; syntax, have a very limited use. That is because the standard inexplicably fails to define the order in which the bitfields are to be packed. Hence, you just don't know. Using them is only useful when they are managed abstractly and when they are explicitly tallied when reading and writing to file (or anything else: integers or video memory or whatever).


However, I don't think anyone has addressed the original design problem. While having a 'nibble' class would be cool, it is impractical. The basic problem is that the smallest unit of reference (in most modern computers) is the byte: eight bits together. It is true that you can manipulate individual bits, but they don't stand alone. Each bit is always associated with a minimum of seven other bits. Thus, a single nibble is convenient until you have to use it somewhere.

Trying to read and write a nibble from file illustrates the problem quite nicely. You have to read or write at least two nibbles at a time. So what do you do with the second nibble? You probably don't want to just throw it away.

What I would recommend instead of a nibble class …

Duoas 1,025 Postaholic Featured Poster

semicolons
A semicolon by itself is considered a null statement, and has no meaning. Modern compilers will typically complain about them unless they explicitly terminate a statement. For example int number_of_lightbulbs_to_change; ; That second semicolon, while probably not an error, is also not useful, so the compiler will complain. It could be an error: if (foo == mane) padme(); ; else hum(); For counter-example for (int n = 0; quux( n ); n++); This last semicolon is in fact a null statement, but it has a purpose: it expresses an empty loop body.

data initializers
Whether or not you can specify an initializer depends on whether or not the file is #included in another.

// foo.hpp
#ifndef FOO_HPP
#define FOO_HPP
namespace foo
  {
  extern const int fooey;
  }
#endif
// foo.cpp
#include "foo.hpp"
namespace foo
  {
  const int fooey = 42;
  }

This is to obey the One Definition Rule.

when to use using
The difference between header files and object source files is important also when using namespaces. In a header file, you should never (and yes, this is one of those rules), never add stuff to the global namespace. It is not your perogative to decide what the person using your library permits in his namespaces. Example:

// bar.hpp
#ifndef BAR_HPP
#define BAR_HPP

#include <iostream>
#include "bazlib.hpp"

using namespace std;  // <-- WRONG! JUST SAY NO!

using baz::buzz;  // <-- WRONG! JUST SAY NO!

#endif

The reason should …

VernonDozier commented: Good summary +5
William Hemsworth commented: Thats a nice big post :) +3
Prabakar commented: Yes, Really nice:) +1
Duoas 1,025 Postaholic Featured Poster

You have three cs there:
line 51
line 55
line 59
Your loop will never terminate because every c is always == first (so no matter which of the three the compiler chooses to use you've got an infinite loop).

Make sure to use just one c.

Also, watch how many times you change first. You want to bump it just once (if I understand you right).

void print() {
    listitem *c=first;

    if (c) {
        printf("%d\n", *c);
        c=first=first->next;

        do{
            printf("%d\n", *c);
            c=c->next;
        }while (c != first);
    }
  }

Hope this helps.

[edit] BTW. What if your circular list has just one item? (It will get printed twice.)

Duoas 1,025 Postaholic Featured Poster

Now you have confused me.

You don't need to allocate the size of a std::string --that's the whole point. But you do need to specify the size of a c-style character array.

Both my methods are correct.
Both use cin.

Never use gets(). (It is pure evil, and should be shot.)

If you want to use the old stdio functions to input c-strings, use fgets()

#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;
int main()
  {
  char name[ 100 ];  // this is an array of characters
  char *p;
  cout.sync_with_stdio();
  cout << "Please enter your name> ";
  fgets( name, 100, stdin );
  if (p = strchr( name, '\n' )) *p = '\0';
  cout << "Hello " << name << "!\n";
  return 0;
  }

Notice how on line 12 I had to manually remove the newline (from the ENTER key) from the input string.

[edit]
Neither incarnation of getline() stops at the first whitespace unless you tell it to. They stop at the end of the line.
However, cin >> foo; does stop at the first whitespace.

Duoas 1,025 Postaholic Featured Poster

Don't test against true. Test against false.

That is the danger in defining values for true and false. Just remember, always (and this is one of 'those' rules...) explicitly test against false. Only implicitly test for true:

if (x != false) yah();
if (x) yah();

if (x == false) fooey();
if (!x) fooey();

If your compiler still complains, just do an explicit cast:

if ((bool)(x || y)) yah();

Good luck!

Duoas 1,025 Postaholic Featured Poster

You are confounding c-style strings and stl strings.
An old c-style string:

#include <cstring>
#include <iostream>
using namespace std;
int main()
  {
  char name[ 100 ];  // this is an array of characters
  cout << "Please enter your name> ";
  cin.getline( name, 100 );
  cout << "Hello " << name << "!\n";
  return 0;
  }

An STL string:

#include <iostream>
#include <string>
using namespace std;
int main()
  {
  string name;  // this is a string object. It has no maximum size
  cout << "Please enter your name> ";
  getline( cin, name );
  cout << "Hello " << name << "!\n";
  return 0;
  }

When you say string foo[ 10 ]; you are saying that 'foo' is an array of ten string objects... probably not what you meant.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The main problem is that iostreams cannot be copied. Consider for a moment the horrors that can occur if you have three copies of an object that manipulates a file sitting around.

You must pass them by [i]reference[/i].

So, if you want your class to have a fstream, you should either make the class uncopyable or give it a reference-counted pointer to a dynamically-allocated fstream.

The [URL="http://www.boost.org/doc/libs/1_35_0/libs/smart_ptr/smart_ptr.htm"]Boost Library's Smart Pointer[/URL] classes may be of use to you. In particular, use
[URL="http://www.boost.org/doc/libs/1_35_0/libs/smart_ptr/shared_ptr.htm"]shared_ptr[/URL]<fstream> fichier;
in your class. When you initialize the class, or open the file (whichever), construct yourself a new fstream
[inlinecode]fichier = new fstream( "essai.txt" );[/inlinecode]
Thereafter, you can copy your class and each [i]copy[/i] will have a pointer to the [i]same[/i] fstream, and you won't have to worry about [b]delete[/b]ing it at the appropriate time. And, of course, distinct instances of your class (not copies) access different files.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I don't use Word, so I can't help... but what you are doing is unlikely to work well anyway because the window class names can change between versions of Word... But I think you should be looking for a RichEdit class...

I think you ought to look at OLE automation.
Here's a page all about word
http://www.kayodeok.btinternet.co.uk/favorites/kbofficewordhowto.htm

Search down near the bottom in "How to automate word" for "paste".

The other option would be to send the proper keyboard sequences to Word to access the Edit|Paste menu item.

Sorry I can't be of more help.

Duoas 1,025 Postaholic Featured Poster

Right. The va_args don't work with object-types.

Duoas 1,025 Postaholic Featured Poster

Olvidaste poner conullas al seis. while (producto != '6') :$

Hope this helps.

VernonDozier commented: Showoff! :) +5
Duoas 1,025 Postaholic Featured Poster

I have never played directly with Qt stylesheets... but it appears that you need to provide an image for the indicator with the color you want. Here's what I found about it:
http://lists.trolltech.com/qt-interest/2006-11/thread00074-0.html
The OP wants to manage different colors for different states, but the underlying problem is the same. There's also a nice link in there to the Qt examples.

While annoying, it shouldn't be too much to create little images that will do the job. Qt makes it particularly easy to include image resources in your project.

The only other way is to completely paint the radiobutton yourself.

Sorry there isn't a simpler answer.

Duoas 1,025 Postaholic Featured Poster

Since you are compiling with the UNICODE flag, you must either indicate that string literals are wide-char directly: L"Hello world!" or (better yet) use the TEXT() macro: PlaySound(TEXT("beep.wav"), 0, SND_LOOP|SND_ASYNC); Have fun.

Duoas 1,025 Postaholic Featured Poster

What you have written is a data class, and either your professor will have you extend it or will have you write a templated linked-list class and use Contributor in a linked list.

I've really only barely glanced at it, and most everything seems to be in order but one:

Serialization
Yep. It's that word. :)

The word 'serial' indicates something that is arranged in a series. In meaning it is very like the word 'sequential'. A serial port on your computer, for example, doesn't send all the information at once, but one 'word' at a time (be that a byte or an integer or whatever). A serial killer is someone who murders over and over again. He doesn't kill a lot of people all at once and be done with it. In all cases, we can speak of the objects (or people) by number. The first byte. The second byte. Etc. The last victim. The penultimate victim. Etc.

A file stream is a serial device. It is an ordered collection of data. A text file represents characters that are ordered to something humans can read. An exe (win) or elf (nix) file represents a collection of codes that are ordered to something the computer can read. Etc.

So, to serialize your class means to take your entire object (which exists all at once) and turn it into discrete, ordered elements that can be sent over a serial device (like an I/O port or …

Duoas 1,025 Postaholic Featured Poster

That's not a problem. Underneath a std::string or a std::vector is just an array anyway, except that all the nasty details of managing it are taken care of for you.

So, yes, use c_str() to get a const char* back that you can use with functions that take them. If your STL is implemented "properly" (IMO) then it shouldn't cost you anything to do it that way.

It looks like the second problem is that I accidentally typed << twice in a row. You can't have two binary operators in a row without an interleaving argument. It has nothing to do with strings. So, change line 32 to:

cout << "char " << i << ": " << c << '\n';

Sorry about that! :$

Duoas 1,025 Postaholic Featured Poster

Just a quick glance it looks OK.

The insertion operator prototype should list its second argument as const: ostream& operator << (ostream& out, const Contributor& InContributor) What makes one Contributor less than another? Answer that and you can write the contents of your < operator.

Hope this helps.

[edit] Oh yeah, your assignment operator's insides should look very much like your copy constructor's insides.

Duoas 1,025 Postaholic Featured Poster

Salem is right. I almost said something about that myself but it has been a while since I've used select() and I forgot you aren't waiting on stdin (even though your comments say you are).

To wait on the FIFO, your call should be retval = select(i+1, &fd, NULL, NULL, &tv); Typically, file descripter variables are named something like "fd". A file descriptor set variable is typically named "fds".

Hope this helps.

[edit] Oh yeah, also remember that you can't read anything until something is first written.

Duoas 1,025 Postaholic Featured Poster

"Overloading" (at least in C++) means that you have more than one function with the same name. In this case, you have three different constructors, but they all have the same name.

The difference is the number and type of arguments it accepts.
The first takes no arguments, so it is the default constructor.
The second takes a list of values to initialize the class, so it is an initializing constructor.
The last takes a reference to another object of the same type (or 'class'), and copies its values, so it is a copy constructor.

In the body of the default constructor, you gave all your object's variable fields default values.
In the body of the initializing constructor, use the arguments to assign values to your object's variable fields.

Keep in mind that since the argument and the field names are identical, you must use this to refer to the object's fields: this->Donation = Donation; Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The only two things I see that are guaranteed problems are first in EnterName(). You should input text using getline().

void WordRead::EnterName()
{
	cout << "Type in the text file path you wish to read: ";
	cin.getline( theFile, 1000 );
}

And second in LoadFile(), your loop will never terminate if you never hit EOF (which can happen if a read error occurs). A better idiom is to terminate if the istream indicates any failure.

for(int i = 0; myFile.good(); i++)

But you've also got another problem. Even if you hit EOF, you still try to add a character to the end of your vector. As an added note, using the class variable ch is much slower than using a local char variable. Below I suggest something better for you.


You should really consider making use of the STL string library. That will make things much easier, and you'll get better performance than a vector of char.

I think you need to work on your variable names also... Variables should be nouns, and functions should be verbs. Both should be descriptive of what it represents.

...
#include <string>

...

private:
	// This is more descriptive: it tells you it is the
	// file's -name-, and not some other thing.
	string theFileName;
	// Fine
	ifstream myFile;
	// Again, this tells you that it is the file's text.
	// 'load' is a verb, and is doubly confusing when
	// used anywhere other than in LoadFile(). …
Duoas 1,025 Postaholic Featured Poster

If you are using the Express edition, you can't.
If you purchased VS, then call the MS support and ask.
Sorry.

Duoas 1,025 Postaholic Featured Poster

The FIFO will never have input until you write something to it. Since you don't write anything to it, select() will always say that there is no input waiting.

Remember, a FIFO must be open at both ends (which you have done), and to read data you must first write data (which you haven't done).

Hence, the first example works because you write, then read. The second fails because you never write before select()ing to read.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

You have discounted newline conversions.

On Windows, the newline character represents the ASCII sequence CR LF.
When your program reads it, it gets '\n'. The newline is encrypted thus and so the output file is shorter than the input file, because the encrypted data doesn't have as many '\n's (if any) as the source.

You'll also notice that when it says File Length: that it gives the shorter size.

When decrypting, you get back that '\n', which is written to file as CR LF, thus increasing the output file size (back to the original size).


Some observations:
<conio.h> is evil.
Use functions.


Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I think you need to spend some time tracing through your algorithm. I'm not sure exactly what it is supposed to do, but I don't think it is doing what you want it to do...
(Given "HELLO", the list it builds is H, E, L, LL, ...)

In any case, your problems are with strncpy().
There is no guarantee that the result string (aux) will be null-terminated, and the way you are doing it, it definitely will not be null-terminated. Make sure to put a '\0' at the end of the string.

Hope this helps.

PS. I know some libraries (notably MS) typedef away *s from pointers, but that is really bad style. If you are using a variable, you should not have to find a typedef to know whether it is a pointer or not, and it makes reading the code harder. It took me a minute to verify that the last three lines of Insert() were doing what they were supposed to be doing...

Duoas 1,025 Postaholic Featured Poster

Ah, it is because seating is declared as a 2D array, but you are only indexing one dimension. Hence the error.

Did you mean to treat seating as a 1D array in your function? I'm not sure how you are trying to index the seating array in your function...

If I am reading it right (from just a quick glance over your code) it should be: if(seating[openRow][openSeat + potential] == '#') Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The compiler believes that seating is an integer. The OP placed the cast there to try to get rid of the error message.

Can we see the class definition where seating is declared? Is there anything else between the class and the variable? Did you #include the header in the .cpp file?

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

C++FAQ-Lite 13.15

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I don't know how you got that far...

You never initialize coeffs. You must set its length before playing with any elements. Or push elts onto the end.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

OK, I told you I'd get you an example. I don't want to spend a lot of time finding the libraries to do it and coding one, but I do have an old program I wrote many many moons ago, when I was still new to programming. It is in Turbo Pascal, but you can translate the important parts to Turbo C++ easily enough. Just a couple notes for you:

  • uses Graph; corresponds to #include <graphics.h> Individual Borland graphics routines are named similarly (I think TC puts them all in lowercase though).
  • foo^ is the same as *foo
  • ReadKey corresponds to getch
  • { and } correspond to /* and */
  • Mark and Release are old Borland heap control procedures. I don't think TC has corresponding procedures... better for you to free() the image data manually.
  • The arrow keys move the background around. ESC quits.
  • The procedures of interest to you are: InitiateGraphics, FlipPages, ClearPage, and the main code block.
  • It is fairly heavily commented in my newbie style.

Ok, so here it is. (I use 80 column limits, but DaniWeb is shorter, so what you see following looks messy. Just click the "Toggle Plain Text" button to cut and paste something more readable.)

program GPImage;
uses Crt,Graph;
var
  GraphDriver, GraphMode    : integer;                { hardware refrences }
  WX1,WY1, WX2,WY2, MX2,MY2 : integer;{ window x1,y1, x2,y2, center of scr }
  CurrentPage               : integer;      { active, hidden graphics page }

  IMAGE_SIZE …
Duoas 1,025 Postaholic Featured Poster

I don't know where you read that, but they're wrong. Multiple display pages is a hardware feature, so you can use it no matter what programming language you use.

Give me a little bit to provide your example..

Duoas 1,025 Postaholic Featured Poster

Dev-C++ uses MinGW.

And AD only said he has seen the problem, not that he tried compiling OPs code.

The problem likely stems from the 16-bit executable trying to do something in a way that XP doesn't like. It is picky about stuff like that. I've re-written old programs to compile with a modern compiler just so they would run properly.

What it sounds like is that the program is not terminating properly, and the DOS emulator (that comes with Windows to run 16-bit applications) is snagging it in memory because of that.

I could be totally wrong. Let me give it a compile and see what happens...

[EDIT] It behaves properly for me on XP using GCC 4.x.

Duoas 1,025 Postaholic Featured Poster

It has been a long time since I played with BGI graphics, and I did it in Turbo Pascal. If you want I'll whip something up to demonstrate page flipping... This is a standard technique, often called "double buffering".

Duoas 1,025 Postaholic Featured Poster

Here's a wild stab in the dark: you are using a really old compiler like Turbo C.

If I'm right, then you should visit one of the following and get yourself a compiler that makes 32-bit executables:
http://www.mingw.org/
http://www.turboexplorer.com/
http://www.microsoft.com/express/vc/

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

It has nothing to do with the function. It is flashing because the DOS emulator is lagging when your code updates the screen.

Now that my brain is working, though, if you are trying to do animations stay away from cleardevice().

There are two little functions to set the active page and the displayed page (I don't remember their names right now... but you can look them up).

The trick is this:
1. set the active page to whichever page is currently hidden
2. clear, draw, etc... whatever you need to do to create the next frame of animation
3. set the visible page to the active page
4. rinse and repeat

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

Using the old BGI functions you are pretty much out of luck... Sorry.

Are you using an old Turbo C compiler or are you using the WinBGIm package?

Duoas 1,025 Postaholic Featured Poster

You only made one error:
1. Tests to see if the variable trial is evenly divisible by the next prime number in the array
2. yep
3. yep
4. yep

C++ has a native boolean type (bool, of course) but in C-related languages any non-zero value is considered true. Hence, saying: if (foo) is exactly the same as saying: if (foo != 0) (or in C++: if (foo != false) ).

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I agree. If it isn't a boolean value, I (almost) always state the condition explicitly.

C, and consequently C++, lend themselves to a lot of "shortcuts" in style. After a while you will get used to looking at the funny jumble of punctuation and understand it easily enough.

Some people, however, like to take it waaay past readability. Ever hear of the IOCCC? It's enough to make anyone's head swim.

Sure is fun though. :)

Duoas 1,025 Postaholic Featured Poster

Every version of python I've ever gotten (including the last three) came with DLL files.

C:\WINDOWS\system32>dir python*.dll
 Volume in drive C is Ceres
 Volume Serial Number is 0000-0000

 Directory of C:\WINDOWS\system32

02/08/2005  05:23 PM           979,005 python23.dll
10/18/2006  09:35 AM         1,871,872 python24.dll
02/21/2008  01:11 PM         2,117,632 python25.dll
               3 File(s)      4,968,509 bytes

You are using Windows, right? Because Linux doesn't use DLLs natively.

Duoas 1,025 Postaholic Featured Poster

You've got the general idea.

The % sign is the modulo (or remainder) operator. So what it is saying is:

"If the number I am looking at (trial) divides evenly by the indexed prime (which should have been written as primes[ [B][/B]i[B][/B] ] to be less confusing), then we have found a composite number."

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I think by this point AD is tired of answering the same question the same way again and again and again...

If you want the machine code for the function, tell your compiler to output the assembly code, chop off everything except the function, and run it through your assembler, or plug the opcodes directly into DEBUG (and the DOS prompt) and save the codes to file.

Duoas 1,025 Postaholic Featured Poster

That was just an example function I created. I expected that you would take the code you needed from it and put it in your own function.

I don't think that TTextBox::Text takes a std::string, does it? You might have to say textBox1->Text = found.c_str(); Hope this helps.

zandiago commented: congrats on featured poster +6
Duoas 1,025 Postaholic Featured Poster

There is no particularly 'easy' answer, but you can use the STL to do it:

#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <deque>

// Our dummy class
template <int n>
struct column_n_t: public std::string { };

// Our dummy class input extractor
template <int n>
std::istream& operator >> ( std::istream& ins, column_n_t <n> & c )
  {
  std::string s;
  std::getline( ins, s );
  std::stringstream ss( s );
  for (int i = 0; i < n; i++)
    ss >> s;
  if (!ss) s.clear();
  c.assign( s );
  return ins;
  }

// A convenient function
template <int n>
std::deque <std::string> extract_column_n( std::istream& ins )
  {
  std::deque <std::string> result;

  std::copy(
    std::istream_iterator <column_n_t <n> > ( ins ),
    std::istream_iterator <column_n_t <n> > (),
    std::back_insert_iterator <std::deque <std::string> > ( result )
    );

  return result;
  }

Now to extract column three from the file:

std::deque <std::string> column_3 = extract_column_n <3> ( myfile );

This only works if you know which column you want to extract (3 is a constant) and if you know for sure that whitespace only appears between columns.

If either one of those preconditions are false some slight modifications will need to be made.

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

The string class does have methods specifically for doing that sort of stuff.
But you can use the standard algorithms just as easily.

#include <algorithm>   // needed by using_iterators()
#include <cctype>      // needed by using_iterators()
#include <functional>  // needed by using_iterators()
#include <iostream>
#include <iterator>    // needed by using_iterators()
#include <string>
using namespace std;

//------------------------------------------------
void using_iterators( string s, string w )
  {
  string::iterator i = search( s.begin(), s.end(), w.begin(), w.end() );
  if (i == s.end())
    {
    cout << "iterators> The text did not contain the word '"
         << w << "'.\n";
    return;
    }

  i = find_if( i +w.length(), s.end(), not1( ptr_fun <int,int> ( isspace ) ) );
  if (i == s.end())
    {
    cout << "iterators> There is no text following the word '"
         << w << "'.\n";
    return;
    }

  string::iterator j = find_if( i, s.end(), ptr_fun <int,int> ( isspace ) );
  string found;
  copy( i, j, back_insert_iterator <string> ( found ) );

  cout << "iterators> The word following '" << w << "' is '"
         << found << "'.\n";
  }

//------------------------------------------------
void using_indices( string s, string w )
  {
  string::size_type i = s.find( w );
  if (i == string::npos)
    {
    cout << "indices>   The text did not contain the word '"
         << w << "'.\n";
    return;
    }

  i = s.find_first_not_of( " \t", i +w.length() );
  if (i == string::npos)
    {
    cout << "indices>   There is no text following the word '"
         << w << "'.\n";
    return;
    }

  string::size_type j = s.find_first_of( " \t", i );
  string found; …
Duoas 1,025 Postaholic Featured Poster

The best way to do that is to use a visual trick.

Capture an image of the button. (You can do this by using GetWindowDC() on your form, then using BitBlt() to transfer the image of the button into a TImage canvas.)

Actually hide the button.

In your form paint, draw the image of the button. Every few score milliseconds or so adjust your image to have more of the form's background color and repaint.

There are a number of ways you can fade the colors of an image with another given color with the Win32 API or by directly manipulating the pixel data yourself...

Hope this helps.

Duoas 1,025 Postaholic Featured Poster

I've never used Dev-C++, but it should have a Windows MediaPlayer component that you can drop on your application, and use it to play the MP3.

You can also google "msdn media control interface" for the APIs you can use to manipulate media devices on Windows.

Good luck.

Duoas 1,025 Postaholic Featured Poster

If I remember correctly the Foo tutorials instruct you to get the pre-compiled binary DLLs.

It should have come with some header files. Did you put them in the include path? Did you tell VC++ where to find the lib files? Did you link with the SDL DLL?

Duoas 1,025 Postaholic Featured Poster

I've seen far worse code... (and I've always gotten myself into a lot of trouble by 'complaining' about it --even when it was obvious that it was costing the company thousands of dollars in delays and workarounds).

It might be worth suggesting to the prof in charge that he consider a term (not now, but in the future ;) ) where a small group of students cull and clean the code, then identify simple refactorings and do them. Tell him it will be good experience for them (if they want it), and it will make it faster (probably true) and smaller (also probably true). If you can show that it breaks under common conditions you can also argue that the effort would increase the program's stability and security.

But for now, don't worry about it. You can't be responsible for the mess. You can only not contribute to it. If you get into making it better you'll just give yourself a headache and produce dissatisfied evaluations of your performance (because you spent your time doing something other than what you were supposed to do).

The best way to get used to the code is just to get a local copy of it and start trying to change things. After playing around with it for a short bit you'll have a pretty general idea of where things are and what you have to do to make modifications. Then you can check out the current copy and start adding/modifying …

Duoas 1,025 Postaholic Featured Poster

I know next to nothing about databases (because I really don't like messing with them).

But I wonder, being separate forms, are you using a separate connection to the database in each form?

It sounds to me like the second form is trying to modify something that is locked by the first form.

That's my wild stab in the dark.