{"id":24868,"date":"2017-10-15T12:42:40","date_gmt":"2017-10-15T07:12:40","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=24868"},"modified":"2017-10-15T12:42:40","modified_gmt":"2017-10-15T07:12:40","slug":"c-program-restrict-mouse-pointer-circle","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/c-program-restrict-mouse-pointer-circle\/","title":{"rendered":"c program to restrict mouse pointer in a circle"},"content":{"rendered":"<p>This program restricts mouse pointer in a circle i.e you can\u2019t move mouse out of a circle. When you try to bring mouse pointer outside the circle, mouse pointer is moved to it\u2019s previous location which is inside the circle. Code to restrict mouse in circle is given below :-<\/p>\n<h2 id=\"c-programming-code\">C programming code<\/h2>\n[pastacode lang=\u201dc\u201d manual=\u201d%23include%3Cgraphics.h%3E%0A%23include%3Cconio.h%3E%0A%23include%3Cdos.h%3E%0A%23include%3Cstdlib.h%3E%0A%23include%3Cmath.h%3E%0A%20%0Aunion%20REGS%20i%2C%20o%3B%0A%20%0Aint%20initmouse()%0A%7B%0A%20%20%20i.x.ax%20%3D%200%3B%0A%20%20%20int86(0X33%2C%20%26i%2C%20%26o)%3B%0A%20%20%20return%20(%20o.x.ax%20)%3B%0A%7D%0A%20%0Avoid%20showmouseptr()%0A%7B%0A%20%20%20i.x.ax%20%3D%201%3B%0A%20%20%20int86(0X33%2C%20%26i%2C%20%26o)%3B%0A%7D%0A%20%0Avoid%20hidemopuseptr()%0A%7B%0A%20%20%20i.x.ax%20%3D%202%3B%0A%20%20%20int86(0X33%2C%26i%2C%26o)%3B%0A%7D%0A%20%0Avoid%20getmousepos(int%20*x%2C%20int%20*y)%0A%7B%0A%20%20%20i.x.ax%20%3D%203%3B%0A%20%20%20int86(0X33%2C%20%26i%2C%20%26o)%3B%0A%20%20%20*x%20%3D%20o.x.cx%3B%0A%20%20%20*y%20%3D%20o.x.dx%3B%0A%20%0A%7D%0A%20%0Avoid%20movemouseptr(int%20x%2C%20int%20y)%0A%7B%0A%20%20%20i.x.ax%20%3D%204%3B%0A%20%20%20i.x.cx%20%3D%20x%3B%0A%20%20%20i.x.dx%20%3D%20y%3B%0A%20%20%20int86(0X33%2C%20%26i%2C%20%26o)%3B%0A%7D%0A%20%0Amain()%0A%7B%0A%20%20%20int%20gd%20%3D%20DETECT%2C%20gm%2C%20midx%2C%20midy%2C%20radius%2C%20x%2C%20y%2C%20tempx%2C%20tempy%3B%0A%20%0A%20%20%20radius%20%3D%20100%3B%0A%20%0A%20%20%20initgraph(%26gd%2C%20%26gm%2C%20%22C%3A%5C%5CTC%5C%5CBGI%22)%3B%0A%20%0A%20%20%20if(!initmouse())%0A%20%20%20%7B%0A%20%20%20%20%20%20closegraph()%3B%0A%20%20%20%20%20%20exit(1)%3B%0A%20%20%20%7D%0A%20%0A%20%20%20midx%20%3D%20getmaxx()%2F2%3B%0A%20%20%20midy%20%3D%20getmaxy()%2F2%3B%0A%20%0A%20%20%20showmouseptr()%3B%0A%20%20%20movemouseptr(midx%2C%20midy)%3B%0A%20%20%20circle(midx%2C%20midy%2C%20radius)%3B%0A%20%0A%20%20%20x%20%3D%20tempx%20%3D%20midx%3B%0A%20%20%20y%20%3D%20tempy%20%3D%20midy%3B%0A%20%0A%20%20%20while(!kbhit())%0A%20%20%20%7B%0A%20%20%20%20%20%20getmousepos(%26x%2C%20%26y)%3B%0A%20%0A%20%20%20%20%20%20if((pow(x-midx%2C2)%2Bpow(y-midy%2C2)-pow(radius%2C2))%3E0)%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20movemouseptr(tempx%2C%20tempy)%3B%0A%20%20%20%20%20%20%20%20%20x%20%3D%20tempx%3B%0A%20%20%20%20%20%20%20%20%20y%20%3D%20tempy%3B%0A%20%20%20%20%20%20%7D%0A%20%0A%20%20%20%20%20%20tempx%20%3D%20x%3B%0A%20%20%20%20%20%20tempy%20%3D%20y%3B%0A%20%20%20%7D%0A%20%0A%20%20%20closegraph()%3B%0A%20%20%20return%200%3B%0A%7D\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>c program to restrict mouse pointer in a circle &#8211; c programming &#8211; When you bring mouse pointer outside circle, mouse pointer is moved to previous location<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82927,1],"tags":[83312,83325,83320,83317,83324,83313,83315,83314,83322,83316,83318,83323,83321,83319,83326],"class_list":["post-24868","post","type-post","status-publish","format-standard","hentry","category-c-programming-2","category-coding","tag-c-program-for-mouse-pointer","tag-c-program-to-change-mouse-cursor","tag-c-restrict-reference","tag-how-to-use-mouse-in-turbo-c","tag-mouse-click-event-in-c-language","tag-mouse-event-in-c","tag-mouse-interaction-in-c","tag-mouse-programming-in-c","tag-mouse-programming-in-c-graphics","tag-mouse-programming-in-c-pdf","tag-mouse-programming-in-computer-graphics","tag-mouse-programming-in-interactive-computer-graphics","tag-restrict-keyword-c11","tag-restrict-keyword-in-c-example","tag-restrict-mouse-pointer-in-circle"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/24868","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=24868"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/24868\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=24868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=24868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=24868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}