|
Hello,
Can someone help me figure out how to make my MFC single document application open a specific file type.
I created the MFC single document application using the VS C++ 7.0 Wizard. It defaults to open all file types. I found the ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) in MyProject.cpp.
How do I customize this so I can open a specific file type such as a .txt?
I looked at the scribble example, but that is a multiple document type and I couldn't see how they did this without overriding OnFileOpen().
Is there a better example that I can learn from?
I am assuming I am not supposed to overwrite the OnFileOpen, but where is this stored and once I select the file and click OK... Where is the filename stored?
What is the correct way to do this?
Thanks.
|
|
|
|
|
hi,
U have create own Method for ID_FILE_OEPN
This will help you..
void CAView::OnFileOpen()
{
char szFilters[]= "TXT Files (*.txt)|*.txt|Jpeg File (*.jpg)|*.jpg|Gif file (*.gif)|*.gif|";
CFileDialog dlg (true, "txt", "",OFN_OVERWRITEPROMPT, szFilters, this);
if (dlg.DoModal()==IDOK){
//Add what u want to do when OK button is pressed
}
}
|
|
|
|
|
Thank You for the help. I will try your method.
|
|
|
|
|
hi,
I am doing Project using MFC/C++. I want to develop the Application with better look and feel..
So I want to add a Picture to the Label and transparent with the Text of the Label. I want to do same procedure for Edit Control.
I know that how to change the Backgroung Color and Font Color.
If any one know how to add picture to the Label with transparent Label Text,please send me a reply.??
OR can I override the CStatic class to do this?
Thanks in advance..
|
|
|
|
|
I got an warning saying that TcpListener was deprecated.
so, What to replace it?
P.S. this is a managed C++ project.
Thanks.
<br />
void Server::RunServer()<br />
{<br />
TcpListener *chatListener;<br />
<br />
try <br />
{<br />
chatListener = new TcpListener( 4500 );<br />
chatListener->Start();<br />
<br />
<br />
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
I know there is a function that will get a file's created or modified date/time and a few other things also, but I can't seem to figure it out. To use the function(s) I need to pass a HANDLE and it seems like the only way to get the handle is to create a CFile object and open the file. But if my program already has the file open as part of the Document/View architecture why would I need to create a CFile object to get the handle? Shouldn't it be readily available somehow through the CDocument class.
Maybe I've missed something?
Thanks in advance for any help you can offer.
|
|
|
|
|
your funny
CFILE is not the only way....anyway I am against MFC in general
You cand also use FindFirstFile() to get the handle.
have fun . . .
gabby
|
|
|
|
|
You could just use CFile::GetStatus() . It takes a filespec, not a handle.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
I'm using the functions from winmm.lib to adjust/mute the system-volume.
When calling the first function ( doesn't matter which one ) from that library about 1mb of memory are allocated, and i've found no way to free it afterwards.
I've looked through every tutorial/guide I've found on the net, but found no solution to this problem.
1MB isn't much, but my program is really small, so I'd be happy if anyone knew how to solve this!
Thanks in advance!
|
|
|
|
|
Hi
I need some help for retrive RGB values from Images using
DIB ,and without using GetPixel and SetPixel API function's
pleaes some source code.
Thanx alot
On Earth nothing impossible,
while your mind running.
Faroqtam
|
|
|
|
|
CDibData (Ok I wrote it) will give you an idea of how to to access the pixels directly (via Windows). Any way, goto the 'bitmap & palette' section of CP (don't forget to look up GDI+).
P.S. The QuickFill article has the most resent version of the CDibData file.
INTP
|
|
|
|
|
This is the call in my app's InitInstance
Using the MFC framework how do i specify that multiple views (of different types) be displayed during a File new or file Open
This is the relationship that I have right now
ADoc
AView
I need
BDoc
BView
1)Now if I add code in InitInstance to add a newDocTemplate with each of these combinations , the framework asks me which type I want to open. I want both types to be opened automatically .How do I achieve this ?
2)Now if Needed two view for a single DOC how can I achieve this ? As for example : a bar graph view and a pie chart view of the same data .
|
|
|
|
|
I will not say this is a good solution!
1) To open multiple views of the same document, the documents may need to know each other (do not like this), which means that any of the views lanched will atomatically lanch the other views.
I know this is no help! But I will point you in some new directions: "The MFC Answer Book" based on the the FAQ maintianed by "Scot Wingo" (10+ years?).
INTP
|
|
|
|
|
Hello,
I have been getting these annoying error and warning messages from the compiler that I really don't understand.
Consider the following code example:
class objA
{
public:
objA(){};
~objA(){};
public:
virtual bool Setup(int){};
bool Setup(float){};
};
class objB : public objA
{
public:
objB(){};
~objB(){};
public:
virtual bool Setup(int){};
};
class C
{
public:
C(){};
~C(){};
public:
bool doTest()
{
objB b;
b.Setup(100);
b.Setup(0.0001);
};
};
So here we get a warning message from the compiler as it doesn't know what function to use -- it is as if it doesn't recognise the base-class' method. I know that somehow this has to do with the virtual keyword in use, but I really don't know why this is happening.
Now consider yet another code example:
class _objA
{
public:
_objA(){};
~_objA(){};
public:
bool Setup(int){};
bool Setup(float){};
};
class _objB : public _objA
{
public:
_objB(){};
~_objB(){};
};
class _C
{
public:
_C(){};
~_C(){};
public:
bool doTest()
{
_objB _b;
_b.Setup(100);
_b.Setup(0.0001);
};
};
Here we have a class being derived from another one but without any virtual methods -- no errors/warnings!
Can someone please explain me what are the compiler/C++/ANSI rules I am missing here?
Thank you very much,
David
|
|
|
|
|
u assume that the call to Setup(float) will be called .
Well the compiler is seeing a virtual Setup(int) as the only function . I am not aware of considerations where if u have one function as virtual other overloaded methods are not considered in overload resolution . This might be what is happenning . Need to dig into stroustrup and find .
|
|
|
|
|
No, virtual has nothing to do with it since you're not calling any methods through a pointer. In your first example, B::Setup() hides all methods in A named Setup() . At the point of call, B::Setup(int) is the only method named "Setup" that is visible. The reason you get no warning in the second example is because you removed B::Setup() , so both A::Setup() overloads are visible.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
|
|
|
|
|
I think you are right!
Your convoluted answer explaned what I dislike aboute C++.
Do not get me wrong! C++ is great, it simplifies so many things. But you need to know at leased 10 times as much (than C) in order to acomplish those goals.
INTP
|
|
|
|
|
Hi Guys,
I use a CRichEditCtrl derived class in my project. I add text with a
CRichEditCtrl ::ReplaceSel() call and images using
IRichEditOle::InsertObject(). In order to keep the size of the content of the
CRichEditCtrl object manageable, I remove the first half of the lines from
the control from time to time. The memory used by those lines is not released
though. The application uses more and more memory. Given enough time, the
whole memory will be usede by my application. How can I fix this problem?
I checked several suspects:
There are no memory leaks.
If I disable the control, the application behaives properly.
If I disable adding images to the control but keep adding text, the problem
persists.
I disabled Undo/Redo capabilities of the CRichEditCtrl control.
Any help is very appreciated.
Thank you,
Chip
|
|
|
|
|
before adding control to main Dialog ,Did u add AfxInitRichEdit()
method to the Dialog?
I see that the Problem many problem occured due to that.this is from MSDN.
"Caution :if you are using a rich edit control in a dialog box (regardless whether your application is SDI, MDI, or dialog-based), you must call AfxInitRichEdit once before the dialog box is displayed
"
|
|
|
|
|
I'm using in fact AfxInitRichEdit2() to initialize the rich edit controls. Thank you for your input.
|
|
|
|
|
I got a trouble with creating MFC aplication on my PC. I create MFC application (any type) but when it comes to compilation I get errors in WinDef.h definitions. Saying:
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(43) : warning C4091: 'typedef ' : ignored on left of 'unsigned long' when no variable is declared
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(43) : error C2143: syntax error : missing ';' before 'constant'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(43) : fatal error C1075: end of file found before the left brace '{' at 'c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(30)' was matched
All this errors point towards the line:
typedef unsigned long ULONG;
Surpisingly averything is O'K on my laptop where I have installed the Visual Studio .NET from the same set of CD's. I brought setting in Tools/Options to the view of working version (on laptop) but it didn't help. Can anyone help with this puzzle? Thanks...
|
|
|
|
|
hi
Did u place the Include and Lib directory path of SDK at the top of Directory paths?
some times this error message is diplayed when Include/LIB path of the SDK is not in the TOP of the Directories..
|
|
|
|
|
Hi
Thanks for your comment.
I did what you suggested (and played with the order of the inlcude and lib files. Now (almost independently on the order of those files) I have a list of errors pointing towards WinReg.h file. Fisrt error points to the second line in:
RegCloseKey (
IN HKEY hKey
);
saying
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinReg.h(145) : error C2065: 'HKEY' : undeclared identifier
Must admit that I don't understand why order of include files is important and what how to get ride of new error messages. Would appreciate any comment.
Thanks, Bakhti
|
|
|
|
|
hai
I want to assign À0"8! to a byte array...ie byt[0] = À, byt[1] = 0 ..and so on..i did as
BYTE byt[5] = "À0"8!";
but its giving errors..how should i do this??
thanks..
|
|
|
|