Re: How do I find and use the window handle of an external application?



On Wed, 12 Apr 2006 15:30:50 +0200, "Vic Joseph"
<vic_ngreply@xxxxxxxxx> wrote:

Hi Mr. French,

Thanks, for a start, for sending me all those links. I shall have to spend
some time checking them out. And thanks too for the warning about
SubClass/Hook.

No problem

You and the VBn community have my sympathy. I have read enough about the
money-grubbing nastiness of the company we depend on for our programming
language(s). Still, B# (or should it be Bflat? Musically, B# is C) does seem
to be a good tool for someone like myself, an amateur making a new start.

I did not know B# should be C
- that makes C# 'D' - how amusing

I feel almost mean about returning to my own question, but I clearly am
still dependent on API calls to get the external window dimensions. If it
does only take a few well-aimed lines of code to do the trick in VB6, I
wonder whether it wouldn't be possible to compile those lines as an .EXE or
as a DLL function. Then perhaps I could launch it from my own program as a
shell process, supplying the window title and two rectangles (the intended
window area and the client area) as arguments. I'm not sure if this is
moonshine, but I'm willing to try anything.

I am sure you can get at the APIs using B#
- it is just that the declarations are different from the VB6 ones

If you know the caption of the Window then you can use FindWindowEx
to get its hWnd eg:

' --- locate Top Window with Caption "TARGET"
hApp = FindWindowEx(0, 0, vbNullString, "TARGET")

Private Declare Function FindWindowEx _
Lib "user32" _
Alias "FindWindowExA" _
(ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) _
As Long

cSharpless has shown you GetClientRect

Assuming it isn't moonshine, the next question is - ahem - would anyone be
prepared to write down those lines of code in VB6 for me; and perhaps even
compile it for me as an .exe or .dll?

If you really find it impossible, then I could do it, but I really
think you would be better off doing it yourself in B#
- at some stage you need to get familiar with APIs
- so a 'work around' would just be delaying things

By the way, just before writing this sentence I downloaded a free Visual
Basic compiler called Visual Basic 5 CCE. At first sight, it looks
wonderfully uncomplicated compared to Visual Studio. I wonder whether I
could use that to compile the VB code myself? And perhaps I could even learn
Visual Basic after all....

Yes, that is VB5, but only creates controls, you can't make an EXE
- VB6 is really VB5 with a few extra bells and whistles

Have a another crack at it in B#
.



Relevant Pages

  • Re: Conversion Problem
    ... That will take you to the help for that control, ... TextChanged event of a combobox and a textbox in VB6? ... pasting a block of text in anything resembling an immediate window... ... supported under Vista - it's the IDE's that aren't supported. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB.NET advantages
    ... the compile will assemble it for you - I'm not sure how useful this would ... > That's stuff you'd never notice if you were using 'Single Procedure View' ... VB 2005 IDE is missing the single procedure view. ... >> out of the immediate window. ...
    (microsoft.public.vb.general.discussion)
  • Re: VB6, VB2005, or Something Else?
    ... So any VB6 successor is free to break compatibility to COM ... That doesn't imply that the "old syntax" couldn't be supported and that the new one couldn't support native code compilation. ... But I think it's a myth that you simply can take your native code and compile it to managed one and expect it to be the same as if you would re-engineer the whole application and rewrite it in .NET. ... But I also stated that this would break compatibility in many ways. ...
    (microsoft.public.vb.general.discussion)
  • Re: Conversion Problem
    ... That will take you to the help for that control, ... TextChanged event of a combobox and a textbox in VB6? ... I'd just point out one of the flaws in VB6 installations. ... pasting a block of text in anything resembling an immediate window... ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VB.NET advantages
    ... That's stuff you'd never notice if you were using 'Single Procedure View' ... > the first error and it will even compile in background, ... I _want_ the IDE to stop on the first compile error. ... > out of the immediate window. ...
    (microsoft.public.vb.general.discussion)