Greenhorn Posted October 11, 2008 Share Posted October 11, 2008 (edited) Moin,I have a problem with a little sample about a digital clock display in a window.The (translated) script works, but the digital clock is not displayed centered in the client area.and so it should be:Could somebody give me a hint what's wrong in the code, please ?I don't know how to debug this in AutoIt.expandcollapse popupFunc WindowProc ($hWnd, $uMsg, $wParam, $lParam) $szBuffer = DllStructCreate ('char szBuffer[2]') $lpszBuffer = DllStructGetPtr ($szBuffer) Switch $uMsg Case $WM_CREATE $hBrushRed = CreateSolidBrush (RGB (255, 0, 0)) SetTimer ($hWnd, $ID_TIMER, 1000, $NULL) ContinueCase ; weiter mit WM_SETTINGCHANGE Case $WM_SETTINGCHANGE GetLocaleInfo ($LOCALE_USER_DEFAULT, $LOCALE_ITIME, $lpszBuffer, 2) $f24hour = (DllStructGetData ($szBuffer, 'szBuffer', 1) == '1') ; GetLocaleInfo ($LOCALE_USER_DEFAULT, $LOCALE_ITLZERO, $lpszBuffer, 2) ; $fSuppress = (DllStructGetData ($szBuffer, 'szBuffer', 1) == '0') ; InvalidateRect ($hWnd, $NULL, TRUE) ; löst eine WM_PAINT Nachricht aus Case $WM_SIZE $cxClient = LOWORD ($lParam) $cyClient = HIWORD ($lParam) Case $WM_TIMER InvalidateRect ($hWnd, $NULL, TRUE) ; löst eine WM_PAINT Nachricht aus Case $WM_PAINT $ps = DllStructCreate ($tagPAINTSTRUCT) $lpPs = DllStructGetPtr ($ps) $hDC = BeginPaint ($hWnd, $lpPs) SetMapMode ($hDC, $MM_ISOTROPIC) ; SetWindowExtEx ($hDC, 276, 72, $NULL) ; SetViewportExtEx ($hDC, $cxClient, $cyClient, $NULL) ; SetWindowOrgEx ($hDC, 138, 36, $NULL) ; SetViewportOrgEx ($hDC, $cxClient / 2, $cyClient / 2, $NULL) ; SelectObject ($hDC, GetStockObject ($NULL_PEN)) ; SelectObject ($hDC, $hBrushRed) ; DisplayTime ($hDC, $f24Hour, $fSuppress) ; EndPaint ($hWnd, $lpPs) Case $WM_CLOSE DestroyWindow ($hWnd) Case $WM_DESTROY KillTimer ($hWnd, $ID_TIMER) DeleteObject ($hBrushRed) ; Aufräumarbeiten PostQuitMessage (0) Case Else Return DefWindowProc ($hWnd, $uMsg, $wParam, $lParam) EndSwitch Return 0; EndFunc ;The full code is attached, it's too long to post it ...GreetzGreenhornupdated ...DigClock.zip Edited October 12, 2008 by Greenhorn Link to comment Share on other sites More sharing options...
martin Posted October 11, 2008 Share Posted October 11, 2008 I just tried playing with it and I got it to show but I'm afraid I don't understand it. Case $WM_PAINT $ps = DllStructCreate($tagPAINTSTRUCT) $lpPs = DllStructGetPtr($ps) $hDC = BeginPaint($hWnd, $lpPs) SetMapMode($hDC, $MM_ISOTROPIC); SetWindowOrgEx($hDC, -50, -36, $NULL); SetWindowExtEx($hDC, 376, 172, $NULL); SetViewportOrgEx($hDC, $cxClient / 2, $cyClient / 2, $NULL); SetViewportExtEx($hDC, $cxClient, $cyClient, $NULL); SelectObject($hDC, GetStockObject($NULL_PEN)); SelectObject($hDC, $hBrushRed); DisplayTime($hDC, $f24hour, $fSuppress); EndPaint($hWnd, $lpPs) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Greenhorn Posted October 11, 2008 Author Share Posted October 11, 2008 (edited) Thank you very much, martin, with that values I didn't played, cause I thought: if it is in the C version correct, why shouldn't it also work in the same way in AutoIt.I'll read on the Book, maybe he (Petzold) explains why he took this values.If you are interested, I could send you the origin C code ...You can take a look at here http://msdn.microsoft.com/en-us/library/ms533192(VS.85).aspx for the coordinate functions of the Flat GDI ...EDIT: I noticed, if I change the window's size, the size of the digit display stops resizing at a specific value in width and height ...GreetzGreenhorn Edited October 11, 2008 by Greenhorn Link to comment Share on other sites More sharing options...
Greenhorn Posted October 12, 2008 Author Share Posted October 12, 2008 (edited) OK,I found the error ! The error was found directly in front of the screen ! It was a copy error in one of the functions: The DllCall in SetViewportOrgEx must be corrected ... Now it works almost fine with the original values in SetWindowOrgEx .EDIT:I noticed that the process of AutoIt.exe does not be ended if I close the window over the Systemmenu !!!Also the TrayIcon must be disabled.The "close button" works well, but the Systemmenu does just close the window, but not AutoIt.exe !How can I handle this to close the application correctly ?It seems AutoIt hangs up in the message loop if I close the window via Systemmenu or if I press the TrayIcon ... EDIT_EDIT:I've got it: I was (naturally) a fault of mine. The GetMessage wants a Nullpointer as parameter and not the window's handle.That's what you get if you work with templates ... GreetzGreenhorn Edited October 12, 2008 by Greenhorn Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now