Subj : Re: double clicks (mouse) To : borland.public.cpp.borlandcpp From : Jack Sawatzky Date : Fri Dec 17 2004 05:34 pm 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. Thanks. #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); } .