Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:28:39+00:00 2026-05-28T08:28:39+00:00

#include <windows.h> #include <time.h> #define _USE_MATH_DEFINES #include <math.h> LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM

  • 0
#include <windows.h>
#include <time.h>
#define _USE_MATH_DEFINES 
#include <math.h>

LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
    static wchar_t szAppName[]=L"circle";
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wndclass;

    wndclass.cbSize=sizeof(wndclass);
    wndclass.style=CS_HREDRAW|CS_VREDRAW;
    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,L"circle",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
    ShowWindow(hwnd,SW_MAXIMIZE);
    UpdateWindow(hwnd);
    SetTimer(hwnd,0,1,0);
    while(GetMessage(&msg,NULL,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}
const int CENTER=300;
const int RADIUS=100;
LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    static HDC wndDC=GetDC(hwnd);
    switch(iMsg)
    {
    case WM_CREATE:
        {
            MoveToEx(wndDC,CENTER+RADIUS,CENTER,0);
            mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, (CENTER+RADIUS)*(65535.0/1366),(CENTER)*(65535.0/768),0,0);
            return 0;
        }
    case WM_PAINT:
        {
            hdc=BeginPaint(hwnd,&ps);
            EndPaint(hwnd,&ps);
            return 0;
        }
    case WM_MOUSEMOVE:
        LineTo(wndDC,LOWORD(lParam),HIWORD(lParam));
        return 0;
    case WM_TIMER:
        {
            srand(clock());
            static int count=0;
            for (int i=0;i<1000;i++)
            {
                count++;
                mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, (CENTER+RADIUS*cos(2*M_PI*count/10000))*(65535.0/1366),
                    (CENTER+100*sin(2*M_PI*count/10000))*(65535.0/768),0,0);
            }
            if (count==10000)
                KillTimer(hwnd,0);
            return 0;
        }
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd,iMsg,wParam,lParam);
}

I expected to get circle but get decagon)
I called mouse_event 10000 times in this program. Message WM_MOUSEMOVE was handled 10 times (same with timer). i.e. mouse_event calls (1000 times) weren’t sended in message queue except for one from 1000. What is reason for it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:28:40+00:00Added an answer on May 28, 2026 at 8:28 am

    The WM_MOUSEMOVE message is a coalescing message. If a mouse_event happens and the application has not yet processed the previous mouse_event, then the previous one is thrown away. In your case, you generated 1000 mouse_events with no intervening message pump, so all but the last one gets thrown away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is algorithm #include<iostream> #include<Windows.h> #include<time.h> using namespace std; int main(){ int a[10]={12,3,5,2,7,80,10,1,16,30}; long
I was under the impression that this code #include <windows.h> #include <stdio.h> int WINAPI
/*language C code*/ #include windows.h typedef struct object_s { SRWLOCK lock; int data; }
Is there a lightweight process execution timer like Unix's time included with Windows? Sometimes
I am experimenting with Beep function on Windows: #include <windows.h> ... Beep(frequency, duration); The
When trying to compile a file that include winnt.h via windows.h, I get the
suppose you have the following structure: #include <windows.h> // BOOL is here. #include <stdio.h>
i want to do this simple piece of code work. #include <iostream> #include <windows.h>
Consider this program: #include <stdio.h> int main() { printf(%s\n, __FILE__); return 0; } Depending
Some time ago I managed to get RoR working on Windows XP. I've been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.