triumphost 120 Posting Whiz

Can someone please help me.. I have just figured out how to read all the values into a multidimensional array.. the thing is the table in the file can change at any time.. It can be any size.. Example:

Old Table to read (not a uniformed table, but all values print):

0 0
0 1
1 0
1 1

New Table to read (does not print all values.. not in order either):

0 0 0 0
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 0
1 1 1 1

Deformed Table:

0 6 12
1 7 13
2 8 14
3 9 15
4 10 16
5 11 17 18           //<-- See the deformed 18? table is not in uniformed rows and columns either.. so the last value never prints.

See how the dimensions of the table changed from 4x2 to 10x4? I want my program to adapt to such changes and be able to give the location of any value. Help please! I've been trying for so long.

#include <iostream>
#include <fstream>
#include <sstream>

using namespace std;

int main()
{

    int col, row, x, y;
    x = y = 0;
    row = 0;
    col = 0;

    fstream File;
    File.open("test.txt", ios::in | ios::out);
    string line;

    while(getline(File, line))
    {
        x++;
        istringstream tokenizer(line);
        string token;

        while(getline(tokenizer, token, ' '))
        {
            y++;
        }
    }

    row …
triumphost 120 Posting Whiz
for(int i = 0; i < hash_array[index].size(); i++)

//Should be:

for(unsigned short i = 0; i < hash_array[index].size(); i++)

Also you cannot compare an int to an iterator.. .begin() and .end() are both iterators..

you can actually do something like: for(it.begin(); it.end(); it++)

triumphost 120 Posting Whiz

What does your code do now?

Does it compile? Are any errors created when you run the program?

I have posted three small sample programs off the following page:

Dynamic Arrays in C++ - Some Basic Examples

They use dynamic arrays and take in numbers of type double.

Hope this helps.

My code compiles.. No errors. It tells you how many rows and columns are found in the file.. I just don't know how to grab the values and put them in the array is all.

triumphost 120 Posting Whiz

I have a file that has the layout:

0 0
0 1
1 0
1 1

I want to read it into a multidimensional array and use the values. The thing is I don't know how to read it in.. I can read the amount of columns and rows the file has.. but I don't know how to read the values.

Also I want it to make a Multidimensional array depending on the amount of columns and rows and then read them into their respective cells.. If the file only contains numbers.. How do I make it read the values in as Integers?

How do I do it?

My Attempt.. It's not homework but it's nice to know how..

#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <sstream>

using namespace std;

int main()
{
    int col, row;
    row = 0;
    col = 0;

    fstream InFile;
    InFile.open("test.txt", ios::in | ios::out);
    string line;

    while(getline(InFile, line))
    {
        row++;
        stringstream s(line);
        string token;
        while(getline(s, token, ' '))
        {
            col++;
            table[row][col];
        }
    }

         //table [row][col];
    string table [row][col];        //Create A MultiDimensional Array depending on the amount of columns and rows..

    cout <<"Rows: "<< row << endl;
    cout<<"Columns: "<< col/row <<endl;
    cout<<table[1][2];
    InFile.close();
}
triumphost 120 Posting Whiz

Hey all. I'll make this quick. I want to search for a pattern and replace it with an empty string using the boost/curl libraries OR strictly c++.. No DotNet.

The below code I have, removes HTML Tags from a file/string:

static string StripTags(string source)
{
    int iSize = (int)source.length();
    char StrData[iSize];
	int arrayIndex = 0;
	bool inside = false;

	for (int i = 0; i < iSize; i++)
	{
	    char let = source[i];
	    if (let == '<')
	    {
            inside = true;
            continue;
	    }
	    if (let == '>')
	    {
            inside = false;
            continue;
	    }
	    if (!inside)
	    {
            StrData[arrayIndex] = let;
            arrayIndex++;
	    }
	}
     return StrData;
    //return new string(StrData, 0, arrayIndex);     //DOES NOT WORK?! Don't know why..
}

But that leaves HUGE white spaces in the file where the HTML tags were..

Then I tried this, but got stuck because the code I had previously never worked even though it said pattern found.. It also said "Ran out of stack space..":

string preg_match_all(const string WebData)
{
    boost::regex expression("<(.|\n)*?>");

    try
    {
        if(boost::regex_match(WebData, expression))
        {
            cout<<"Match Found.. Replacing with Empty String";
            boost::regex_replace(WebData, expression, "");
        }
        else
            cout<<"Match Not Found";
    }
    catch(exception &e)
    {
        cout<<e.what();
    }
    return WebData;
}

The PHP Code I'm trying to emulate with C++...

preg_match_all("|<td(.*)</td>|U",$table,$rows);
 
foreach ($rows[0] as $row){
	if ((strpos($row,'<th')===false)){
 
		preg_match_all("|<td(.*)</td>|U",$row,$cells);

		$number = strip_tags($cells[0][0]);
triumphost 120 Posting Whiz

A couple things come to mind:

1. you don't have to use the third parameter; it might be better to leave it out.

http://www.cplusplus.com/reference/string/string/find/

2. I can't remember all the characters that require escaping in a string sequence...have you tried searching for something simpler, like alpha text without any other characters?

I figured it out by trial and error..

size_t Start, End;
  Start = DataHolding.find("<table cellspacing=\"0\" class=\"wsod_quoteData\">");
  End = DataHolding.find("</table>", Start, 8);
  
  string Final = DataHolding.substr(Start, End-Start);     //From the Start Pos, Copy Everything Until the End Pos to a string..
triumphost 120 Posting Whiz

Hey guys I'm here again with another problem. I want to search in a string for a string with quotes in it.

Example:

String to search = {'  </a></div></div></div><div class="clearfix"><table cellspacing="0" class="wsod_quoteData"><tr><td class="wsod_last wsod_lastIndex" nowrap="nowrap"  '}

What to search for = {'   <table cellspacing="0" class="wsod_quoteData">   '}
Then if found, from there, search for {'   </table>   '}

How can I search for the first string if it has quotes and spaces in it?

What I have so far:

//DataHolding is a string that contains the entire HTML file contents in it.

  size_t Start = DataHolding.find("<table cellspacing=\"0\"" " class=\"wsod_quoteData\">", 46);
  size_t End = DataHolding.find("</table>", Start, 8);

The strings never get found..

My PHP version (THIS WORKS):

$content = str_replace($newlines, "", html_entity_decode($raw));
$start = strpos($content,'<table cellspacing="0" class="wsod_quoteData">');
$end = strpos($content,'</table>',$start) + 8;
$table = substr($content,$start,$end-$start);
preg_match_all("|<td(.*)</td>|U",$table,$rows);
triumphost 120 Posting Whiz

You could do it in either language.
If you don't like it running in the browser, you make a command-line version.

########################################################################
# Read content from a web page
$fileInFile=fopen("http://server.ext/Resources/SmallTextFile.txt", "rb");
while(!feof($fileInFile))
{
   $strData = fgets($fileInFile);
   printf($strData);
}
fclose($fileInFile);

How would I do it in C++?

triumphost 120 Posting Whiz

Hi guys. I have a php script that reads some values off a website and prints to a file every second.. The thing is, the script is always ran in my browser and I don't like that.

I want to write a c++ program that can run that script within it and write the data to a file.

If that is not possible, can I use C++ to read the contents off of a website, given the link?

Example: The php script is given the link to the website and given the elements the data is contained in. It reads that into an array and prints the data to a file.. If the data is between two div tags with a unique ID, the php file will look for the div tags with that ID and print it to an array.. Can I do this in C++??

TLDR: Can C++ Run PHP scripts/files? Can C++ Read data from a website without opening my browser?

triumphost 120 Posting Whiz

Such a stupidly easy program.. I don't see why u wouldn't be able to make it.. took me 5 minutes max to make this.. Of course it can be optimized but I will not do this for you.. Secondly since I'm posting it below and I don't know if it's really your friend or for you, I will have to trust that you understand the code below or else u are just screwing yourself over.

@Mods:
If I get an infraction for this, there is no rule saying I cannot post code as long as I wrote it myself. As for spelling, there is no forum rules saying I must spell you instead of u. So whoever gave me an infraction just now for that, get a life.

#include <iostream>
#include <cmath>
#include <windows.h>

using namespace std;

float x, y;
bool Compare(float x, float y);

int main()
{
	cout<<"Enter a value for X: ";
	cin>> x;
	cin.ignore();
	
	if(cin.fail())
	{
		cout<<"Error. The value must be a number! \n\n";
		cin.clear();
		cin.get();
	}
	
	cout<<"Enter a value for Y: ";
	cin>> y;
	cin.ignore();
	
	if(cin.fail())
	{
		cout<<"Error. The value must be a number! \n\n";
		cin.clear();
		cin.get();
	}
	
	if(Compare(x, y) == true)
	{
		cout<<"The values  have a difference of at least 0.0001\n";
	}
	else
	{
		cout<<"The values do not have a difference of at least 0.0001\n";
	}
	
	cin.get();
	return 0;
}

bool Compare(float x, float y)
{
	float z = abs(x - y);
	
	if(z < 0.0001)
	{
		return true;
	}
	else
	{
		return …
triumphost 120 Posting Whiz

Solved it myself.. I can now scroll parent windows when the iFrame has reached the bottom.. Tested and works in all browsers:

FF, Opera, IE, Safari, Chrome. Thanks anyway though. Always a pleasure to post on Daniweb.com

function handle(delta) 
{
	var d=delta*-10;
	window.scrollBy(0,d);
}

function wheel(event)
{
	var delta = 0;
	if (!event)
		event = window.event;				//  For IE.
			
	if (event.wheelDelta)
	{
		delta = event.wheelDelta/120;		//  IE/Opera.
		if (window.opera)
			delta = -delta;				//  In Opera 9.
	}
	else if (event.detail)
	{
		delta = -event.detail/3;			//  Mozilla case.
	}
					
	if (delta)									//  If scrolling up, delta is positive. If scrolling down, delta is negative.
		handle(delta);
		
	if(scrollHeight == document.body.scrollHeight)	//  If at the bottom of the frame page, scroll parent window.
	{
		window.parent.parent.scrollBy(0,20);
	}

	if (event.preventDefault)					//  Ignore default mousewheel actions.
		event.preventDefault();
	event.returnValue = false;
}

if (window.addEventListener)						//  Continuously Listen For MouseScroll Events.
		/** DOMMouseScroll is for mozilla. */
		window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel; 				//  IE/Opera.
triumphost 120 Posting Whiz

I have an iFrame that is 1024px X 700px. I removed the scrollbars using Scrolling="No" because the scrollbars don't look very pleasing to my eyes. I use javascript to scroll the iFrame but for the life of me, I cannot figure out how to detect if I'm already at the bottom of the iFrame. How can I detect if I'm at the end of the document in an iFrame so that I can scroll the parent window instead of the iFrame.

TLDR: If document position is at the bottom of the iFrame, I want to scroll the parent window.

<script type="text/javascript">
			function handle(delta) {
			var d=delta*-10;
			window.scrollBy(0,d);
			}

			function wheel(event){
					var delta = 0;
					if (!event)
							event = window.event;				//  For IE.
					if (event.wheelDelta) {
							delta = event.wheelDelta/120;		//  IE/Opera.
							if (window.opera)
									delta = -delta;				//  In Opera 9.
					} else if (event.detail) {
							delta = -event.detail/3;			//  Mozilla case.
					}
					
					if (delta)									//  If scrolling up, delta is positive. If scrolling down, delta is negative.
							handle(delta);

					if (event.preventDefault)					//  Ignore default mousewheel actions.
							event.preventDefault();
				event.returnValue = false;
			}

			if (window.addEventListener)						//  Continuously Listen For MouseScroll Events.
					/** DOMMouseScroll is for mozilla. */
					window.addEventListener('DOMMouseScroll', wheel, false);
			window.onmousewheel = document.onmousewheel = wheel; 				//  IE/Opera.
		</script>
triumphost 120 Posting Whiz

providing the code you are using will help in getting your problem solved , please provide the code

All the javascript is at the very last lines of the code.. Lines 18 for Index and 66 for Main.

Index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
		
		<link href="style.css" rel="stylesheet" type="text/css" media="screen" title="Default Styles" />
 		<title>Javascript Domination</title>
	</head>
	
	<body>
		<iframe name="MainFrame" src="Main.html" width="1024px" height="700px" frameborder="0" scrolling="no" marginwidth="0" marginheight="0">
			If you are reading this, your browser DOES NOT support iFrames.
		</iframe>
	</body>
	
	<script type='text/javascript'>
		 //<![CDATA[
		 document.write ("<a href='http://validator.w3.org/check?uri=" +
			 location.href+ "\;ss=1;verbose=1' target='display'>" +
			 "<img src='http://gblearn.com/images/valid-xhtml10.png' " +
			 "width='60' height='21' border='0' " +
			 "alt='Valid XHTML 1.0 Transitional.' " +
			 "title='Valid XHTML 1.0 Transitional.' /></a>")
		 dt=new Date(document.lastModified);
		 document.write("<small> This page was last modified on " +
						 dt.toLocaleString() + "</small>")
		 //]]>
		</script>
</html>

Main.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
		
		<link href="style.css" rel="stylesheet" type="text/css" media="screen" title="Default Styles" />
 		<title>Javascript Domination</title>
	</head>
	
	<body>
		<div class="maincontent">
			<a href="Index.html"><img src="Logo.PNG" alt="Javascript Domination." width="100%" height="100px" border="0px"/></a>
				<div id="hnav">
					<ul>
						<li><a href="Index.html" target="MainFrame">Home</a></li>
						<li><a href="Tutorials.html" target="MainFrame">Tutorials</a></li>
						<li><a href="TimeLine.html" target="MainFrame">Time-Line</a></li>
						<li><a href="StaffList.html" target="MainFrame">Staff-List &amp; Profiles</a></li>
						<li><a href="AboutUs.html" target="MainFrame" id="last">About Us</a></li>
					</ul>
				</div>
			
			<table class="maintable">
				<tr>
					<td width="250px" class="leftnav">
						<ul class="leftnavpad">
							<li class="menuwhite">Introduction</li>
								<li class="styletype">
									<ol class="leftnavpos">
										<li><a href="Cpp01.html">Variables.</a></li>
										<li><a href="Cpp02.html">Loops.</a></li>
										<li><a href="Cpp03.html">Alert, Confirm, Prompt.</a></li>
										<li><a href="Cpp04.html">Operators.</a></li>
										<li><a href="Cpp05.html">Input &amp; Output to the screen.</a></li> …
triumphost 120 Posting Whiz

[IMG]http://i.imgur.com/DGegu.png[/IMG]


I have that page above.. But the thing is the entire website was made using an iFrame that loads another page.. Each page has one of those at the bottom. Thing is when the main page loads the second page, there are duplicates of those at the bottom. I want it so that when there are duplicates, I can remove the main one. How would I even get started on that? I don't know where to look at all.

I looked up stuff but the only thing I found was the remove html elements using $('.class').remove(); Which doesn't do what I want. I only know very little javascript, lots of css, lots of html and lots of C++.. I don't know any other languages.

triumphost 120 Posting Whiz

You would first have to know how to use bitmaps quite well and take screenshots in C++.

You'd then get the raw code of the bitmap and compare it with the image on screen. This might require you to know how to do arrays really well too. Since your going to have to compare the RGB colours of the bitmaps which is stored in arrays.

You would also have to have a tolerance on the image/colours because the recognition would definitely NOT be exactly the same pixels.

http://www.codeproject.com/KB/graphics/BitmapCompare.aspx

triumphost 120 Posting Whiz

What I don't understand is why the teacher would give you such a large project without having taught you the basics! I mean come on.. that project is obviously not a beginner project and yet you who do not know where to even start, has to write that much code..

At least attempt something and myself or others will try and push you along the way or even contribute a couple lines of code.

triumphost 120 Posting Whiz

His question is pretty clear to me.. He wants a menu in his program and when a user presses "M", the menu shows/hides itself. The user can press "M" at any time during execution. Doesn't matter where in the program they press it..


I would do something like:
Create a backgroundworker/thread that checks for the press of the 'M' key while the program is active/visible on screen. When 'M' is pressed, the menu opens.. simple as that.
Basically a thread with a hotkey 'M'. Also you might wanna specify if your using .Net or just a plain old console program or Win32 API.

triumphost 120 Posting Whiz
<include FormName.h>

Form1::Visible = false;
FormName ^ Form2 = gcnew FormName();
Form2->ShowDialog();

That should be more than enough.. It's what I use.. If u made your form2 in the same project as Form1.h then just include the Form2.h file in the first form.. that way u don't need to make a constructor & destructor.

triumphost 120 Posting Whiz

Hi All, I'm making a website for my school project but I have a problem with the pre tag. I used a table to define the layout of my site. But now I want to add content using the <pre> tag and it stays in the center -__- even when I style it to the left with a margin or vertical-align.. It just won't go left no matter what!

Please help me figure out the problem.. I've been looking for 2 hrs now and can't figure it out. Screenshots below the code.

Side Help: I also wanna know how to get syntax highlighting without javascript because for this project I cannot use javascript at all.. its strictly css and html.

"Index.html"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta name="description" content="A Website dedicated to teaching hacking and the concepts of programming..." />
		<meta name="keywords" content="web page, namespace, classes, pointers, tutorials, tools, hacking, source code, programming, C++" />
		<meta name="robots" content="all" />		
	
		<!--CSS Styling-->
		<link href="style.css" rel="stylesheet" type="text/css" media="screen" title="Default Styles" />
		<title>Namespace Computer Science</title>
	</head>

	<body>
		<a href=""><img src="Logo.PNG" alt="The Art of Exploitation Title." width="100%" height="100px" border="1px green"/></a>
		
		<h2 id="h2">Your Learning Reference To Programming &amp; Reverse-Engineering.</h2>
		<br />
		<hr /> 
		<!-- Expandable Menu!-->
			<div id="hnav">
				<ul>
					<li><a href="#">Home</a></li>
					<li><a href="#">Tutorials</a></li>
					<li><a href="#">Products</a></li>
					<li><a href="#">FAQs</a></li>
					<li><a href="#" id="last">Contact Us</a></li>
				</ul>
			</div>			
		<br />
		<hr />
		<br />
		<a name="Tutorials"></a>
		<p class="pcolour">Tutorials:</p>
		<table …
triumphost 120 Posting Whiz

I think thats how u do it below.. U have to use pointers because the way your doing it, the array disappears when the function returns since the array was declared in the function.. which is why I'd use a global array.. anyway since the array disappears when the function returns, if u try to grab data from the array in any other function, it will be trying to get data from an address that doesn't exist..

That's the best that I could explain it.. I really don't know how to explain it well but thats sorta how I understand it..

int *getCorrectAnswers(int[]);
int *CAnswers = getCorrectAnswers(correctAnswers);
int *getCorrectAnswers(int correctAnswers[])
{
const int ARRAY_SIZE = 20;  // Array size
	correctAnswers[ARRAY_SIZE];	 // Array with 20 correct answers
	int count;						 // Loop counter variable
	ifstream inputFile;			 // Input file stream object
	
	inputFile.open("C:\\Users\\sixcore\\Documents\\Visual Studio 2010\\Projects\\exam_grader\\CorrectAnswers.txt"); // Correct answers
	
	// Read the 20 correct answers from the file into the array.
	for (count = 0; count < ARRAY_SIZE; count++)
		inputFile >> correctAnswers[count];
	
	// Close the file.
	inputFile.close();

	return correctAnswers;
}
triumphost 120 Posting Whiz

Hey I did a little debugging just now about 5 minutes ago.. and the problem is as expected of course.. first I re-wrote all your blocking detection to see if your blocked or not.. and I got stuck on the third spot.. then I copy pasted your code and got stuck on the sixth spot.. there was an obvious reason behind it..

Try changing the code to the stuff below.. wait 30 seconds and u will see exactly why your program doesn't do what you want.. trust me the program is still running, the position of the X is changing.. but because you left it as X, it isn't noticeable..

int i = 0;  //just do it.. put this global variable right before the function below..

void mazeTraverse(char m[][12], int posY, int posX)
{
	static int update = time(0) % 10;

	while(time(0) % 10 != update);
	if(time(0) % 10 == 9)
		update = 0;
	else
		update = (time(0) % 10) + 1;

    i= i+1;

	m[posY][posX] = i;

U will notice some messed up characters! then on the 6-9th try, the maze will get messed up.. ignore it!! the maze goes back to normal and u see the problem clearly! You should notice that the characters just keep going back and forth! That is the problem.. It's not that the X isn't moving, but rather it keeps going back and forth in the same two positions.

I don't really like the algorithm used because it's hard to implement …

triumphost 120 Posting Whiz

Umm you know showing us what the solved maze would look like or what the maze itself would look like would really help us understand the problem and visualize the maze and where it gets stuck...
For the guys who have a tough time visualizing the maze: [Img]http://i.imgur.com/Lw5uO.png[/img]

Hmm I see what u mean.. it gets stuck at position 4.. I'll post back if I solve it.

triumphost 120 Posting Whiz

Lol the reason why the screen goes away is because right after doing primenum(x).. you need the cin.get(); but instead u have:

cout<<"\n Here are all the prime numbers up to "<<x<<".\n";
primenum(x);
    //Put a cin.get(); here to pause the program instead of the console just disappearing..
return 0;
triumphost 120 Posting Whiz

What I would have done is almost the same but a little different.. I would loop through the arrays like you did and I would print the number of the missed question to the screen and the correct answer to it.. I would put a counting integer in the loop aswell so that it counts how many were missed. Next I'd also make a global integer that would grab how many were right and divide that by 20.

My attempt at outputting the missed questions and answers to them.. I'd then add a global variable to count how many were wrong..

int wrong = 0; // global variable.

		while (arraysEqual && count < SIZE)
		{
			if (correctAnswers[count] != studentAnswers[count])
				arraysEqual = false;
			count++;
                        wrong++;
			
			if(studenAnswers[count] == "\n")     //My attempt at detecting a missed answer which would probably be a newline character in the file.
			{
				cout<<"The Student Missed Question: #"<<count<<"\n";
				cout<<"The Correct Answer to the question is: "<<correctAnswers[count]<<"\n";
			}
		}

Iunno if this is what u want but this is how I'd to the grade thing..

void testGrade(float[], int)
	{
		int grade;
		cout << "Going to now show the grade if it is higher than 70%.\n";
		
		grade = (20 - wrong)/20;  //This gives all the correct ones then divides by the total amount of questions..
		grade *= 100; //This gives a percentage.. in other words: grade = grade * 100.. Now u can do the >=70% thing..
		
		if (grade >= 70)
			cout << "The student has passed.\n"; …
triumphost 120 Posting Whiz

U posted some incomplete code there..

setw is an undeclared function you are attempting to use..
also DataIn is aggregated for whatever reason I do not know.. U don't even have headers in your code..

I included <iostream> <windows.h> <string>
but that only got rid of some of the errors not all..

triumphost 120 Posting Whiz

It does not reset because your using "Goto"... goto will just skip over everything and jump over code.. all the input is still in the input buffer..

I fixed the goto's below.. u can figure it out easily.. as for the "your number 0" appeared blah blah blah amount of times.. u can fix that.. because I did not enter 0..

always says your number 0 appeared...

#include <iostream>

using namespace std;

int digit,square,remainder,ok;
int counter = 0;
int number = 0;

void Start()
{
     while(number <= 0)
     {
        cout << "Input an integer!" << endl;
        cin >> number;
        if (number <= 0)
        {
            cout << "You entered incorrect data, input an integer!" << endl;
            continue;
        }
        else
            break;
     }
}

void Start2()
{
     while((digit < 0) || (digit > 9))
     {
        cout << "Input a digit!" << endl;
        cin >> digit;
        if (digit < 0)
        {
             cout << "You entered incorrect data, input a digit!" << endl;
             continue;
        }
        if (digit > 9)
        {
             cout << "You entered incorrect data, input a digit!" << endl;
             continue;
        }
        else
            break;
     }
}
    
int main()
{
    do
    {
            if(number  <= 0)
            {
              Start();
            }
            else
                Start2();
            
            square = number*number;
            while(square > 0)
            {
                remainder = square % 10;
                if (remainder==digit)
                {
                   counter++;
                }
                square = square / 10;
            }
            
            if (counter>0)
               cout << "Your digit " << digit << " appeared " << counter << " times " << endl;
            else
                cout << "Your digit was not found" …
triumphost 120 Posting Whiz

k it goes:

if ((remainder of number/10) is greater than max then)
{
    max = that remainder;
}
number = number/10;

//Repeat everything above while number does not = 0;

Example:

int max = 0;
int number = 10;

//10/10 = 1 remainder 0;

if(0 > max)  //if remainder is greater than max.. then..
{
   max = 0; //because the remainder of 10/10 is 0.
}
//number = 10/10;  Therefore Number = 1;
number = 1;

//now the while loop says: while number != 0, do whatever is inbetween.. well.. Number = 1 right now.. so we do it again.

//1/10 = 0 remainder 1;
if(1 > 0)  // max = 0 as stated above when we did it the first time.
{
  max = 1;  // max = the remainder of 1/10.. which is 1.
}
number = 1/10;  // this is now <= 0 so it breaks out of the while loop.. and prints max. it doesn't do decimals because its an integer. so u round it to the nearest whole basically.

cout<<"Largest: "<<max<<"\n";  //should print 1 since max = 1;
cin.get();  //this will pause the screen so u can see the output..
triumphost 120 Posting Whiz

int max = 0;

u have to put the int because u have to declare to the compiler that the value of max is an integer and not a floating point number... its a whole number that can be negative or positive.. in other words, no letters, no decimals, etc..

max = 0 does not have a type.. and the compiler cannot know if max is a char or int or float or long, etc. you set it to 0 to initiate it with a value because if you don't then it is assumed a random number.. use a breakpoint and you will see.

! means not
= means equal example: x = 0. y = 0.
< less than
> greater than
!= not equal
== comparing left to right equals.. example: if(left == right) then do something..
/= means a number = itself divided by #.. Example: A /= 10.. means A = A/10

*= means a number = itself multiplied by #.. Example: A *= 10.. means A = A*10
+=
-= same thing..
++ means increase.. so A++ would be keep increasing A by 1..
-- opposite of above.

How does it give the max number? because while the number is not 0, it keeps testing and testing until the number = 0.. when it does, then it breaks out of the loop and prints it on screen for u.

triumphost 120 Posting Whiz

The below code compiles.. gives only one warning which I cba to fix.. its basically fopen to fopen_s.. u can fix that easily.. its just a compiler warning though.

// File.cpp
#include "header.h"
#include <iostream>
using namespace std;


/* open raw socket, set promiscuous mode */
void init_net() {

	WSADATA w;
	SOCKADDR_IN sa;
	DWORD bytes;
	char hostname[HOSTNAME_LEN];
	struct hostent *h;
	unsigned int opt = 1;

	if (WSAStartup(MAKEWORD(2,2), &w) != 0)
		die("WSAStartup failed\n");

	if ((s0k = socket(AF_INET, SOCK_RAW, IPPROTO_IP)) == INVALID_SOCKET)
		die("unable to open raw socket\n");

	// use default interface
	if ((gethostname(hostname, HOSTNAME_LEN)) == SOCKET_ERROR)
		die("unable to gethostname\n");

	if ((h = gethostbyname(hostname)) == NULL)
		die("unable to gethostbyname\n");

	sa.sin_family = AF_INET;
	sa.sin_port = htons(6000);
	memcpy(&sa.sin_addr.S_un.S_addr, h->h_addr_list[0], h->h_length);

	if ((bind(s0k, (SOCKADDR *)&sa, sizeof(sa))) == SOCKET_ERROR)
		die("unable to bind() socket\n");

	if (promiscuous)	/* -d on the command line to disable promiscuous mode */
		if ((WSAIoctl(s0k, SIO_RCVALL, &opt, sizeof(opt), NULL, 0, &bytes, NULL, NULL)) == SOCKET_ERROR)
			die("failed to set promiscuous mode\n");
}



int main() {

	char pak[PAKSIZE];
	DWORD bytes;
	init_net();

	WriteData( "Program has started: " );
	WriteData( "\r\n\r\n" );

	while(1)
	{
		memset(pak, 0, sizeof(pak));
		if ((bytes = recv(s0k, pak, sizeof(pak), 0)) == SOCKET_ERROR)
		{
			die("socket error on recv\n");
		}else{
			process_pak(pak, bytes);
		}
	}
}



void WriteData( const char* buffer )
{
	FILE * pFile;
	pFile = fopen( "./File1.txt", "a" );
	printf( buffer );
	fprintf( pFile, buffer );
	fclose( pFile );
}


/* parse pak, print out requested fields */
void process_pak(char *pak, int len) {

	struct iphdr *ip;
	struct tcphdr *tcp;
	char *data;
	unsigned …
triumphost 120 Posting Whiz
#include <windows.h>

Sleep(1000);

that works fine.. doesn't give me any errors..

triumphost 120 Posting Whiz

The problem is the below code.. I created my controls.. The thing is that when I press the button, the edit control shows up on top of all controls except for the button that was pressed.. then if I move the mouse, all the other buttons under it, show up ontop.. All the other controls should have been hidden when the button was pressed.. I tried making the edit control as topmost but it didn't work.. In .Net I would usually rightclick the edit control and press bring to front.

case WM_CREATE:
            Button1 = CreateWindowEx(NULL, "Button","Install", WS_CHILD | WS_VISIBLE | BS_PUSHLIKE, 6, 54, 100, 23, hwnd, (HMENU)Button1_ID, ghInst, NULL);
            Button2 = CreateWindowEx(NULL, "Button","Help", WS_CHILD | WS_VISIBLE | BS_PUSHLIKE, 225, 54, 100, 23, hwnd, (HMENU)Button2_ID, ghInst, NULL);
            //RICHEDIT_CLASS NOT WORKING!
            HelpMenu = CreateWindowEx(WS_EX_TOPMOST, "EDIT", NULL, WS_BORDER | ES_READONLY | WS_CHILD | ES_MULTILINE | ES_AUTOVSCROLL | WS_DISABLED, 0, 0, 331, 119, hwnd, (HMENU)HelpMenu_ID, ghInst, NULL);
                SendMessage(HelpMenu, WM_SETFONT, (unsigned int)GetStockObject(ANSI_VAR_FONT), 0);
                //SendMessage(HelpMenu, EM_SETMARGINS, EC_USEFONTINFO, 0);
            TitleLabel = CreateWindowEx(NULL, "Static", "Welcome to Bleh\'s Program", WS_CHILD | WS_VISIBLE, 18, 9, 315, 17, hwnd, (HMENU)TitleLabel_ID, ghInst, NULL);
            CheckBox = CreateWindowEx(NULL, "Button", "Safe-Mode", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 14, 84, 99, 21, hwnd, (HMENU)CheckBox_ID, ghInst, NULL);
            CheckBox2 = CreateWindowEx(NULL, "Button", "Update", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 242, 84, 70, 21, hwnd, (HMENU)CheckBox2_ID, ghInst, NULL);
            //SetWindowText();
            break;

        case WM_COMMAND:
            switch (HIWORD(wParam))
            {
                case BN_CLICKED:
                    if(LOWORD(wParam) == Button1_ID)
                    {
                        SetWindowText(HelpMenu, "Starting The Program.");
                        ShowWindow(HelpMenu, SW_SHOW);
                        //BN_GETCHECK
                        break;
                    }
                    break;
            }
            break;

Oh can can someone show me how …

triumphost 120 Posting Whiz

Kk so I've been using these functions for quite some time and everytime I write a new program and decide to use them, I have to open up old ones and copy paste them with a whole bunch of include n crap. I decide I'd try to make a DLL that has the functions include and then load it and just use them.. I don't know if I made the DLL right, even though it compiles.. and I don't know how to load it in .Net C++

I plan to make 2 versions of this DLL.. the one below for .Net and another one for Win32 Api. Can anyone check to see if I did the .Net one right and explain to me how to load this? Or what about including it as a resource and loading it from there?


Managed DLL.h

#ifdef MANAGEDDLL_EXPORTS
#define MANAGEDDLL_API __declspec(dllexport)
#else
#define MANAGEDDLL_API __declspec(dllimport)
#endif

#include <Windows.h>
#pragma managed
#using <mscorlib.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::IO;
using namespace System::Windows::Forms;

// This class is exported from the Managed DLL.dll
class MANAGEDDLL_API ManagedDLL {
public:
	ManagedDLL(void);
	bool extractResource(WORD resourceID, LPCWSTR outputFilename, LPCWSTR resName);
	void ResourceInfo(LPTSTR ResourceLocation, LPTSTR ResourceType, int ResourceID);
};

extern void ReplaceFile(String^ fileToMoveAndDelete, String^ fileToReplace, String^ backupOfFileToReplace);

Managed DLL.cpp

// Managed DLL.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "Managed DLL.h"
#include <tchar.h>
#include <iostream>
#pragma comment(lib, "advapi32.lib")
#include <tlhelp32.h>
#include <conio.h>
#include <cstdlib>
#include <Winuser.h>
#pragma comment(lib, …
triumphost 120 Posting Whiz

U might wanna fix your reset.. because it definitely doesn't re-open the program or reset it.. it just exits.. anyway I fixed the quantity problem for u.. I just added variables at the top such as:

choc, cheese, pandan, fruit, banana and set them all to zero.. then I added after the total calculation:
choc += order; aka choc = choc + order.. same thing..
cheese += order;
etc..

then u just make quantity = choc + cheese + pandan + fruit + banana;
and whala.. remove your case statements and put if's without the else's.. and bam.. good to go.

P.S. A case statement is like a lot of if-else statements.. just more simple.. when you do that, it goes if this.. then cout choc cake.. else cout cheese else blah blah.. it doesn't do them all.. so you have to remove the else's so it goes if this cout choc cake.. if that cout cheese and blah blah.. that way it prints everything rather than only one! That's why we got rid of the case statements.

#include <iostream>
#include <windows.h>

using namespace std;
int main()
{

int order=0,quantity,cake;
float payable=0,cash,price,change,total1;
char pitz;
triumphost 120 Posting Whiz
HWND ActiveWin = GetActiveWindow();  //Gets a handle to the window..

char WindowText[256];
GetWindowTextA(ActiveWin, WindowText, 256);   //Will get the window title for u..

//Assuming the active window is notepad!
if((WindowText == "Notepad") && (ActiveWin != NULL))
{
   //read the text from notepad..
   HWND notetxt = FindWindowEx(ActiveWin, NULL, "Edit", NULL);
   int length = SendMessage(notetxt, WM_GETTEXTLENGTH, 0, 0);

   string textinside;

   int meh = SendMessage(notetxt, WM_GETTEXT, length, textinside);

   cout<<textinside;  //Prints the retrieved text to the console..
}
triumphost 120 Posting Whiz

Try adding some spaces and lining up brackets.. put some spaces between your comparisons like: Meh = bleh.. not meh=bleh.. thats hard as hell to read..

also instead of doing C:\\bleh\\meh.. you can do C:/bleh/meh.. much easier.
I don't like GetMessage so I changed it to PeekMessage below as getmessage waits forever (if u need this just change it to getmessage) until a message is received.. I also added code as an example how you'd be using your hotkeys.. I used F9 as I didn't know what 0x41 represented.

You don't really have a callback procedure so its hard to tell you how to use getmessage/peekmessage as this isn't a winapi/win32 program.. its a console prog. If you don't wanna write a win32prog, u can always add a thread to the program which checks if notepad is running or not.. I added example code below to show how to check which processes are running.

I'm actually pretty sure that Console Programs don't get messages at all.. but I could be wrong so I left the peek message in the application below the standard callback proc..

Standard CallBack Proc (Win32/API):

MSG msg;
    while(GetMessage(&msg, NULL, 0, 0 ))
    { 
            TranslateMessage(&msg); 
            DispatchMessage(&msg); 
    } 
    
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
       switch(msg.message)
       {
           case WM_HOTKEY:
                if(msg.wParam == F9_KEYID)
                {
                              //Blehh.... Do stuff here..
                }
                                        
           case WM_CLOSE: 
                    FILE *f3=fopen("C:/text.txt","a+");
                    fprintf(f3,"Hotkey pressed");
              break;

           default:
                   return DefWindowProc(hWnd, message, wParam, lParam);
       }
}
#include "stdafx.h"
#include "windows.h" …
triumphost 120 Posting Whiz

I've been programming in C++ for quite some time now and I know all functions must return a value.. but can someone tell me WHY we return 0?

I mean it compiles even when I don't put return 0.. and the program executes fine.. I can see in some functions we'd return a variable or a value.. but for int main() why do we always have to write return 0? Someone told me its the new standard that we don't have to type it anymore but I'm so used to return 0 that I can't not type it. I also heard its because when a function returns a value other than 0, it means something is wrong and the operating system can check the value it returned and check for memory leaks or something..

what if I returned 256? it still works.. :c

also can someone explain when i use unsigned variables?? I never use them unless a function on MSDN requires it.. so is there any use of them other than passing them to functions as parameters? Oh and when do we use constants? I mean I can just use a float or integer instead of const int or const float.. just don't change the value right? When do we use constants :S

I saw someone do this:

const float PI = 3.14159265f;
const float DEGREE_TO_RADIAN_FACTOR = 0.0174532925f;

can someone explain why there is an "f" at the end of the values??

Thanks …

triumphost 120 Posting Whiz

ur missing the Avi.o in your Lib Folder...

triumphost 120 Posting Whiz

This is the entire code... I still can't figure out how to call the target(); in my button code..

/**
 *  Copyright 2010 by Benjamin J. Land (a.k.a. BenLand100)
 *
 *  This file is part of the SMART Minimizing Autoing Resource Thing (SMART)
 *
 *  SMART is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  SMART is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with SMART. If not, see <http://www.gnu.org/licenses/>.
 */

package smart;

import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.WritableRaster;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLClassLoader;
import java.net.URLEncoder;
import java.net.HttpURLConnection;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Locale;
import java.util.HashMap;
import java.util.Map;
import java.util.Hashtable;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; …
triumphost 120 Posting Whiz

My problem is that I don't know how to make my button do: public void target(Canvas it);
when its pressed.. if that can't be done, I want to tell my window it's minimized and then restored even when it isn't..

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
        at smart.Client.target(Client.java:155)
        at smart.Client.actionPerformed(Client.java:686)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$1.run(Unknown Source)
        at java.awt.EventQueue$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown
Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at smart.BlockingEventQueue.dispatchEvent(BlockingEventQueue.java:158)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
triumphost 120 Posting Whiz

How do I call the function in the button section?? I tried doing target(); and got when the program ran, it gave me some exception thing..

package smart;

import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.WritableRaster;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLClassLoader;
import java.net.URLEncoder;
import java.net.HttpURLConnection;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Locale;
import java.util.HashMap;
import java.util.Map;
import java.util.Hashtable;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import sun.applet.AppletClassLoader;

public class Client implements ActionListener, ChangeListener {
    public void target(Canvas it) {
        if (it == canvas) {
            return;
        }
        boolean iam = blocking;
        if (iam) {
            stopBlocking();
        }
        BlockingEventQueue.removeComponent(canvas);
        if (canvas == null) iam = true;
        canvas = it;
        canvas.setRefresh(refresh);
        if (blitThread != null) {
            blitThread.stop();
        }
        blitThread = createBlitThread();
        BlockingEventQueue.addComponent(canvas, new EventRedirect() {

            @Override
            public void dispatched(AWTEvent e) {
                if ((e instanceof MouseEvent && e.getID() == MouseEvent.MOUSE_CLICKED) || (e instanceof KeyEvent)) {
                    clientFrame.requestFocusInWindow();
                }
            }
        });
        BlockingEventQueue.setBlocking(canvas, iam);
        if (iam) {
            startBlocking();
        }
        if (initseq != null) {
            nazi.sendKeys(initseq);
            initseq = null;
            System.out.println("Init Sequence Dispatched");
        }
        blitThread.start();
    }
}

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == blockingbtn) {
         [B]   //Call that target(); function here...[/B]
        }
    }
triumphost 120 Posting Whiz

Why does it always return true?! No matter what I do it says the bitmaps are the same.. I want it to tell the difference between the two bitmaps.. like if they look alike with a slight tolerance to make sure that it doesn't have to be a perfect match..

This is what I started out with.. I need a little push or some help please..

#include <iostream>
#include <windows.h>
#include <gdiplus.h>

#pragma comment(lib, "Gdi32.lib");

using namespace std;

bool CompareBitmaps(HBITMAP HBitmapLeft, HBITMAP HBitmapRight);

int main()
{
    HBITMAP HBitmapLeft = LoadBitmap("C:/Users/Brandon/Desktop/Untitled.bmp");
    HBITMAP HBitmapRight = LoadBitmap("C:/Users/Brandon/Desktop/Untitled2.bmp");
    if (CompareBitmaps(HBitmapLeft, HBitmapRight) == true)
    {
        cout<<"They are the same";
    }
    DeleteObject(HBitmapLeft);
    DeleteObject(HBitmapRight);

    return 0;
}

bool CompareBitmaps(HBITMAP HBitmapLeft, HBITMAP HBitmapRight)
{
    if (HBitmapLeft == HBitmapRight)
    {
        return true;
    }

    if (NULL == HBitmapLeft || NULL == HBitmapRight)
    {
        return false;
    }

    bool bSame = false;

    HDC hdc = GetDC(NULL);
    BITMAPINFO BitmapInfoLeft = {0};
    BITMAPINFO BitmapInfoRight = {0};

    BitmapInfoLeft.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    BitmapInfoRight.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

    if (0 != GetDIBits(hdc, HBitmapLeft, 0, 0, NULL, &BitmapInfoLeft, DIB_RGB_COLORS) &&
        0 != GetDIBits(hdc, HBitmapRight, 0, 0, NULL, &BitmapInfoRight, DIB_RGB_COLORS))
    {
        // Compare the BITMAPINFOHEADERs of the two bitmaps

        if (0 == memcmp(&BitmapInfoLeft.bmiHeader, &BitmapInfoRight.bmiHeader,
            sizeof(BITMAPINFOHEADER)))
        {
            // The BITMAPINFOHEADERs are the same so now compare the actual bitmap bits

            BYTE *pLeftBits = new BYTE(BitmapInfoLeft.bmiHeader.biSizeImage);
            BYTE *pRightBits = new BYTE(BitmapInfoRight.bmiHeader.biSizeImage);
            BYTE *pByteLeft = NULL;
            BYTE *pByteRight = NULL;

            PBITMAPINFO pBitmapInfoLeft = &BitmapInfoLeft;
            PBITMAPINFO pBitmapInfoRight = &BitmapInfoRight;

            // calculate the size in BYTEs of the additional

            // memory needed for the bmiColor …
triumphost 120 Posting Whiz

I have a game client that has a button to allow input and when toggled on it will block input..
Thing is sometimes even when u toggle it off, it still blocks user input.. Other times there is an extremely HUGE delay before it accepts input..

I was thinking if I could hook into the application and send input such as keyboard input directly to the message queue on the press of a button.

I tried ::sendmessage but the application takes a whole 3 minutes before it sends keystrokes to the game.

I don't know how to hook into windows nor the message hook with .NET managed and I don't know API.. so Im asking is there any other way to do this other than hooking or am I forced to hook and learn how to? If im forced, does anyone have any *Amazing* hook tutorials on doing such a thing?

triumphost 120 Posting Whiz

Normal buttons look Rectangular and I was trying to figure out how to round the edges of it and found myself with a headache.. How do those pro designers do it? How do they get the custom GUI's and the buttons rounded or even custom buttons in any shape?

Kind of look like this: http://i.imgur.com/QGdco.png

There are no tutorials around on this :c I tried searching a lot.. and only find things telling you to just copy and paste this and that.. and include some file..

So anyone do this before or know how to do it?
I code in .Net Managed and I'm learning Win32 API. Can read API but not write it :c

triumphost 120 Posting Whiz

A couple questions I have for anyone that knows WINAPI as Im trying to learn it right now..
I usually program in .Net Managed and the basic console stuff.

First: Is there a designer for WinAPI like there is in Visual Studio Form App Editor? Or is it just outright hard as hell?
Second: If there is no Form Designer, How do you know where to place buttons and stuff?
Third: Does everything I need to do go in: LRESULT CALLBACK WindowProcedure ? Because it really seems that way.. There is no "Body" to my program?

Fourth: How do I call a function in WinAPI? I don't want it in WinMain because it freezes my program..
Fifth: Where in the world do I put if-else statements.. In WinMain or the WindowProcedure thing?
Sixth: How do I make stuff execute in a specific order?? You know like in a console it goes:

int main()
{
  cout<<"This executes first\n";
  cout<<"This executes second.. \n";
  count<<"And finally I execute second to last..\n";
 return 0; //Last thing to execute.
}
triumphost 120 Posting Whiz

Not sure why this moderator or admin or whatever deleted my previous thread because it wasn't anything malicious.. My problem is that getfileattribute doesn't work for me.. and my code below is just a snippet of my entire program which is below that..

Dear Mod: I think you deleted it because you saw me testing it on a crack file.. obviously im going to test it on any file I can find on my desktop other than a text file because it isn't working.. Next time wait until I wake up to defend myself before you infract me. The program is meant to delete viruses and folders containing them.. You enter the path to them in the textboxes and press delete.. thats not malicious. I meant to also put:

if(remove(File.c_str())  //Doesn't work on hidden or read only files..
{
   MessageBox::Show("Deleted successfully");
}
GET_FILEEX_INFO_LEVELS fInfoLevelId = GetFileExInfoStandard;
WIN32_FILE_ATTRIBUTE_DATA lpFileInformation;
int ret;
 
ret = GetFileAttributesEx((LPCWSTR)File.c_str(), fInfoLevelId, &lpFileInformation);

if(lpFileInformation.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE)
{
	MessageBox::Show("archive");
}
if(lpFileInformation.dwFileAttributes == FILE_ATTRIBUTE_COMPRESSED)
{
	MessageBox::Show("comp");
}
if(lpFileInformation.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
{
	MessageBox::Show("dir");
}
if(lpFileInformation.dwFileAttributes == FILE_ATTRIBUTE_READONLY)
{
	MessageBox::Show("readonly");
}
if(lpFileInformation.dwFileAttributes == FILE_ATTRIBUTE_HIDDEN)
{
	MessageBox::Show("hidden");
}

My whole Program...

#define REPEAT do{
#define UNTIL( condition ) }while(!(condition));

#pragma once
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "user32.lib")
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <sys/stat.h> 


namespace FileDeleter {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::Security::Permissions;
	using namespace System::Runtime::InteropServices;

	/// <summary>
	/// …
triumphost 120 Posting Whiz

I don't see where u got rid of the tan :S Tan = cos#/sin#.. I don't see that anywhere :S

And this is what I used:

float K1 = (M * K0);
	float K2 = (K0 * nu) * ((sin(2 * lat))/4);
	float K3 = (((k0 * nu) * sin(lat)) * ((pow(cos(lat), 3))/24) * (5 - (pow(tan(lat), 2)))) + ((9 * esq) * (pow(cos(lat), 2))) + ((4 * (pow(esq, 2))) * (pow(cos(lat), 4)));
	
	float y = K1 + (K2 * (pow(p, 2))) + (K3 * (pow(p, 4)));
	float northing = y;
	
	float K4 = (K0 * nu * cos(lat));
	float K5 = ((k0 * nu * (pow(cos(lat), 3)))/6) * (1 - ((pow(tan(lat), 2)) + (esq * (pow(cost(lat), 2)))));
	
	float x = (K4 * p) + (K5 * (pow(p, 3)));
	float easting = x;

I did the bedmas myself so I put the brackets in the right spot assuming his equations were right in the first place, the bedmas in the above would be correct.

triumphost 120 Posting Whiz

omg.. thread of hate? I Love dev-C++ for the argument that it doesn't work well on windows 7.. thats a load.. It works perfectly if they knew how to install it..

Only one problem I ever found with it.. that was Build error 16.. switching to a different compiler fixes that.. Happens when u have included extra resources like a dll that imports functions from another language like pascal..
Switching to another compiler like codeblocks fixed it but visualstudio 2010 also has the same error 16 build problem like dev c++ so I just thought it was a normal error..

Though one problem is that the intellisense for it doesn't work on win7.. thats fine just gives me all the more reason to learn the code without relying on intellisense.. As far as I know: intellisense doesn't work for vs2010 either (for c++ programs & .net).

Still no reason to bash it.. code compiles, easy to use..

triumphost 120 Posting Whiz

Umm but the bot does have access to the game's code.. the game is coded in java and the bot has to use reflection to determine player position or else I would have to use a whole bunch of colour finding functions to determine if they moved or not..

Btw the game in question is runescape.. Not that I play it, its just that I wanted to challenge this game as I see a lot of bots out there for it but can't figure out how they made it.. and they're all made in Java so I thought I'd make the first C++ one to see how hard it would be and if it would be possible to load java in c++ and how hard that would be :S

But judging by the amount of replies.. I guess it must be out of my league :c

triumphost 120 Posting Whiz

Hi guys, I'm currently switching from mechanical engineering to Computer Programming analyst in September so I have a few months to learn how to do this..

What I want to do is make a Bot for a game.. The game is written in Java and I want to load it in C++ and use mouse functions to play for me..

I need a little push because I searched all over google and came across JNI and stuff but I still can't find any examples or someone who thought of this idea before :S


How would I go about calling java in c++ or invoking it.. I basically was trying to create a form with a large area and then I want to have it load the java applet.. If this is possible does anyone have any examples or links I can refer to?

triumphost 120 Posting Whiz

Uhh Iunno what I was thinking above.. the Code is right.. but I meant to say that there are no differences as Async only raises the DoWork Event.. I was thinking async versus sync..

Hate the stupid 30 min edit timing..