|
Yes, but Carlo just indicated one of flaws in the OP's code. I agree that it wouldn't solve 'the problem' of the OP, but it might (hopefully) prevent the OP from shooting his own face sometime in the future.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
i havent any problem with new delete , occur exception even this case
void CUseTestLibDlg::OnBinitlib2()
{
CTest pcTest;
}
|
|
|
|
|
The problem's obviously in CTest's destructor. The only significant activity in CTest's destructor will be calls to m_str1's and m_str2's destructors. Therefore, the access violation is happening somewhere in there.
I suspect there's something not quite right with your project settings - check that the library and main app are using hte same MFC and C run-time library settings.
|
|
|
|
|
I have just started at a new job. Here we are new to using JNI ( for bridging C++ / Java ). I am new to JNI so please forgive my noobness
In our (win32) Java app we are loading a C++ DLL. On the Java side we have several instances of "SomeJClass" each of these instances needs access to corresponding instance of "SomeCClass" on the DLL side. The DLL exposes entry-points such as GlobalDoSomethingInC(). Here I must call the instance method of Doer::DoSomethingInC(). So I need a smooth way to map the respective this-pointers. I also need to do the same mapping when a DLL thread discovers something interesting that it needs to notify the corresponding Java-instance of.
I can think of several solutions, but I do not like them too much. My question is, is there a better way than this ?
1 Java calls C:GetNewInstance(). This returns an int that is actually a pointer to the new C instance. Java stores it in m_myCInstance. Then Java calls GlobalDoSomethingInC(), and 1a
void GlobalDoSomethingInC()<br />
{<br />
jobj tmpJ = NewGlobalRef( env, obj );<br />
Doer* myDoer = <reinterpret_cast>( Doer )tmpJ->GetMyCInstance();<br />
myDoer->DoSomething();<br />
DeleteGlobalRef( env, tmpJ );<br />
}<br />
</reinterpret_cast>
1b or:
Doer* myDoer = <reinterpret_cast>( Doer )instanceParam->DoSomethingInC();<br />
<br />
</reinterpret_cast> 2 For calling from C to Java, things look, maybe, better
In the constructor C calls back into Java and stores
the Java instance reference
in a member variable. m_myJInstance.<br />
In all subsequent calls m_myJInstance can be used to call back Java.<br />
In the destructor we need to call DeleteGlobalRef( env, m_myJInstance );<br />
Not too bad I suppose. But it really safe to store the jobject reference. I mean: What happens when the GC moves the object around?
3 Our present solution does "work". But it belongs on rather on http://www.codinghorror.com/blog/
Another question, for JNI experts only. How much juice does it cost to do this sequence:
<br />
jobj tmpJ = NewGlobalRef( env, obj );<br />
tmpJ->GetMyCInstance();<br />
DeleteGlobalRef( env, tmpJ );
Thanks
Adam
........................
Life is too shor
|
|
|
|
|
I have a MDI application which has several document types. And I am adding sub-menus dynamically for some of the document types. The follwoing is the code snippet
class CMyMenu: public CMenu
{
int data1;
...
public:
virtual ~CMyMenu(){};
};
Then in the mainframe I declare a function AddNewMenu
CMainFrame::AddMenu(HMENU hMenu)
{
CMyMenu *pMenu = (CSMenu*)CSMenu::FromHandle( toolbarMenu );
CMyMenu* popup1 =
new CSMenu(), *popup2 = new CSMenu();
//create the two pop-up menus
createPopup1(&popup1);
createPopup2(&popup2);
pMenu ->AppendMenu( MF_POPUP, (UINT)popup1->GetSafeHmenu(), "Popup1" );
pMenu ->AppendMenu( MF_POPUP, (UINT)popup2->GetSafeHmenu(), "Popup2" );
...
}
My question is if I call ::DestroyMenu(hMenu) later on, it will delete all the submenus but will it delete the associated "CMyMenu" objects too or do I have to save both popup1 and popup2 to delete the objects my self
Please reply
Thanks
|
|
|
|
|
Farhat Aisha wrote: My question is if I call ::DestroyMenu(hMenu) later on, it will delete all the submenus but will it delete the associated "CMyMenu" objects too or do I have to save both popup1 and popup2 to delete the objects my self
Well I guess you can either choose to believe the documentation, or not. If you don't believe it then you can perform some tests to see if it leaks.
DestroyMenu[^]
Remarks
Before closing, an application must use the DestroyMenu function to destroy a menu not assigned to a window. A menu that is assigned to a window is automatically destroyed when the application closes.
DestroyMenu is recursive, that is, it will destroy the menu and all its submenus.
|
|
|
|
|
Hi,
Actually i need to vanish the 'X'-box from the system menu & keep only Minimize-Box in the menu bar.
I'hv used a code stuff under OnInitDialog()---
CMenu* cmenu = this->GetSystemMenu(FALSE);
cmenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED);
OR
CMenu* cmenu = GetSystemMenu(FALSE);
cmenu ->RemoveMenu(SC_CLOSE,MF_BYCOMMAND );
cmenu ->RemoveMenu(0,MF_BYPOSITION);
==>In both cases ,it only disabling the X-box not vanishing from the menu bar.
So is there any way to totally clear this X-box.
If then plz repay as soon as possible.
Thanks in advance
|
|
|
|
|
You could modify the code in this article[^] (see the PaintCap.h and PaintCap.cpp files in the file linked from the article) to draw the title-bar yourself. That way you can decide exactly which boxes to draw...
|
|
|
|
|
Shashi.Shinde wrote: So is there any way to totally clear this X-box.
Not without removing the entire system menu, or drawing it yourself.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
Please rephrase your query such that people can understand it. Also, the 'bold' font face doesn't particularly look charming.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
I see nothing different, other than some changes in font styling. If you can explain your difficulty better, I will be in a position to understand it and possibly offer you help.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Purish Dwivedi wrote: I have created a multilingual application. When I am changing the language, the old language characters are not remove,while new language character is being overwritten.
Well, I suppose this is the true spirit of a MULTIlingual application.
BTW We're really genii, and we might guess your problem and find the solution without even seeing a single line of your code. Unfortunately we cannot fully exploit our superpowers here, to not shock the mean people.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Purish Dwivedi wrote: WOW,
What an answer.
Well, question helped.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In French we have an expression: "A question stupide, réponse stupide", which translates to "Stupid question, stupid answer". I think it makes complete sense here
|
|
|
|
|
In Italy we have a similar expression: "A domanda stupida, risposta intelligente" (well, I twisted a bit... ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
Are you about to deleting delete that message too?
[added]
I suppose my guess was correct...
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Wednesday, April 29, 2009 6:26 AM
|
|
|
|
|
Hello Friends
How can i add text just with Mouse Cursor.Actually i m writing one case on MOUSEMOVE.So i want to display X and y Coordinates with Mouse Cursor.I m getting X and y Coordinates.But how to add with mouse cursor.
Thanks & Regards
yogesh
|
|
|
|
|
|
handle it in the targeted windows in which you want to draw. Than you can draw it in the paint routines or access the HDC of the window.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I need to develop a coonection setting manger using vc++.but i know nothing about it.can anyone please help me in the project.
thanx in advance.
|
|
|
|
|
Do you nee connection setting manager for network configuration?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|