jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Posters with such disregard for order probably won't read the sticky, either. I feel your pain, but the only solution to this one is mild electric shocks through the keyboard.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Votes need to be spaced apart by 10(?) seconds. If you do it any more rapidly than that, you have to refresh the page. This is done to prevent scripts, bots, your sister, etc., from rapidly down or upvoting posts.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

sorrrrrrrrry!

It's my bad, I was a poor role model when I was trying to be a smartazz.

Don't worry about WaltP, as long as you don't walk on his lawn he won't press charges.

mitrmkar commented: Mmm, are you sure about WaltP?? +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm currently working on recoding all of DaniWeb from scratch

Editing for high rep users? ;) Just kidding, I know when to quit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

All I know is that Yankee Doodle came to town riding on a pony. My guess is, it was a big pony, or he was a small man. I don't know about Washington's arrangements.

I've lost 10 minutes of my life asking myself some pretty pointless questions.

Whatever it takes to get you to stop posting... ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Just omit the break in the middle. Switch statements "fall through" until they reach a break;

case 'a':
case 'A': //do stuff here
break;
FriXionX commented: fast help, thanks. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

NubTruck's approach is correct if you have a Win32API application. I was asking about that because if you were using a different GUI API, the approach would be different.

If you are using the Express Edition of Visual Studio, it is "missing" a resource editor (resources being all the "baggage" your application can carry, icons, bitmaps, etc.). You have to generate your own resource scripts to be fed into the resource compiler that does come with the EE.

Something like http://www.resedit.net/ (not affiliated with this product) gives you back that resource editing. Have a look at that. Regardless, I would take Nubtruck's advice and take a few steps back in that tutorial to see where you first stopped understanding. If you are going to get into this sort of thing, the fundamentals are important.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Does your program run in a window, or is it a command line program?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I used Qt_SDK_Windows_online_v1_1_en . There may be an updated version by now.

A brief runthrough of what I think I selected for install:

Uncheck APIs (counterintuitive, but unless you're doing mobile development, not needed)

In Documentation: Get rid of Qt Mobility and Symbian (if you're just doing PC development)

Miscellaneous: Check Mingw 4.4 (Examples and sources if you need them)
Development tools: Desktop Qt: this is the meat of it, select Qt 4.7.3 (or latest), check the third option down off of that to get the mingw version (no need to take the Visual Studio version if you don't need it, that will save you a ton of disk space)

Uncheck Maemo Toolchain (unless you need these compilers, but they are also for mobile development -- I think it puts all of these on the path, which gums up trying to use the regular compiler)

Try it with that, and babysit the error messages, as if you have a firewall/antivirus all of the command line programs it's running in the background will drive that AV program nuts (and Qt is a reputable product), so you may need to turn it off. If it doesn't take a long time to install, something is wrong, because this is a mammoth.

sDJh commented: thank you! +6
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's a lot of stuff included in the default installation that's for embedded systems. I remember Qt getting confused between the embedded compilers and the actual gcc installation, so I removed the embedded ones (I think this was mainly an issue in QtCreator). I also seem to remember a permissions issue being a problem (and having to turn off my security program for the duration of the install). If either of those two ring a bell, you may want to reinstall.

I don't know anything about backwards compatibility issues, but I would trust that the version of mingw that it comes with can handle all the switches that their "make" tries to throw at it (and there's a ton, if you do a verbose run of the make). I don't know how well the different versions get along.

Try that out and see if it improves things.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is your question?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It looks like you have somewhere around Qt 4.4. There is now Qt 4.7 which comes with mingw 4.5, which is much more up to date. It could be a corrupt installation of mingw, so reinstalling your version might help, but try the latest version.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Get rid of lines 4-7. You can't have 2 mains in your program. It can't find the .exe file to start it because the code is not compiling successfully. Monitor the messages at the bottom of the Visual C++ screen to see the errors in your compilation. Double click on them to bring you to the line that has the error.

This is in no way your fault, Microsoft is trying to generalize main to be able to handle different encodings, and it's confusing as all get out when you're first getting started. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are the error messages?

(it looks like you're missing the std:: qualification on cout, endl etc. The best way to deal with that in your case is to put

using std::cout;
using std::endl;
using std::cin;

at the top and leaving the rest of the code alone. Note that you could use a blanket using namespace std; at the top, but that's a bad habit to get into, as it pollutes your namespace, rendering all of the hundreds of names housed in std:: unusable for anything else, or worse, causing conflict with your functions and variables of the same name.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Read Wikipedia's explanation of encapsulation to see some of the philosophy behind it.

You could certainly make it public, but what if you want people using your classes not to have to muck around with those things. As an example, what if you wanted to change the way you stored the member variables? If they are private, all you'd have to do is modify getdim() and you'd be good to go. Everyone could access the values like they always did. If the member variables were public, you'd need to modify each time they are used in the code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

getdim() is declared as public in the base class, and the inheritance is public, so the derived classes will have access to this method (as public).

This method retrieves the values of the dim1 and dim2 variables by reference. In triangle and rectangle , the values of d1 and d2 are passed into the method, and are assigned the values of dim1 and dim2 respectively.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So now just use the .c_str() to get back the const char * representation, cvLoadImage(line.c_str());

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure why you're using anything but fstream across the board to do your file reading. See http://www.cplusplus.com/doc/tutorial/files/ for a good tutorial. Do everything C++ style up until the last step, once you have your std::string and have done all of the necessary manipulations, only then use the .c_str() method to finally pass it to the OpenCV function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Read training.txt into another vector of strings, call it trainingVec or something.

Return just personNames[nearest-1] (so you have it in a std::string representation.

Step through trainingVec, using the .find() method of each of the strings to see if it contains personNames[nearest-1] If it does, use .find() on that same element of trainingVec to locate the '/' , and using .substr() to grab the portion of the string after '/' .

Then, use the .c_str() method to convert to a C-string for use in the OpenCV function. That way, the mainstay of your manipulations can be done with the std::string .

Probably clear as mud, so take a crack at it, and post back with your revised code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes. All of the controls have an .Enabled property that will allow them to be active or inactive (grayed out). You can also use the .Visible property to take them out of the form temporarily.

Having the logic carried out in a particular order could be done simply by checking to see if there is anything in the TextBox.Text property before allowing the user to change the radiobutton, or as sophisticated as setting a boolean variable during one of the Textbox events, and ultimately checking if it's true in the CheckChanged event of the radio button.

Start playing around with some of the simpler aspects of the UI (how do I gray out or hide one button by pushing another), or if you're beyond that point, take a crack at some of what you describe and post back with specific problems.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster


He had too few Geek genes

Perhaps he should have tried khakis.

jingda commented: lol +0
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

From the member rules

Keep it Clear
-Do post in full-sentence English

Since you are on the thread already you can remind the user that this is the case.


Otherwise the punishment is being forced to interact with the site using a 1980 Motorola cell phone with a one line screen.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Up in the middle of the Form1.h where all of the pictureboxes, etc. are declared. Add:

private: Bitmap ^ map;
private: Graphics ^g;

Make a method:

private static void resetGraphics()
{
   map = gcnew Bitmap(375,307); //though you should code these based on dimensions of 
                                //your pictures
   g = Graphics::FromImage(map);
}

And in your form's constructor, call resetGraphics();

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's going to be some difficulty right off the bat when you are mixing the unmanaged C++ (the std::vector ) and the managed form (which uses an offbeat dialect of C++ called C++/CLI, so some of the data structures and syntax are different).

The GUI uses something called event-driven programming (which isn't unique to Winforms, most GUIs use it in some way), but essentially, you're not moving through your code linearly, you are doing something in response to someone clicking a checkbox, typing in a textbox, or clicking a button. So, rather than getline, you could, for example, have the user type something in the textbox, and once they select a radiobutton, your code will read the text into variable xyz.

Instead of using a vector (which is theoretically possible, but requires some juggling in most cases), you should use a cli::array (see http://www.functionx.com/cppcli/index.htm) for some decent tutorials) or a .NET List object.

So, that's probably a lot to digest... A lot of the good tutorials for .NET are written for C#, but you can still reference them, as the classes and member methods are all the same, except for the -> and :: notation used in C++ with pointers and namespaces.

Post back as you run into any issues.

ddanbe commented: Nice explanation, but I still hate the word GUI! :) +14
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you declare Map and g as private member variables of your form, you can make a function that instantiates them (sets the values to gcnew Bitmap(375,307) and Graphics::FromImage(Map) respectively. Call this function once from the forms constructor, and any subsequent times you need to "clear" your map. In unmanaged code, any subsequent calls to the function would cause a tremendous memory leak, but the garbage collector will free the memory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Paste in one of your case statements and a screenshot of your control (if available), and someone should be able to run you through it. You might be able to shortcut some of your logic based on the characteristics of the controls.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm having a hard time finding information on it with examples for C++.

Yes, this is a chronic problem for doing winforms in C++/CLI. You're best bet is to look for similar C# examples and translate them, as it's really the same .NET framework for both. One of the best I've found is here.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry it took me so long to get back. I had tried to reinstall VC++ 2008 on my computer so I could get better intellisense, but I wasn't able to, so I cobbled this together in VC++ 2010 today.

I never liked to mess around with the Paint handlers unless I knew I was redrawing something over and over. You end up having to invalidate it to get it to redraw.

I'll give my rationale in the comments, you may need to retool this a bit to get what you need.

int combinedwidth = pictureBox1->Width + pictureBox2->Width;
int maxheight = Math::Max(pictureBox1->Height,pictureBox2->Height);
//this assumes the pictureboxes will be mapped right next to each other
//so grab the combined length and get the highest height


Bitmap ^ bmp = gcnew Bitmap(combinedwidth,maxheight);
//We're going to draw on this bitmap

Graphics ^ g = Graphics::FromImage(bmp);
//create a graphics instance and link it up with our premade bitmap

Rectangle rectpb1 = Rectangle(Point(0,0),pictureBox1->Size);
Rectangle rectpb2 = Rectangle(Point(pictureBox1->Width+1,0),pictureBox2->Size);
//Since the 2 original bitmaps had been scaled down to fit the pictureboxes, I'm //building two rectangles the same size of the picturebox, but 2nd is offset the //width of the first picture
//Obviously you can determine the offsets directly from the variables if you need to

g->DrawImage(pictureBox1->BackgroundImage,rectpb1);
g->DrawImage(pictureBox2->BackgroundImage,rectpb2);
//Draw the images right onto the graphics instance

bmp->Save("C:\\Users\\XXXXX\\Pictures\\workofart.jpg");

See if that overall technique works better. Before this code, I had preset the jpgs to the BackgroundImage property of the pictureboxes, and used ImageLayout::Stretch so they were …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where is the code for the overloaded operator? Please make some attempt at that code and post back.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

to save the images in more then one Picturebox at a time?

I'm assuming you're doing this as a winforms project? (it seems like that, but there's some ambiguity).

To save more than one picturebox into a bitmap at a time, you're going to have to make a Graphics instance and assign a bitmap to it that that has dimensions big enough to hold all of picturebox images.

You can then use Graphics.DrawImage to place each of those images from the picturebox into the bitmap and save it out like you indicated in your post.

Post back if you're not using Winforms to do this or if any issues crop up.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm still having a hard time understanding what information you are after. I recommend that you pick a basic tutorial (could even be Wikipedia) and get a basic feel for the language. Once you've done that, you will no doubt have specific issues, and you can post those to your heart's content.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go to the designer and select your form. Go over to the properties window and select the lightning bolt (to get the events). Find "Form closing" (not "Form closed") and double click the cell to the right of it. This will put the event handler code into your Form1.h and you can flesh that out as you see fit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you don't rework insertNode() like I was saying, of course it's not going to sort. Get the insert procedure correct and the deleting will be trivial. Do you have access to a debugger? (I don't remember how good the one was in VC6). You need to step through your code and watch as the nodes are added. I've given you a pointer, but I'm not going to rewrite it for you. Take another crack at it and post back your new insertNode() function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You reset head pointer to null on line 38. Why? It's guaranteed to follow the path of that first if statement each time, and what if there already is a valid head pointer? (hint pass it into your function) That may not be the problem, but it's one of the first places I would look.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Line 28:

newNodePtr->pengarang = pengarang;

You are only copying the pointer over, not the contents of the string. Use strcpy(newNodePtr->pengarang,pengarang); instead (or better, since you don't know how large your source string is, use strncpy).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What is the partations of c++?

Please clarify what you mean by "partations".

What kind of programmes I can built with?

Go through some open source projects and see what languages they use. Something like this can give you some idea

And why it's the best programming languages?

That's a highly subjective question. It's definitely not the best choice in all situations.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What was the code that you were using for the bubble sort, and where did you place it?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, only high school kids from Singapore... ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have a look at this (there's a nicer version for VS 2010, it's probably virtually the same set of keybindings).

Mr. K commented: THanks Jonsca +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have a question as to why you are displaying in your add method. Your add method should do nothing more than add the two numbers together. You may want to check with your specification to make sure that your code is not supposed to add the two together and return a reference to a third number. Either way, though, your display should be separate from your operations.

Seeing if your imaginary portion is 0 takes an if statement in the display function. If you want to choose which form to display (,) vs a+bi, I would say add a parameter to your display function (with a default value of one way or the other) which governs how the output is printed.

Otherwise, you need to be a bit more specific rather than saying "need something here." You are the one that knows this program best at this point, you need to present it to us as if we've never seen it before.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Posting your question on multiple sites is inconsiderate.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Better you must read it properly....

Better you reread the thread because you don't seem to understand the clear explanation that Narue was giving about undefined behavior.

Killer.bee commented: Ohh i think you need to rereas -1
Nick Evan commented: counter. +16
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The game board is the tricky part because it's not square. It's probably most convenient to make it a square and then do bounds checking to make sure the move you are going to make is still on the board. You should probably do this in the move function with a series of if statements. You can also adjust your board within the move function.

Your displayboard function doesn't make much sense. Just output it using a loop like you were trying to do in the main function. Adjust the bounds on your for loops to print out only the valid portions.

Keep going with it, and test it incrementally to make sure all of the parts are working before moving on.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

By virtue of C# being the more prevalent .NET language, most of the tutorials don't use the C++/CLI syntax. You're better off looking at a C# site like http://www.c-sharpcorner.com/Articles/ArticleListing.aspx?SectionID=1&SubSectionID=167 and trying to translate the syntax (sticking in :: and -> when needed).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What steps have you taken in starting to solve the problem? Have you decided on how you will represent the board? Are you going to use classes? These are the things you need to think about and start sketching out on paper even before you begin. Write as much of the code as you can, and post back with specific issues.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Good to know. I'll have to keep my eyes out for some guidelines about this kind of thing. I'm starting to figure out a bit more about the optimizations of the managed code and the juggling act that goes on with the unmanaged pieces, but in terms of the settings it's confusing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What /clr setting do you have set for the compilation? If you don't have any on there, it will try to compile your code as native.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not familiar with C#

All you have to remember is that C# used '.' for both namespaces (which would use '::' in C++) and member variables/methods (which would use either '.' or -> to access a class/struct depending on whether the variable is a pointer or not).

I agree with AD, if you're using C++/CLI, use the available methods in .NET.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Delete line 5 of Form1.cpp and move lines 20-24 out of Form1.cpp and into a new file xxx.cpp. It shouldn't make that much of a difference, but it's good to keep Form1.cpp clean.

I had told you that in xxx.h, you need to qualify String^ as System::String^ as the compiler has no notion of it otherwise.

System::String ^ParseBBCode(System::String ^OriginalText)[B];[/B]

(you didn't have the semicolon after the declaration, but I'm not sure if that was a typo.

emanfman commented: you helped very much. thank you! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're calling the function in Form1.h, correct? As long as your .cpp file is part of the project, everything should be fine. No, do not move the body of the function to the header.

It's confusing because in the Winforms programs, the Form1.h also contains a lot of definitions. If you have included the one line header in Form1.h, are calling the function in Form1.h, and have the associated .cpp file with the body of the function as a part of the same project, you've done all you need to do.