|
use a Base ptr to point to Derived Object
so when deived class is instantiated,first base class constuctor will be called then the derived.llarly when the memory allocated to derived object gets cleaned up the reverse should takes place first the destructor of derived must be called and then base destructor.
so if cleaning takes place via base pointer the destructor must be made virtual.
but i suggest u to always make base destructor virtual if u want to derive class form the base class
never say die
|
|
|
|
|
I am creating the installer package for MFC app with InstallShield. Now I want while installing the user should not be able to select the subfeatures twice in the Customed installation. He should be able to select the sub feature only once. for the second time he will not be allowed. How can i do that?
|
|
|
|
|
Hi
Im just learning how to wrap a window procedure and i am following this tutorial from stromcode.
I am wondering why would I have to create an object of the class first and then store it as pointer variable (Win32WrapperClass* pWnd)?
Is there a reason why this has to be done, because i thought that if i create a Win32WrapperClass object now it would have no relation to the Win32WrapperClass i would create in my main.cpp
<br />
<br />
LRESULT CALLBACK Win32WrapperClass::stWinProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
<br />
Win32WrapperClass* pWnd;<br />
<br />
if (uMsg == WM_NCCREATE) {<br />
SetWindowLong(hWnd, GWL_USERDATA, (long)((LPCREATESTRUCT(lParam))->lpCreateParams));<br />
}<br />
<br />
pWnd = (Win32WrapperClass *)GetWindowLong(hWnd, GWL_USERDATA);<br />
<br />
if (pWnd) return pWnd->WinProc(hWnd, uMsg, wParam, lParam);<br />
else return DefWindowProc(hWnd, uMsg, wParam, lParam);<br />
any help on this would be great
cheers
|
|
|
|
|
Doing so allows you to write object oriented code and at runtime can easily manage the state of the window because you can always retreive the object associated with the window using the GWL_USERDATA given the window handle.
Vipin - MVP
|
|
|
|
|
It is a little bit tricky to explain. First important point: the window procedure has to be static because static member functions and standard member functions behave differently (and don't have the same prototype). Standard member functions are kind of 'attached' to an instance of your class (so when they are called they 'know' to which instance they belong). In fact this is done by passing an additional parameter to your function, which the this parameter of the instance (and thus the pointer to the instance). This is done implicitely and the user doesn't know about it (it's hidden).
Now if you take a static member function, the behavior is different: for a static member function, it is shared among all instances of the class and thus, doesn't belong to any particular instance of the class. This has two consequences: first, there is no need for the implicit 'this' parameter (because the function doesn't blong to an instance) and second, the function doesn't have access to data from a particular instance: in a static function, you cannot access non-static member, you can only access to static member variables and functions (which are then shared among all instances).
For the windows procedure, it accept only a certain type of functions prototypes which are not member functions, thus the only way to have it in your class is to declare it static. The consequence is that it doesn't which instance it belongs to, so the need to 'save' first the this parameter associated with the specific window handle. This will allow you to get the 'this' parameter later and to be able to call the non-static window procedure of a particular instance.
Hope this helps, if you need some more precisions, don't hesitate to ask
|
|
|
|
|
Hi,
I am creating one mdi application, which has say 5 forms(like employee management, leave management, etc.). these forms are derived from CFormView. What i want is if user clicks one of 5 menus the corresponding form should be shown as child window. I want know how to create an instance for these forms. How to make this for as a child window and how to show it? that is my problem.
|
|
|
|
|
Hi,
You should create dialogs at runtime and then show them in menu command handlers.
Basically it will be like this:-
CDialog *pDlg = new CDialog;
pDlg->Create(id,...)
Then you can show or hide them using
pdlg->ShowWindow(...)
There would be samples here in codeproject to get you started.
Microsoft - MVP
|
|
|
|
|
But I want it as MDI child window. How to do it?
|
|
|
|
|
Even if i have only one formview, how to show this view say when the user click a menu? (I mean other than FileNew menu). And this view should have only one instance.
-- modified at 11:50 Tuesday 24th January, 2006
|
|
|
|
|
Hello All,
i need help about how i implement a TabView(e.g. in an application) to use property sheets like the time site.
It would be a great help for me if anyone has an example.
Sorry for my bad english.
|
|
|
|
|
Hi All,
I would like to develop a Remote Task Manager utility, which reads the Tasks running on a remote machine(s). Does anybody give me a hint, how it can be done in C++/MFC.
Thanks in Advance
Regards,
Satya
|
|
|
|
|
Hi,
You can implement this using tool-help library... For more information search MSDN with "tool-help Library". Rest is sockets.
Hope this will help you.
|
|
|
|
|
Try this:
http://www.codeproject.com/internet/RemoteAdmin.asp
|
|
|
|
|
Thanks Guys )
|
|
|
|
|
I am making an application for Pocket PC using dialog based MFC on embedded VC++.
I try to attach an application like Word, Excel on dialog.
I used "SetParent" to attach the application on dialog.
The code is like this.
::SetParent(dlg.m_hSWnd, m_hWnd);
"dlg.m_hSWnd" is the handle of application that I want to attach on dialog.
"m_hWnd" is the handle of dialog.
Actually, applications are shown on dialog well.
However, it is shown without command bar that the application originally has.
What I hope to know is how to show the command bar.
If you know something about this kind of problem, help me please..
this code is what I tried
CDlgSelect dlg;
if ( IDOK == dlg.DoModal() )
{
::SetParent(dlg.m_hSWnd, m_hWnd);
CMenu *a=CMenu::FromHandle(dlg.m_hSMenu);
SetMenu( a );
::CommandBar_Show(dlg.m_hSWnd, true);
::SetForegroundWindow(dlg.m_hSWnd);
}
-- modified at 5:55 Tuesday 24th January, 2006
|
|
|
|
|
I'm not sure it's 100% relevant, but you could search MSDN for "dsoframer". Perhaps that will give you some ideas.
Mike Stephenson
|
|
|
|
|
hi,
i was stuck up in the project where a string is to be supplied to the notepad so that it can be saved anywhere else,
can anyone who knows the answer help me,
appreciation in advance,
paul
-- modified at 5:44 Tuesday 24th January, 2006
|
|
|
|
|
|
|
For non-user interaction:
cant you just save the string to a file with .txt extention? is it specific to the notepad application?
For user-interaction required:
You can also (maybe consider) use the clipbord to put the text data there and the user can then say paste to put the content whereever the user wants to paste.
This way you dont have to open a notepadd application all the time for each text that needs to be tranfered.
-Prakash
|
|
|
|
|
hi,
thanks for ur reply,
the situation is there is a string that should be displayed, when i press a button in the dialog box, in the text file(notepad), later the user can save the text file wherever he wants,.
if you write the explanation in detail that would be nice,
thanks in advance,
paul
-- modified at 8:42 Friday 27th January, 2006
|
|
|
|
|
Can someone tell me how to override the explorers implementation of Drop event for a specific case? More elaborately, I need to provide a custom implementation of the Drop event when a file is dragged from my namespace extension to a Windows folder.
Thanks and Regards,
Anil
|
|
|
|
|
do you want to transfer a file from your namespace system to windows file system rite?
And your namespace system does not contain windows filesystem data?
-Prakash
|
|
|
|
|
Exactly!! What is supposed to happen is I will give the details of the file as well as the directory to which it is to be downloaded to an Applet and it will do what is necessary. Can you help me with this?
Thanks and Regards,
Anil
|
|
|
|
|
Humm, it is difficult to hook on to someone else implementation of the drag drop.
This is what i did,
1.I had a service running the background which simulated my application specific clipboard.
2.Implement ICopyHook[^], The service implements this hook
3. Specify a directory name which is very unique, like C:\program files\<guidno>
4. When you want to drag drop, put this unique directory name in the clipboard and send other files that needs to be copied to the service that is running the background.
5. When the files are droped, windows will try to copy the files, now we hook that copy operation at the directory level, check that this is the unique directory, so the src data belongs to us.
6. dismiss the copy operation so that windows does not do any copying stuff, now the service has the src files, and destination direcotry.
7. Start your custom copy operation.
Complecated But i could not find any other solution, but it worked very nicely.
Actually i did not test this for drag-drop, i have tested this for copy-paste task.
Hope this helps you in someway.
-Prakash
|
|
|
|