Re: SetMapMode



"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


.



Relevant Pages

  • Re: Algorithm for "Windows Center" and "Windows Width"
    ... a typo in my example: window width should be 300 and window center 40. ... For 16 bit pixel values, you have a potential range of 65536 values but you have only a display range of 256 values, so some manipulation must be done. ... Finally the resultang y,How can i use this y to adjust W/l? ... identity (no rescale values or Modality LUT, ...
    (comp.protocols.dicom)
  • Re: Threading problem with Garbage Collector
    ... It itself controls calls to a DLL ... "A"), it loads the DLL, which in turn then creates a window (it needs to, ... Disposemethod it uses the label window to synchronize the FreeLibrary ... delegate void DelegateKillDLL(); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Simulating Control-Alt-Delete?
    ... Winlogon.exe window or not. ... all desktops and all top level windows. ... the WinLogon window didn't show. ... > Write this part of your test suite as a DLL, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: capture screen even when workstation is locked
    ... /// Number of adjacent color bits for each pixel. ... PHYSICALWIDTH = 110, ... paper has a physical height value of 6600 device units. ... /// Only the client area of the window is copied. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: VB6 runtime is supported on Windows 7
    ... The settings window was fairly extensive ... DLL and the settings are organized into a UDT rather ...
    (microsoft.public.vb.general.discussion)