|
Please don't cheat, his question is actually very well defined. If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
do you really believe the code shown is the actual code?
that was only the tip of some iceberg; we can only guess what stuff is hiding below the surface.
|
|
|
|
|
Of course I don't believe that's the actual code and I'm pretty sure it hides tons of code behind. Anyway my point is still valid (and you know that ).
BTW it is friday, have a or two.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I thought I recalled what Luc Pattyn said, but went searching and basically came up with the same thing that Saurabh has presented. There is also a difference between the current C++ standard and the draft of the next standard. The current guarantees order only until the next access-specifier specifier.
The text in the draft for the new standard is:
Nonstatic data members of a (non-union) class with the same access control (clause 11) are allocated so that later members have higher addresses within a class object. The order of allocation of non-static data members with different access control is unspecified (11).
So to extend Saurabh's example:
class Foo<br />
{<br />
public:<br />
int x1;<br />
int y1;<br />
<br />
private:<br />
int x2;<br />
int y2;<br />
<br />
public:<br />
int x3;<br />
int y3;<br />
};
The draft for the new standard (unless its been changed from the one I looked at ) guarantees the order x1 - y1 - x3 - y3, while under the current standard the storage order of x1 and x3 is unspecified.Please do not read this signature.
|
|
|
|
|
I have been trying to interface with a software program which uses a message made up of a 20 word array of unsigned shorts;
unsigned short messageData[20];
I have been trying to use data from a home GPS system which includes Lat and Long and heading.; these have been converted from strings to floats.
e.g.
float lat, long, heading;
My problem is that as I know the scaling factors and least Sig Bit (LSB) for the lat, long and heading in the messageData buffer;
e.g.
For lat and long
LSB = 8.377E-08; Twos complement - 32 bits Max/ Min -180 to +180
For Heading
LSB 0.00549306; Twos complement - 16 bits Max/ Min -180 to +180
Setting the heading:-
unsigned short heading = (unsigned short)(newHeading/0.00549306);
messageData[10] = heading;
Getting the heading:-
bool negative;
unsigned short currentField = messageData[10];
if(currentField & 0x8000)
{
negative = true;
}
else
negative = false;
float heading = (currentField & 0x7FFF) * g_nScalings[wordPos];
if(negative)
heading = -(180 - heading);
But this does not work as I expected; am I missing something?
As for the 32 bit latitude, I was going to this:-
Setting the Latitude:-
union
{
int lat_long;
unsigned short buff[2];
}convert;
unsigned short highWord, lowWord;
int newData = (int)(fEngValue/8.377E-08);
convert.lat_long = newData;
highWord = convert.buff[1];
lowWord = convert.buff[0];
I need to get and set data in the message that is of type unsigned short and use in my program as scaled floats.
Any suggestions please.
|
|
|
|
|
Could you please elaborate a bit.
Could you post inputs, wrong and expected outputs?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you're dealing with floats that have been converted to strings, just convert them back to floats.
The unsigned short is the same as wchar_t - you should be able to use an explicit cast to 'convert' between them.
_wtof() converts a wchar_t string to a double , which you can then cast to a float , if the value is withing the range of type float .
_ecvt() converts a double (or float cast to double ) to a wchar_t string, though you'll have to do some string manipulation to put the sign and/or decimal in the indicated place(s).
Both functions are in <stdlib.h> .
Hope this is useful,
MZR
|
|
|
|
|
Sorry not made myself very clear.
Forget about strings to floats thats OK.
I need to cast from a float to a unsigned short using the information about the format about the unsigned short;
e.g. top bit is sign, LSB is the scaling.
Now if I run my code with a heading set to 3.45 this sets the unsigned short to 0xB999 which is not what I expected.
Or looking at it the other way if the value of the unsigned short is 0x0001 then this would represent heading = (float)0x0001 * LSB.
The messageData holds the data as unsigned shorts which need to be processed on Get and Set if that makes sense.
For Lat and Long two elements are used, for heading just one.
|
|
|
|
|
1.
could you give some actual data samples, where both the short representation and the real value are known?
four or more pairs would be good.
2.
for 32-bit data, for sure there only is one sign bit, so both halves need different treatment.
|
|
|
|
|
Just to recap and get things right in my mind; if a heading value is represented as an unsigned short (16 bits) with bit 1 = 0.000030517578125; so the range is -1 to + 1 and if we multiple by 180 we get -180 to +180 degrees - more useful
Now for a test I set heading to 3.45 then the following occures.
3.45/0.000030517578125 = 1B999 in Hex; but as we can only store 16 bits in the unsigned short the debugger shows B999 as the value.
Now when I come to decode that vaue via:-
B999 * 0.000030517578125 = 1.44998169 which is wrong and if x 180 to get into degrees then get 260.99.
Now for reading another value say, e.g. the value is 1234hex then we get:-
1234Hex * 0.000030517578125 = 0.14221191 and if we convert into degrees then get 0.14221191 * 180 = 25.598144 degrees.
Hope this helps to explan what I am trying to do.
|
|
|
|
|
I see you ignored all I asked and said.
If I understood what you meant correctly, then:
the LSB value is 360/0x10000 (approx 0.00549)
assuming a monotonous binary representation (as opposed to e.g. sign+mantissa), we get:
0x7FFF = almost 180
0x0000 = 0
0x8000 = -180
3.45 --> 3.45*0x10000/360 = 628 = 0x0274
-3.45 --> -3.45*0x10000/360 = -628 = 0xFD8C
|
|
|
|
|
Sorry Luc, as you may have noticed I am getting more confused, but think getting there from your last post.
One field in this array was height which ranged from 0 to 10,000, but the LSB was 0.5, and the sign not used; e.g. bit 15 was data.
So if you had 0000 0000 0000 1000 which is 8 then that represented 4 meters. I got this working and then turned to see why the heading and lat/long were not!
But with heading which did use the sign and had a range of -1 to +1 and a very small LSB.
May next question is are they a formula to handle these types of conversions. Just for a Windows platforn with the VS environment.
Still need to sort out the two unsigned short Lat and Long.
|
|
|
|
|
I have link: http://site/request.php?345923489
Please help me on MFC.
|
|
|
|
|
See here."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
I'm using customized CTreeCtrl for drag and drop operation.
When drag an item with image from one tree to the another tree how can i copy image
i am using DropTarget inherited from COleDropTarget.
How can i get my drop window point there in my drop target.
void CDragDropTreeCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hTSelItem = pNMTreeView->itemNew.hItem;
m_hDragItem = hTSelItem;
SelectItem(hTSelItem);
Select(hTSelItem, TVGN_DROPHILITE);
if(m_pDragImage)
delete m_pDragImage;
m_pDragImage = CreateDragImage(hTSelItem);
ASSERT(m_pDragImage);
VERIFY (m_pDragImage->BeginDrag (0, CPoint (8, 8)));
VERIFY (m_pDragImage->DragEnter (GetDesktopWindow (), ((NM_TREEVIEW *)pNMHDR)->ptDrag));
m_bDragging = TRUE;
m_hDropItem = NULL;
m_nDropIndex = -1;
m_pDropWnd = this;
SetCapture();
COleDataSource *poleSourceObj = new COleDataSource ;
CTreeDropTarget::m_shWndTreeCtrl = m_hWnd;
DROPEFFECT dropeffect = poleSourceObj->DoDragDrop();
SendMessage(TVM_SELECTITEM, TVGN_DROPHILITE,0);
if ( dropeffect == DROPEFFECT_MOVE)
DeleteItem(hTSelItem);
delete poleSourceObj;
*pResult = 0;
}
void CDragDropTreeCtrl::MouseMove(CPoint point)
{
if(m_bDragging)
{
CPoint pt (point);
ClientToScreen (&pt);
VERIFY (m_pDragImage->DragMove (pt));
VERIFY (m_pDragImage->DragShowNolock (FALSE));
CWnd* pDropWnd = WindowFromPoint (pt);
ASSERT (pDropWnd);
if (pDropWnd != m_pDropWnd)
{
if (m_hDropItem)
{
((CDragDropTreeCtrl*)m_pDropWnd)->SelectDropTarget(NULL);
m_hDropItem = NULL;
}
}
m_pDropWnd = pDropWnd;
pDropWnd->ScreenToClient (&pt);
VERIFY (m_pDragImage->DragShowNolock (TRUE));
}
}
void CTreeDropTarget::OnDragLeave( CWnd* pWnd )
{
m_pDestTreeCtrl = (CDragDropTreeCtrl *)pWnd;
m_pDestTreeCtrl->m_bDragging = true;
m_pSourceTreeCtrl->m_bDragging = false;
m_pDestTreeCtrl->m_pDragImage = m_pSourceTreeCtrl->m_pDragImage;
m_pDestTreeCtrl->SendMessage(TVM_SELECTITEM, TVGN_DROPHILITE,0);
}
DROPEFFECT CTreeDropTarget::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point )
{
DROPEFFECT dropeffectRet = DROPEFFECT_COPY;
if ( (dwKeyState & MK_SHIFT) == MK_SHIFT)
dropeffectRet = DROPEFFECT_MOVE;
m_pDestTreeCtrl = (CDragDropTreeCtrl *)pWnd;
m_pDestTreeCtrl->m_pDropWnd = (CDragDropTreeCtrl *)pWnd;
m_pSourceTreeCtrl->MouseMove(point);
HTREEITEM hTItem = m_pDestTreeCtrl->HitTest(point);
if ( hTItem != NULL )
{
m_pDestTreeCtrl->Expand(hTItem, TVE_EXPAND);
m_pDestTreeCtrl->SelectDropTarget(hTItem);
}
CRect rectClient;
pWnd->GetClientRect(&rectClient);
pWnd->ClientToScreen(rectClient);
pWnd->ClientToScreen(&point);
int nScrollDir = -1;
if ( point.y >= rectClient.bottom - RECT_BORDER)
nScrollDir = SB_LINEDOWN;
else
if ( (point.y <= rectClient.top + RECT_BORDER) )
nScrollDir = SB_LINEUP;
if ( nScrollDir != -1 )
{
int nScrollPos = pWnd->GetScrollPos(SB_VERT);
WPARAM wParam = MAKELONG(nScrollDir, nScrollPos);
pWnd->SendMessage(WM_VSCROLL, wParam);
}
nScrollDir = -1;
if ( point.x <= rectClient.left + RECT_BORDER )
nScrollDir = SB_LINELEFT;
else
if ( point.x >= rectClient.right - RECT_BORDER)
nScrollDir = SB_LINERIGHT;
if ( nScrollDir != -1 )
{
int nScrollPos = pWnd->GetScrollPos(SB_VERT);
WPARAM wParam = MAKELONG(nScrollDir, nScrollPos);
pWnd->SendMessage(WM_HSCROLL, wParam);
}
return dropeffectRet;
}
|
|
|
|
|
Did you try DragEnter(NULL, ..) ? Check your definition of Irrationality[ ^]
1 - Avicenna
5 - Hubbard
3 - Own definition
|
|
|
|
|
Yes i tried that but have same issue there.
|
|
|
|
|
OK.
(May be other windows do not know how to draw it...)
Would you set another application cursor instead ? Check your definition of Irrationality[ ^]
1 - Avicenna
5 - Hubbard
3 - Own definition
|
|
|
|
|
m_pDestTreeCtrl->m_pDragImage = m_pSourceTreeCtrl->m_pDragImage;
is it ok??
If you find any useful link pls give it to give me..
|
|
|
|
|
Hi,
My application exe is not working on another machine (XP), when I try to launch It displays error like:
CreateProcess failed;code 14001
The application failed to start because the application configuration file is incorrect. Reinstalling the application may fix the problem.
What configuration has to set?
|
|
|
|
|
Did u gaive the MFC option as "Use MFC in a Static Library" and build your application. Just check ( [^]) Величие не Бога может быть недооценена.
|
|
|
|
|
its a win32 application (windows)
|
|
|
|
|
Just build the application with the configuration mentioned above. Величие не Бога может быть недооценена.
|
|
|
|
|
Possibly you have to run this [^] on the target machine.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Just reinstall the vc software.
|
|
|
|