Subj : Re: double clicks (mouse) To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Fri Dec 17 2004 09:02 pm > (Red in face.) No need for that! > Maybe you can see something I missed. If I comment out the message box for a single click the double click message box works well. The first mbox times it out. It isn't that the first mbox resets something because if I change the delay from 700 to 7000 (long enough for even me to hit the Esc key upon seeing the first mbox), the double click mbox appears on the second click. (plus a couple of cut-and-paste fixes like hdc = hDC, declaring a WINDCLASSEX and commenting out the undeclared close structure instance - you cut and paste as badly as I do! ) Side note: You DO know that merely saying #include brings in all those header files that are listed? For others reading this: The demo (and many others) that the try-double-clicking quicky program that I posted came from is part of this: http://www.mulroy.org/hello.zip .. Ed > Jack Sawatzky wrote in message > news:41c37b1d@newsgroups.borland.com... > > I have a file < test.cpp > that had code from a previous > test. I cleared the text, and carefully copyed in your code. > Then compiled it. But in fact I had forgotten to save the file > first, so the compiler gleefully compiled the previous code. > (Red in face.) > > Now I did it right, and your file works perfectly. I carefully > compared your code to mine and could see no important > differences. Maybe you can see something I missed. > > > #include > #include > #include > #include > #include > > LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); > > > int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, > LPSTR szCmdLine, int iCmdShow) > { > static char szAppName[] = "Electron"; > HDC hdc; > HWND hwnd; > MSG msg; > > wndclass.cbSize = sizeof (wndclass); > wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; > wndclass.lpfnWndProc = WndProc; > wndclass.cbClsExtra =0; > wndclass.cbWndExtra =0; > wndclass.hInstance = hInstance; > wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION); > wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); > wndclass.hbrBackground = (HBRUSH) GetStockObject > (WHITE_BRUSH); > wndclass.lpszMenuName = NULL; > wndclass.lpszClassName = szAppName; > wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION); > > RegisterClassEx (&wndclass); > > hwnd = CreateWindow (szAppName, // window class name > "Understand Electronics", // window caption > WS_OVERLAPPEDWINDOW, // window style > CW_USEDEFAULT, // initial x position > CW_USEDEFAULT, // initial y position > CW_USEDEFAULT, // initial x size > CW_USEDEFAULT, // initial y size > NULL, // parent window handle > NULL, // window menu handle > hInstance, // program instance handle > NULL); // creation parameters > > clos.dwCallback = (DWORD)hwnd; > > SetDoubleClickTime(700); > > ShowWindow (hwnd, iCmdShow); > UpdateWindow (hwnd); > > while (GetMessage (&msg, NULL, 0, 0) >0) > { > TranslateMessage (&msg); > DispatchMessage(&msg); > } > return msg.wParam; > } > > > //WINDOW message handling > > LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, > WPARAM wParam, LPARAM lParam) > { > PAINTSTRUCT ps; > RECT rect; > char str[130]; > HBITMAP hbm; > HDC hmem; > HDC hDC; > > > > switch (iMsg) > { > case WM_CREATE : > return 0; > case WM_PAINT : // 952x702 pixels > hdc = BeginPaint (hwnd, &ps); > SetTextAlign (hdc,TA_BASELINE); > GetClientRect (hwnd, &rect); > Cx=(LONG)(rect.left+rect.right)/2; > Cy=(LONG)(rect.top+rect.bottom)/2; > ...... > > EndPaint (hwnd, &ps); > return 0; > > case WM_LBUTTONDBLCLK : > MessageBox(hwnd,"DoubleLeft","Button", MB_OK ); > return 0; > > case WM_LBUTTONDOWN : > MessageBox(hwnd,"Left","Button", MB_OK ); > return 0; > > case WM_RBUTTONDOWN : > MessageBox(hwnd,"Right","Button", MB_OK ); > return 0; > > case WM_DESTROY : > PostQuitMessage (0); > return 0; > } > return DefWindowProc (hwnd, iMsg, wParam, lParam); > } .