variable help

I made a variable later in my code, but earlier in the code I need to call it, how do I do this? its the hwnd of my windows application.
Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <windows.h>

int main()
{
    HWND my_window_handle = nullptr ;

    for( int i = 0 ; i < 100 ; ++i )
    {
         if( my_window_handle ) ::ShowWindow( my_window_handle, SW_SHOW ) ;

         // ...

         if( my_window_handle == nullptr )
             my_window_handle = ::FindWindow( nullptr, "some top-level window's title" ) ;


         // ...

         if( my_window_handle ) ::ShowWindow( my_window_handle, SW_HIDE ) ;

         // ...
    }
}

Topic archived. No new replies allowed.