<windows.h> provides a function MoveWindow() to move the console from one position to another. It requires 6 parameters. The source code is given below.
#include<windows.h>#include<stdio.h>HWND WINAPI GetConsoleWindowNT(){// declare function pointer typetypedef HWND WINAPI (*GetConsoleWindowT)(void);// declare one such function pointerGetConsoleWindowT GetConsoleWindow;// get a handle on kernel32.dllHMODULE 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 undocumentedif ( GetConsoleWindow == NULL ) {return NULL;} // call the undocumented function\return GetConsoleWindow();}int main(){CONSOLE_SCREEN_BUFFER_INFO SBInfo;HWND hWnd = GetConsoleWindowNT();SetConsoleTitle("Programming-technique- Tutorial");MoveWindow(hWnd,950,500,400,200,TRUE);printf("Hello Every One\nThis is small window ");getch();return 0;}
No comments:
Post a Comment
Comment