|
DimpleSurana wrote:
Any Hints/Help to populate this struct with a non-local Timezone data.
I live in GMT-0600, which is known as CST here in the U.S. If I wanted the time for EST, or GMT-0500, I would do something like:
TIME_ZONE_INFORMATION tzi = {0};
SYSTEMTIME stUniversal = {0},
stLocal = {0};
tzi.Bias = 300;
GetSystemTime(&stUniversal);
SystemTimeToTzSpecificLocalTime(&tzi, &stUniversal, &stLocal);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi David,
I really appreciate the code snippets you give me. But i wanted to know that how do i add DST information to it too. For eg. EST timezone see's DST.
I idea is that "stLocal" will be given its TimeZone only once & hence forth onwards it should always know its TimeZone's Time including DST.
Thanks,
Dimple
|
|
|
|
|
Check out the DaylightBias member of the TIME_ZONE_INFORMATION structure.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Do u have ne generic solution that will update the time object based on the incoming timezone.
This is gonna require some manual programming i believe so was loking otu for a code snippet.
Dimple
|
|
|
|
|
Nothing that revolves around a "timezone identifier." Otherwise, the DaylightBias and Bias members should solve your problem.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi!
Having problem by using sprintf. I have the hexadecimal 2B67, and will convert it to decimal by using sprintf.
Can someone help me?? I know how to do vice verca.
|
|
|
|
|
As far as i know there is no datatype called hexadecimal.
What is the actuaal data type wheather its Int, long, or string
if its string then you need to convert it to long or int and use the following statemetn
printf("%d",nHexNum);
or
printf("%ld",lHexNum);
Which ever fits rite.
I have lost more blood shaving than on the battlefield - Adolf Hitler
|
|
|
|
|
Mr.Prakash wrote:
As far as i know there is no datatype called hexadecimal.
Then what do you call base-16 numbers?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
humm, is there any data type called base-16 in c/c++????
I have lost more blood shaving than on the battlefield - Adolf Hitler
|
|
|
|
|
No, but there are base-16 numbers, also known as hexadecimal numbers. Referring back to styve's post, he wanted to convert a base-16 number (hexadecimal) to a base-10 number (decimal).
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I certaily agree with you? I was trying to be within the context of C/C++,
Many newbies consider this as hexadecimal no.
int x = 0xff;
I have lost more blood shaving than on the battlefield - Adolf Hitler
|
|
|
|
|
Mr.Prakash wrote:
Many newbies consider this as hexadecimal no.
int x = 0xff;
While 0xff is indeed a hexadecimal number, the variable x is simply a spot in memory.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
What you mean by hexadecimal 2b67 ???
From the machine, it's just the same than 11111 in base-10...
The hexadeciaml is just the way YOU represent the number. But for the machine, it just sees 0's and 1's.
|
|
|
|
|
As I understand you are trying to get hexadecimal equivalent of numeric, as mentioned by others; all data in memory stayed in hexadecimal format, the issue is to display that in hexadecimal acsii char array, take a look below;
DWORD dwTest;
char a[20];
dwTest=0xAABBCCDD;
sprintf(a,"%x",dwText);
AfxMessageBox(a);
|
|
|
|
|
--------------------Configuration: Wyse2 - Win32 Debug--------------------
Here is the only error I get when building my app: Any ideas? I am using VC++ 6.0
Compiling resources...
Compiling...
stdafx.cpp
Wyse160.cpp
Linking...
LINK : fatal error LNK1104: cannot open file "nafxcwd.lib"
Error executing link.exe.
Souce code:
// Wyse160.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Wyse160.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#undef mc
//#define mc
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
DCB dcb;
int fSuccess;
DWORD dwResult;
DWORD BaudRate;
BYTE ByteSize;
BYTE Parity;
BYTE StopBits;
CString csErrMsg;
CString csTitle;
CString csComm;
char inBuffer[512];
char outBuffer[512];
int Read1COMM(char * inBuffer, DWORD nBytesToRead);
int Write1COMM(char * outBuffer,DWORD nBytesToWrite);
// Fill in the default com port and values for DCB: 9600 bps, 8 data bits, no parity and 2 stop bits
char *pcCommPort = "COM2";
BaudRate = CBR_9600; // set the baud rate
ByteSize = 8; // data size
Parity = NOPARITY; // set parity
StopBits = TWOSTOPBITS; // two stop bits
csTitle.Format("Data Station Wyse Terminal %.2f", version);
SetConsoleTitle(csTitle);
m_hMainWait = CreateEvent( NULL, FALSE, FALSE, NULL);
pcCommPort = "COM1";
BaudRate = CBR_9600;
Parity = NOPARITY;
ByteSize = 8;
StopBits = ONESTOPBIT;
/*Parity = EVENPARITY;
Parity = ODDPARITY;
Parity = NOPARITY;
Parity = MARKPARITY;
StopBits = ONESTOPBIT;
StopBits = ONE5STOPBITS;
StopBits = TWOSTOPBITS; */
csTitle.Format("Data Station Wyse Terminal %.2f %s", version, pcCommPort);
SetConsoleTitle(csTitle);
CommTimeouts = new _COMMTIMEOUTS;
/* m_PKeybrdThread = 0;
m_PScreenThread = 0;*/
m_bLine = false;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
m_hCom = CreateFile (pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // open as exclusive access
NULL, // no security
OPEN_EXISTING,
0, // not overlapped I/O
NULL // comm device
);
if (m_hCom == INVALID_HANDLE_VALUE)
{
wyseErr("Connect to COM port failed.");
return (1);
}
// Configure the comm port
fSuccess = GetCommState(m_hCom, &dcb);
if (!fSuccess)
{
// Handle error
wyseErr("Could not get COM state.");
return (2);
}
dcb.BaudRate = BaudRate;
dcb.ByteSize = ByteSize;
dcb.Parity = Parity;
dcb.StopBits = StopBits;
fSuccess = SetCommState(m_hCom, &dcb);
if (!fSuccess)
{
wyseErr("Could not set COM state.");
return (3);
}
CommTimeouts->ReadIntervalTimeout = MAXDWORD;
CommTimeouts->ReadTotalTimeoutConstant = 0;
CommTimeouts->ReadTotalTimeoutMultiplier = 0;
CommTimeouts->WriteTotalTimeoutConstant = 0;
CommTimeouts->WriteTotalTimeoutMultiplier = 0;
fSuccess = SetCommTimeouts(m_hCom, CommTimeouts);
if (!fSuccess)
{
wyseErr("Could not set COM timeouts.");
return (4);
}
fSuccess = GetCommTimeouts(m_hCom, CommTimeouts);
if (!fSuccess)
{
wyseErr("Could not get COM timeouts.");
return (5);
}
printf ("Serial port %s is successfully reconfigured.\n", pcCommPort);
WaitForSingleObject(m_hMainWait, 2000);
Write1COMM(outBuffer,2 /*{# of bytes to write}*/);
Read1COMM(inBuffer,1 /*{# of bytes to read}*/);
_onexit (exitMain);
while (m_bRunning)
{
dwResult = WaitForSingleObject(m_hMainWait, 1000);
}
}
return nRetCode;
/*******************************************************************/
} /* END OF MAIN ROUTINE ********************************************/
/*******************************************************************/
int exitMain ()
{
m_bRunning = false;
return 0;
}
int Read1COMM(char * inBuffer, DWORD nBytesToRead)
{
DWORD nBytesRead = 0;
DWORD dwResult;
int nResult;
m_hCOMMWait = CreateEvent( NULL, FALSE, FALSE, NULL);
while (!nBytesRead)
{
nResult = ReadFile(m_hCom, inBuffer, 1, &nBytesRead , NULL);
if (nBytesRead)
inBuffer[nBytesRead] = 0;
else
dwResult = WaitForSingleObject(m_hCOMMWait, 100);
}
return nBytesRead;
}
int Write1COMM(char * outBuffer,DWORD nBytesToWrite)
{
/* char inBuffer[InBuffSize];*/
DWORD nBytesWritten;
int fSuccess;
nBytesWritten=0;
fSuccess = WriteFile(m_hCom, outBuffer, nBytesToWrite, &nBytesWritten , NULL);
/* m_PKeybrdThread = NULL; */
return fSuccess;
}
|
|
|
|
|
Woah, No need for the code, there is no logic error just linking error that means there is no problem with the code (from compilers view point )
Any way, did you add the nafxcwd.lib entry in the lib in the link tab in project settings.
I have lost more blood shaving than on the battlefield - Adolf Hitler
|
|
|
|
|
|
To get the text of a combobox item I'm currently using the code below:
m_cbCommand.GetLBText (m_cbCommand.GetCurSel (), csItem) I'm just curious as to if this is the best way to be doing this? I didn't really see any other related methods to get the text, but the way I'm using seems clunky. Thanks for any ideas.
- monrobot13
|
|
|
|
|
Nothing wrong in the code. Its perfectly legal.
I have lost more blood shaving than on the battlefield - Adolf Hitler
|
|
|
|
|
monrobot13 wrote:
I'm just curious as to if this is the best way to be doing this?
It's not. Use GetWindowText() instead. Depending on the style of combobox used, GetLBText() will not always get the text in the edit control.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Ah, that's sounds much better. Didn't even think of that. Thanks.
- monrobot13
|
|
|
|
|
// Show head
if (features->Head.bHeadFound)
{
const SHeadFeatures *pHead = &features->Head;
// Show head features (by green color)
if (pHead->bHeadSizeFound)
{
image.DrawMarker(pHead->iHeadTopX,pHead->iHeadTopY, sz,0, 0x00ff00);
image.DrawMarker(pHead->iHeadLeftX, pHead->iHeadLeftY, sz,0, 0x00ff00);
image.DrawMarker(pHead->iHeadRightX, pHead->iHeadRightY, sz,0,0x00ff00);
image.DrawMarker(pHead->iChinCenterX, pHead->iChinCenterY, sz,0, 0x00ff00);
image.DrawMarker(pHead->iChinLeftX, pHead->iChinLeftY, sz,0, 0x00ff00);
image.DrawMarker(pHead->iChinRightX, pHead->iChinRightY, sz,0, 0x00ff00);
}
if (pHead->bLeftTempleFound)
image.DrawMarker(pHead->iTempleLeftX, pHead->iTempleLeftY, sz,0, 0x00ff00);
if (pHead->bRightTempleFound)
image.DrawMarker(pHead->iTempleRightX,pHead->iTempleRightY, sz,0, 0x00ff00);
if (pHead->bSplFaceFound)
DrawSpline(pHead->hSpl_face,image,0x00ff00);
// Show head bounding box (by green color)
if (pHead->bBoundsFound)
{
image.DrawRect(features->Head.iLeftTopBoundX, features->Head.iLeftTopBoundY,
features->Head.iRightTopBoundX, features->Head.iRightTopBoundY,
features->Head.iLeftBotBoundX, features->Head.iLeftBotBoundY,
features->Head.iRightBotBoundX, features->Head.iRightBotBoundY,0x00ff00);
image.DrawLine(pHead->iFaceLeftTopBoundX, pHead->iFaceLeftTopBoundY,
pHead->iFaceRightTopBoundX, pHead->iFaceRightTopBoundY,0x00ff00);
}
}
CAN SOMEONE EXPLAIN TO ME THIS SET OF CODE
THANK ALOT
|
|
|
|
|
Why does it need any explanation??? Just compile and run it you will see it on the screen.
is it C#?
I have lost more blood shaving than on the battlefield - Adolf Hitler
|
|
|
|
|
Goh Hui Beng wrote:
CAN SOMEONE EXPLAIN TO ME THIS SET OF CODE
no, I won't, at least not right now, please ask a more specific question, what's the problem, what exactly you don't understand ?
it seems to be quite explicit ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
ok my problem is that i want this code to output some specific points like iLipBottomX the coordinate value.
but this code actually detects and draws out the picture.
From this can u deduce wat variable must i printf to get the result i want?
The SMouthFeature structure contain these variable
bool bMouthFound; // Mouth finding flag
bool bSplMouthFound; // Mouth spline finding flag
HSPLINE hSpl_mouth; // Mouth spline handle
bool bSplLipTopFound; // Top lip spline finding flag
HSPLINE hSpl_lip_top; // Top lip spline handle
bool bSplLipBottomFound; // Bottom lip spline finding flag
HSPLINE hSpl_lip_bottom; // Bottom lip spline handle
bool bLipTopFound; // Top lip point finding flag
int iLipTopX; // x coordinate of the top lip point
int iLipTopY; // y coordinate of the top lip point
bool bMouthCenterFound; // Mouth center finding flag
int iMouthCenterX; // x coordinate of the mouth center
int iMouthCenterY; // y coordinate of the mouth center
bool bLipBottomFound; // Bottom lip point finding flag
int iLipBottomX; // x coordinate of the bottom lip point
int iLipBottomY; // y coordinate of the bottom lip point
bool bMouthLeftCornerFound; // Mouth left corner finding flag
int iLeftCornerX; // x coordinate of the mouth left corner
int iLeftCornerY; // y
u understand or do u need further info i can provide
|
|
|
|
|