enumwindows but different

General FreeBASIC programming questions.
Jermy
Posts: 7
Joined: Apr 12, 2016 10:29

enumwindows but different

Postby Jermy » Jan 19, 2019 6:41

Hi dear people

Is it possible to translate the code below?
EnumWindows normally requires a callback function.
here a lambda function is used so that no separate function is needed for the Callback function

Code: Select all

'#Include <utility>

'HWnd FindTopWindow(DWORD pid)
'{
'    std::pair<HWnd, DWORD> params = { 0, pid };
'
'    // Enumerate the windows Using a lambda To process each Window
'    BOOL bResult = EnumWindows([](HWnd HWnd, LPARAM lParam) -> BOOL
'    {
'        auto pParams = (std::pair<HWnd, DWORD>*)(lParam);
'
'        DWORD processId;
'        If (GetWindowThreadProcessId(HWnd, &processId) && processId == pParams->Second)
'        {
'            // Stop enumerating
'            SetLastError(-1);
'            pParams->first = hwnd;
'            Return FALSE;
'        }
'
'        // Continue enumerating
'        Return TRUE;
'    }, (LPARAM)&params);
'
'    If (!bResult && GetLastError() == -1 && params.first)
'    {
'        Return params.first;
'    }
'
'    Return 0;
'}
Tourist Trap
Posts: 2754
Joined: Jun 02, 2015 16:24

Re: enumwindows but different

Postby Tourist Trap » Jan 19, 2019 9:56

Jermy wrote:Hi dear people

Is it possible to translate the code below?
EnumWindows normally requires a callback function.
here a lambda function is used so that no separate function is needed for the Callback function

I'm not really answering to your question. I just try to guess that you want to use Enumwindows to get informations on your monitors. Maybe I guess wrong of course.

Maybe you can try this topic, if you just want to know about your monitors (read page 1 and 2):
viewtopic.php?f=6&t=26460&hilit=monitor&start=15#p244004

I can't remember where I used EnumWindow, maybe in the Callback topic by fxm in the documentation section of this forum. There is a callback as I can remember but it's a predefined type of windows if I remember well, so just declare it as a variable. Anyway if I remember where I put this I'll give you more.

Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests