永发信息网

windows 启动程序的过程,需要调用那些函数?

答案:2  悬赏:20  手机版
解决时间 2021-01-31 13:29
  • 提问者网友:回忆在搜索
  • 2021-01-30 14:00
windows 启动程序的过程,需要调用那些函数?
最佳答案
  • 五星知识达人网友:零点过十分
  • 2021-01-30 14:33
给你个例子,建议用 DevC++ 编译 :

#include


LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);


char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;


wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);


wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;

wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;


if (!RegisterClassEx (&wincl))
return 0;


hwnd = CreateWindowEx (
0,
szClassName,
"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);


ShowWindow (hwnd, nFunsterStil);


while (GetMessage (&messages, NULL, 0, 0))
{

TranslateMessage(&messages);

DispatchMessage(&messages);
}


return messages.wParam;
}



LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
全部回答
  • 1楼网友:愁杀梦里人
  • 2021-01-30 16:03
先在窗口注册目标窗口的回调函数parentproc: // set parent window original processing. m_oriparentproc = ::getwindowlong(m_hparentwnd, gwl_wndproc); ::setwindowlong(m_hparentwnd, gwl_wndproc, (long)parentproc); 然后定义回调函数parentproc,就可以接受目标窗口的所有窗口消息了: static lresult callback parentproc(hwnd hwnd, uint umsg, wparam wparam, lparam lparam) { // find the shadow window pointer via parent window handle. atlassert( m_szshadowwindows.find(hwnd) != m_szshadowwindows.end() ); cthemedshadowwnd *pthis = m_szshadowwindows[hwnd]; wndproc pdefproc = (wndproc)pthis->m_oriparentproc; switch(umsg) { case wm_destroy: { // destroy the shadow window. pthis->destroywindow(); break; } default: { if (::iswindowvisible(hwnd)) { pthis->adjustwindowpos(); } break; } } return pdefproc(hwnd, umsg, wparam, lparam); }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯