MCPcopy Create free account
hub / github.com/acl-dev/acl / WndProc

Function WndProc

lib_fiber/samples-gui/SimpleWin/SimpleWin.cpp:221–341  ·  view source on GitHub ↗

函数: WndProc(HWND, UINT, WPARAM, LPARAM) 目标: 处理主窗口的消息。 WM_COMMAND - 处理应用程序菜单 WM_PAINT - 绘制主窗口 WM_DESTROY - 发送退出消息并返回

Source from the content-addressed store, hash-verified

219//
220//
221LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
222{
223 switch (message) {
224 case WM_COMMAND:
225 {
226 int wmId = LOWORD(wParam);
227 // 分析菜单选择:
228 switch (wmId) {
229 case IDM_ABOUT:
230 DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
231 break;
232 case IDM_EXIT:
233 DestroyWindow(hWnd);
234 break;
235 case IDM_START_LISTENER:
236 {
237 fiber_server = new CFiberServer();
238 if (fiber_server->BindAndListen(server_port, server_addr)) {
239 HMENU hMenu = GetMenu(hWnd);
240 EnableMenuItem(hMenu, IDM_START_LISTENER, MF_DISABLED);
241 EnableMenuItem(hMenu, IDM_STOP_LISTENER, MF_ENABLED);
242 printf(">>>Start fiber to listen on %s:%d, thread=%d\r\n",
243 server_addr, server_port, GetCurrentThreadId());
244 fiber_server->start();
245 } else {
246 delete fiber_server;
247 fiber_server = NULL;
248 }
249 }
250 break;
251 case IDM_STOP_LISTENER:
252 {
253 if (fiber_server) {
254 fiber_server->kill();
255 fiber_server = NULL;
256 printf(">>>Listener fiber stopped!\r\n");
257 }
258 HMENU hMenu = GetMenu(hWnd);
259 EnableMenuItem(hMenu, IDM_START_LISTENER, MF_ENABLED);
260 EnableMenuItem(hMenu, IDM_STOP_LISTENER, MF_DISABLED);
261 }
262 break;
263 case IDM_START_CONNECT:
264 for (int i = 0; i < 10; i++) {
265 go[=] {
266 CFiberConnect client(server_addr, server_port, 10000);
267 client.Start();
268 };
269 }
270 break;
271 case IDM_RESOLVE_THREAD:
272 go[=]{
273 const std::string name = "www.google.com";
274 std::vector<std::string> addrs;
275 go_wait[&] {
276 if (!GetHostByname(name.c_str(), &addrs)) {
277 printf(">>>resolve DNS error, name=%s\r\n", name.c_str());
278 }

Callers

nothing calls this directly

Calls 11

GetHostBynameFunction · 0.85
GetAddrInfoFunction · 0.85
BindAndListenMethod · 0.80
killMethod · 0.80
StartMethod · 0.80
beginMethod · 0.80
ifFunction · 0.50
startMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…