Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • Last Modified:

confused CStatic

I am using a dialog based application, and I can't figure out how to get CStatic to show up.  I think the problem is I am not using the right pointer to the CDialog, but I am not sure...

here is how I am trying to do it:
CStatic myStatic;
myStatic.Create("asdasdasds",WS_CHILD|WS_VISIBLE, CRect(10,10,150,50),this);

this appears in a onclick for a button on my dialog, but it doesn't seem to work..

I know the CAppDlg is where I want it to appear, but I can't use that...error...

please explain so that I might understand?


1 Solution
sorry if this is wrong,
  i happen to be away from my pc, and no chance to check it over.
   if there is a showwindow() function for this cstatic, call that function and see

again, sorry if it is wrong, in fact i'm not sure
myStatic.Create("asdasdasds",SS_SIMPLE | WS_CHILD | WS_VISIBLE, CRect(50,50,150,150),this);    

Make myStatic a member variable of your dialog class or it will be deleted when u live the local scope and the window is destroyed too.
do you have sth like this:

void CMyDialog::OnFoo()
  CStatic myStatic;

the destructor of CStatic will immediately destroy the static (even before it has been painted).

either make the static member of your dialog class, or use
myStatic.Detach() before you leave the function.

bebonhamAuthor Commented:
yes, is was getting destroyed, thanks

for another 25 points ...

the function that this is in also opens a file dialog, to select a they should be able to do this more than once, but I can only call the create method how do I check to see if I've already called it, and how do I edit it after I've created it.


bebonhamAuthor Commented:
thanks, figured out the last myself (I think)

I put the create in the OnInitDialog()

and I then used SetWindowText to change it.

Thanks guys,

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now