|
AOA!
last night as i was trying to do one of my Assignments i tried to open a form using my Class inherted from CFormView!
the problem is that i was able to show the form as i want but as i close this window using the CWnd::DestroyWindow() i get an Assert Failure!
the Code i am using to initialize the window is as follows:
//defined in MyClass.h;
CMyClass Form;
CMyMainView::OnInitialUpdate()
{
CView::OnInitialUpdate();
CRect Rect;
GetClientRect(Rect);
Form.Create(NULL,"NewForm",WS_VISIBLE|WS_BORDER|WS_CHILD,Rect,this,1234,NULL);
}
And to Destroy the Window
CMyMainView::OnFileNew()
{
Form.DestroyWindow();
}
i cant understand y i get the assert failure when i click the new button on the toolbar!
the Assert Failure Message i get is as follows:
Debug Assertion Failed!
Program:E:\Chummi.exe
File:dbgheap.c
Line:1101
Expression:_CrtIsValideHeapPointer(pUserData)
//bla bla bla
plz help!
shoaib!
|
|
|
|
|
You must allocate Form dinamically because CView::PostNcDestroy contains delete this . Make it CMyClass *pForm .
rechi
|
|
|
|
|
Thankx Man ! u r the Gr8est! ;)
|
|
|
|
|
Hiya I have an MFC app that writes data to my SQL database. The columns lenghts are set to 30. But when I open my SQL database to view the contents, I can only see the first 15 chars of each column..
How do I get the SQL database to display the full columns lenghts when it is opened??
Thanks,
grahamoj.
|
|
|
|
|
What do you mean by "the SQL database"?
Regards,
Alvaro
Quitters never win. Winners never quit. But those who never win and never quit are idiots. -- despair.com
|
|
|
|
|
I meant that I have SQL loaded on my machine for doing database stuff..
What I do is write the info to the database and then using Enterprise Manager, go in to the table to view it. All of the string is in the column. I can see it when I expand the column.
What I want to be able to do is when I open the table in Enterprise Manager, I want the column already expanded to the full lenght of the string...
Any ideas,
grahamoj
|
|
|
|
|
hi ppl.
i am making an Internet Explorer toolbar plugin using the sample Kbbar.
In it i want to load a dialog from resources. but it resulted in Debug assertion failure.
Upon debugging in depth i came to find out that AfxGetResourceHandle() was the reason, as call to this function or a call to MAKEINTRESOURCE macro resulted in the Debug Assertion failure problem. plz help me in that.
here is the portion of the code :
m_pMsgDlg = new CMsgDlg(this); /* m_pMsgDlg is a pointer of CMyDialog: public CDialog */
if (m_pMsgDlg->Create(IDD_MSGDLG, tempPtr) == FALSE)
{
MessageBox("no dialog");
}
plz plz help me.
Farrukh
|
|
|
|
|
Try this:
HINSTANCE hsav= AfxGetResourceHandle();
AfxSetResourceHandle(theApp->m_hInstance);
m_pMsgDlg = new CMsgDlg(this);
if (m_pMsgDlg->Create(IDD_MSGDLG, tempPtr) == FALSE)
{
MessageBox("no dialog");
}
AfxSetResourceHandle(hsav);
rechi
|
|
|
|
|
thankiew very much for help.
i tried the solution that u provided.
but the problem is still there.
i found that AfxGetApp() returns 0 always.
i donno whats the problem.
to put into your notice, i will like to tel that i am using the KbBar sample
that comes with MSDN and is also available on this site for downloading.
thanx again.
Byez
Farrukh
|
|
|
|
|
Don't use AfxGetApp() but the singleton theApp , The one and only.
[EDIT]
But first make sure that you wrote AFX_MANAGE_STATE(AfxGetStaticModuleState()); at the beginning of your function.
[/EDIT]
rechi
|
|
|
|
|
multiple Documents in SDI applications.
Hi,
I have an application that is mainly a SDI form based app. There is no sence in opening more than one document in a time. I use a technique to switch between 4 different views based on the state of the app and again, there is no need to see two of the views at the same time.
I have a few ScrollView derived Ctrls on the FormView where I already had problems that mouseactivation on the ScrollView derived class will send a SetActiveView to the mainFrame. This results in unexpected program behavoir (mostly program crashes later on). For these problems I already have a workaround.
Yesterday I tried to include debugging capablities using the CEditLog class with a CEditView ctrl in a CControlBar. Again I had the problem that upon activation the CeditView Window sends SetActiveView calls to the MainFrame and additionally will call CDocument::SetModified (). I choosed the EditView since I wanted to use the search / serialize capabilities, but the CEditView needs a Document, so I gave an empty CDocument to the CEditView. But this only leads to additional problems. Terminating the application while the focus is on the ControlBar leads to crashes since the View has changed and so on.
I don't really want to switch to an MDI application, only to support edit capabilities or better a second CView derived window.
Does anybody have similar experiences with something like this? Must I switch to an MDI app?
Thanks in advance
Dirk
|
|
|
|
|
hello,
i'm working with ListCtrl in VC7.
i'm trying to detect if in "MouseMove" event the Left Button mouse is Down(Thx Thomas George & Joel Lucsy ) but i have a little problem
i do :
<br />
BOOL ClistctrlView::PreTranslateMessage(MSG* pMsg)<br />
{<br />
<br />
if (pMsg->Message == WM_LBUTTONDOWN)<br />
{<br />
ButtonDown = TRUE;<br />
}<br />
if (pMsg->Message == WM_LBUTTONUP)<br />
{<br />
ButtonDown = FALSE;<br />
}<br />
if (pMsg->Message == WM_MOUSEMOVE)<br />
{<br />
if (ButtonDown == TRUE)<br />
{<br />
AfxMessageBox("goooood");<br />
}<br />
<br />
if (pMsg->Wparam & MK_LBUTTON)<br />
{<br />
AfxMessageBox("goooood");<br />
}<br />
<br />
}<br />
return CListView::PreTranslateMessage(pMsg);<br />
}
I can Detect WM_LBUTTONDOWN, LBUTTONUP, MOUSEMOVE but if i want to detect in MouseMove if The left button is down it doesn't work !!!
And if i try this code in "CView" object, it works great !
any ideas ??
Thx in advance
|
|
|
|
|
jeremysay wrote:
i want to detect in MouseMove if The left button is down
Maybe you should not do (pMsg->Message == WM_MOUSEMOVE) but something like (pMsg->Message & WM_MOUSEMOVE). Because if you have both the button down and the mouse moving, your Message will be equal to (WM_MOUSEMOVE |WM_LBUTTONDOWN ) which is different from WM_MOUSEMOVE alone. Je suis clair ou pas ?
~RaGE();
|
|
|
|
|
Ok thx i'm going to try....
i keep you informed
|
|
|
|
|
O yes !!! (c'est tres clair !!! lol)
Thx it works great !!!!
|
|
|
|
|
Let's say I have a main window and 3 child windows.I want when minimizing the main window the child windows to remain on the desktop. I'm trying with SetParent() function but I'm missing something...what is it?
|
|
|
|
|
You may make the parent of the childs the desktop window on the child creation.
For example if a child is a modeless dialog, you create it like this
m_MyDlg.Create(IDD_MYDIALOG, GetDesktopWindow());
There is many problems with this method, but I think they may be overcomed.
|
|
|
|
|
Hi !
Is there any documentation about the excel automation classes ? I'm trying to set the format of a range of cells as "centered" and "text", but i do not know how to do it.
lpDisp = sheet.GetRange(COleVariant(start), COleVariant(start));
ASSERT(lpDisp);
range.AttachDispatch(lpDisp);
Here ...
range.SetValue(COleVariant(tmp));
Thanks...
~RaGE();
|
|
|
|
|
I don't know whether there's anywhere a *real* documentation.
But opening the Excel help, then choosing the topic Programming Information -> Microsoft Visual Basic Reference gives you an overview of all available objects, methods, ...
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
In fact, if you include excel8.h in the MFC project, you can also see all the methods, object and so on. The only problem is, that the parameters of the functions are mainly COleVariant . So if i have Range::SetNumberFormat(const VARIANT& newValue) , i'm lost without documentation
Any idea ?
~RaGE();
|
|
|
|
|
Sorry, I don't know any suitable documantation.
But the "documantation" I mentioned (yes, I mean the one from Excel) tells you what type the properties have. This should be sufficiant to set the corresponding data type for your VARIANT which is passed in your function call. So f.i. the NumberFormat property is of type string, you provide a VARIANT of type VT_BSTR etc.
I know it's not very practable, but for me it works.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
Could you tell me (i mean a sample code), as an example, how to have my range of cells get the "centered" property ? Because there is no SetStyle or something like that ...
Thank you very much (if you do not have time, don't bother, it is not that important..)
~RaGE();
|
|
|
|
|
The property to be set is HorizontalAlignment.
So if you have a pointer to your range, calling
range->SetHorizontalAlignment(COleVariant(xlHAlignCenter));
should work. Without use of MFC or similar, it could be more like
VARIANT var;
var.vt = ???;
var.??? = xlHAlignCenter;
range->set_HorizontalAlignment(var);
But I don't know of what type xlHAlignCenter is, so you should figure that out before setting the Variant parameter.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|
|
Schlaubi wrote:
range->SetHorizontalAlignment(COleVariant(xlHAlignCenter));
That's what I've tried from the beginning, but compiler does not know about xlHAlignCenter, so even the type cast would not fit. Anyway, i have found in Article ID: Q179706 in the MSDN, that the value for xlVAlignCenter (so the vertical alignement) is -4108, assumed this would be the same for horizontal alignement, tried ... and it worked !
So i'm done, even if i would really love to have a table giving indications like
xlHAlignCenter=-4108;
Lots of thank for your help, i own you a ...
~RaGE();
|
|
|
|
|
Rage wrote:
So i'm done, even if i would really love to have a table giving indications like
No problem
f.i. for Excel:
Search the corresponding olb / tlb file, in my case it's excel9.olb, located in program files\microsoft office\office. Then open the file with oleview, delivered with MS VS. Now you have a perfect overview of all interfaces and enums. In your case, the enum xlhalign provides you all values you need. As for all other constants, too.
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
|
|
|
|