Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

@nbaztec: The += operator does not work with integers.

1) ListBox is most likely a private member of MyProgDlg.cpp and is therefore unaccessible outside that class.

2) CString class has a Format() method whose parameters are identiacal to sprintf()

CString str;
DWORD dbIndex = 123;
str.Format("Line# %u", devIndex);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look at that CppSqlIite project and header file. execScalar() returns an int, not a string. Therefore strcpy() will not work. Read this and find out how to get the result set after the query. (that's the same link you posted in your original thread starter post.)

And you need to add SqLite3.cpp to your program's project because it has to be compiled along with your program. You could make it a library if you want to, but that isn't necessary if you are using it for only this project.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

which government (country)?

In USA you have to take a Civil Service exam in order to get a job with the US government. See your local Civil Servie to get that exam. Here's a link

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Under Windows 7 you will get that error if you are not the one who created the folder in the first place. Log into your computer as Admin account and you should be able to delete the folder. If not, then (again running as Admin) change the folder's properties and set its ownership to you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First use Microsoft's memory diagnostics tool described here to verify the computer's ram is ok

If that's ok then check the hard drive for errors -- click here.

If there are no errors there either, then most likely its a problem with the program you are running. I'd go back to the manufacture and ask them if there is a compatability issue with Windows 7 operating system.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, run an antivirus program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Of course it doesn't work.

Since you can't rewrite the file, the only thing I can suggest is when the file is originally written pad each line with spaces at the end to make room for the new data. So instead of

"1 2"

you would have written

"1 2             "

Then you could do something like this:

int main()
{
    std::string line;
    size_t offset = 0;
    std::fstream out;
    out.open("TextFile.txt", std::ios::in | std::ios::out);
    // add 9 to the first white space in the second line
    if( !out.is_open() )
    {
        std::cout << "Error opening the file\n";
        return 1;
    }
    // read the first line
    std::getline(out,line);
    // get the offset to the beginning of the line that 
    // I need to rewrite
    offset = (size_t)out.tellg();
    // read the line that needs to be updated
    std::getline(out,line);
    // find the position of the last space in the line
    size_t pos = line.find("  ");
    line[pos+1] = '9';  
    // back to the beginning of the line that 
    // needs to be updated
    out.seekg(offset,std::ios::beg);
    // rewrite the entire line
    out << line;
    out.close();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, that is correct.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have my sympathies on your job loss. A lot of companies are screwing over their older works for the very reasons you suggest. And the IT field is not immune. I've heard a lot of horror stories about age discrimination in the IT industry. Anyone over about 25 is a hasbin for many companies.

You will find yourself at a very very big disadvantage if you do not have a college degree in IT field. For entry level position certifications are not very important -- many companies don't even look at them.

The most important thing you can do is get that bachelor's degree in IT. If you already have a bachelors in some other field then go back to school and get another one in IT. And at your age you might even want to get an MBA.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sizeof(*np) is NOT dereferencing the pointer. The sizeof is an operator that is expanded at compile time, not runtime. *np is just getting the type of object that np was declared as, in this case struct nlist. sizeof(*np) is just another way of saying sizeof(struct nlist). Programmers like to use *np there so that the sizeof operator will be correct for anything declared as np -- such as if you change it from struct nlist to int.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't think so.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ok, got this figured out. You need to code a copy constructor for class win which will be called for push_back into the vector of win objects.

Whether it works the way you want it to, I don't know. But I got it to run without crashing.

class win
{
public:
    win(COORD org , COORD size, winStyle ws)
    {
       allocbuffer(org,size,ws);
    }
    win(const win& w)
    {
        allocbuffer(w._org,w._size,w._ws);
    }
    ~win();
    void addElement(CUIelement x){}
    const CHAR_INFO * getBuffer(); 
    void drawWin(HANDLE hOut);
    winStyle getWinStyle();
private:
    void allocbuffer(COORD org , COORD size, winStyle ws);
    CHAR_INFO * _buffer;
    COORD _org;	
    COORD _size;
    winStyle _ws; 
};

void win::allocbuffer(COORD org ,COORD size, winStyle ws)  
{
    _org = org;
    _size = size;
    _org = org;
    _buffer = new CHAR_INFO[size.X * size.Y];
    for (int y = 0; y < size.Y ; ++y) {
        for (int x = 0; x < size.X; ++x) {
            int offset = x+((size.X-1)*y);
            _buffer[offset].Char.AsciiChar = 0x23;
            _buffer[offset].Attributes = fWhite;
        }	
    }	
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program is trashing the stack and/or the heap somewhere. I compiled with vc++ 2010 express and it get assertion error when exiting the program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Does Tom Hudgson = Glass Joe?

Must be nice to get paid for playing games :)

Do you know if its available on MS-Windows 7? Or just PSN and Xbox Live? Oh well, its probably too difficult for an old man like me anyway. I have yet to play Donkey Kong :(

Glass_Joe commented: Haha too funny +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably yes. Why don't you just try it and find out for yourself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a better insertion sort algorithm

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You will most likely have to write your own sort algorithm and swapping, so that you can keep both colums together when a swap is needed.

If you have never written a sort algorithm, then I will suggest the Insertion Sort, because it's the easiest to implement, even though it might be the slowest to run.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

breakpoints do not tamper with windows focus, but does screw up keyboard focus. If you're trying to type something and a breakpoint occurs then the keyboard focus is lost. Yes, I've encountered that situation.

I've use Micirosft compilers (vc++ 6.0, 2005 and 2010) to debug lots of difficult programs, including client/server, DLLs and ActiveX controls. I've never encountered a situation in which it was impossible to use a debugger. Sometimes it may have been more convenient to use debug messages or debug logs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Where does IsValidReadPtr exist? I can't find it with google. There is an IsBadReadPtr(), but M$ says its obsolete and not trustworthy.

>> is there a function which says "Yes
There is Microsoft's IsWindow(). Other than that -- no.


[edit]Oh I think I know where you found IsValidReadPtr -- in one of Microsoft's header files. But that is a macro which uses the now obsolete IsBadReadPtr().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And I'd like to have Bill Gates' $65 Million home :) (Actually not -- taxes and utilities are too expensive).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is why Obama got the Peace Prize. Most Americans also wonder why he got it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb.

Interesting -- how did go from electronics to patient research?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just because it "could" create circular references doesn't prevent the coder from including the header file when you know that it won't.


>>If you did not include this header you can not access Form.h objects/code regardless of private or public.

Of course not -- that's just normal C/C++. Actually, you wouldn't be able to use the form at all for anything if you don't include the header file.

I don't actually like the idea of changing the access type from private to public, but then I'm not the one writing the program. IMO it would be better design to write a public method in Form1 that updates all its image controls, then call that public method BOARD_Unselect_All(). That way the data in Form1 can remain private.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what link? The link I posted here? (I hate not having post numbers in these threads any more :(

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you talking about precompiled header files? Both Microsoft's VC++ 2010 (and earlier versions too) and g++ support that (other compilers might too, I don't know). You have to create a header file that includes other header files as well as function prototypes, constants, classes, structures and externs. Then you just have to include that header file in each of the *.cpp files. It makes compiling large projects a lot faster because the compiler will not process all those header files for each *.cpp file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

didn't you bother to read the thread???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> think you again forgot that this is a c forum

I must be losing my mind in my old age :(

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>makes no difference if the code is private or public in a class, you can not access this code outside the class it is in.


Wrong. See the code snippet I posted -- which I tested before I posted it. The objects in Frm had to be made public in order for that to work.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You mean you can't send/receive files using Windows Explorer? If not then how are you trying to do it?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably this boost library

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Now how do you think you can change the two lines I previously posted so that it also prints out the line before the break statement?


>>ancient dragon==pure knowledge)
Only because I've been doing this sooooo long (about 25 years) :) You'll get there too -- just keep at it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I hope is a reflection of the amount of work and time I have spent helping other people in the C and C++ forums. It doesn't reflect a thing in Community Center because all we get there is either up or down votes without actually affect anyone's rep points. And since this thread is in Geek's Lounge I'm not concerned about affecting anyone's rep points with my down vote(s). I down vote a little more liberally here than I would anywhere else in DaniWeb.

In other DaniWeb forums if I disagree with something someone wrote I would normally just down vote the post instead of also subtracting from his rep points -- afterall 16 negative rep points is a lot to overcome. On the otherhand, if I agree then I will most likely also give then 33 deserved positive rep points.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have already written half the program. After line 26 add some code that checks if the line just read is the one you want. If it is, then put in a break statement.

if( this is the line I want )
   break;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>If you scroll through the posts in this thread you will see that MANY of them have been unnecessarily hit with multiple negatives for no better reason than personal disagreement with opinion.

And the problem with that is what? That's one of the reasons rep system exists.

>> someone still came along and anonymously down-voted it which makes me chuckle
Apparently someone else came along and upvoted it. So now you';re even.

>> I can't see much else I'd need to contribute beyond that
Agree - this thread has run its course.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You declared the third parameter as const char*. That's why the compiler complained about that assignment.

the function prototype in the header file is wrong. GetDirectory() has three parameters, not two. The last parameter can NOT be const.

The assignment is wrong anyway. returnbuf is where you have to copy the data.

strcpy(returnbuf,db.execScalar(command.c_str()));

In the main application program

char iobuf[255] = {0};
char* return = GetDirectory("something here", "something here", ibuf);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To query a text file you have to read the entire file from start to finsh. Read a line, check if it's the one you are looking for. If it is, then stop reading. Otherwise, if it is not then read the next line.

There is no other way to do it with text files because they have variable length lines.

Binary files would have a much more efficient method of searching.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Doesn't this work? It worked for me after I made PictureBox1 public instead of private.

#include "Form`.h"
...
<snip>
        void BOARD_Unselect_All(FormsTest::Form1^ Frm)
        {
            Frm->pictureBox1->BackgroundImage = Image::FromFile("elephant_pla.gif");
        }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I didn't create it -- I had nothing to do with that web site.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what doesn't work? compliler errors? or something else?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>The bottom line is that these soldiers are adults
You have obviously never been in the US military :) adults my foot! The majority are 18-25 year olds and often need to be treated as a child. They are far away from home (mommy and daddy), alone, lonely, and have not seen their loved ones for quite some time. Young people like that get into lots of trouble (such as alcohol and drugs) if it weren't for Big Daddy military brass who carry a big stick. Even General of the Armies Dwight Eisenhower referred to them as "enlisted swine".

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

replace getch() with std::cin.get() and include <iostream> header file.

As for ebooks -- try this

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>that is the correct syntax for vb.net
The example is for C#, but vb.net and c++/CLR Forms is identical.

just replace "this" with the name of the form -- in the example you posted it would be "frm".

The unfortunate thing is that the controls are declared private to the window class, therefore you will not be allowed to change the picture from another class. But I suppose you could change it from private to public, or write a public method that wraps the private controls.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Mine has this entry

%CommonProgramFiles%\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

turbo c++ is an ancient compiler that uses obsolete c++ header files and follows obsolete c++ standards. Bring yourself into the 21st century and learn how to write modern c++ code.

That is one of the problems with learning to program using ancient turbo c and turbo c++. You switch to a modern compiler and you have to unlearn almost everything you thought you knew.

conio.h is specific to turbo c and Microsoft. Don't expect the rest of the world to follow suite.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you have already been working on it, where is the pseudocode or c++ code that you have written?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lookup the picturebox properties. What you want is probably this example

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Let's see the code you have tried.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you set up event handling functions for the controls that are on the form being passed in? If not then you need to do that because that is what makes the controls do things.