|
This is something I wish someone would write an article on - with an aim of avoiding having to nest header includes in MFC projects. The problem arises as translation units include headers you're not expecting them to, and a nice directed include graph of an MFC app would be a boon.
But here's a tip that might help - if you add a new class, include its header in the cpp file that holds the application class (MyApp.cpp) right after stdafx.h. Then, include it in whatever .cpp file will be using it, before the header for that file.
The application class is typically the first translation unit to get compiled in these projects, and often the scope of its includes (doc and view, e.g.) are what cause the kaffufle.
later...
Actually, on reading your message again, you might be able to just get by with a forward declation of the form class at the top of the header, since you are just declaring a pointer.
----
"If you would see the invisible, you must look carefully at the visible."
Santayana
|
|
|
|
|
Hi
I am starting the netmeeting application from vc++ application using
createprocess.
But it just starts the netmeeting application. But My reqmt is to start
and connect to ip address x.x.x.x. and username xxx and password xxx.
How do i achieve this. If i use netmeeting sdk can i do that...what is exact api
for this..
how do i use callto function ?
Also if i want to run a netmeeting shortcut in my desktop, how do I achieve this. i.e i want to simulate the double click of a shortcut icon, which will launch the application associated with it.
any idea..thanks in advance
raju
|
|
|
|
|
I think you want to use ShellExecute, which allows you to specify command line parameters.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
In OnNewDocument in my MDI, I go out and get a bunch of information. Depending on what is retrieved, I need to use a different view, in my case a CEditView or CHtmlView. I have looked over the article "Replacing a view in a doc-view application" but that article assumes you already have a view. Specifically the lack of a AfxGetMainWnd()->MDIGetActive() causes problems.
I want to use one type of view if the CDocument data meets a certain condition and a different view if it meets another condition. Can anyone point me in the right direction?
|
|
|
|
|
Check the Paul DiLascia article that appeared in Feb'96 issue of MSJ:
http://msdn.microsoft.com/library/periodic/period96/SFFD.htm
The solution doesn't use OnNewDocument. Instead, it overrides the InitialUpdateFrame, which is a virtual method of CDocTemplate. The decision which view to use is delegated to user-defined method. This allows you to display CEditView or CHtmlView depending on context.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
With a few modifications it worked like a champ. Thanks.
|
|
|
|
|
Someone can send me an example of an MDI Application where I can open file of different extension, (extension created by myself)
If not, how register the extensions...and no more obtain the following message : IDP_FAILED_TO_CREATE ?
Thank a lot.
Leo.
|
|
|
|
|
It's all done in OnOpenDocument in your View class, although from memory some of it routes back through your App class as well with the first file you open. Just overload it, show your own dialog, with the extensions shown you want to support, then examine the return and load the file appropropriately.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
i'm trying to use SetScrollSizes() and ScrollToPosition() in my program. I've put #include <afxwin.h> in my program. However, the debugger still keep saying "undeclared identifier".
What happen??????
p.s.: again....it works in my previous program....i just copy the code to my new program....
|
|
|
|
|
i have two C files and want to add to my new project. I've used these files in MFC programming before and everything fines. However, this time when i compiled these files, i got the following error message:
"fatal error C1010: unexpected end of file while looking for precompiled header directive"
I didn't change anything.......then i tried to just compile the file (this lead me to create a new project).....i used the same directory...same location...nothing change.......and it works!!!!!!!!!!
Does anyone know what happeneD?
|
|
|
|
|
Your project is configured to use precompiled headers. Usually precompiled headers are included in the stdafx.h file. To solve your problem do one of the following:
(a) put the line
#include "stdafx.h"
in your .c files
(b)
go to FileView in the workspace window. Right-click on your .c file and select "Settings". Go to C/C++ page and select "Precompiled headers" category. Click on "Not using precompiled headers" and OK. YOu have to repeat this for all .c files.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi Tomasz,
Thanks for your quick response!!! You are superb!!!!!
Richard
|
|
|
|
|
Hi,,
I'm having problem with loading and saving (serializable) bmp files...
but i know how to do that in a dialog base application,,,,
I like to know how to do that in MDI...
Thanks
Ehsan
Ehsan Behboudi
|
|
|
|
|
Hi Ehsan, I have the same problem with my MDI application and i don't find out the bug.
Maybe you found it
Fred
|
|
|
|
|
I am using a listbox control to show a report on a record.
I can load the listbox the first time but i can not clear it for a second loading.
The new data just gets appended to the end of the list.
I am using the following to load the listbox
nIndex gets reset everytime the listbox is set.
m_choslist.InsertString(nIndex,msg);
|
|
|
|
|
call ResetContent() method on the listbox.
|
|
|
|
|
try yourlist.ResetContent();
gm
|
|
|
|
|
I have one problem with my MDI Application.
I don't manage to implement correctly OnOpenDocument in my view Class. Someone can give one examlpe ?
Thank for advance for your help
Fred.
|
|
|
|
|
class CData
{
// members
CData* pChildList;
}
CList<cstruct, cstruct&="">* pDataList, pTempList;
pTempList = pDataList->GetHead()->pChildList; //how to correct this line?
How can I make pTempList to point to pChildList?
|
|
|
|
|
Change 'class CData' to 'struct CData' or make pChildList a public member. Members of classes are private by default, while default struct members access is set to public.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
the class CData is public alright?. the compiler gave this error msg:
error C2582: 'operator =' function is unavailable
|
|
|
|
|
Change your variable declaration to:
CList* pDataList, pTempList;
to
CList* pDataList, *pTempList;
pTempList without asterisk declares object, not a pointer to an object.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
What i have to do is to limit the amount of users able to access an application over the network at the same time. The application i am talking about ist not a client server app. It's just something like a calculator sitting on a network cd-rom drive.
i have to find out, how many users started this application on their workstation. If the limit of users has been reached, the next user shall not be able to start it.
i have not the slightest idea how to achieve this. Could someone please give me a hint?
|
|
|
|
|
So the application is executed on separate machines, right? In this case you need some place to keep "shared application state" - number of users. You can store it in some database available to all workstations or in a file located on network server. When your app starts, it should increment the number of users. During app shutdown you should decrement this number.
The hard part begins when you realize that application can crash and leave inconsistent information in database/shared file. Possible workaround would be saving separate 'record' for each workstation running your program. This record would contain workstation ID and "last access time". The time field is updated periodically when program runs, the updating stops after crash. If application crashes, the record would remain, but another instance of the application could be able to determine - by using time field - that the record is invalid. In this case, you need common time settings on all workstations.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thank you. I was already thinking about some kind of file located on a network server. The thing with the timestamp is a good idea. Would be even better if i could use server time. I will have to figure that out.
What really troubles me is the installation of such a thing. i think the user has to be admin to install the application. And at which directory should that file be stored. It should be definitely a common directory because every workstation has to access it. Every workstation should have the writeaccess to this directory. i don't think it will be the system-directory because in most cases only admin has writeaccess to the system-directory. So how do i figure out which directory to use? I can't ask the user during installation "please tell me a common directory on the network-server where i can put the secret access control file".
So as always the details are killing me. any further help would be appriciated.
|
|
|
|