|
Hi,
I need to change the title of a dialog box, this is what I have tried:-
<code>
CDlgCal dlgCal(this);
dlgCal.SetWindowText("Step to something");
if(dlgCal.DoModal()==IDOK)
{
blah blah blah .....
}
</code>
But I get this ASSERT error when it runs ....
<b>ASSERT(::IsWindow(m_hWnd));</b>
Any ideas?
Thanks.
Ali
|
|
|
|
|
The window hasn't been created at this point, only the object that will be managing the window.
You need to handle the WM_INITDIALOG message and call SetWindowText() then.
Software is everything. It also sucks. Charles Fishman [^]
Awasu 1.0.2 (beta)[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Yes it's because your window doesn't exist when you call the SetWindowText function. It's better to change the text in the OnInitDialog() overloaded member function.
|
|
|
|
|
You have to do the SetWindowText inside the OnInitDialog (or later)...
The problem with Modal Windows dialogs is the Win32 Window is created & destroyed in DoModal(), i.e. it does not exist before the call.
Since MFC is supposed to be a "light wrapper", it doesn't do the same level of abstraciton as .NET or (shudder) VB.
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
The assertion comes because you try to set the text before the dialog is created with DoModal(), so the dialog has no handle, and the API function fails.
To do it properly, go in the CDlgCal::OnInitDialog() (Override the WM_INITDIALOG message if you do not have that function present in the class browser), and put your code in this function. i.e. :
... CDialog::OnInitDialog(...bla...)
{
...
SetWindowText("Step to something");
...
}
~RaGE();
|
|
|
|
|
Thanks guys - for the replies - there are some nice expainations there. I've moved my 'SetWindowText' call and its all working fine now.
Thanks again, Ali.
Ali
|
|
|
|
|
hi,
i've developed a program that puts a struct into a linked list... Wenn i put the new record into my list, and i read it after that, the program crashes(wenn getting the CString)...
the problem is that my list is not updated at all... if i read a number that is inserted with the value 3, it has the value -2421523832 wenn retreiving it...
now i want to know how to update my list, not that i don't know it at all but my way is not working.
i get the pointer(Leverancier) to my struct in the function that updates the list...
<br />
NewLeverancier = new CLeverancierStruct;<br />
NewLeverancier = Leverancier;<br />
m_LeveranciersLijst.AddTail(NewLeverancier);<br />
should this work?
[]D [] []D []
|
|
|
|
|
Hi Willen,
I asked this very question a couple of days ago. Didn't you undesrstand my reply? If so, I'll gladly try to make myself clearer, if you're so kind as to tell me what you didn't get.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
well it didn't work...
i made the the struct then i send the pointer to that struct towards the function to safe it in the list... than after that i just want to put it into the linked list...
so: you say i have to do this:
<br />
<small>NewLeverancier = new CLeverancierStruct(*Leverancier );<br />
m_LeveranciersLijst.AddTail(NewLeverancier);</small>
[]D [] []D []
|
|
|
|
|
okey, i tried it one more time, and it does copy the values of the struct but the problem with the CString still remains....
[]D [] []D []
|
|
|
|
|
oke...
I'm getting pretty crazy here... it was all a compiler fault... i rebuilt my hole project and guess what: problem solved.... damn those debug files....
thanx for helping me out...
[]D [] []D []
|
|
|
|
|
You need to give us some more information. From the code above it looks like you
have a pointer which you set to a new struct instance. You then point it to
a previous instance which you add to the list...? It may already be in!
You mention strings and numbers without giving us actual facts / definitions.
Try something like the following (if you like MFC):
struct Foo
{
int nBar;
};
CTypedPtrList<CPtrList, Foo *> FooList;
Foo *f1 = new Foo;
Foo *f2 = new Foo;
f1->nBar = 3;
f1->nBar = 17;
FooList.AddTail (f1);
FooList.AddTail (f2);
Foo *f = FooList.GetHead ();
TRACE1("nBar=%i\n", f->nBar);
f = FooList.GetHead ();
TRACE1("nBar=%i\n", f->nBar);
...
There are STL equivalents to the above code, but I'm not so confident with STL to rattle
out a chunk of code off the top of my head.
Iain.
|
|
|
|
|
Hi,
I have programmed a MFC application under Win XP, and now i try to run my app on Win98.
I have copied the following files to the win98 system dir:
MFC42.dll, msvcp60.dll, msvcrt.dll
I get the following error:
The MSVCRT.DLL file is linked to missing export NTDLL.DLL RtlGetNtVersionNumbers
With Dependency Walker i see that the version of ntdll.dll not correct is for my app. When i copy a newer version of ntdll.dll to the system dir, windows doesnt start correctly.
Have i copied the wrong MSVCRT.DLL? Which DLL's do you normally use?
Thanks for helping me!
Willem
|
|
|
|
|
you can link your program statically with MFC
|
|
|
|
|
giant_hao wrote:
you can link your program statically with MFC
I have tried it, but then i get the error "Failed to create empty document", I get this error on the XP machine where i compiled the application. If i link the app normally, then the app runs fine!(under XP)
|
|
|
|
|
I can only get the menu of main frame by the operation of "AfxGetMainWnd()->GetMenu()",if I want to get the menu which is owned by specific document template,how can I do?
|
|
|
|
|
If you have access to the CDocTemplate objects that were registered in InitInstance you can get it like this:
pTemplate->m_hMenuShared
You can get a specific doc template by iterating the CDocManager object:
CDocManger = *pDocMan = AfxGetApp()->m_pDocManager;
POSITION pos = pDocMan->GetFirstDocTemplatePosition();
while (pos)
{
CDocTemplate *pTemplate = pDocMan->GetNextDocTemplate(pos);
// make use of the pTemplate here.
}
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
I design a webservice with c#,
this webservice have some [WebMethod(EnableSession=true)]'s method
but when I use it with c++,Session lose
why?
thanks, codeproject
|
|
|
|
|
How can I pass arguments to CDialog allowing me to update a CListCtrl?
ie OnDblClick/etc, I call a modal CDialog for editing purposes, however I cannot pass arguments (ie ListItem contents to change).
Basic question - guess I am basically lost
|
|
|
|
|
You could pass the address of the list control to the dialog just before you call the dialog's DoModal() . For example:
void OnDblClick()
{
CMyDialog dlg (this);
dlg.m_pListCtrl = &listCtrl;
dlg.DoModal();
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
How do I convert this type.
I'm importing the CDOSYS lib, and I need to call the
pFld->put_Value(_variant_t(myconvertedtype));
the Microsoft examples use static "myaddress@something.com" , and I've not done stuff with this before.
Thanks for your help.
|
|
|
|
|
CComVariant varMe("this is long ascii"String");
pFld->put_Value(varMe);
|
|
|
|
|
Sorry the proper answer is:
_variant_t vtTemp;
char* szTemp;
...
...
szTemp= (char*)malloc(100);
strcpy(szTemp,"hello there");
vtTemp.SetString(szTemp);
pFld->put_Value(vtTemp);
free(szTemp);
|
|
|
|
|
Hi,
The following compiles fine under gcc, but generates a compile error on line 2 in VC 7.0.9466 (error C2988: unrecognizable template declaration/definition)
template<class t,class="" alloc="">
template<class t1=""> // <------ error
CDSVectorBase<t,alloc>&
CDSVectorBase<t,alloc>::operator*=(const T1 &x)
{
...
Is this a problem with the C++ compiler, or is the code not ANSI compliant?
Thanks.
|
|
|
|
|
Can you please modify your post (or repost) using < and > for the angle brackets, otherwise codeproject thinks they are HTML tags and so does not display them.
Dave
http://www.cloudsofheaven.org
|
|
|
|