Pages

Saturday, 23 April 2016

Move console windows using C++ and windows function.

ou can move your console windows at your desire location in screen and also resize the size of console windows  by using this source code in code::block.


#include <windows.h>
#include<stdio.h>
HWND WINAPI GetConsoleWindowNT(void)// declare function pointer type
    typedef HWND WINAPI (*GetConsoleWindowT)(void); // declare one such function pointer
     GetConsoleWindowT GetConsoleWindow;// get a handle on kernel32.dll
     HMODULE hK32Lib = GetModuleHandle(TEXT("KERNEL32.DLL")); // assign procedure address to function pointer
     GetConsoleWindow =(GetConsoleWindowT)GetProcAddress(hK32Lib,TEXT("GetConsoleWindow"));
     // check if the function pointer is valid
     // since the function is undocumented

     if ( GetConsoleWindow == NULL ) {
          return NULL;
     }
     // call the undocumented function
     return GetConsoleWindow();
}

int main(){
    HWND hWnd=GetConsoleWindowNT();
    MoveWindow(hWnd,1230,750,200,100,TRUE);
}

No comments:

Post a Comment