|
Is there a way to check and change the monitor resolution from the VC++ program.
I needed a big dialog to previwe 4 camera feeds on the dialog box each occupying a display area of 352x288 and with adequate spacing between each display area. the dialog has a few buttons also. So i cant fit all of these in a dialog if the monitor 800x600 resolution.
So when i run the application in a diff machine i can check the resolution and fix it.
|
|
|
|
|
nripun wrote: Is there a way to...change the monitor resolution from the VC++ program.
See ChangeDisplaySettings() .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Can you send me an example that I run it an HTML file run .
tnks
|
|
|
|
|
ShellExecute(NULL,"open","yourHTMLFilePath.html",NULL,NULL,SW_SHOWNORMAL);
Nibu thomas
Software Developer
|
|
|
|
|
|
man ! do you look at your answers[^] when asking for something ?!
[edit]
ah I see, you deleted your post after my second reply to make people think I'm dumb ?
but you failed...
[/edit]
-- modified at 7:52 Tuesday 7th March, 2006
|
|
|
|
|
how to get the current system IP address?
JAYARAJ
|
|
|
|
|
|
i got it thanks
CString CIP::GetIP()
{
CString strIp;
//Init winsock
WSADATA wsaData;
int nErrorCode = WSAStartup(MAKEWORD(1,1), &wsaData);
if (nErrorCode != 0) {
//Cannot initialize winsock
return _T("");
}
char strHostName[81];
if (gethostname(strHostName, 80)==0)
{
hostent *pHost = gethostbyname(strHostName);
if (pHost->h_addrtype == AF_INET)
{
in_addr **ppip=(in_addr**)pHost->h_addr_list;
//Enumarate all addresses
while (*ppip)
{
in_addr ip=**ppip;
strIp = CString(inet_ntoa(ip));
ppip++;
if (strIp!=_T("")) {
break;
}
}
}
}
return strIp;
}
JAYARAJ
|
|
|
|
|
Hi,
Im using the CTime to calculate the date when adding number of days. The
strange thing is that when I add 58 and 59 days to the same date it returns
the same date. Here is the small code:
void DateCalc(int Days)
{
int Date=1;
int Month=9;
int Year1,Month1,Day1;
CTime Check( 2006, Month,Date,0,0,0);
Check+=CTimeSpan( Days,0,0,0);
Year1=Check.GetYear();
Month1=Check.GetMonth();
Day1=Check.GetDay();
TRACE("Year %d Month %d Date %d\n",Year1,Month1,Day1);
}
... function(...)
{
DateCalc(58); //add 58 days to 1/9/2006
DateCalc(59); //add 59 days to 1/9/2006
Both TRACE(..) functions within DateCalc(..) displays :
Year 2006 Month 10 Date 29
Year 2006 Month 10 Date 29
Anyone explain this?
Neil
|
|
|
|
|
Just try COleDateTime instead of CTime .
Nibu thomas
Software Developer
|
|
|
|
|
How do I add number of days to date? I tried the below, but didnt allow me to dd days to it.
int Month=9;
int Date=1;
COleDateTime Check( 2006, Month,Date,0,0,0);
Check+=CTimeSpan( 58,0,0,0);
Neil
|
|
|
|
|
NeilDevlin wrote: Check+=CTimeSpan( 58,0,0,0);
Check+=COleDateTimeSpan( 58,0,0,0);
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
That worked, thanks..
Neil
|
|
|
|
|
<wild guess>
British Summer Time ends on 29 Oct. My guess is that the CTime class is doing some BST/GMT stuff behind your back. I'd check the hour value of the Check variable, to see if that's changing.
</wild guess>
|
|
|
|
|
NeilDevlin wrote: Anyone explain this?
Go ahead and output the hour, minute, and second. Notice that the first one is 00:00:00 while the second one is 23:23:00. That BST thing is affecting you. To solve this, simply add another 0 to the CTime constructor.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
How do I find the number of bits set in a given integer number without using any while/for loop?
|
|
|
|
|
myInt mi = ;
int iCpt = 0;
for (int i = 0; i < sizeof(mi) * 8; i++) {
if ((mi & 0x1) == 0x1) {
iCpt++;
}
mi >> 1;
}
printf("mi contains %d '1'\n", iCpt);
ps: don't cross posts the forums. delete your question on the C++/CLI forum, as it is not a managed C++ question
-- modified at 6:51 Tuesday 7th March, 2006 (thanks stephen)
|
|
|
|
|
I don't believe this code will work:
v2.0 wrote: //For each bits in the integer
for (int i = 0; i < sizeof(mi); i++) {
Say "MyInt" is of type char . In this case sizeof(char) is 1. So the loop only loops once - But it should loop 8 times. With the following modification it will work:
for (int i = 0; i < sizeof(mi)*8; i++) {
PS: This assumes 8 bit chars - A fair assumption but not universally true on all platforms.
Steve
|
|
|
|
|
yep sorry, i fixed it consequently.
thanks
|
|
|
|
|
v2.0 wrote: for (int i = 0; i < sizeof(mi) * 8; i++) {
I believe that amar specifically indicated no while or for loops.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
yes, badKarma already notified me about that point that i did not see firstly
|
|
|
|
|
Given this:
#include <iostream>
#include <bitset>
using namespace std;
typedef bitset<sizeof(int)*8> IntBitSet;
You can count the bits like this:
cout << IntBitSet(42).count();
Steve
|
|
|
|
|
that's good, but very expensive way though
|
|
|
|
|
With templates only the methods actually called are compiled. Also, in general, the methods will be inline. That said the MSVC6 STL bitset class isn't as good as it could be and it will be slower then manually written code. With a good compiler (which MSVC6 is not) and a good STL there is no reason why it can't be just as efficient.
Steve
|
|
|
|