Re: SetMapMode
- From: "Mike Williams" <mikea@xxxxxxxxxxxxxxxxx>
- Date: Sat, 24 Mar 2007 08:42:32 -0000
"Michael C" <nospam@xxxxxxxxxx> wrote in message news:eUTdGQabHHA.4632@xxxxxxxxxxxxxxxxxxxxxxx
Why hasn't anyone suggested iterating through the controls collection
of the form in question? You can do the same with the forms collection
also. They will need to pass in the Forms collection to your object.
Someone just has! But there are probably two reasons why you are the first to do so. Firstly, if Steve is not prepared to write his code in such a way that the user passes the Control to his dll (something which I suggested some time ago and which he decided against) then he is unlikely to want the user to pass the Form or the Forms collection either. The second reason is because Steve has said that the window handle which is being passed to his dll is not necessarily the handle to a VB window. Steve has said that he wants his code to work with only a window handle to work with and nothing else, regardless of the fact that it might not be a VB window. Besides, Steve apparently wants to "read" the VB ScaleMode of the window (if indeed it is the window of a VB object and if that object actually does have a ScaleMode property) in order that he can calculate the pixel values of the passed coordinates in accordance with the ScaleMode, but doing it that way assumes that the person who wrote the code that "called" his function is actually using the ScaleMode units for his coordinates. This is very unlikely in the case of a VB programmer, because most of them are used to passing pixel values to DLL functions and that is very likely what they will have done when calling his own function. So, if Steve's code is going to find out the ScaleMode of the VB object which owns the window (if it is a VB window) and then perform the necessary conversion to pixels then he is going to "get it wrong" in most cases, because the programmer will have quite probably have passed pixel values regardless of the VB ScaleMode. In order to reduce the possibility of this happening then Steve is going to need to include documentation with his DLL to tell VB people to use ScaleMode values for the coordinates, otherwise, as is the "almost standard" VB practice when calling DLLs, they will use pixels. And if he is going to do that then he might as well tell them in his documentation to use pixels regardless of the ScaleMode (which is almost certainly what they would have done anyway without any documentation to go on). Far better to simply assume that the coordinates passed are in units appropriate to the current mapping mode of the window's DC, which is what everything else does, including almost all of the standard Windows API functions.
Mike
.
- Follow-Ups:
- Re: SetMapMode
- From: Michael C
- Re: SetMapMode
- References:
- SetMapMode
- From: Steve
- Re: SetMapMode
- From: Mike Williams
- Re: SetMapMode
- From: Steve
- Re: SetMapMode
- From: Mike Williams
- Re: SetMapMode
- From: Steve
- Re: SetMapMode
- From: Mike Williams
- Re: SetMapMode
- From: Steve
- Re: SetMapMode
- From: Michael C
- SetMapMode
- Prev by Date: Re: Runtime error 48
- Next by Date: Re: Show a textbox next to each row in a listview
- Previous by thread: Re: SetMapMode
- Next by thread: Re: SetMapMode
- Index(es):
Relevant Pages
|