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

  • Home
  • SEARCH
  • 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 7640985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:48:31+00:00 2026-05-31T08:48:31+00:00

So I was making a function to print text layered across a different window,

  • 0

So I was making a function to print text layered across a different window, and I wanted it to be in a separate thread so I can run a timer for the text to display while leaving the user open to continue using the program. However, when I compile I get this error:

error C2664: '_beginthreadex' : cannot convert parameter 3 from 'overloaded-function' to 'unsigned int (__stdcall *)(void *)'

Here’s the main cpp file:

#include "stdafx.h"
#include "Trial.h"

int main()
{
wchar_t* text = L"Message!";
HWND hwnd = FindWindowW(0, L"Halo");
unsigned threadID;
_beginthreadex(0, 0, DrawText,(void *)(hwnd, 175, 15, text, 8), 0 , &threadID);
// Other function here
}

And here’s the header file Trial.h: (it’s a little sloppy, but works fine and since most monitors are around 2ms updates, sleep(2) should help prevent flicker).

#pragma once    
#include <Windows.h>
#include <string>
#include <process.h>

void DrawText(HWND hWnd, float x, float y, wchar_t* mybuffer, float DisplayTime)
{
SetForegroundWindow(hWnd);
HDC hdc = GetDC(hWnd);
SetBkColor(hdc,RGB(255, 255, 255));                   // While Background color...
SetBkMode(hdc, TRANSPARENT);                        // Set background to transparent so we don't see the white...

int howmany = sizeof(mybuffer) * 2;

DisplayTime *= 500;
int p = 0;
while(p < DisplayTime)
{
            // Shadow Offset
    SetTextColor(hdc,RGB(0, 0, 0)); 
    TextOut(hdc,x+2,y+2, (LPCWSTR)mybuffer,howmany);

    // Primary text
    SetTextColor(hdc,RGB(255, 0, 0));   
    TextOutW(hdc,x,y,(LPCWSTR)mybuffer,howmany);

    UpdateWindow(hWnd);
    p++;
    Sleep(2);
}
ReleaseDC(hWnd,hdc);
_endthreadex(0);
}

I’ve looked through multiple examples, checked the syntax, and made sure that I didn’t mess up on _beginthreadex, but can’t seem to find the cause of the problem 😐

  • 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-31T08:48:32+00:00Added an answer on May 31, 2026 at 8:48 am

    In a nutshell thread startup functions need to follow an exact prototype, and not the one you used.

    They can accept a function that takes a single void *.

    There are several solutions.

    1. Change your function to accept a void*. Right away cast it to a ‘struct *’ of some type you have created and has the data you want. You would typically create the struct in main with new/malloc, and then delete/free it when you don’t need it in the thread function.
    2. The somewhat cleaner alternative is to ‘new’ up an object of a class you have made. Give that class a public static method that takes said void *. Use the static method as the thread starter, and pass the address of the object as ‘this’. Then have the static cast the void * to the object type and call some ‘start/run’ routine on the object proper. Have the object delete itself before returning from the thread routine unless you have a more coordinated solution across the threads.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When making a function call in Linux (or OS X for that matter), can
Going slightly crazy here. I'm making an Ajax call using jQuery.post as follows: $.post('php/print.php',{data:dS},function(res){...
Im making firefox extension. One function stores value in every tab, to use it
i am making an upload with Ajaxupload plugin and i am using this function
I have the following code making a GET request on a URL: $('#searchButton').click(function() {
Hay guys, I'm making a simple preload function (function($) { $.fn.preload = function(settings) {
Ok, I attempted at making my own search function which doesnt work very well.
I've got an html page from where Im making this call periodically: function logon(id)
Hey, so I'm making an iPhone app and in there is a common function
Im making my own function to search for the total number of something. but

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.