|
|
Hi
Is it possible to call a c# dll from an unmanaged code writen using VC 7?
Thanks in advance.
|
|
|
|
|
If you register the DLL with COM, yes: you can use #import in C++ to import the type library generated by regasm .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Can you point me some article/tutorial that explain how to do this?
Thanks.
|
|
|
|
|
Hi
I have a control that can either be created dynamically (using CWnd::Create()) or is created directly by windows when placed on a dialog using the dialog editor.
In both cases PreSubclassWindow is called by the framework, which I then use to initialize the control. I don't use OnCreate to do the intialization as OnCreate is not called when the control sits inside a dialog. My Initialzation function which is called from PreSubclassWindow creates other child controls used by my control. Everything works out well when the control is created as part of a dialog control, but everything seems to fall apart when creating my control dynamically using CMyControl::Create(...);
Having stepped through the creation code, windows always calls CWnd::Attach twice when creating dynamically, with the second call to Attach causing the debug assertion as the controls window is already attached the first time around.
Anyone got any ideas about whats going here whith a pssible solution?
Thanks
Garth
|
|
|
|
|
Hi Garth
The question you pose is an interesting one. In fact all the questions you've asked are quite amazing. You're either incredibly clever or supremely (?) stupid as no one on this forum has ever answered you're questions. Anyway let me have a crack at it.
Create a method, call it say, Initialize() which creates all the child windows etc.
Override Create a method CMyControl::Create() which clients must call when creating your control dynamically. Add a BOOL property (member variable) to the control, call it say 'm_bIsDynCreate', and set it to FALSE in constructor of the control. Now in your custom Create() function, set this variable to TRUE, call the base Create method e.g. CWnd::Create(...) and then call your intialize method. In your Overriden PreSubclass method, test 'm_bIsDynCreate'. If it is FALSE, call Initialize(..), otherwise don't, as it will have already been called when creating the control dynamically. When called as part of the creating cycle of a dialog, it will be called in PreSubclass window.
Here is some source code for your perusal.
<br />
BOOL CGarthsCtrl::Create(const RECT & rect,CWnd* pParentWnd,UINT nID,DWORD dwStyle)<br />
{<br />
m_bIsDynCreate=TRUE;<br />
if(!CWnd::Create("GARTHSCTRL",NULL,dwStyle|CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW,rect,pParentWnd,nID))<br />
return FALSE;<br />
Initialize();<br />
<br />
return TRUE;<br />
<br />
}<br />
<br />
void CGarthsCtrl::PreSubclassWindow()<br />
{<br />
CWnd::PreSubclassWindow();<br />
if(m_bIsDynCreate==FALSE)<br />
Initialize();<br />
<br />
}<br />
Funnily enough, Garth, I was experiencing just the same problem this afternoon. Talk about coincidences.
Anyway I hope this helps you somewhat.
Regards
Garth
|
|
|
|
|
Thanks Garth
You're solution is, to say the least, very elegant and masterfull.
Excellent.
It's solved all my problems. (I'm still having a cash flow problem though
Regards
Garth
|
|
|
|
|
Garth Watkins wrote:
You're solution is, to say the least, very elegant and masterfull.
Excellent.
It's solved all my problems
There is No Doubt your are Genius
"I Think this Will Help"
[Vote One Here,.....]
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi guys
I've got a Doc-View app and from the view I open a CDialog.
What I want to do is to open my child CDialog to an absolute position from the screen.
What I have to use and what parameters I have to put in?
I've tried MoveWindow and set window pos without succes.
Thanks in forwarding
Doc
|
|
|
|
|
try the CWnd::SetWindowPos() fuction
regards,
Rajesh
|
|
|
|
|
Thanks guy, but what's the first parameter in SetWindowPos.
I've just want to move the dialog.
Best Regards
Doc
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/setwindowpos.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wcemfc4/html/aflrfcwndcolcolsetwindowpos.asp
-.-
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I wrote
"I've tried MoveWindow and setwindowpos without succes."
Already read msdn link, but not working , maybe something wrong in my parameters?
I don't now, but sorry a MSDN link won't help.An example will help a lot.
Doc
|
|
|
|
|
If you are using CWnd::SetWindowPos() the first parameter can be set to NULL.
Using the API ::SetWindowPos() the first parameter is the handle to the window to move.
e.g.
SetWindowPos(NULL, nLeft, nTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
<p></p>
where
nLeft and nTop - specify the top left corner of the window or
::SetWindowPos(hWnd, NULL, nLeft, nTop, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
<p></p>
where
hWnd - is the handle to the dialog window
nLeft and nTop - specify the top left corner of the window
NOTE: We do not need to specify the width and height if we have SWP_NOSIZE.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
|
Just one more question
It's possible that if I declare my dialog as a PopUp dialog, the Setwindowpos doesn't work?
Well actually is not working, my dialog always appears in the same place.
I'll do the setwindowpos in the oninitdialog method.
I'm using
SetWindowPos(NULL,x,y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
It doesn't matter x,y the dialog always is drawn in the same place.
Thanks
Doc
|
|
|
|
|
I have used the same method to position dialogs in the past without problems.
What does your OnInitDialog look like. Are you sure that it is being called?
If so what does SetWindowPos return. NOTE: This should be non-zero if it is successful!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Hi Ant
You're right all is working correctly (SetWindowPos returns 1), for an instant I can see my dialog in the right position but after OnInitDialog, the dialog returns to a centered position in the window.
I've searched in the dialog class and no CenterWindow() is called.
Do you remmeber something similar? Maybe a property of the dialog? Something relative to the app?
I'm really confused about what does return the dialog to the center.
Thanks a lot for your time
Doc
|
|
|
|
|
Hi Ant
Forget last post.
I've found a CenterWindow called after dialog opens,sorry. (((
You help me a lot.Thanks a lot for your support
Doc
|
|
|
|
|
Hi to all,
I learning myself the vc++,I undestood the mfc programming ie how to program ,but i am confusing to do a project with aid of mfc's.I have little confusion how to do or append the mfc classes,how many classes are there?
Is it the right way to learn the classes in mfc
Please guide me regarding this the way of learning the vc++
What are "must"class to append how Can I know?
any reference books?
My heartful thanks those reply this mail.
Regards,
Munisamy
|
|
|
|
|
Get the book by Jeff Prosise on MFC windows programming. It will be your best resource.
-- Rocky Dean Pulley
|
|
|
|
|
I need to invoke a html page on my local machine say C:\\xyz.html via shellexecute.
When i use
ShellExecuteNULL,"Open","C:\\xyz.html",NULL,NULL,SW_SHOWMAXIMIZED);
one of the existing IE windows is getting altered..All that i need is - none of the existing IE windows should get disturbed.But i need this html page to be invoked in a new IE window. Also i tried this way.
ShellExecuteNULL,"Open","IExplore",NULL,NULL,SW_SHOWMAXIMIZED);
ShellExecuteNULL,"Open","C:\\xyz.html",NULL,NULL,SW_SHOWMAXIMIZED);
The first statement invoked a new IE window.But the latter statement did not alter this newly created IE window,but it set one of the already existing windows to xyz.html....Can anyone help me in this?
URagav
Everything can be sacrificed for truth, but truth cannot be sacrificed for anything .
|
|
|
|
|
ShellExecute(NULL,"IExplore.exe","C:\\xyz.html",NULL,NULL,SW_SHOWMAXIMIZED);
suhredayan There is no spoon.
|
|
|
|
|
thnx it worked.
URagav
Everything can be sacrificed for truth, but truth cannot be sacrificed for anything .
|
|
|
|
|
Booh, I hate it. I can't stand it when applications open their HTML files in Internet Explorer, although Firefox is set as my default browser.
modified 12-Sep-18 21:01pm.
|
|
|
|
|