Navigation Bar With C/C++ (Part-1)

 Hello friends, welcome to our new post today we will create a Navigation Bar with C/C++.


              


I know you are surprized after reading the title but yes its true we will create a navigation bar with some hover effects in C/C++. The C/C++ language is not for this type of program but i have created just for fun hope you like it. 


SOURCE CODE

#include<graphics.h>

int main()

{

initwindow(700,600,"HOVER",20,50);

int h_color=9,a_color=9,c_color=9;

int page=0;

while(1)

{

setactivepage(page);

setvisualpage(1-page);

settextstyle(4,HORIZ_DIR,4);

//home

setcolor(h_color);

outtextxy(50,100,"Home");

//about

setcolor(a_color);

    outtextxy(220,100,"About");

    

    

    //contact

    setcolor(c_color);

    outtextxy(390,100,"Contact");

    

    

    //cursor

    POINT cursor;

    GetCursorPos(&cursor);

    

    

    //logic

    

       //home

    if((cursor.x >=50+20 && cursor.x<=170+20)&&(cursor.y>=100+50 &&cursor.y<=150+50))

    h_color=14;

    else

    h_color=9;

          //about

    if((cursor.x >=220+20 && cursor.x<=340+20)&&(cursor.y>=100+50 &&cursor.y<=150+50))

    a_color=14;

    else

    a_color=9;

  //contact

    if((cursor.x >=390+20 && cursor.x<=550+20)&&(cursor.y>=100+50 &&cursor.y<=150+50))

    c_color=14;

    else

    c_color=9;     

    

    page=1-page;

    delay(10);

}

getch();

closegraph();

}



NOTE- If you are getting some errors related to header file so you need to download graphics.h header file and you have to add it on compiler after that you are able to run all graphics program so you can read blog How TO Run Graphics Program or you can watch Video for graphics.h header setup.


Post a Comment

Previous Post Next Post