|
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
|
|
|
|
|
Hi
in my application i try to set an printer fonts.From msdn i took this example how it do.
CHOOSEFONT cf;
LOGFONT lf;
HFONT hfont;
// Initialize members of the CHOOSEFONT structure.
cf.lStructSize = sizeof(CHOOSEFONT);
cf.hwndOwner = (HWND)NULL;
cf.hDC = (HDC)NULL;
cf.lpLogFont = &lf;
cf.iPointSize = 0;
cf.Flags = CF_SCREENFONTS;
cf.rgbColors = RGB(0,0,0);
cf.lCustData = 0L;
cf.lpfnHook = (LPCFHOOKPROC)NULL;
cf.lpTemplateName = (LPSTR)NULL;
cf.hInstance = (HINSTANCE) NULL;
cf.lpszStyle = (LPSTR)NULL;
cf.nFontType = SCREEN_FONTTYPE;
cf.nSizeMin = 0;
cf.nSizeMax = 0;
// Display the CHOOSEFONT common-dialog box.
ChooseFont(&cf);
// Create a logical font based on the user's
// selection and return a handle identifying
// that font.
hfont = CreateFontIndirect(cf.lpLogFont);
//After this i has hfont variable vary by NULL,and try to
//select it into printer device context m_hPrinterDC
//(this variable was initialized early and
//also have a proper value,because of when i output text
//on one or do any other acts all work fine.
//In this step i try to select created logical font into dc
HGDIOBJ hf1 = SelectObject(m_hPrinterDC,&hfont);
//This function return NULL,what meant an error.
Where is my fault?????
Also i try to change some params in cf structure like this:
cf.hDC = m_hPrinterDC;
cf.Flags = CF_PRINTERFONTS;
cf.nFontType = PRINTER_FONTTYPE;
But result exactly same.
Thanks.
|
|
|
|
|
Search Article on Microsoft website -> "How To Use Printer Device Fonts"
It might be of help, if need to use Printer Font.
|
|
|
|
|
I create followng:
CDialog dlg;
dlg.Create(IDD.pWnd);
dlg appears, but I neeed to hide it,
I made following:
but no resilt,
how to do it?
<br />
int cWaitDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
<br />
<br />
this->ModifyStyle(WS_VISIBLE,0,0);<br />
<br />
lpCreateStruct->style |= WS_VISIBLE;<br />
lpCreateStruct->style -= WS_VISIBLE;<br />
<br />
this->ShowWindow(SW_HIDE);<br />
<br />
if (__super::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
<br />
<br />
return 0;<br />
}<br />
<br />
BOOL cWaitDlg::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
<br />
cs.style |= WS_VISIBLE;<br />
cs.style -= WS_VISIBLE;<br />
<br />
int j = cs.style & WS_VISIBLE;<br />
<br />
return __super::PreCreateWindow(cs);<br />
}<br />
<br />
<br />
|
|
|
|
|
vgrigor wrote:
this->ModifyStyle(WS_VISIBLE,0,0);
lpCreateStruct->style |= WS_VISIBLE;
lpCreateStruct->style -= WS_VISIBLE;
this->ShowWindow(SW_HIDE);
What are you trying to do here? If you want the window to be hidden, why not just remove the WS_VISIBLE style from the dialog template? Otherwise, the code you have makes no sense. Note this may not work as CDialog::OnInitDialog() "shows" the window explicitly.
vgrigor wrote:
if (__super::OnCreate(lpCreateStruct) == -1)
Is this a construct for Windows CE? Just curious.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Removing style not prevent from appearing,
so that even I hide by comman Window will flick one moment,
and that is problem.
Need to to appear at any.
Until commanded else.
|
|
|
|
|
vgrigor wrote:
Removing style not prevent from appearing...
I suspected such.
vgrigor wrote:
Need to to appear at any.
Until commanded else.
What does this mean?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Sorry I did notinitially
typed text question:
now I added it:
I create followng:
CDialog dlg;
dlg.Create(IDD.pWnd);
dlg appears, but I neeed to hide it,
with no any time of apperiance,
I made following: code above...
but no resilt,
how to do it?
|
|
|
|
|
Derive a class from CDialog using the dialog template. In that class' constructor, call Create(IDD) .
CMyDialog *pDlg;
...
pDlg->ShowWindow(SW_SHOW);
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|