Jump to content
Sign in to follow this  

Problem with displaying Polygons

Recommended Posts



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.

Posted Image

and so it should be:

Posted Image

Could somebody give me a hint what's wrong in the code, please ?

I don't know how to debug this in AutoIt.

Func 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
             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)
    Return 0;

The full code is attached, it's too long to post it ...



updated ...


Edited by Greenhorn

Share this post

Link to post
Share on other sites

I just tried playing with it and I got it to show but I'm afraid I don't understand it.

            $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.

Share this post

Link to post
Share on other sites

Thank you very much, martin, :P

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 ...



Edited by Greenhorn

Share this post

Link to post
Share on other sites


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 ... :(:P

Now it works almost fine with the original values in SetWindowOrgEx .


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 ... :idea:


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 ... :P



Edited by Greenhorn

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this