1.函數(shù)說明:FindWindow,Win32 API函數(shù)。
創(chuàng)新互聯(lián)是一家專注于網(wǎng)站設計、網(wǎng)站建設與策劃設計,北碚網(wǎng)站建設哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設10余年,網(wǎng)設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:北碚等地區(qū)。北碚做網(wǎng)站價格咨詢:18982081108
FindWindow函數(shù)返回與指定字符串相匹配的窗口類名或窗口名的最頂層窗口的窗口句柄。這個函數(shù)不會查找子窗口。
2.函數(shù)原型:
HWND FindWindow( LPCTSTR lpClassName,
LPCTSTR lpWindowName
);3.參數(shù)說明:
lpClassName
指向一個以null結(jié)尾的、用來指定類名的字符串或一個可以確定類名字符串的原子。如果這個參數(shù)是一個原子,那么它必須是一個在調(diào)用此函數(shù)前已經(jīng)通過GlobalAddAtom函數(shù)創(chuàng)建好的全局原子。這個原子(一個16bit的值),必須被放置在lpClassName的低位字節(jié)中,lpClassName的高位字節(jié)置零。
lpWindowName
指向一個以null結(jié)尾的、用來指定窗口名(即窗口標題)的字符串。如果此參數(shù)為NULL,則匹配所有窗口名。
4返回值:
如果函數(shù)執(zhí)行成功,則返回值是擁有指定窗口類名或窗口名的窗口的句柄。
如果函數(shù)執(zhí)行失敗,則返回值為 NULL ??梢酝ㄟ^調(diào)用GetLastError函數(shù)獲得更加詳細的錯誤信息。5.使用示例:HWND hWndRcv = ::FindWindow(NULL,"123");if(hWndRcv != NULL){ AfxMessageBox("找到123窗口");}
給你個例子,建議用 DevC++ 編譯 :
#include windows.h
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(messages);
/* Send message to WindowProcedure */
DispatchMessage(messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
純C的應該不行.必須要用到WIM32 SDK Dev-cpp. 我沒用過所以這方面不大清楚.你可以用以下方法.
你要先查找輸出"ABC"的這個窗口的句柄.獲取句柄后用ShowWindow(HWND hWnd, int nCmdShow);最下化窗口.或最大化窗口.
因為查找窗口的教程很多就不多說了.
網(wǎng)站題目:c語言制作窗口函數(shù) c語言窗口程序設計
URL網(wǎng)址:http://chinadenli.net/article10/dodiddo.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供云服務器、營銷型網(wǎng)站建設、網(wǎng)站排名、網(wǎng)站設計公司、Google、網(wǎng)站收錄
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)