C++ 关于ShowWindow()的疑问
生活随笔
收集整理的這篇文章主要介紹了
C++ 关于ShowWindow()的疑问
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
IDE: Code::Blocks 16.01
操作系統(tǒng):Windows 7 x64
最初的代碼,目的是為了隱藏窗口出現(xiàn)在任務(wù)欄上的圖標(biāo)。
1 #include <windows.h>2 3 using namespace std;4 5 int main()6 {7 HWND hWnd;8 9 /* Retrieves a handle to the foreground window (the window with which the user is currently working). */ 10 hWnd = GetForegroundWindow(); 11 12 /* Hides the window and activates another window. */ 13 ShowWindow(hWnd, SW_HIDE); 14 15 return 0; 16 }Build > Run,確實是能隱藏。但似乎出現(xiàn)了一個Bug:Run之后,無法Abort!
好吧,只能開啟Windows任務(wù)管理器,看了進程,沒有出現(xiàn)相應(yīng)的進程,無奈之下,只能關(guān)閉IDE,重新打開。
重復(fù)了幾次,依舊如此!
后來對代碼稍作修改:
1 #include <windows.h>2 #include <conio.h>3 #include <stdio.h>4 5 using namespace std;6 7 int main()8 {9 char cKey; 10 HWND hWnd; 11 12 /* Retrieves a handle to the foreground window (the window with which the user is currently working). */ 13 hWnd = GetForegroundWindow(); 14 15 /* Hides the window and activates another window. */ 16 ShowWindow(hWnd, SW_HIDE); 17 18 cKey = getch(); 19 printf("%c \n", cKey); 20 21 return 0; 22 }Build > Run,能隱藏,Run之后,仍然無法Abort!
好吧,開啟Windows任務(wù)管理器,看了進程,相應(yīng)的進程出現(xiàn)了,選擇 > 結(jié)束進程。回到IDE,依舊無法Abort!What the hell? 還是得關(guān)閉IDE。
不知道是IDE的問題,還是ShowWindow()的問題導(dǎo)致這種情況。
總結(jié)
以上是生活随笔為你收集整理的C++ 关于ShowWindow()的疑问的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 树莓派做百度云盘离线下载器BaiduPC
- 下一篇: Opencvchina网站:把证件照蓝色