Hey,
I have a dlg based gui and I create a bunch of text on it dynamicaly. I'd like to add a reset button which would clear everything off of the window. I can delete the edit boxes, but I don't know how to delete the CStatic objects.
Thanks.
Hey,
I have a dlg based gui and I create a bunch of text on it dynamicaly. I'd like to add a reset button which would clear everything off of the window. I can delete the edit boxes, but I don't know how to delete the CStatic objects.
Thanks.
Everything is relative...
NVM, doenst work
I guess I have to use soemthing else, like a button control that can be deleted, eh?
Everything is relative...
What do you mean deleted? Do you mean remove them from the dialog or just not show them anymore? You can always useto change the visibility, or you could useCode:item->showwindow(sw_hide)as well to change the item to "invisible".Code:SetDlgItemText( ID, "" )
static text doesn't have an ID. so I don't think I can do SetDlgItemText.
and I'm not sure how showwindow(sw_hide) work and what exactly it does/parameters it takes.
Basicly the text is dynamically created depending on how much data there is. If the user runs the function twice the old text from last run should not appear. Right now it just writes over as much as is avalable the second time, but the rest still stays.
I'll look into the showwindow- hide business.
Everything is relative...
OK, showwindow() would hide the whole window. I want to keep the window and just get rid of the text on it.
Everything is relative...
A CStatic does have an ID associated with it...
as do all controls associated with a window (CStatic or otherwise)
Last edited by dpro; 08-26-2005 at 03:06 PM. Reason: Making more clear
Incorrect.Originally Posted by earth_angel
Correct.Originally Posted by dpro
By default, when you create a CStatic object it's ID is IDC_STATIC which is equivalent to 0xFFFFFFFF and used automatically under the assumption you won't send/receive any messages with the control. Just specify a unique ID instead. (This is all assuming you're using MFC, which it sounds like you are.)
Oh, OK.
I didn't know you can specify an ID for static text.
I'm trying to do this now:I also tried delete pstatic; but it doesn't destroy the text or make it invisible. Here's how I make it:Code:CStatic* pstatic; i=0; while((pstatic = (CStatic*) GetDlgItem(i+700)) != NULL) { pstatic->SetDlgItemText(i+700, "" ) ; i++; }and I am using MFC with MS VC++ 6.0Code:myStaticf = new CStatic; myStaticf->Create(_T(FAD.vectDL[i].Param), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(x1,y,x2,y+h), this, i+700);
Last edited by earth_angel; 08-29-2005 at 07:16 AM.
Everything is relative...
Did you actually set the ID for the item?
What I am catching from this is that, you have an ID which is 700-7nm where n and m are numbers. You are iterating through each one, and doing something to them, i.e. changing something about them, hiding them, or showing them correct?
As for showing and hiding the "window -> i.e. cstatic" I was mistaken.
You should use this if possible.
True will "show" the cstatic and false will "hide" the cstatic.Code:GetDlgItem( ITEM_ID )->EnableWindow( TRUE/FALSE );
i set the id to 700+i where i goes from 0 to whatever. So the IDs are 700, 701, 702, 703, etc.
EnableWindow() still leaves the text on the window, it is just not active, ie.. it's grey instead of black.
I'm running out of ideas to get rid of this stupid text.
Everything is relative...
Can you post a larger snippet of the code so I can get a better look on how you are using it?
And well I was right the first time, use showwindow... not enablewindow..
Last edited by dpro; 08-29-2005 at 03:09 PM. Reason: Silly mistake...
>>pstatic->SetDlgItemText(i+700, "" ) ;
this sets a child window of pStatic's text to "" (not the text of pStatic)
use something like
Code://test to see if we have a static with that ID while((pstatic = (CStatic*) GetDlgItem(i+700)) != NULL) { SetDlgItemText(i+700, "" ) ; i++; }
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Here's the whole thing:
Creation:At the top of the function I try to check if there is text already and get rid of it if there is and write a new set.Code:CStatic* myStaticf; x1=215, y=125, x2=300, h=15; structLink templink; templink.BParam = '\0'; for(i=0; i< FAD.vectDL.size(); i++) { myStaticf = new CStatic; if ( strncmp(FAD.vectDL[i].Param, "ENDL", 4) != 0 && strncmp(FAD.vectDL[i].Param, "END", 3) != 0) { myStaticf->Create(_T(FAD.vectDL[i].Param), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(x1,y,x2,y+h), this, i+700); y+=19; } }Running this, I get some of the text hidden, but it seems to be very random. I've attached the display after the function has been run twice. So it fist loaded a file with 17 labels to be printed and then with only 10. So the text with no edit boxes beside it shouldn't be there.Code:CStatic* pstatic; i=0; // FAD while((pstatic = (CStatic*) GetDlgItem(i+700)) != NULL) { pstatic->ShowWindow(SW_HIDE); i++; }
Edit: Couldn't attach it. They say whatever size I put it's too large.
Last edited by earth_angel; 08-30-2005 at 06:36 AM.
Everything is relative...