Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
Autor |
Nachricht |
Nitroxis
Anmeldungsdatum: 27.02.2008 Beiträge: 300 Wohnort: Irgendwo...
|
Verfasst am: 01.07.2008, 15:57 Titel: Herausfinden zu was ein Handle gehört |
|
|
Hallo,
Klingt zwar doof, aber geht sowas?
Also wenn man ein Handle (hWnd) von irgentwas hat, wie kann man dann herausfinden von was es ist (z.B. von einem Fenster, einem Button, ...) |
|
Nach oben |
|
 |
Elektronix
Anmeldungsdatum: 29.06.2006 Beiträge: 742
|
Verfasst am: 01.07.2008, 16:24 Titel: |
|
|
Diese Übersicht sollte der Proger eigentlich selbst behalten. Oder was hast Du da vor?
Das hWnd wird bekanntlich von CreateWindow(ex) zurückgegeben. CreateWindowEx belegt da irgendeine Struktur (in Basic: UDT), z. B. CreateStruct, in der auch der Fenstertyp bzw. Style festgehalten wird. _________________ Und die Grundgebihr is aa scho drin- DOS is jo nett. |
|
Nach oben |
|
 |
28398
Anmeldungsdatum: 25.04.2008 Beiträge: 1917
|
Verfasst am: 01.07.2008, 17:14 Titel: |
|
|
Code: | type HWND__
i as integer
end type
type HWND as HWND__ ptr |
Dieses i wird vermutlich ein Pointer auf eine properitäre Struktur sein - und damit uns und der Öffentlichkeit unzugänglich
Ist daher nicht möglich.  |
|
Nach oben |
|
 |
dreael Administrator

Anmeldungsdatum: 10.09.2004 Beiträge: 2529 Wohnort: Hofen SH (Schweiz)
|
Verfasst am: 01.07.2008, 19:34 Titel: |
|
|
<NICHT_GANZ_ERNST>
Ersteigere Dir doch im EBay ein alter Commodore Amiga, denn dort sind diese Speicherstrukturen beim Kickstart offiziell dokumentiert und können sogar im dortigen AmigaBASIC mit PEEK() sehr einfach ausgewertet werden.
</NICHT_GANZ_ERNST>
Ein artverwandtes Werkzeug ist sonst "lsof" unter UNIX/Linux, welche die offenen Dateien und Sockets zusammen mit den zugehörigen Prozessen anzeigt. Auf der Microsoft-Familie sind dies am ehesten die ehemaligen sysinternals.com-Utilities (heute zu Microsoft gehörend). _________________ Teste die PC-Sicherheit mit www.sec-check.net
Zuletzt bearbeitet von dreael am 01.07.2008, 19:37, insgesamt einmal bearbeitet |
|
Nach oben |
|
 |
Elektronix
Anmeldungsdatum: 29.06.2006 Beiträge: 742
|
Verfasst am: 01.07.2008, 19:35 Titel: |
|
|
@28398
Das stimmt so nicht. Das Handle ist einfach eine Kennzahl, mit dem Windows die Fenster identifiziert. Es ist kein Pointer.
Das zweite ist natürlich ein Pointer auf das Handle. _________________ Und die Grundgebihr is aa scho drin- DOS is jo nett. |
|
Nach oben |
|
 |
Nitroxis
Anmeldungsdatum: 27.02.2008 Beiträge: 300 Wohnort: Irgendwo...
|
Verfasst am: 01.07.2008, 20:44 Titel: |
|
|
Also ist es nicht möglich herauszufinden, wozu z.B das Handle 1000 gehört? |
|
Nach oben |
|
 |
Elektronix
Anmeldungsdatum: 29.06.2006 Beiträge: 742
|
Verfasst am: 01.07.2008, 21:24 Titel: |
|
|
Windows vergibt die Handles ziemlich willkürlich, also ohne System, das vom User erkennbar wäre. Du kannst also nicht direkt feststellen, welches Handle zu welchem Fenster gehört (außer, Du läßt es Dir anzeigen). Aber es sollte möglich sein, die Fensterattribute wie Style und Klasse über das Handle abzufragen. Da müßte ich jetzt aber länger suchen.  _________________ Und die Grundgebihr is aa scho drin- DOS is jo nett. |
|
Nach oben |
|
 |
Elektronix
Anmeldungsdatum: 29.06.2006 Beiträge: 742
|
Verfasst am: 02.07.2008, 09:51 Titel: |
|
|
So, hab mir jetzt netterweise die Mühe gemacht:
Mit GetWindowLong kann man verschiedene Merkmale eines Fensters abfragen:
Borland-C++-Hilfe hat Folgendes geschrieben: | The GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory of a window.
LONG GetWindowLong(
HWND hWnd, // handle of window
int nIndex // offset of value to retrieve
);
Parameters
hWnd
Identifies the window and, indirectly, the class to which the window belongs.
nIndex
Specifies the zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. To retrieve any other value, specify one of the following values:
Value Action
GWL_EXSTYLE Retrieves the extended window styles.
GWL_STYLE Retrieves the window styles.
GWL_WNDPROC Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure.
GWL_HINSTANCE Retrieves the handle of the application instance.
GWL_HWNDPARENT Retrieves the handle of the parent window, if any.
GWL_ID Retrieves the identifier of the window.
GWL_USERDATA Retrieves the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window.
The following values are also available when the hWnd parameter identifies a dialog box:
Value Action
DWL_DLGPROC Retrieves the address of the dialog box procedure, or a handle representing the address of the dialog box procedure. You must use the CallWindowProc function to call the dialog box procedure.
DWL_MSGRESULT Retrieves the return value of a message processed in the dialog box procedure.
DWL_USER Retrieves extra information private to the application, such as handles or pointers.
Return Values
If the function succeeds, the return value is the requested 32-bit value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASS structure used with the RegisterClass function. |
Außerdem kann man mit GetWindowText den Text in der Kopfleiste (bzw. auf Controls den Text auf dem Control) ermitteln.
Es gibt auch noch andere GetWindowXXX-Funktionen. _________________ Und die Grundgebihr is aa scho drin- DOS is jo nett. |
|
Nach oben |
|
 |
Nitroxis
Anmeldungsdatum: 27.02.2008 Beiträge: 300 Wohnort: Irgendwo...
|
Verfasst am: 03.07.2008, 19:45 Titel: |
|
|
Danke!
Kann man eigentlich überprüfen ob ein Handle verwendet wird? Denn es muss ja nicht unbedingt ein Fenster sein (oder?), sondern es könnte ja auch ein anderes Control sein. Außerdem kann ja nicht jedes handle von 0 bis 2^31 verwendet werden. |
|
Nach oben |
|
 |
28398
Anmeldungsdatum: 25.04.2008 Beiträge: 1917
|
Verfasst am: 03.07.2008, 20:22 Titel: |
|
|
Code: | If hHandle->i = 0 then return NOT_USED |
Würde ich mal vermuten... |
|
Nach oben |
|
 |
|