楼主真够懒的,DELPHI F1按下去都可以看到的东西。。hWndIdentifies the window whose messages are to be retrieved. One value has a special meaning: Value Meaning NULL GetMessage retrieves messages for any window that belongs to the calling thread and thread messages posted to the calling thread via PostThreadMessage.
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg; // Initialize global strings
MyRegisterClass(hInstance); // my initialization
ZeroMemory(g_szFileNamePath, 200); // surppose lstrlen(szCmdLine) < 200
memcpy(g_szFileNamePath, lpCmdLine, lstrlen(lpCmdLine)); // Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
} return msg.wParam;
}
win32的程序框架如上
入口 WinMain , 需要注册自己的窗口类 然后 指定窗口处理函数
然后就获取消息循环 翻译 转发消息 然后对不同的消息的处理 就需要你的窗口处理函数中实现 如果你不想处理某些消息 那么就 调用
DefWindowProc(hWnd, message, wParam, lParam); 即可
application.ProcessMessages
就是相当于vb的Doevents的
你要首先却你的控制台程序有没有消息循环,没有的话,这个过程是没用的
不如说如何在dephi的控制台程序中使用这个函数。或者整个程序比必须使用纯api构建吗
DispatchMessage(Msg);也就是前面 while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}就类似实现 ProcessMessages 了,
知道了他的含义,自己写一个不就行了。
感兴趣你可以看一下 VCL 中这部分的代码。
======================================================while (GetMessage(&msg, NULL, 0, 0))
TranslateMessage(&msg);
DispatchMessage(&msg);======================================================
你把上面的接受消息的句柄设置为null?
是指接受所有windows的消息 还是指不接受消息?
是不是我的控制台程序中必须先创建一个句柄啊?
NULL GetMessage retrieves messages for any window that belongs to the calling thread and thread messages posted to the calling thread via PostThreadMessage.