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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:29:39+00:00 2026-05-25T21:29:39+00:00

I’ve created a print preview class, PPREVIEW, containing a print preview window, which is

  • 0

I’ve created a print preview class, PPREVIEW, containing a print preview window, which is supposed to popup over my app’s main window, while disabling it. When user closes preview window, it is supposed to enable main window and destroy PPREVIEW object. I’d like to use it in the following way:

PPREVIEW *p=new PPREVIEW;
//next, preview window is created, user interaction begins
p->ShowPreview(<parameters>); //but this function returns
delete p;

Since ShowPreview does return, the above line would destroy object while window is still visible. If it was a modal dialog box, this would be possible, since DialogBox function doesn’t return at that point.
I thought i could put “delete this” somewhere upon destruction of the print preview window. Naturally WM_DESTROY comes to mind. But MSDN states at http://msdn.microsoft.com/en-us/library/windows/desktop/ms632620%28v=vs.85%29.aspx the following: “it can be assumed that during processing of WM_DESTROY child windows still exist”, so there’s still possibility some of them will refer to instance’s variables (and they do, i was getting random access violation errors when i tried that, so i backed out).

Currently i’ve opted to:
– create some global variable,
– in WM_DESTROY of print preview window i put EnableWindow(MainWindow, TRUE) and set that global variable to FALSE.
– Then, upon main window’s WM_ENABLE event i’m testing global variable for FALSE and deleting object.

But this is quite unelegant and requires that i program this behavior for every window that uses print preview, so i decided to pursue previous approach, which is: create, use, possibly self-delete. I need either:
– information when exactly could i use “delete this” in PPREVIEW window procedure, if this approach isn’t unwise for some reason i am unaware of
– an idea how to make ShowPreview method to not return, mimicking DialogBox behavior.
– other suggestions that achieve my goal

Please assist.

  • 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-25T21:29:40+00:00Added an answer on May 25, 2026 at 9:29 pm
    1. Your ShowPreview function should call ShowWindow() to show the preview window. It should also do whatever is needed to the main form, e.g. disabling it.
    2. When your preview window receives WM_CLOSE it should delete the C++ object that wraps it. Some part of this process also needs to call DestroyWindow() on the underlying window handle. The default handling of WM_CLOSE would do this, but perhaps you would want this in the C++ object’s destructor.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has

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.