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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:35:17+00:00 2026-05-26T17:35:17+00:00

I have a class called GUIMain which registers, creates, and shows a main window

  • 0

I have a class called GUIMain which registers, creates, and shows a main window for my program. On it is a button which, when the user clicks it, displays an additional window.

If I was writing this in C#, I would have two options:

AdditionalForm myForm = new AdditionalForm();
myForm.ShowDialog(this); // blocking. Returns when myForm is closed;
someOtherFunction();

or

AdditionalForm myForm = new AdditionalForm();
myForm.Show(this);   // non-blocking.
someOtherFunction(); // runs while myForm is still visible

or, heck, even this would work:

AdditionalForm myForm = new AdditionalForm();
new Thread(new ThreadStart(delegate()
  {
    myForm.ShowDialog(this);   // blocks in a separate thread
  })).Start();
someOtherFunction(); // runs while myForm is still visible   

But I’m writing this in C++, not C#.

I have an additional class called PreviewWindow which has the public member functions Register(), Create(), and Show(). The last function contains a message loop which basically makes it a blocking call – analogous to C#’s ShowDialog().

How can I either re-write PreviewWindow::Show() so that it doesn’t have a blocking loop:

while (GetMessage(&msg, 0, 0, 0))
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}

Or alternatively, how can I call it on a separate thread?

I’ve currently got:

previewWindow = new PreviewWindow(hInstance, hWnd);

previewWindow->Register();
previewWindow->Create();
previewWindow->Show();         // blocks :(
previewWindow->DisplayImage(); // never runs.

I have tried CreateThread but it’s not liking that the 3rd argument is a member function. I’ve tried making it a static member function but it doesn’t seem to like that either. It’s saying DWORD (__stdcall *)() isn’t compatible with LPTHREAD_START_ROUTINE.

  • 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-26T17:35:18+00:00Added an answer on May 26, 2026 at 5:35 pm

    You should have only one event loop, it will handle all windows except modal ones (which run their own message loop to block the UI). Then your PreviewWindow::Show is just ShowWindow(handle, SW_SHOW);. Multi-threading should generally be saved for when it’s absolutely necessary.

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

Sidebar

Related Questions

I have a class called User with static function loginRequired(), which returns false if
I have a class called EventConsumer which defines an event EventConsumed and a method
I have a class called Path for which there are defined about 10 methods,
I have a class called UserInfo that contains details about a given user. There
I have a class called SparseMatrix which contain a private vector of type Cell.
I have a class called SynonymMapping which has a collection of values mapped as
I have a class called MembershipHelper, which I am using in my ASP.NET project.
I have a class called IssuesView which implements INotifyPropertyChanged . This class holds an
I have a class called formStyle which occurs several times in my webpage. Is
I have a class called imageResizing. It has a member, MAX_WIDTH_ORIGINAL_IMG which is defined

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.