Subj : Re: double clicks (mouse) To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Thu Dec 16 2004 10:30 pm > Great going, guys. You settled the etiquette issue, but > forgot about the problem! Fine. Below is a simple C++ Hello World! program with double click support added by the lines indicated by their obvious departure from the normal indenting. Compare it to what you are doing. .. Ed --------------------------------- #define STRICT #include /* The variable declared below is created by the startup code * (all Windows C/C++ compilers create it). It has the same * value as the first HINSTANCE calling argument to WinMain */ extern HINSTANCE _hInstance; static const char title_name[] = "HelloGUI Demo Program"; LRESULT CALLBACK MainProc( HWND hwnd, UINT msge, WPARAM wParam, LPARAM lParam) { static const char hello_world[] = "Hello World"; switch (msge) { case WM_LBUTTONDBLCLK : { MessageBox( hwnd, "Double Click Received", "", MB_OK | MB_APPLMODAL); return 0; } case WM_PAINT : { PAINTSTRUCT ps; // info structure filled in by BeginPaint BeginPaint(hwnd, &ps); /* write a line of text * * note that lstrlen is a Windows-supplied function that * does the same thing as strlen (but doesn't nuke the * program like strlen does if the pointer it is given * is NULL) */ TextOut(ps.hdc, 0, 0, hello_world, lstrlen(hello_world)); EndPaint(hwnd, &ps); return 0; } // when it's closed, we want to discard the window case WM_CLOSE : { DestroyWindow(hwnd); break; } // send message to main loop ordering the program to end case WM_DESTROY : { PostQuitMessage(0); return 0; } } return DefWindowProc(hwnd, msge, wParam, lParam); } HWND Init() { WNDCLASS wc; // holds data used to set up the window's class HWND main_hwnd; /* set up the structure of information about our * window's class and register the class */ wc.lpfnWndProc = MainProc; // function to call to handle window wc.lpszClassName = title_name; // set window caption wc.lpszMenuName = NULL; // no menu /* the rest are common values used by most programs */ // repaint if horiz or vert changes wc.style = CS_HREDRAW | CS_VREDRAW; wc.style |= CS_DBLCLKS; // no extra per-class or per-window data needed wc.cbClsExtra = wc.cbWndExtra = 0; // handle of our program's instance wc.hInstance = _hInstance; // default icon wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // default mouse cursor wc.hCursor = LoadCursor(NULL, IDC_ARROW); // default background color wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); if (RegisterClass(&wc)) // if the class registered ok { /* Make the window */ main_hwnd = CreateWindow( title_name, title_name, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, // default position CW_USEDEFAULT, CW_USEDEFAULT, // default size HWND_DESKTOP, // parent window is the desktop NULL, // no menu used _hInstance, // instance handle for our program NULL); // no extra creation data } else main_hwnd = NULL; return main_hwnd; } int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int nCmdShow) { MSG msg; HWND hwnd = Init(); if (hwnd) // if window creation was successful { ShowWindow(hwnd, nCmdShow); // show the window UpdateWindow(hwnd); // cause its contents to be painted /* NOTE: Most Windows examples test for a zero * return value like this: * * while (GetMessage(&msg, NULL, 0, 0)) * * If you look at the docs for Windows 2000 and * Windows XP you will see that it might receive * a -1 return value and that value should also * end the loop. Testing for a return value of * greater than zero is now what must be done. */ while (GetMessage(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); // handle messages sent to DispatchMessage(&msg); // program & its windows } } return msg.message; } --------------------------------- > Jack Sawatzky wrote in message > news:41c24e25$1@newsgroups.borland.com... > Great going, guys. You settled the etiquette issue, but > forgot about the problem! > Please read my second posting (above) where I provided > enough information to show that the code body works, > but for some reason double clicks aren't getting through. .