|
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
|
|
|
|
|
That's simply great !!!
Vielen Dank !
~RaGE();
|
|
|
|
|
No problem!
C'est toujours un grand plaisir de aider. (Sorry for that bad French, but my French lessons are already 5 years gone);
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
|
|
|
|
|
Hello,
I need to place all the tabs of a property sheet in the same line and make the user scroll over them, and after reading the MSDN I've written this:
int CPSParametritzacions::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
this->EnableStackedTabs(FALSE);
if (CPSAutoRedimensionable::OnCreate(lpCreateStruct) == -1) return -1;
return 0;
} But it doesn't work...
I'm almost sure that I am missing something...
Thank you in advance.
|
|
|
|
|
what happens if you follow the MSDN example exactly. i.e.
int CMyPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
EnableStackedTabs(FALSE);<br />
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
return 0;<br />
}
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
int CPSParametritzacions::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
this->EnableStackedTabs(FALSE);
if (CPSAutoRedimensionable::OnCreate(lpCreateStruct) == -1) return -1;
return 0;
}
int CMyPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
EnableStackedTabs(FALSE);
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
the only differences I see are in bold font... and I don't believe they are significant...
The fact is that this must not be the reason... (it's obvious why), but the other one... My problem is that the CPSAutoRedimensionable class it's a class derived from the base class property sheet and that I don't know why I can't call directly CPropertySheet::OnCreate from my CPSParametritzacions class.
Thank you in advance, and thank you for your interest too.
|
|
|
|
|
Hi....
I am doing a Project in which I want to close a selected port which is opened by another application. How can I Solve the Same? Which function to be used??Please Help
Thanks in Advance.
SAN
|
|
|
|
|
Do you have the source code to the other application? If so it would be easy to do. If not, I'm not sure if this could even be done.
Rob
|
|
|
|
|
What I need to do is move my existing resources from the executable into separate resource DLLs, separated by language. Does anyone have links to any tutorials, guides, or other articles about resource DLLs in general?
Jon Sagara
I have no complaint with the “mentoring concept” or the marriage concept or the sex concept. But if you pay for any of those, something’s wrong.
-- John T. Reed in The real estate B.S. artist detection checklist [^]
|
|
|
|
|