2013-10-14 73 views
0

我是相當新的(進入一級高中課程大約10周),我試圖看看如何格式化命令提示符窗口。我已經學會了如何設置窗口的大小,但不是位置。我使用的代碼::塊在Windows XP如何在左上角打開命令提示符窗口?

+0

如果您已經知道如何設置尺寸,相當難以置信。使用SetConsoleWindowInfo()。專注於編寫有趣而有用的程序,而不是試圖控制機器。用戶已經知道如何移動控制檯窗口,並且不太可能對您的選擇感到滿意。寫一個計算器,練習編碼技巧的優秀初學者項目。 –

+0

如果您發佈了一些您的嘗試代碼,它可以提供更多相關幫助:) – ryyker

回答

0

首先,Read This
然後,嘗試這些...(批處理文件)

Set mycmdHeight=40 
Set mycmdWidth=80 
Set mycmdxPos=0 
Set mycmdyPos=120 

或者編程,看herehere

0

您可以使用windows功能將控制檯窗口移動到您想要的位置。 首先看看返回當前窗口句柄的函數。

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(); 
} 

使用上面的函數來獲取當前窗口的句柄。現在

HWND hwnd = GetConsoleWindowNT(); 

,你可以使用的MoveWindow函數像下面在你的願望位置移動視窗:您

MoveWindow(hWnd,1230,750,200,100,TRUE); 

你可以得到完整的示例程序here