LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX(Treeview) in LabVIEW

OK, that was easy:

x and y are returned from the MouseMove event;
call GetDC, with hWnd=0. This returns the screen's hDC
call GetDeviceCaps, with the hDC, and LOGPIXELSX (88) as parameter
call GetDeviceCaps, with the hDC, and LOGPIXELSY (90) as parameter
call ReleaseDC, with hWnd=0, and the hDC
multiply x by 1440, and devide by the returned value of LOGPIXELSX
multiply y by 1440, and devide by the returned value of LOGPIXELSY

The number returned from GetDeviceCaps is the logical number of pixels per
inch (or the dpi). It seems to me that the x and y dpi's are the same, but I
don't know if it's always true...

BTW it is tested, and it works...

Regards,

Wiebe.


"Wiebe@AIR" wrote in message
news:3e79980b$0$146$e4fe514c@dreader9.news.xs4all.nl...
> Hi,
>
> Skip all the previous, it doesn't work anyway...
>
> The factor for me is 15. So the MouseMove parameters must be multiplied by
> 15.
>
> Why 15?
>
> My number of dpi (dots per inch) is 96. The TWIPS means a factor 20 of
> printer dots, which is always 1/1440. So, 1440 / 96 = 15!
>
> So the new question is, how to get the dpi...
>
> Regards,
>
> Wiebe.
>
>
>
> "Wiebe@AIR" wrote in message
> news:3e7987b9$0$150$e4fe514c@dreader9.news.xs4all.nl...
> > Hi,
> >
> > How about the function:
> >
> > int SetMapMode(
> > HDC hdc, // handle to device context
> > int fnMapMode // new mapping mode
> > );
> >
> > And GetMapMode?
> >
> > Some modes are: MM_ISOTROPIC, MM_TWIPS,
> > MM_TEXT,MM_LOMETRIC,MM_LOENGLISH,MM_ANISOTROPIC
> >
> > Don't know if you should use the VI's Hwnd or the Container's to get the
> DC.
> >
> > I'll try it myself, it sould be easy...
> >
> >
> > Regards,
> >
> > Wiebe.
> >
> > "INTP56" wrote in message
> > news:506500000005000000D3DC0000-1042324653000@exchange.ni.com...
> > > Here are some things I've uncovered.
> > >
> > > I've determined that the same behavior is seen using the TreeView with
> > > Excel VBA. However, using the TreeView with VB6 works (on the same
> > > machine). Apparently, when using VB6, the TreeView.MouseMove event
> > > returns the X,Y coordinates in TWIPS. In Excel VBA and LabVIEW,
> > > TreeView.MouseMove returns the X,Y coordinates in Pixels. In either
> > > case, TreeView.HitTest expects the X,Y coordinates in TWIPS.
> > >
> > > I don't know how .NET affects all this. As I understand it, there is
> > > no simple TWIPS = Pixels * n conversion. There is a TWIPStoPixelsX
> > > (and Y) function, but Excel VBA doesn't know about it, so I doubt
> > > LabVIEW will. Someone suggested that I hit the Win32API to get pixels
> > > per inch information (since 1440 TWIPS = 1 inch), but didn't give me
> > > more information than that. I've cruised the MSDN website, but
> > > couldn't find any such call.
> > >
> > > As I see it, the behavior of the TreeView control itself is not
> > > consistant from VBA to VB6, so I don't think NI will be able to do
> > > anything about it. I'm sure Microsoft's position will be, "It works if
> > > you use our development systems, so what is there to fix?". I think I
> > > will just have to give up on this idea.
> > >
> > > Unless some can come up with an easy way to do the translation, I'll
> > > simply force my users to actually click on a node to generate the
> > > required event.
> > >
> > > Bob
> >
> >
>
>
0 Kudos
Message 11 of 14
(1,366 Views)
Wiebe,

Thanks a lot. HitTest now works as expected.

This now brings up another concern, support. I'm using Win2K, will LabView still be able to find the DLL files in XP? NT4? 98? Me? etc., especially after I compile the program into an executable. This is the first time I've used the Win32API from LabVIEW. I've read (briefly) about others having problems with LabVIEW finding DLL's (although I can't seem to find them now)

Anyway, thanks again for your solution. As someone once said, "The answer is obvious....once you know it"
0 Kudos
Message 12 of 14
(1,366 Views)
To give some idea about the backwards compatibility of the api's...

Most win3.11 api's are still there. Most new windows versions have new
functions, but the old once are still used. E.g. XP has some new functions
for skinning applications.

The GetDeviceCaps is supported by 95/98/me/nt/2k and xp. This function will
not be removed very soon. If it needs to be changed, MS will just add new
parameters, but keep the old parameters unchanged. Or, if it cannot be
avoided, MS adds a function with Ex added to it, e.g. GetDC -> GetDCEx. The
old one is not removed.

Finding dll's can be a problem if the dll is shipped with an executable, and
got lost. If the dll is in the windows system directory, the system (and LV
)
will always find them. If it's not there but it is registered, it will also
be found. If it is not in the system dir, and is not registered, it has to
be in the application directory, or in a subdirectory of the application.

BTW. Why worry about the future of the dll, and not about the future of the
OCX?

Regards,

Wiebe.


"INTP56" wrote in message
news:5065000000050000005ADD0000-1042324653000@exchange.ni.com...
> Wiebe,
>
> Thanks a lot. HitTest now works as expected.
>
> This now brings up another concern, support. I'm using Win2K, will
> LabView still be able to find the DLL files in XP? NT4? 98? Me? etc.,
> especially after I compile the program into an executable. This is the
> first time I've used the Win32API from LabVIEW. I've read (briefly)
> about others having problems with LabVIEW finding DLL's (although I
> can't seem to find them now)
>
> Anyway, thanks again for your solution. As someone once said, "The
> answer is obvious....once you know it"
0 Kudos
Message 13 of 14
(1,366 Views)
Wiebe,

You are right. I've never (directly) hit the API before, so there is some "fear of the unknown" issues. Since I had a copy of Appleman's VB Guide to the Win32API, actually creating the Library functions was straight forward. If I can't depend on USER32 and GDI32 being there, I don't want to support it.

In fact, I've already run across a user with a new laptop (purchased Feb 2003) with Win2k but only had TreeView 5.0 available, so my demo program kept bombing on his machine. This was an actual issue, not an irrational fear!

For anyone who's interested, here is HitTester.vi including Wiebe's API calls.

Wiebe, thanks again for all your help.

Bob Martin
0 Kudos
Message 14 of 14
(1,366 Views)