陳冠霖
陳冠霖

Reputation: 21

SetWindowPos didn't change command prompt size

I want to change the size of the command prompt. Below is my code. Although it runs, the size doesn't change as intended. What could be the issue, and how can I resolve it? Alternatively, are there other methods to change the size of the command prompt?

includelib User32.Lib 
GetStdHandle proto STDCALL: DWORD
SetWindowPos proto STDCALL :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

.data
 SWP_SHOWWINDOW equ 0040h
.code
main PROC
 mov eax,5
 call WriteDec
 INVOKE GetStdHandle,STD_OUTPUT_HANDLE
 INVOKE SetWindowPos,eax,0,0,0,20,20,SWP_SHOWWINDOW
 call WriteDec
 call WaitMsg
 exit
main ENDP
end main

I have also tried this method, but the result is not what I intended. I want to change the size of the entire command prompt window, not just the length of its contents.

INCLUDE Irvine32.inc
includelib User32.Lib 

GetStdHandle proto STDCALL: DWORD

.data
    rect SMALL_RECT <0, 0, 5, 5> ; 設定新的視窗大小

.code
main PROC
    mov eax, 5
    call WriteDec
    INVOKE GetStdHandle, STD_OUTPUT_HANDLE
    INVOKE SetConsoleWindowInfo, eax, TRUE, addr rect ; 設定新的視窗大小
    call WriteDec
    call WaitMsg
    exit
main ENDP
end main

Upvotes: 0

Views: 17

Answers (0)

Related Questions