Monday, July 28, 2014

.Net Framework Web Browser Class


Web Browser class is one of the most important class provided by .NET Framework for tasks related with web. It has lots of methods which can be used to implement web related tasks such as web scraping, creating a inbuilt browser in a software and many more.

Now I am going to let you know how to create program which will search a given word in yahoo search engine using this WebBrowser class. The language I am using to explain is C# here but you can use languages as visual C++, F#, VB as well.
You need to have some knowledge about C# and HTML before begin to do this task because almost all the things are represented in HTML in a web page thus you need to have an  understanding about HTML. Also if you do not know anything about C# then you are again in trouble. Therefore the prerequisites are C# (I am using Visual Studio 2013 IDE)  and HTML.

Lets get into work,

open visual studio and go to New => project => select windows forms Application under C#

Then you will see a windows form appear with title Form1. Now drag  a "button", "textbox" and a "web browser" from the tool box.


 Set the URL of the web browser as https://www.yahoo.com and text of the button(not the name) as "Go".
you have to make sure that the names of each component were not changed.
web browser name  : webBrowser1
button name            : button1
text box name         : textBox1

Now click on the text box and set TextChanged event as shown below:


just double clik on the TexChanged event(highlighted in yellow).

then a new file will be opened(Form1.cs)  and you will see a method called "textBox1_TextChanged".

 Now always when we  type something on the text box, this method is invoked. What we expect from this is when we type something on the text box it should be appeared on the search box of the yahoo search engine. Now we place a code inside textBox1_TextChanged method to do this task.

How it looks like after adding the code

The piece of code we used it shown above. Now your basic HTML and C# knowledge will help you to understand what happened and I will explain how we got the element ID.(p_13838465-p).

go to the shown link using your web browser. https://www.yahoo.com

now right click on the search box and click Inspect Element (I assume you know these things)

Finding ID of the search box

Then you will see the ID of the search box.

Our next step is setting the "go" button in the windows form work as "search web" button in the web page.

set button click event handler on the "go" button or just double click on the "go" button to set it automatically. set following code to the button1_Click method.

You can find the ID of the search button by the same method used to find the ID of search box.


This is all with coding and now you can test your program by running the code.

When you run the program you will see the web page is loaded into the web browser window.

Then type anything in the text box of the program, then you will see same text appears on the search box too.

When you click the "go" button it will search the web with the entered word.

I hope now you got an idea about some of usages of the web browser class. Like this you can do lots of advanced things with using this class.

Comment below If you have any question regarding this program.

Saturday, May 31, 2014

How to create c++ header files and make them work in ubuntu

You can easily create header files in c++ and work with them using an IDE(Integrated Development Environment) such as CodeBlocks, Eclipse, etc. If you are using an IDE, you just need to create the relevant files( such as header file, implementation file and main file) and compile them directly using the IDE. so when you give the compile command  the IDE care the rest of the tasks and give you the output.

But if you are going to do this task in a terminal(ubuntu) without using any IDE then you will have to do these all the steps done by the IDE manually. Therefore here is explained how the same thing can be done by using terminal.(only the steps are shown and not in much details)

step 1 :

You need to create the header file as you need
(a sample header file is shown below)

// rectangle.h  (begining of the file)


#ifndef _RECTANGLE_H
#define _RECTANBLE_H


double area(int length, int width);
// initialize any functions as you need
#endif


// end of the file

you need to save this as a header file.(rectangle.h)

step 2 :

Now you need to create the implementation file.
(a sample implementation file is shown below)

//rectangle.cpp (begining of the file)

#include <iostream>
#include "rectangle.h"

using namespace std;


double area(int length, int width){

    return length*width;

}


// end of the file

you need to save this file as a c++ file (rectangle.cpp)


step 3 :

Now you need to create the main file
(a sample main file is shown below)


// main.cpp  beginning of the file

 #include <iostream>
#include "rectangle.h"

int main(){

    std::cout<< area(4,4);

    return 0;

}


// end of the file

you need to save this file as a c++ file (main.cpp)

step 4 :

Now you can run these files on terminal.

put all the above 3 files into a same folder. then open terminal and go to the folder where these 3 files reside. (using "cd" command   eg : "cd Desktop\header_test_folder")

first you need to compile all c++ files.
type bellow command for each c++ file

g++ -c filename.cpp
 //other cpp files (if any)
g++ -c main.cpp

example : (for above files)

g++ -c rectangle.cpp
g++ -c main.cpp

now you need to link these files and create the executable file.
so you need to run below command for that.

g++ -o finalfilename main.o filename.o  // otherfiles.o (if any) 

example : (for above files)

g++ -o finalrectangle main.o rectangle.o

now you can see there is a new file in your directory(finalfilename)
you need to run that file

./finalfilename

for above example

./finalrectangle

now it will be running on the terminal.









Sunday, February 16, 2014

Assemble Your Dream PC



Hello friends, today from this short article I am going to describe  about pc configurators.  Actually there is a dream computer in everyone's mind. Which may be powerful pc with high performance with magnificent components.


Now you are capable of assembling your dream pc virtually. That means now you can make your dream computer virtually using desired components. so after creating it you can see how it looks like and know the total price of the computer.

This virtual assembly can be done using a pc configurator software which is available online free of charge. So you can build any computer you like and get an understanding about that computer. I have provided some links of pc configurators. Now you can go to those web sites and begin building any pc you like.

 PC Configurators

  Artilces You may like  :  Cloud Gaming   Blu-Ray Disc