|
Looking for the correct syntax to do the following.
I have a C++ dialog based application.
I would like to code a button to have the following functionality when pressed.
1. Launch a video player , like quicktime or mediaplayer
2. Play a video clip that i will supply.
Anyone know the syntax for this in C++ ?
|
|
|
|
|
Try here.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Does anyone know of a reliable formula that returns a text color that appropriately contrasts a background color? Even something as coarse as black or white will suffice - a la:
COLORREF getTextColor
(COLORREF rgbBkgColor)
{
if (...)
return (RGB (0, 0, 0));
return (RGB (255, 255, 255));
} Unfortunately the standard brightness formula doesn't appear to be accurate for all colors.
int nBrightness = (GetRValue (rgbBkg) * 299 +
GetGValue (rgbBkg) * 587 +
GetBValue (rgbBkg) * 114) / 1000;
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
well try this :
// r = red
// g = green
// b = blue
int i = 0;
if((r > b)&&(r > g))i = 1; // red is primary
if((g > r)&&(g > b))i = 2; // green is primary
if((b > r)&&(b > g))i = 3; // blue is primary
switch(i)
{
case 1:
SetColor(0,255,255);
break;
// and so on
}
// ofcourse there is other combinations, just think of them and define their contrast
CRPG, FRPG, Oblivion Fan
Hater of Counter Strike ( i hate it soo much damn it );
|
|
|
|
|
Unfortunately this doesn't work too well. I ended up using a modified version of the brightness algorithm (see my later post).
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Have you tried this: rgbBkgColor = ~rgbBkgColor;
You may not like the results, but it should work. Your only other (reasonable) choice would be to let the user decide (better), but that is not always possible.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Unfortunately this doesn't work too well. I ended up using a modified version of the brightness algorithm (see my later post).
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I ended up using a modified version of the brightness algorithm.
COLORREF CDlgWeatherMate::getTextColor
(COLORREF rgbBkgColor)
{
COLORREF rgbText = RGB (255, 255, 255);
int nRed = GetRValue (rgbBkgColor);
int nGreen = GetGValue (rgbBkgColor);
int nBlue = GetBValue (rgbBkgColor);
int nBrightness = (nRed*299 + nGreen*587 + nBlue*114) / 1000;
if (nBrightness > 150)
rgbText = RGB (0, 0, 0);
if (rgbText == RGB (255, 255, 255)) {
if ((nRed == 0) && (nBlue == 0) && (nGreen > 153))
rgbText = RGB (0, 0, 0);
}
return (rgbText);
} /ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I don't know if this will work any better, but this is what I have in one of my libraries: (I think the luminosity algo came from a Paul D. MSDN article)
int AfxGetLuminosity(COLORREF color)
{
const int HLSMAX = 240;
const int RGBMAX = 255;
int nRed = GetRValue(color);
int nGreen = GetGValue(color);
int nBlue = GetBValue(color);
int nRGBMax = max(max(nRed, nGreen), nBlue);
int nRGBMin = min(min(nRed, nGreen), nBlue);
return (((nRGBMax + nRGBMin) * HLSMAX) + RGBMAX) / (2 * RGBMAX);
}
...
COLORREF colorText = ((AfxGetLuminosity(colorBackground) > 120) ? RGB(0,0,0) : RGB(255,255,255));
In Italy for thirty years under the Borgias they had warfare, terror, murder, bloodshed - but they produced Michelangelo, Leonardo da Vinci and the Renaissance. In Switzerland they had brotherly love, five hundred years of democracy and what did that produce - the cuckoo clock!
-- Harry Lime
|
|
|
|
|
Thanks, Jack! I'll try it out. I'm a big fan of PDL and have faith in his code.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Tried it out - unfortunately it gives the same results as the brightess algorithm. But it works equally well if I add the green hack.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I use Visual C++ 2003 .NET, and i have a problem with task list. The thing is that sometimes it simply don't works. When i click on the Task List Tab it wont jump out. So i have to exit from IDE and run it again to see errors in Task List. Although task list worked for many years on many diffrent systems for me, Is there any option to set Task List not to work.
Task List works after i first run IDE and compile a few projects. And then simply like it doesn't exists.
CRPG, FRPG, Oblivion Fan
Hater of Counter Strike ( i hate it soo much damn it );
|
|
|
|
|
It does not realy matter what IDE (or languange) you're using.
It sounds like you're stepping on some toes, some where in your program. There is some thing still running, that probably should not be (it shuts down when the IDE shuts down, usually [good design]). I know that this should not affect the task manager, but then there is what is logical and what is reality.
I would probably place system calls to execute the task manager at specific points in my code. Consider it a type of single stepping, if the call successeds then exit the task manager (manualy). You should also place TRACE() commands in your code to tell you if a call to the task manager succeded or not.
Have fun!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hey John, the OP was talking about the task list inside the Visual Studio IDE
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I've encountered the same problem, it happens occasionally and just as you said, closing and reopening the IDE seems to get rid of it. Don't know why it happens though
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
hi
i'm trying to make my app to sit in the Physical Memory ?
i read an article from microsoft and it said that i can get PhysicalMemory by using VirtualAlloc which returns my a range of adresses of memory
how can i put in this range an object?
how can i make my application to sit in this range?
or by any other way?
(may be somthing with working set ?? )
|
|
|
|
|
You need to do some more reading: VirtualAlloc() is essentialy used to reserve (a number of virtual memory pages [range of memory]) memory for your applications use. Then you can use VirtualAlloc() to commit individual pages, without consuming physical storage until it is needed.
In other words, it does not allocate physical memory directly!
As for your app sitting in physical memory: it probably does (while running), unless it is rediculously large. The only time the whole of your program is not in physical memory is when it is to large or some other program is active and it needs the physical memory space.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
VirtualAlloc doesn't make your app sit in physical memory. It simply reserves and/or commits a range of virtual addresses for you. You might want to take a look at the VirtualLock function, but are you sure your app absolutely needs to be in physical memory?
how can i put in this range an object?
VirtualAlloc simply returns a void*, you can have an array of structs which have a pointer to the starting address of the region and the region size, if you want to.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello all,
I have CAsyncSocket class I have rewritten the virtual member function OnReceive:
void CCommunication::OnReceive( int nErrorCode )
{
if( nErrorCode == WSAENETDOWN ){
ASSERT( 0 );
return;
}
// do my useful task
// parent
CAsyncSocket::OnReceive( nErrorCode );
}
This clas is used in main dialog window.
Sometimes I am loosing packets ... Why?
All packets are on the ethernet but I dont receive some of them. For example: There are 4 packets on the ETH but I receive only first three.
This happens about three seconds after application start on Cel.900MHz@256MbRAM, and when I drag the main window by the title bar on the SempronMobile 3000+@704MbRAM
The application is MFC dialog based. The communication is UDP.
Thank you for any suggestion ...
xSoptik
|
|
|
|
|
|
Hello all,
I would like to change window size by the actual string size. The string size deplend on the actual font.
I am not able to get actual string lenght in pixels ...
Do you now any function that returns actual string length in pixels?
thank you for any advice
|
|
|
|
|
The GetTextExtent... functions will do that.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Hey everybody. Does anybody got a clue why this code doesn't work? I wanted to simply create a string with that number in it, without using sprintf.
void Test (long lSomeValue)<br />
{<br />
char *cValue = (char*)malloc(15);<br />
char *cText = (char*)malloc(50);<br />
<br />
cText = "The number is: ";<br />
_ltoa(lSomeValue, cValue, 10);<br />
strcat(cText, cValue);<br />
MessageBox(0, cText, "bla", 0);
}<br />
Test(10);
So how can I do this without using sprintf? And without using CString class.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote:
void Test (long lSomeValue)
{
char *cValue = (char*)malloc(15);
char *cText = (char*)malloc(50);
cText and cValue are pointers. Right now they point to the memory locations returned by the malloc function.
Axonn Echysttas wrote:
cText = "The number is: ";
cText now points to a different memory location then it did before. It now points to a static memory containing the text "The number is: ". To actually copy the text into the memory that was allocated with malloc you have to use strcpy()
strcpy (cText, "The number is: ");
Axonn Echysttas wrote:
_ltoa(lSomeValue, cValue, 10);
strcat(cText, cValue);
Here the strcat function will fail, most likely with an access violation, because the memory pointed to by cText is readonly memory.
To see this happen, run the program in the debugger, and step through the Test() function, watching the values of cValue and CText as you go. The debugger will give you the memory address pointed to be the pointers, followed by the text contained in that memory. Note the addresses that are assigned by the malloc calls. Now see how when you call cText = "The Number is: "; the address that cText points to changes well as the text, but when you call _ltoa(lsomevalue, cValue, 10); the address that cValue points to remains the same, but the text at that address changes.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks PJ Arends. This is the second time you pull me out of my misery : D. This question was actually for an article I'm working on... for the Code Project that is. It's about inter-process communication. I hope in 2 weeks it's gonna be done, since I'm not working at it all the time. Anyway... I understand now the memory issue. I'm not such an expert in these things since I started using Visual C++ recently compared to you guys. I'm gonna post a message here when I uploaded that article. But I wrote to the Code Project staff, since I got a user-name problem (lost my old e-mail) and they didn't answer yet. Until they do even if I finish it I won't be able to upload it.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|