Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Power Lifting Lever Belt
SkullVamp
Updated:
Yesterday at 10:32 PM
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Yesterday at 3:55 PM
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Thursday at 2:23 PM
Ad icon
Wechat qr verification
Pawan2005
Updated:
Thursday at 1:28 AM
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Wednesday at 5:34 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
Programming in C/C++
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Enigma_1" data-source="post: 7855725" data-attributes="member: 78173"><p>onna thwath pissu <img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" />code ekak thiyenawa. mechchara kal api dakala thibbe MSDOS wala colors na kiyala (e kiyanne only black and white) . me program eka DOS prompt eke text colors walin print karanawa. </p><p>menna code eka</p><p></p><p>[CODE]</p><p>/*</p><p>major colors are </p><p>FOREGROUND_RED,FOREGROUND_BLUE,FOREGROUND_GREEN</p><p>BACKGROUND_BLUE,BACKGROUND_GREEN and BACKGROUND_RED</p><p>you can create new colors by performing the bitwise operations on these colors </p><p>please note that the MSDOS is not based on RGB color scheme. So the MSDOS is </p><p>only support for 6 colors (as far as I know).</p><p></p><p>FOREGROUND_INTENSITY - this increase the intensity of the text in the DOS screen</p><p>BACKGROUND_INTENSITY - this will increae the intensity of the bcakground color of the DOS screen</p><p></p><p>*/</p><p></p><p></p><p>#include <windows.h></p><p>#include <stdio.h></p><p></p><p>HANDLE hConsole;</p><p>CONSOLE_SCREEN_BUFFER_INFO ScreenBufInfo;</p><p></p><p>WORD colorWhite =BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_RED;</p><p></p><p>//These constants are used to draw the lines </p><p>char line[] = {</p><p> 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,</p><p> 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,</p><p> 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,</p><p> 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0x0A</p><p> };</p><p></p><p>void cPrintf(const char* szValue,WORD color);</p><p></p><p>int main()</p><p>{</p><p> </p><p> cPrintf("This is Red Color\n",FOREGROUND_RED);</p><p> cPrintf("This is Blue Color\n",FOREGROUND_BLUE);</p><p> cPrintf("This is Green Color\n",FOREGROUND_GREEN);</p><p></p><p> printf("\n");</p><p></p><p> cPrintf("This is Red with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_RED);</p><p> cPrintf("This is Blue with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_BLUE);</p><p> cPrintf("This is Green with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_GREEN);</p><p> cPrintf("This is Yellow with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED);</p><p> cPrintf("This is Green with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);</p><p> cPrintf("This is Purple with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_RED);</p><p> </p><p> printf("\n");</p><p></p><p> cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_RED);</p><p> cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_BLUE);</p><p> cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_GREEN);</p><p> cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED);</p><p> cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);</p><p> cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_RED);</p><p> </p><p> printf("\n");</p><p> cPrintf("This is Red Color with Background\n",FOREGROUND_RED|colorWhite);</p><p> cPrintf("This is Blue Color with Background\n",FOREGROUND_BLUE|colorWhite);</p><p> cPrintf("This is Green Color with Background\n",FOREGROUND_GREEN|colorWhite);</p><p> printf("\n\n");</p><p> system("pause");</p><p> return 0;</p><p>}</p><p></p><p></p><p>void cPrintf(const char* szValue,WORD color)</p><p>{</p><p> // free the memeory for the struct</p><p> ZeroMemory(&ScreenBufInfo,sizeof(ScreenBufInfo)); </p><p> //geting the handle of the console</p><p> hConsole = GetStdHandle(STD_OUTPUT_HANDLE); </p><p> // saving the original values of the console buffer</p><p> GetConsoleScreenBufferInfo(hConsole,&ScreenBufInfo);</p><p> //setting the new color</p><p> SetConsoleTextAttribute(hConsole,color);</p><p> //printing the value with new color</p><p> printf(szValue);</p><p> // resting the color to its normal values </p><p> SetConsoleTextAttribute(hConsole,ScreenBufInfo.wAttributes);</p><p>}</p><p>[/CODE]menna screen shot ekak</p><p><img src="http://img5.imageshack.us/img5/4151/colorli.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p>code eka comment karala thiyenna. eth first time APIS ekka deal karana kenek ta meka tikak amaru wei. onama problem ekak ahanna. ona support ekak dennum <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></p><p></p><p>podi deyak kiyanna amathaka una. mama meka compile kale Visual studio 2005 eken. eth oyagollan ta anith IDEs unath use karanna puluwan. me program eka linux wala run karanna ba. windows OS eke witharai. Borland C++ compilers eken meka compile karanna puluwan weida kiyana eka gana num sure na. compilation errors awoth kiyanna </p><p><a href="http://www.microsoft.com/express/Downloads/" target="_blank">http://www.microsoft.com/express/Downloads/</a></p><p>me thiyenne Vs 2008/2010 Express editions download karaganna link ekak .</p></blockquote><p></p>
[QUOTE="Enigma_1, post: 7855725, member: 78173"] onna thwath pissu :rofl:code ekak thiyenawa. mechchara kal api dakala thibbe MSDOS wala colors na kiyala (e kiyanne only black and white) . me program eka DOS prompt eke text colors walin print karanawa. menna code eka [CODE] /* major colors are FOREGROUND_RED,FOREGROUND_BLUE,FOREGROUND_GREEN BACKGROUND_BLUE,BACKGROUND_GREEN and BACKGROUND_RED you can create new colors by performing the bitwise operations on these colors please note that the MSDOS is not based on RGB color scheme. So the MSDOS is only support for 6 colors (as far as I know). FOREGROUND_INTENSITY - this increase the intensity of the text in the DOS screen BACKGROUND_INTENSITY - this will increae the intensity of the bcakground color of the DOS screen */ #include <windows.h> #include <stdio.h> HANDLE hConsole; CONSOLE_SCREEN_BUFFER_INFO ScreenBufInfo; WORD colorWhite =BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_RED; //These constants are used to draw the lines char line[] = { 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB, 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB, 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB, 0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0xDB,0x0A }; void cPrintf(const char* szValue,WORD color); int main() { cPrintf("This is Red Color\n",FOREGROUND_RED); cPrintf("This is Blue Color\n",FOREGROUND_BLUE); cPrintf("This is Green Color\n",FOREGROUND_GREEN); printf("\n"); cPrintf("This is Red with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_RED); cPrintf("This is Blue with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_BLUE); cPrintf("This is Green with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_GREEN); cPrintf("This is Yellow with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED); cPrintf("This is Green with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE); cPrintf("This is Purple with high intensity\n",FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_RED); printf("\n"); cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_RED); cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_BLUE); cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_GREEN); cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED); cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE); cPrintf(line,FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_RED); printf("\n"); cPrintf("This is Red Color with Background\n",FOREGROUND_RED|colorWhite); cPrintf("This is Blue Color with Background\n",FOREGROUND_BLUE|colorWhite); cPrintf("This is Green Color with Background\n",FOREGROUND_GREEN|colorWhite); printf("\n\n"); system("pause"); return 0; } void cPrintf(const char* szValue,WORD color) { // free the memeory for the struct ZeroMemory(&ScreenBufInfo,sizeof(ScreenBufInfo)); //geting the handle of the console hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // saving the original values of the console buffer GetConsoleScreenBufferInfo(hConsole,&ScreenBufInfo); //setting the new color SetConsoleTextAttribute(hConsole,color); //printing the value with new color printf(szValue); // resting the color to its normal values SetConsoleTextAttribute(hConsole,ScreenBufInfo.wAttributes); } [/CODE]menna screen shot ekak [IMG]http://img5.imageshack.us/img5/4151/colorli.jpg[/IMG] code eka comment karala thiyenna. eth first time APIS ekka deal karana kenek ta meka tikak amaru wei. onama problem ekak ahanna. ona support ekak dennum :D podi deyak kiyanna amathaka una. mama meka compile kale Visual studio 2005 eken. eth oyagollan ta anith IDEs unath use karanna puluwan. me program eka linux wala run karanna ba. windows OS eke witharai. Borland C++ compilers eken meka compile karanna puluwan weida kiyana eka gana num sure na. compilation errors awoth kiyanna [URL]http://www.microsoft.com/express/Downloads/[/URL] me thiyenne Vs 2008/2010 Express editions download karaganna link ekak . [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom