|
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.
|
|
|
|
|
Do you really think it would be the solution: installing,for instance, Visual C++ on every customer 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]
|
|
|
|
|
|
How can I add word wrap to this code for drawing text:
CPaintDC dc(this);
CRect r;
GetClientRect(&r);
Gdiplus::Graphics* g = Gdiplus::Graphics::FromHDC(dc.m_hDC);
CString txt;
GetWindowText(txt);
Gdiplus::Font myFont(m_FontName, m_FontSize, m_FontStyle);
Gdiplus::StringFormat format;
Gdiplus::RectF rf;
g->MeasureString(txt, txt.GetLength(), &myFont, Gdiplus::PointF(r.left, r.top), &rf);
Gdiplus::Color color;
color.SetFromCOLORREF(m_Color);
Gdiplus::SolidBrush whiteBrush(color);
g->DrawString(txt, txt.GetLength(), &myFont,
rf, &format, &whiteBrush);
g->Flush();
delete g; There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Graphics.DrawString takes a bounding rectangle, give it the maximum width you want, and sufficient height.
Graphics.MeasureString will calculate the required height when given the (same) maximum width.
|
|
|
|
|
Thanks There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|