Question

When compiling like this:

void DisplayPos (void)
{
    SetWindowPos (ConsoleWindow, HWND_TOPMOST, 0, 0, 600, 600, SWP_SHOWWINDOW);
}

int main (void)
{
    HWND ConsoleWindow = GetConsoleWindow();
    DisplayPos ();
}

GCC will report:

Line 3 | error: 'ConsoleWindow' undeclared (first use in this function) // expected

But is it feasible to pass HANDLE to another function without declaring a new one? Thanks.

Was it helpful?

Solution

Appreciate @cHao 's help. :-)

I answered my own question.

void DisplayPos (HWND ConsoleWindow)
{
    SetWindowPos (ConsoleWindow, HWND_TOPMOST, 0, 0, 600, 600, SWP_SHOWWINDOW);
}

int main (void)
{
    HWND ConsoleWindow = GetConsoleWindow();
    DisplayPos (ConsoleWindow);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top