How can i get host application handle in dll project with Delphi without passing handle parameter

Sayat Ertüfenk

I Have a dll project. I have to get host application handle. I Can't pass handle from host application to dll project because the host application is not mine.

The host application runs on second monitor but when the host application calls my form (dll) the form shown in first monitor. I have to detect host application screen coordinates or i have to detech the host application runs on first monitor or second monitor.

David Heffernan

You are looking for top-level windows in your process. Find them like so:

  1. Call GetCurrentProcessId to obtain your process ID.
  2. Call EnumWindows to enumerate all top level windows.
  3. In the enumeration callback, for each top level window, call GetWindowThreadProcessId to obtain the process ID that owns the window. Any that match the process ID found in step 1 are from your process.

The problem that you face is that step 3 might identify multiple such windows. You can call GetWindow passing GW_OWNER to obtain the owner of the window and use that to trim down the field of candidates. What you perceive as being the main window is likely to have no owner, but the other top level windows may well be owned. Even this cannot be guaranteed to trim the field down to a single candidate and you very likely will need to come up with some additional logic.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can i handle events in Delphi?

How can I handle GET data in koa

How to passing the parameter to event handle in reactjs

How can i debug my DLL project with Delphi's PAServer

how can I handle this type with only one parameter?

How can I handle exceptions and errors in a Java web application?

How can I handle the exit of the calling application in a class library?

How can I handle nested case statements without an indentation tree?

How can I handle a hover the Polymer way without external libraries?

How can I get container object in repository class without passing parameter?

How can I determine if, given a window handle, the window handle is part of the Windows UI as opposed to an application?

How can I use variables without passing them as a parameter?

How to handle an exception without closing application?

How can I get the handle to the property sheet in CPrintDialogEx

How can I get user input with HTML to handle in JS?

how can I get handle errors from UseInterceptors Decorator

How to Handle Passing in String Values via `mssql` package in Node Project

Plugin-system: How to handle events between host application and plugin

How to handle passing data around internally within the app, in an PHP application?

How can I handle flags without parameters in bash without using getopts?

How to handle deprecation of 'project' parameter for combineLatest (in rxjs from 6.5)

Delphi: How to get Application.MainForm if the Application is nil (in dll)

How can I handle this IndexOutOfBounds exception?

How can I handle network exceptions in VBA?

how can i handle the attachment of an attachment?

How can I handle long Int with GraphQL?

How can I handle errors in picocli?

How can i handle this promise correctly?

How can I handle nested whens in Joi?