Article View: borland.public.cppbuilder.nativeapi
Article #12097Re: DPtoLP
From: Ed Mulroy [TeamB]
Date: Fri, 26 Dec 2003 19:58
Date: Fri, 26 Dec 2003 19:58
75 lines
3352 bytes
3352 bytes
I assume that the code you posted has a cut and paste error, that
anisotropic mode, window size and viewport size are set long before the
mouse move message is received.
If so then try these things:
while debugging break at the SetMapMode call and examine the
values of xwin, ywin, width and height to make sure they are
as you expect
place the call SetErrorMode(0); prior to your call to DPtoLP
If not then try moving the SetMapMode, SetWindowExtEx and SetViewportExtEx
calls to the code associated with processing WM_CREATE
If you have difficulty deciphering the meaning for a GetLastError return
value then you might call this function which will display the text meaning
of the message in a message box.
-----------------
void ShowLastError(DWORD err_number)
{
TCHAR *err_msg;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
err_number,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)(&err_msg),
0,
NULL);
MessageBox(HWND_DESKTOP, err_msg, "Error", MB_OK);
LocalFree(err_msg);
}
-----------------
. Ed
> M. Finch wrote in message
> news:3fec8cda$1@newsgroups.borland.com...
>
> I seem to be missing how the DPtoLP function works. I am using
>
> POINT pt;
> .
> .
> case WM_MOUSEMOVE:
>
> pt.x = (LONG)LOWORD(lParam);
> pt.y = (LONG)HIWORD(lParam);
>
> SetMapMode(hDC,MM_ANISOTROPIC);
> SetWindowExtEx(hDC, xwin,ywin,NULL);
> SetViewportExtEx(hDC,width,-height,NULL);
>
> // Mouse moves are stored in pt.x and pt.y in DEVICE
> COORDINATES?? // Using the DPtoLP function should return
> their coordinates in LOGICAL COORDINATES??
>
> retval = DPtoLP(hDC, &pt, 1);
> reterr = GetLastError();
>
> I find that I get an error in the retval and I retrieve the error using
> GetLastError() which is 87. 87 is Invalid Parameter as defined
> in System Error Codes on MSDN.
>
> Anyone have any ideas on what is causing the error?
> Should I expect that the coordinates returned are
> pt.x = pt.x * (xwin / width)
> pt.y = pt.y * (ywin / height)
>
> which are the device coordinates times the ratio of logical to
> device coordinates??
Technical Details
Message-ID:
<3fec92e4@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fec8cda$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,51ae0f0f4731a002 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-12-26 12:09:36 PST From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fec8cda$1@newsgroups.borland.com> Subject: Re: DPtoLP Date: Fri, 26 Dec 2003 14:58:27 -0500 Lines: 77 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 24.74.175.102 Message-ID: <3fec92e4@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1072468708 24.74.175.102 (26 Dec 2003 11:58:28 -0700) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail