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 9122275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:03:51+00:00 2026-06-17T06:03:51+00:00

I have a simple window application with declared main window callback procedure: WNDCLASSEXW wcx;

  • 0

I have a simple window application with declared main window callback procedure:

WNDCLASSEXW wcx;
/* ... */
wcx.lpfnWndProc = MainWndProc;

and after the WinMain I declared LRESULT CALLBACK MainWndProc(HWND mainWindow, UINT msg, WPARAM wparam, LPARAM lparam) { /* ... */} and all is working ok, but I wonder is it possible to have this MainWndProc as a lambda inside WinMain ?

  • 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-06-17T06:03:52+00:00Added an answer on June 17, 2026 at 6:03 am

    You can use a lambda, provided it has no captures then it has an implicit conversion to function pointer:

    #include <iostream>
    
    typedef void (*func)();
    
    static func some_func;
    
    int global;
    
    int main() {
      some_func = [](){ std::cout << "Hello\n"; }; // Fine
      some_func(); 
      int local;
      some_func = [&](){ local = 1; }; // Illegal - No conversion
      some_func = [](){ global = 1; }; // Fine
    }
    

    The problem really is how much you can usefully do in a lambda as a callback without captures. You can still resort to “globals”, in the same way you might with a regular function as the callback.

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

Sidebar

Related Questions

I have a simple wpf application. In main window i have stack panel and
I have a WPF database viewer application: It's a simple main window containing a
My i have to develop simple window based iphone application. In my first screen
I have a simple Qt application that launches a window with a QWebView. I
I have a wpf application with a simple window that shows a text in
I have a simple WPF single window application contains Textboxes and Buttons. And I
I have a simple application with just a window and a user control. The
I have a simple windows service application I am trying to debug in VS
enter code here Hi All, I have a simple windows service application that connects
I have a requirement to create a simple windows forms application that allows an

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.