Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

confused CStatic

Posted on 2001-09-04
5
533 Views
Last Modified: 2013-11-20
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?

Thanks,

Bob
0
Comment
Question by:bebonham
5 Comments
 
LVL 1

Expert Comment

by:orange_juice
ID: 6455335
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
0
 
LVL 2

Accepted Solution

by:
BogdyPtr earned 50 total points
ID: 6455617
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.
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6455619
do you have sth like this:

void CMyDialog::OnFoo()
{
  CStatic myStatic;
  myStatic.Create(...)
}

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.

Peter
0
 
LVL 8

Author Comment

by:bebonham
ID: 6456869
yes, is was getting destroyed, thanks

for another 25 points ...

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

Thanks,

Bob
0
 
LVL 8

Author Comment

by:bebonham
ID: 6456942
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,

Bob
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
Whole sheet autoscrub still needed 19 51
iSeries DB2 Query 2 97
Line meaning 9 87
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question