🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #428

WM_TIMER / WM_PAINT

#428
From: UO
Date: Sat, 12 Apr 2008 08:54
82 lines
2812 bytes
Hi,

Consider the following code:

// 1
int g_cnt;

    case WM_CREATE:
        SetTimer(hwnd, IDTIMER0, 20, NULL);
        g_cnt = 0;
    break;

    case WM_TIMER:
        g_cnt++;
        if(g_cnt > 1)
            Messagebox(hwnd, "g_cnt > 1", "info", MB_OK); //A
        SomeCode(); // takes 100ms time.
        g_cnt--;
    break;

After creating the window, because the code in "case WM_TIMER:" takes more 
time than the
poll time of the timer, do WM_TIMER messages fill the message queue buffer 
in the end? I've noticed,
the line marked with "A" never executes, that means g_cnt is never greater 
than one.

Now consider the following code:

// 2
char buf[100];
int g_cnt;

    case WM_TIMER:
        g_cnt++;
            sprintf(buf, "g_cnt=%d", g_cnt);
            MessageBox(hwnd, buf, "info", MB_OK); //B
        g_cnt--;
    break;

Here, g_cnt increases with the display of every MessageBox.
After g_cnt reaches approx. 650, the program displays an "Access Violation" 
(in PC);
The limit "650" is only "45" in my embedded device powered with WindowsCE.
What is the difference between Code //1 and Code //2 ?

Another question, consider the following code:
//3

RECT rect;
PAINTSTRUCT ps;
HDC hdc;

    case WM_CREATE:
        SetTimer(hwnd, IDTIMER0, 20, NULL);
        cnt = 0;
        GetClientRect(hwnd, &rect);
    break;

    case WM_TIMER:
        KillTimer(hwnd, IDTIMER0);

        //Do some coordinate-calculations for the objects that are displayed 
in WM_PAINT:

        InvalidateRect(hwnd, &rect, FALSE);
        SetTimer(hwnd, IDTIMER0, 20, NULL);
    break;

    case WM_PAINT:
        hdc = BeginPaint(hwnd, &ps);
        //DisplayObjects();
        EndPaint(hdc, &ps);
    break;

I've never noticed that "case WM_TIMER:" and "case WM_PAINT:" are executed
simultanously. Is it always true in this case? I have to be sure because it 
would be
disaster if the coordinates of the objects are changed while they are 
displayed.

Thanks...
Technical Details
Message-ID: <48007897$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!news.isoc.lu!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,23aafd5476c6b2a9,start
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "UO" <uo@uott>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: WM_TIMER / WM_PAINT
Date: Sat, 12 Apr 2008 11:54:03 +0300
Lines: 90
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 81.213.76.81
Message-ID: <48007897$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1207990423 81.213.76.81 (12 Apr 2008 01:53:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!news.isoc.lu!newsgroups.borland.com!not-for-mail