Opposite of FindClass$

Blitz3D Forums/Blitz3D Programming/Opposite of FindClass$

API
.lib "user32.dll"
api_FindWindowB% (lpClassName, lpWindowName$) : "FindWindowA"


Code
Function FindClass$(t1$)
	b = api_FindWindowB(0, t1$)
		
	bbank = CreateBank(256)
	
	length = api_GetclassName( b, bbank, 255 )
	
	For i = 0 To length - 1
		class1$ = class1$ + Chr$(PeekByte(bbank, i))
	Next

	FreeBank bbank
	
	;DebugLog("Class = " + class1$)
	
	
	Return class1$
	
End Function



any ideas on how to do the opposite? (FindTitle$("Class", 0))

Hmm, but there could be more than one window with the same class. Maybe try GetForeGroundWindow and GetNextWindow ?
;this code returns the hwnd for every window on the desktop
hwnd = api_GetForegroundWindow()

Print hwnd

Repeat
hwnd = api_GetNextWindow(hwnd, 2)
Print hwnd
Until hwnd = 0

WaitKey()

End


you would need GetClassName() pass the hwnd pointer of the window whos classname to wish to obtain.

woops maybe missunderstood, see FindWindowEx() this enables you to search all child windows of the passed parent hwnd, or you can start searching from child after using the second param

after obtaining the hWnd of a window, how can you tell if its been destroyed?

Maybe enumerate all hwnds that are open, and see if the hwnd is in the list.

pass hwnd to IsWindow() found in user32.dll, this determines whether the specified window handle identifies an existing window.

That worked :D, thanks alot Kev

happy to help :)