문제

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.

도움이 되었습니까?

해결책

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top