user-0 提问: 如何屏蔽控制台程序wm_size消息

回复:
user: user-0
content: 引用 5 楼 jerry_dqh 的回复:[quote=引用 4 楼 wangli1000000 的回复:] [quote=引用 3 楼 jerry_dqh 的回复:] [quote=引用 2 楼 wangli1000000 的回复:] [quote=引用 1 楼 jerry_dqh 的回复:] 啥意思，是指控制台窗口可以拖大拖小的那个消息 ？  嗯，就是。[/quote] 控制台没有处理消息的消息循环，网上搜索一下系统hook相关的。[/quote]   请看一下，case WINDOW_BUFFER_SIZE_EVENT:  是不是控制台窗口可以拖大拖小的消息？  #include <windows.h> #include <stdio.h>   VOID ErrorExit(LPSTR); VOID KeyEventProc(KEY_EVENT_RECORD);  VOID MouseEventProc(MOUSE_EVENT_RECORD);  VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD);     int main(VOID)  {      HANDLE hStdin;      DWORD cNumRead, fdwMode, fdwSaveOldMode, i;      INPUT_RECORD irInBuf[128];      int counter=0;        // Get the standard input handle.         hStdin = GetStdHandle(STD_INPUT_HANDLE);      if (hStdin == INVALID_HANDLE_VALUE)          ErrorExit(TEXT("GetStdHandle"));         // Save the current input mode, to be restored on exit.         if (! GetConsoleMode(hStdin, &fdwSaveOldMode) )          ErrorExit(TEXT("GetConsoleMode"));         // Enable the window and mouse input events.         fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;      if (! SetConsoleMode(hStdin, fdwMode) )          ErrorExit(TEXT("SetConsoleMode"));         // Loop to read and handle the input events.         while (counter++ <= 100)      {          // Wait for the events.             if (! ReadConsoleInput(                  hStdin,      // input buffer handle                  irInBuf,     // buffer to read into                  128,         // size of read buffer                  &cNumRead) ) // number of records read              ErrorExit(TEXT("ReadConsoleInput"));             // Dispatch the events to the appropriate handler.             for (i = 0; i < cNumRead; i++)          {             switch(irInBuf[i].EventType)              {                  case KEY_EVENT: // keyboard input                      KeyEventProc(irInBuf[i].Event.KeyEvent);                      break;                     case MOUSE_EVENT: // mouse input                      MouseEventProc(irInBuf[i].Event.MouseEvent);                      break;                     case WINDOW_BUFFER_SIZE_EVENT: // scrn buf. resizing                      ResizeEventProc(                          irInBuf[i].Event.WindowBufferSizeEvent);                      break;                     case FOCUS_EVENT:  // disregard focus events                     case MENU_EVENT:   // disregard menu events                      break;                     default:                      ErrorExit(TEXT("Unknown event type"));                      break;              }          }     }         return 0;  }   VOID ErrorExit (LPSTR lpszMessage)  {      fprintf(stderr, "%s\n", lpszMessage);      ExitProcess(0);  }   VOID KeyEventProc(KEY_EVENT_RECORD ker) {     printf("Key event: ");       if(ker.bKeyDown)         printf("key pressed\n");     else printf("key released\n"); }   VOID MouseEventProc(MOUSE_EVENT_RECORD mer) { #ifndef MOUSE_HWHEELED #define MOUSE_HWHEELED 0x0008 #endif     printf("Mouse event: ");       switch(mer.dwEventFlags)     {         case 0:             printf("button press\n");             break;         case DOUBLE_CLICK:             printf("double click\n");             break;         case MOUSE_HWHEELED:             printf("horizontal mouse wheel\n");             break;         case MOUSE_MOVED:             printf("mouse moved\n");             break;         case MOUSE_WHEELED:             printf("vertical mouse wheel\n");             break;         default:             printf("unknown\n");             break;     } }   VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD wbsr) {     printf("Resize event\n"); 	 } [/quote] 这个消息不是，是改变窗口buffer缓冲大小的，比如可以缓冲100行，还是可以缓冲200行，超过的就不能在窗口中显示了。 搜索了一下，你可能不要自己处理，看SetConsoleWindowInfo这个函数是否能设置console窗口的大小。[/quote]   我说的不是设置控制台窗口大小，我说的是当鼠标在窗口边上时，拖动鼠标改变窗口大小。SetConsoleWindowInfo函数是设置console窗口大小的。

user: user-1
content: 引用 4 楼 wangli1000000 的回复:[quote=引用 3 楼 jerry_dqh 的回复:] [quote=引用 2 楼 wangli1000000 的回复:] [quote=引用 1 楼 jerry_dqh 的回复:] 啥意思，是指控制台窗口可以拖大拖小的那个消息 ？  嗯，就是。[/quote] 控制台没有处理消息的消息循环，网上搜索一下系统hook相关的。[/quote]   请看一下，case WINDOW_BUFFER_SIZE_EVENT:  是不是控制台窗口可以拖大拖小的消息？  #include <windows.h> #include <stdio.h>   VOID ErrorExit(LPSTR); VOID KeyEventProc(KEY_EVENT_RECORD);  VOID MouseEventProc(MOUSE_EVENT_RECORD);  VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD);     int main(VOID)  {      HANDLE hStdin;      DWORD cNumRead, fdwMode, fdwSaveOldMode, i;      INPUT_RECORD irInBuf[128];      int counter=0;        // Get the standard input handle.         hStdin = GetStdHandle(STD_INPUT_HANDLE);      if (hStdin == INVALID_HANDLE_VALUE)          ErrorExit(TEXT("GetStdHandle"));         // Save the current input mode, to be restored on exit.         if (! GetConsoleMode(hStdin, &fdwSaveOldMode) )          ErrorExit(TEXT("GetConsoleMode"));         // Enable the window and mouse input events.         fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;      if (! SetConsoleMode(hStdin, fdwMode) )          ErrorExit(TEXT("SetConsoleMode"));         // Loop to read and handle the input events.         while (counter++ <= 100)      {          // Wait for the events.             if (! ReadConsoleInput(                  hStdin,      // input buffer handle                  irInBuf,     // buffer to read into                  128,         // size of read buffer                  &cNumRead) ) // number of records read              ErrorExit(TEXT("ReadConsoleInput"));             // Dispatch the events to the appropriate handler.             for (i = 0; i < cNumRead; i++)          {             switch(irInBuf[i].EventType)              {                  case KEY_EVENT: // keyboard input                      KeyEventProc(irInBuf[i].Event.KeyEvent);                      break;                     case MOUSE_EVENT: // mouse input                      MouseEventProc(irInBuf[i].Event.MouseEvent);                      break;                     case WINDOW_BUFFER_SIZE_EVENT: // scrn buf. resizing                      ResizeEventProc(                          irInBuf[i].Event.WindowBufferSizeEvent);                      break;                     case FOCUS_EVENT:  // disregard focus events                     case MENU_EVENT:   // disregard menu events                      break;                     default:                      ErrorExit(TEXT("Unknown event type"));                      break;              }          }     }         return 0;  }   VOID ErrorExit (LPSTR lpszMessage)  {      fprintf(stderr, "%s\n", lpszMessage);      ExitProcess(0);  }   VOID KeyEventProc(KEY_EVENT_RECORD ker) {     printf("Key event: ");       if(ker.bKeyDown)         printf("key pressed\n");     else printf("key released\n"); }   VOID MouseEventProc(MOUSE_EVENT_RECORD mer) { #ifndef MOUSE_HWHEELED #define MOUSE_HWHEELED 0x0008 #endif     printf("Mouse event: ");       switch(mer.dwEventFlags)     {         case 0:             printf("button press\n");             break;         case DOUBLE_CLICK:             printf("double click\n");             break;         case MOUSE_HWHEELED:             printf("horizontal mouse wheel\n");             break;         case MOUSE_MOVED:             printf("mouse moved\n");             break;         case MOUSE_WHEELED:             printf("vertical mouse wheel\n");             break;         default:             printf("unknown\n");             break;     } }   VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD wbsr) {     printf("Resize event\n"); 	 } [/quote] 这个消息不是，是改变窗口buffer缓冲大小的，比如可以缓冲100行，还是可以缓冲200行，超过的就不能在窗口中显示了。 搜索了一下，你可能不要自己处理，看SetConsoleWindowInfo这个函数是否能设置console窗口的大小。

user: user-0
content: 引用 3 楼 jerry_dqh 的回复:[quote=引用 2 楼 wangli1000000 的回复:] [quote=引用 1 楼 jerry_dqh 的回复:] 啥意思，是指控制台窗口可以拖大拖小的那个消息 ？  嗯，就是。[/quote] 控制台没有处理消息的消息循环，网上搜索一下系统hook相关的。[/quote]   请看一下，case WINDOW_BUFFER_SIZE_EVENT:  是不是控制台窗口可以拖大拖小的消息？  #include <windows.h> #include <stdio.h>   VOID ErrorExit(LPSTR); VOID KeyEventProc(KEY_EVENT_RECORD);  VOID MouseEventProc(MOUSE_EVENT_RECORD);  VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD);     int main(VOID)  {      HANDLE hStdin;      DWORD cNumRead, fdwMode, fdwSaveOldMode, i;      INPUT_RECORD irInBuf[128];      int counter=0;        // Get the standard input handle.         hStdin = GetStdHandle(STD_INPUT_HANDLE);      if (hStdin == INVALID_HANDLE_VALUE)          ErrorExit(TEXT("GetStdHandle"));         // Save the current input mode, to be restored on exit.         if (! GetConsoleMode(hStdin, &fdwSaveOldMode) )          ErrorExit(TEXT("GetConsoleMode"));         // Enable the window and mouse input events.         fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT;      if (! SetConsoleMode(hStdin, fdwMode) )          ErrorExit(TEXT("SetConsoleMode"));         // Loop to read and handle the input events.         while (counter++ <= 100)      {          // Wait for the events.             if (! ReadConsoleInput(                  hStdin,      // input buffer handle                  irInBuf,     // buffer to read into                  128,         // size of read buffer                  &cNumRead) ) // number of records read              ErrorExit(TEXT("ReadConsoleInput"));             // Dispatch the events to the appropriate handler.             for (i = 0; i < cNumRead; i++)          {             switch(irInBuf[i].EventType)              {                  case KEY_EVENT: // keyboard input                      KeyEventProc(irInBuf[i].Event.KeyEvent);                      break;                     case MOUSE_EVENT: // mouse input                      MouseEventProc(irInBuf[i].Event.MouseEvent);                      break;                     case WINDOW_BUFFER_SIZE_EVENT: // scrn buf. resizing                      ResizeEventProc(                          irInBuf[i].Event.WindowBufferSizeEvent);                      break;                     case FOCUS_EVENT:  // disregard focus events                     case MENU_EVENT:   // disregard menu events                      break;                     default:                      ErrorExit(TEXT("Unknown event type"));                      break;              }          }     }         return 0;  }   VOID ErrorExit (LPSTR lpszMessage)  {      fprintf(stderr, "%s\n", lpszMessage);      ExitProcess(0);  }   VOID KeyEventProc(KEY_EVENT_RECORD ker) {     printf("Key event: ");       if(ker.bKeyDown)         printf("key pressed\n");     else printf("key released\n"); }   VOID MouseEventProc(MOUSE_EVENT_RECORD mer) { #ifndef MOUSE_HWHEELED #define MOUSE_HWHEELED 0x0008 #endif     printf("Mouse event: ");       switch(mer.dwEventFlags)     {         case 0:             printf("button press\n");             break;         case DOUBLE_CLICK:             printf("double click\n");             break;         case MOUSE_HWHEELED:             printf("horizontal mouse wheel\n");             break;         case MOUSE_MOVED:             printf("mouse moved\n");             break;         case MOUSE_WHEELED:             printf("vertical mouse wheel\n");             break;         default:             printf("unknown\n");             break;     } }   VOID ResizeEventProc(WINDOW_BUFFER_SIZE_RECORD wbsr) {     printf("Resize event\n"); 	 }

user: user-1
content: 引用 2 楼 wangli1000000 的回复:[quote=引用 1 楼 jerry_dqh 的回复:] 啥意思，是指控制台窗口可以拖大拖小的那个消息 ？  嗯，就是。[/quote] 控制台没有处理消息的消息循环，网上搜索一下系统hook相关的。

user: user-0
content: 引用 1 楼 jerry_dqh 的回复:啥意思，是指控制台窗口可以拖大拖小的那个消息 ？  嗯，就是。

user: user-1
content: 啥意思，是指控制台窗口可以拖大拖小的那个消息 ？